From 8754846901ab1e41922f1a7462fc8f8a7164b69c Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 1 Aug 2024 21:11:35 +0100 Subject: [PATCH] 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. --- src/animated_tile.cpp | 8 ++++---- src/animated_tile_func.h | 2 +- src/industry_cmd.cpp | 2 +- src/newgrf_animation_base.h | 2 +- src/town_cmd.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp index 946c66a985..e200788ad5 100644 --- a/src/animated_tile.cpp +++ b/src/animated_tile.cpp @@ -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); } diff --git a/src/animated_tile_func.h b/src/animated_tile_func.h index 6a871f1bc5..315b10511a 100644 --- a/src/animated_tile_func.h +++ b/src/animated_tile_func.h @@ -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(); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 0c17a38105..f38dc5d5c7 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -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; } } diff --git a/src/newgrf_animation_base.h b/src/newgrf_animation_base.h index fffb31133e..af4562ffa2 100644 --- a/src/newgrf_animation_base.h +++ b/src/newgrf_animation_base.h @@ -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); diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 79e9950791..44679fbf19 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -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); }