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

@@ -365,7 +365,7 @@ public:
*/
inline uint Monthly(uint base) const
{
return (uint)((static_cast<uint64_t>(base) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / std::max<uint64_t>((_state_ticks - this->last_compression).base(), DAY_TICKS));
return (uint)((static_cast<uint64_t>(base) * 30 * DAY_TICKS * DayLengthFactor()) / std::max<uint64_t>((_state_ticks - this->last_compression).base(), DAY_TICKS));
}
NodeID AddNode(const Station *st);

View File

@@ -595,7 +595,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
SetDParam(1, time / _settings_time.ticks_per_minute);
GetString(builder, STR_LINKGRAPH_STATS_TOOLTIP_TIME_EXTENSION_GENERAL);
} else {
SetDParam(0, time / (DAY_TICKS * _settings_game.economy.day_length_factor));
SetDParam(0, time / (DAY_TICKS * DayLengthFactor()));
GetString(builder, STR_LINKGRAPH_STATS_TOOLTIP_TIME_EXTENSION);
}
}

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) {