Codechange: Allow adding to animated tile list without marking dirty.

This avoids redundant tile refreshes when the caller has already marked a tile dirty, or knows it does not need refreshing.

Loosely backported from JGRPP.
This commit is contained in:
Peter Nelson 2024-08-01 21:11:35 +01:00 committed by Peter Nelson
parent 79369a886a
commit 8754846901
5 changed files with 8 additions and 8 deletions

View File

@ -32,13 +32,13 @@ void DeleteAnimatedTile(TileIndex tile)
}
/**
* Add the given tile to the animated tile table (if it does not exist
* on that table yet). Also increases the size of the table if necessary.
* Add the given tile to the animated tile table (if it does not exist yet).
* @param tile the tile to make animated
* @param mark_dirty whether to also mark the tile dirty.
*/
void AddAnimatedTile(TileIndex tile)
void AddAnimatedTile(TileIndex tile, bool mark_dirty)
{
MarkTileDirtyByTile(tile);
if (mark_dirty) MarkTileDirtyByTile(tile);
include(_animated_tiles, tile);
}

View File

@ -12,7 +12,7 @@
#include "tile_type.h"
void AddAnimatedTile(TileIndex tile);
void AddAnimatedTile(TileIndex tile, bool mark_dirty = true);
void DeleteAnimatedTile(TileIndex tile);
void AnimateAnimatedTiles();
void InitializeAnimatedTiles();

View File

@ -800,7 +800,7 @@ static void MakeIndustryTileBigger(TileIndex tile)
case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
AddAnimatedTile(tile);
AddAnimatedTile(tile, false);
break;
}
}

View File

@ -128,7 +128,7 @@ struct AnimationBase {
switch (callback & 0xFF) {
case 0xFD: /* Do nothing. */ break;
case 0xFE: AddAnimatedTile(tile); break;
case 0xFE: AddAnimatedTile(tile, false); break;
case 0xFF: DeleteAnimatedTile(tile); break;
default:
Tframehelper::Set(obj, tile, callback);

View File

@ -2466,7 +2466,7 @@ static inline void ClearMakeHouseTile(TileIndex tile, Town *t, uint8_t counter,
IncreaseBuildingCount(t, type);
MakeHouseTile(tile, t->index, counter, stage, type, random_bits);
if (HouseSpec::Get(type)->building_flags & BUILDING_IS_ANIMATED) AddAnimatedTile(tile);
if (HouseSpec::Get(type)->building_flags & BUILDING_IS_ANIMATED) AddAnimatedTile(tile, false);
MarkTileDirtyByTile(tile);
}