mirror of https://github.com/OpenTTD/OpenTTD
(svn r3196) Use structs instead of magic offsets into arrays
parent
8d57bfc921
commit
ce9cbb9c47
|
@ -1026,13 +1026,23 @@ static void HandleBrokenAircraft(Vehicle *v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int8 _aircraft_smoke_xy[16] = {
|
|
||||||
5,6,5,0,-5,-6,-5,0, /* x coordinates */
|
|
||||||
5,0,-5,-6,-5,0,5,6, /* y coordinate */
|
|
||||||
};
|
|
||||||
|
|
||||||
static void HandleAircraftSmoke(Vehicle *v)
|
static void HandleAircraftSmoke(Vehicle *v)
|
||||||
{
|
{
|
||||||
|
static const struct {
|
||||||
|
int8 x;
|
||||||
|
int8 y;
|
||||||
|
} smoke_pos[] = {
|
||||||
|
{ 5, 5 },
|
||||||
|
{ 6, 0 },
|
||||||
|
{ 5, -5 },
|
||||||
|
{ 0, -6 },
|
||||||
|
{ -5, -5 },
|
||||||
|
{ -6, 0 },
|
||||||
|
{ -5, 5 },
|
||||||
|
{ 0, 6 }
|
||||||
|
};
|
||||||
|
|
||||||
if (!(v->vehstatus & VS_AIRCRAFT_BROKEN)) return;
|
if (!(v->vehstatus & VS_AIRCRAFT_BROKEN)) return;
|
||||||
|
|
||||||
if (v->cur_speed < 10) {
|
if (v->cur_speed < 10) {
|
||||||
|
@ -1043,8 +1053,8 @@ static void HandleAircraftSmoke(Vehicle *v)
|
||||||
|
|
||||||
if ((v->tick_counter & 0x1F) == 0) {
|
if ((v->tick_counter & 0x1F) == 0) {
|
||||||
CreateEffectVehicleRel(v,
|
CreateEffectVehicleRel(v,
|
||||||
_aircraft_smoke_xy[v->direction],
|
smoke_pos[v->direction].x,
|
||||||
_aircraft_smoke_xy[v->direction + 8],
|
smoke_pos[v->direction].y,
|
||||||
2,
|
2,
|
||||||
EV_SMOKE
|
EV_SMOKE
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,11 +13,16 @@ static const SpriteID _tree_sprites_1[4] = {
|
||||||
static const byte _tree_base_by_landscape[4] = {0, 12, 20, 32};
|
static const byte _tree_base_by_landscape[4] = {0, 12, 20, 32};
|
||||||
static const byte _tree_count_by_landscape[4] = {12, 8, 12, 9};
|
static const byte _tree_count_by_landscape[4] = {12, 8, 12, 9};
|
||||||
|
|
||||||
static const byte _tree_layout_xy[4][8] = {
|
typedef struct TreePos {
|
||||||
{9, 3, 1, 8, 0, 0, 8, 9},
|
uint8 x;
|
||||||
{4, 4, 9, 1, 6, 9, 0, 9},
|
uint8 y;
|
||||||
{9, 1, 0, 9, 6, 6, 3, 0},
|
} TreePos;
|
||||||
{3, 9, 8, 2, 9, 9, 1, 5},
|
|
||||||
|
static const TreePos _tree_layout_xy[][4] = {
|
||||||
|
{ { 9, 3 }, { 1, 8 }, { 0, 0 }, { 8, 9 } },
|
||||||
|
{ { 4, 4 }, { 9, 1 }, { 6, 9 }, { 0, 9 } },
|
||||||
|
{ { 9, 1 }, { 0, 9 }, { 6, 6 }, { 3, 0 } },
|
||||||
|
{ { 3, 9 }, { 8, 2 }, { 9, 9 }, { 1, 5 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const PalSpriteID _tree_layout_sprite[164+(79-48+1)][4] = {
|
static const PalSpriteID _tree_layout_sprite[164+(79-48+1)][4] = {
|
||||||
|
|
|
@ -251,7 +251,7 @@ static void DrawTile_Trees(TileInfo *ti)
|
||||||
{
|
{
|
||||||
uint16 m2;
|
uint16 m2;
|
||||||
const uint32 *s;
|
const uint32 *s;
|
||||||
const byte *d;
|
const TreePos* d;
|
||||||
byte z;
|
byte z;
|
||||||
|
|
||||||
m2 = _m[ti->tile].m2;
|
m2 = _m[ti->tile].m2;
|
||||||
|
@ -308,10 +308,10 @@ static void DrawTile_Trees(TileInfo *ti)
|
||||||
uint32 image = s[0] + (--i == 0 ? GB(ti->map5, 0, 3) : 3);
|
uint32 image = s[0] + (--i == 0 ? GB(ti->map5, 0, 3) : 3);
|
||||||
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
||||||
te[i].image = image;
|
te[i].image = image;
|
||||||
te[i].x = d[0];
|
te[i].x = d->x;
|
||||||
te[i].y = d[1];
|
te[i].y = d->y;
|
||||||
s++;
|
s++;
|
||||||
d += 2;
|
d++;
|
||||||
} while (i);
|
} while (i);
|
||||||
|
|
||||||
/* draw them in a sorted way */
|
/* draw them in a sorted way */
|
||||||
|
|
Loading…
Reference in New Issue