mirror of https://github.com/OpenTTD/OpenTTD
Add: Accessor to test if a tile may be animated.
parent
3a310f1802
commit
be505ec459
|
@ -530,7 +530,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
|
||||||
void DoClearSquare(TileIndex tile)
|
void DoClearSquare(TileIndex tile)
|
||||||
{
|
{
|
||||||
/* If the tile can have animation and we clear it, delete it from the animated tile list. */
|
/* If the tile can have animation and we clear it, delete it from the animated tile list. */
|
||||||
if (_tile_type_procs[GetTileType(tile)]->animate_tile_proc != nullptr) DeleteAnimatedTile(tile);
|
if (MayAnimateTile(tile)) DeleteAnimatedTile(tile);
|
||||||
|
|
||||||
bool remove = IsDockingTile(tile);
|
bool remove = IsDockingTile(tile);
|
||||||
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0);
|
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0);
|
||||||
|
|
|
@ -2203,7 +2203,7 @@ bool AfterLoadGame()
|
||||||
|
|
||||||
for (auto tile = _animated_tiles.begin(); tile < _animated_tiles.end(); /* Nothing */) {
|
for (auto tile = _animated_tiles.begin(); tile < _animated_tiles.end(); /* Nothing */) {
|
||||||
/* Remove if tile is not animated */
|
/* Remove if tile is not animated */
|
||||||
bool remove = _tile_type_procs[GetTileType(*tile)]->animate_tile_proc == nullptr;
|
bool remove = !MayAnimateTile(*tile);
|
||||||
|
|
||||||
/* and remove if duplicate */
|
/* and remove if duplicate */
|
||||||
for (auto j = _animated_tiles.begin(); !remove && j < tile; j++) {
|
for (auto j = _animated_tiles.begin(); !remove && j < tile; j++) {
|
||||||
|
|
|
@ -194,6 +194,16 @@ inline void AddProducedCargo(TileIndex tile, CargoArray &produced)
|
||||||
proc(tile, produced);
|
proc(tile, produced);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if a tile may be animated.
|
||||||
|
* @param tile Tile to test.
|
||||||
|
* @returns True iff the type of the tile has a handler for tile animation.
|
||||||
|
*/
|
||||||
|
inline bool MayAnimateTile(TileIndex tile)
|
||||||
|
{
|
||||||
|
return _tile_type_procs[GetTileType(tile)]->animate_tile_proc != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
inline void AnimateTile(TileIndex tile)
|
inline void AnimateTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
AnimateTileProc *proc = _tile_type_procs[GetTileType(tile)]->animate_tile_proc;
|
AnimateTileProc *proc = _tile_type_procs[GetTileType(tile)]->animate_tile_proc;
|
||||||
|
|
Loading…
Reference in New Issue