Codechange: Move Ticks into their own class

This commit is contained in:
Tyler Trahan
2023-08-16 09:01:24 -04:00
parent 30172fc037
commit fca2b37726
34 changed files with 132 additions and 116 deletions

View File

@@ -822,7 +822,7 @@ static void TownTickHandler(Town *t)
i = t->growth_rate;
} else {
/* If growth failed wait a bit before retrying */
i = std::min<uint16_t>(t->growth_rate, TOWN_GROWTH_TICKS - 1);
i = std::min<uint16_t>(t->growth_rate, Ticks::TOWN_GROWTH_TICKS - 1);
}
}
t->grow_counter = i;
@@ -1868,7 +1868,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32_t townnameparts, TownSi
t->cache.population = 0;
/* Spread growth across ticks so even if there are many
* similar towns they're unlikely to grow all in one tick */
t->grow_counter = t->index % TOWN_GROWTH_TICKS;
t->grow_counter = t->index % Ticks::TOWN_GROWTH_TICKS;
t->growth_rate = TownTicksToGameTicks(250);
t->show_zone = false;
@@ -3236,7 +3236,7 @@ static CommandCost TownActionFundBuildings(Town *t, DoCommandFlag flags)
* tick-perfect and gives player some time window where they can
* spam funding with the exact same efficiency.
*/
t->grow_counter = std::min<uint16_t>(t->grow_counter, 2 * TOWN_GROWTH_TICKS - (t->growth_rate - t->grow_counter) % TOWN_GROWTH_TICKS);
t->grow_counter = std::min<uint16_t>(t->grow_counter, 2 * Ticks::TOWN_GROWTH_TICKS - (t->growth_rate - t->grow_counter) % Ticks::TOWN_GROWTH_TICKS);
SetWindowDirty(WC_TOWN_VIEW, t->index);
}