Add wrappers to get and update the current effective day length factor

This commit is contained in:
Jonathan G Rennison
2024-02-09 19:39:58 +00:00
parent db8b77a72e
commit 516e8defb5
20 changed files with 66 additions and 42 deletions

View File

@@ -319,12 +319,12 @@ void StateGameLoop_LinkGraphPauseControl()
DoCommandP(0, PM_PAUSED_LINK_GRAPH, 0, CMD_PAUSE);
}
} else if (_pause_mode == PM_UNPAUSED && _tick_skip_counter == 0) {
if (_settings_game.economy.day_length_factor == 1) {
if (DayLengthFactor() == 1) {
if (_date_fract != LinkGraphSchedule::SPAWN_JOIN_TICK - 2) return;
if (_date.base() % _settings_game.linkgraph.recalc_interval != (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY) / 2) return;
} else {
int date_ticks = (NowDateTicks() - (LinkGraphSchedule::SPAWN_JOIN_TICK - 2)).base();
int interval = std::max<int>(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / (SECONDS_PER_DAY * _settings_game.economy.day_length_factor)));
int interval = std::max<int>(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / (SECONDS_PER_DAY * DayLengthFactor())));
if (date_ticks % interval != interval / 2) return;
}
@@ -355,12 +355,12 @@ void OnTick_LinkGraph()
{
int offset;
int interval;
if (_settings_game.economy.day_length_factor == 1) {
if (DayLengthFactor() == 1) {
if (_date_fract != LinkGraphSchedule::SPAWN_JOIN_TICK) return;
interval = _settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY;
offset = _date.base() % interval;
} else {
interval = std::max<int>(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / (SECONDS_PER_DAY * _settings_game.economy.day_length_factor)));
interval = std::max<int>(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / (SECONDS_PER_DAY * DayLengthFactor())));
offset = (NowDateTicks() - LinkGraphSchedule::SPAWN_JOIN_TICK).base() % interval;
}
if (offset == 0) {