Replace day length scaled tick macros with global variables.

This is to avoid needing to expensively re-calculate them all the time.
Instead update them by incrementing.
This commit is contained in:
Jonathan G Rennison
2016-09-10 00:32:00 +01:00
parent d733955d33
commit 375b069f82
16 changed files with 54 additions and 27 deletions

View File

@@ -1262,7 +1262,7 @@ void CheckCaches(bool force_check)
* always to aid testing of caches. */
if (_debug_desync_level < 1) return;
if (_debug_desync_level == 1 && CURRENT_SCALED_TICKS % 500 != 0) return;
if (_debug_desync_level == 1 && _scaled_date_ticks % 500 != 0) return;
}
/* Check the town caches. */
@@ -1527,13 +1527,15 @@ void StateGameLoop()
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
_tick_skip_counter++;
_scaled_tick_counter++; // This must update in lock-step with _tick_skip_counter, such that it always matches what SetScaledTickVariables would return.
_scaled_date_ticks++; // "
if (_tick_skip_counter < _settings_game.economy.day_length_factor) {
AnimateAnimatedTiles();
CallVehicleTicks();
} else {
_tick_skip_counter = 0;
AnimateAnimatedTiles();
IncreaseDate();
AnimateAnimatedTiles();
RunTileLoop();
CallVehicleTicks();
CallLandscapeTick();