mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r6252) Replace a comglomerate of ifs for animated station tiles by a small table and a loop iterating over it
This commit is contained in:
parent
26b153b1df
commit
b536c2e4e0
@ -2238,61 +2238,32 @@ static void TileLoop_Station(TileIndex tile)
|
|||||||
|
|
||||||
static void AnimateTile_Station(TileIndex tile)
|
static void AnimateTile_Station(TileIndex tile)
|
||||||
{
|
{
|
||||||
|
typedef struct AnimData {
|
||||||
|
StationGfx from; // first sprite
|
||||||
|
StationGfx to; // last sprite
|
||||||
|
byte delay;
|
||||||
|
} AnimData;
|
||||||
|
|
||||||
|
static const AnimData data[] = {
|
||||||
|
{ GFX_RADAR_LARGE_FIRST, GFX_RADAR_LARGE_LAST, 3 },
|
||||||
|
{ GFX_WINDSACK_FIRST, GFX_WINDSACK_LAST, 1 },
|
||||||
|
{ GFX_RADAR_INTERNATIONAL_FIRST, GFX_RADAR_INTERNATIONAL_LAST, 3 },
|
||||||
|
{ GFX_RADAR_METROPOLITAN_FIRST, GFX_RADAR_METROPOLITAN_LAST, 3 },
|
||||||
|
{ GFX_RADAR_DISTRICTWE_FIRST, GFX_RADAR_DISTRICTWE_LAST, 3 },
|
||||||
|
{ GFX_WINDSACK_INTERCON_FIRST, GFX_WINDSACK_INTERCON_LAST, 1 }
|
||||||
|
};
|
||||||
|
|
||||||
StationGfx gfx = GetStationGfx(tile);
|
StationGfx gfx = GetStationGfx(tile);
|
||||||
//FIXME -- AnimateTile_Station -> not nice code, lots of things double
|
const AnimData* i;
|
||||||
// again hardcoded...was a quick hack
|
|
||||||
|
|
||||||
// turning radar / windsack on airport
|
for (i = data; i != endof(data); i++) {
|
||||||
if (IS_BYTE_INSIDE(gfx, GFX_RADAR_LARGE_FIRST, GFX_RADAR_LARGE_LAST+1)) {
|
if (i->from <= gfx && gfx <= i->to) {
|
||||||
if (_tick_counter & 3)
|
if ((_tick_counter & i->delay) == 0) {
|
||||||
return;
|
SetStationGfx(tile, gfx < i->to ? gfx + 1 : i->from);
|
||||||
|
|
||||||
if (++gfx == GFX_RADAR_LARGE_LAST+1)
|
|
||||||
gfx = GFX_RADAR_LARGE_FIRST;
|
|
||||||
|
|
||||||
SetStationGfx(tile, gfx);
|
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
//added - begin
|
|
||||||
} else if (IS_BYTE_INSIDE(gfx, GFX_RADAR_INTERNATIONAL_FIRST, GFX_RADAR_METROPOLITAN_LAST + 1) || IS_BYTE_INSIDE(gfx, GFX_RADAR_DISTRICTWE_FIRST, GFX_RADAR_DISTRICTWE_LAST + 1) ) {
|
|
||||||
if (_tick_counter & 3)
|
|
||||||
return;
|
|
||||||
|
|
||||||
gfx++;
|
|
||||||
|
|
||||||
if (gfx == GFX_RADAR_INTERNATIONAL_LAST+1) {
|
|
||||||
gfx = GFX_RADAR_INTERNATIONAL_FIRST;
|
|
||||||
}
|
}
|
||||||
else if (gfx == GFX_RADAR_METROPOLITAN_LAST+1) {
|
break;
|
||||||
gfx = GFX_RADAR_METROPOLITAN_FIRST;
|
|
||||||
}
|
}
|
||||||
else if (gfx == GFX_RADAR_DISTRICTWE_LAST + 1) {
|
|
||||||
gfx = GFX_RADAR_DISTRICTWE_FIRST;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetStationGfx(tile, gfx);
|
|
||||||
MarkTileDirtyByTile(tile);
|
|
||||||
//added - end
|
|
||||||
} else if (IS_BYTE_INSIDE(gfx, GFX_WINDSACK_FIRST, GFX_WINDSACK_LAST+1)) {
|
|
||||||
if (_tick_counter & 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (++gfx == GFX_WINDSACK_LAST+1) {
|
|
||||||
gfx = GFX_WINDSACK_FIRST;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetStationGfx(tile, gfx);
|
|
||||||
MarkTileDirtyByTile(tile);
|
|
||||||
// handle intercontinental windsock
|
|
||||||
} else if (IS_BYTE_INSIDE(gfx, GFX_WINDSACK_INTERCON_FIRST, GFX_WINDSACK_INTERCON_LAST+1)) {
|
|
||||||
if (_tick_counter & 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (++gfx == GFX_WINDSACK_INTERCON_LAST+1) {
|
|
||||||
gfx = GFX_WINDSACK_INTERCON_FIRST;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetStationGfx(tile, gfx);
|
|
||||||
MarkTileDirtyByTile(tile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user