diff --git a/src/crashlog.cpp b/src/crashlog.cpp index 6d878d1caf..8af0103b8f 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -559,7 +559,7 @@ char *CrashLog::FillCrashLog(char *buffer, const char *last) buffer = this->TryCrashLogFaultSection(buffer, last, "times", [](CrashLog *self, char *buffer, const char *last) -> char * { buffer += UTCTime::Format(buffer, last, "Crash at: %Y-%m-%d %H:%M:%S (UTC)\n"); - buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u)\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, _settings_game.economy.day_length_factor); + buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u)\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, DayLengthFactor()); LogGameLoadDateTimes(buffer, last); return buffer; }); @@ -677,7 +677,7 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last, const DesyncE extern uint32_t _frame_counter; buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u), %08X\n", - _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, _settings_game.economy.day_length_factor, _frame_counter); + _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, DayLengthFactor(), _frame_counter); LogGameLoadDateTimes(buffer, last); if (!_network_server) { extern Date _last_sync_date; @@ -738,7 +738,7 @@ char *CrashLog::FillInconsistencyLog(char *buffer, const char *last, const Incon extern uint32_t _frame_counter; buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u), %08X\n", - _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, _settings_game.economy.day_length_factor, _frame_counter); + _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, DayLengthFactor(), _frame_counter); LogGameLoadDateTimes(buffer, last); if (_networking && !_network_server) { extern Date _last_sync_date; diff --git a/src/date.cpp b/src/date.cpp index acf9dc494a..cc85b807fa 100644 --- a/src/date.cpp +++ b/src/date.cpp @@ -35,6 +35,7 @@ uint8_t _tick_skip_counter; ///< Counter for ticks, when only veh uint64_t _scaled_tick_counter; ///< Tick counter in daylength-scaled ticks StateTicks _state_ticks; ///< Current state tick StateTicksDelta _state_ticks_offset; ///< Offset to add when calculating a StateTicks value from a date/date fract/tick skip counter +uint8_t _effective_day_length; ///< Current effective day length uint32_t _quit_after_days; ///< Quit after this many days of run time extern void ClearOutOfDateSignalSpeedRestrictions(); @@ -87,7 +88,7 @@ void SetDate(Date date, DateFract fract) StateTicks GetStateTicksFromCurrentDateWithoutOffset() { - return ((int64_t)(DateToDateTicks(_date, _date_fract).base()) * _settings_game.economy.day_length_factor) + _tick_skip_counter; + return ((int64_t)(DateToDateTicks(_date, _date_fract).base()) * DayLengthFactor()) + _tick_skip_counter; } void RecalculateStateTicksOffset() @@ -95,6 +96,11 @@ void RecalculateStateTicksOffset() _state_ticks_offset = _state_ticks - GetStateTicksFromCurrentDateWithoutOffset(); } +void UpdateEffectiveDayLengthFactor() +{ + _effective_day_length = _settings_game.EffectiveDayLengthFactor(); +} + #define M(a, b) ((a << 5) | b) static const uint16_t _month_date_from_year_day[] = { M( 0, 1), M( 0, 2), M( 0, 3), M( 0, 4), M( 0, 5), M( 0, 6), M( 0, 7), M( 0, 8), M( 0, 9), M( 0, 10), M( 0, 11), M( 0, 12), M( 0, 13), M( 0, 14), M( 0, 15), M( 0, 16), M( 0, 17), M( 0, 18), M( 0, 19), M( 0, 20), M( 0, 21), M( 0, 22), M( 0, 23), M( 0, 24), M( 0, 25), M( 0, 26), M( 0, 27), M( 0, 28), M( 0, 29), M( 0, 30), M( 0, 31), diff --git a/src/date_func.h b/src/date_func.h index 40c8c0cfff..4f6bb48791 100644 --- a/src/date_func.h +++ b/src/date_func.h @@ -37,6 +37,14 @@ inline Date ConvertYMDToDate(const YearMonthDay &ymd) #define _cur_year (_cur_date_ymd.year) +inline uint8_t DayLengthFactor() +{ + extern uint8_t _effective_day_length; + return _effective_day_length; +} + +void UpdateEffectiveDayLengthFactor(); + /** * Checks whether the given year is a leap year or not. * @param yr The year to check. @@ -49,22 +57,22 @@ inline bool IsLeapYear(Year yr) inline Date StateTicksToDate(StateTicks ticks) { - return (ticks.base() - _state_ticks_offset.base()) / (DAY_TICKS * _settings_game.economy.day_length_factor); + return (ticks.base() - _state_ticks_offset.base()) / (DAY_TICKS * DayLengthFactor()); } inline StateTicks DateToStateTicks(Date date) { - return ((int64_t)date.base() * DAY_TICKS * _settings_game.economy.day_length_factor) + _state_ticks_offset.base(); + return ((int64_t)date.base() * DAY_TICKS * DayLengthFactor()) + _state_ticks_offset.base(); } inline DateTicks StateTicksToDateTicks(StateTicks ticks) { - return (ticks.base() - _state_ticks_offset.base()) / _settings_game.economy.day_length_factor; + return (ticks.base() - _state_ticks_offset.base()) / DayLengthFactor(); } inline StateTicks DateTicksToStateTicks(DateTicks date_ticks) { - return ((int64_t)date_ticks.base() * _settings_game.economy.day_length_factor) + _state_ticks_offset.base(); + return ((int64_t)date_ticks.base() * DayLengthFactor()) + _state_ticks_offset.base(); } /** @@ -102,7 +110,7 @@ inline Ticks TimetableDisplayUnitSize() if (_settings_time.time_in_minutes) { return _settings_time.ticks_per_minute; } else { - return DAY_TICKS * _settings_game.economy.day_length_factor; + return DAY_TICKS * DayLengthFactor(); } } diff --git a/src/departures.cpp b/src/departures.cpp index a2ecb1b1ef..8ee0d52ee6 100644 --- a/src/departures.cpp +++ b/src/departures.cpp @@ -887,6 +887,6 @@ Ticks GetDeparturesMaxTicksAhead() if (_settings_time.time_in_minutes) { return _settings_client.gui.max_departure_time_minutes * _settings_time.ticks_per_minute; } else { - return _settings_client.gui.max_departure_time * DAY_TICKS * _settings_game.economy.day_length_factor; + return _settings_client.gui.max_departure_time * DAY_TICKS * DayLengthFactor(); } } diff --git a/src/economy.cpp b/src/economy.cpp index e904160a48..9a3dc4f507 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -2731,13 +2731,13 @@ void UpdateCargoScalers() { uint town_scale = _settings_game.economy.town_cargo_scale; if (_settings_game.economy.town_cargo_scale_mode == CSM_DAYLENGTH) { - town_scale = Clamp(town_scale * _settings_game.economy.day_length_factor, 1, 5000); + town_scale = Clamp(town_scale * DayLengthFactor(), 1, 5000); } _town_cargo_scaler.SetScale((town_scale << 16) / 100); uint industry_scale = _settings_game.economy.industry_cargo_scale; if (_settings_game.economy.industry_cargo_scale_mode == CSM_DAYLENGTH) { - industry_scale = Clamp(industry_scale * _settings_game.economy.day_length_factor, 5, 3000); + industry_scale = Clamp(industry_scale * DayLengthFactor(), 5, 3000); } _industry_cargo_scaler.SetScale((industry_scale << 16) / 100); _industry_inverse_cargo_scaler.SetScale((100 << 16) / std::max(1, industry_scale)); diff --git a/src/engine.cpp b/src/engine.cpp index 9f7001e016..db427b9328 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -315,7 +315,7 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity) const */ Money Engine::GetDisplayRunningCost() const { - return this->GetRunningCost() * _settings_game.economy.day_length_factor; + return this->GetRunningCost() * DayLengthFactor(); } /** diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 66ef746320..c1ab94852c 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -1214,16 +1214,16 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { val *= 74; val /= _settings_time.ticks_per_minute; } else { - if ((10 % _settings_game.economy.day_length_factor) == 0) { + if ((10 % DayLengthFactor()) == 0) { decimals = 0; - } else if (_settings_game.economy.day_length_factor > 50) { + } else if (DayLengthFactor() > 50) { decimals = 2; val *= 100; } else { decimals = 1; val *= 10; } - val /= _settings_game.economy.day_length_factor; + val /= DayLengthFactor(); } return { val, decimals }; } diff --git a/src/landscape.cpp b/src/landscape.cpp index 4a977d8be6..b84ea00176 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -733,10 +733,10 @@ static std::vector _tile_loop_counts; void SetupTileLoopCounts() { - _tile_loop_counts.resize(_settings_game.economy.day_length_factor); - if (_settings_game.economy.day_length_factor == 0) return; + _tile_loop_counts.resize(DayLengthFactor()); + if (DayLengthFactor() == 0) return; - uint64_t count_per_tick_fp16 = (static_cast(1) << (MapLogX() + MapLogY() + 8)) / _settings_game.economy.day_length_factor; + uint64_t count_per_tick_fp16 = (static_cast(1) << (MapLogX() + MapLogY() + 8)) / DayLengthFactor(); uint64_t accumulator = 0; for (uint &count : _tile_loop_counts) { accumulator += count_per_tick_fp16; @@ -753,7 +753,7 @@ void RunTileLoop(bool apply_day_length) { /* We update every tile every 256 ticks, so divide the map size by 2^8 = 256 */ uint count; - if (apply_day_length && _settings_game.economy.day_length_factor > 1) { + if (apply_day_length && DayLengthFactor() > 1) { count = _tile_loop_counts[_tick_skip_counter]; if (count == 0) return; } else { @@ -795,7 +795,7 @@ void RunTileLoop(bool apply_day_length) void RunAuxiliaryTileLoop() { /* At day lengths <= 4, flooding is handled by main tile loop */ - if (_settings_game.economy.day_length_factor <= 4 || (_scaled_tick_counter % 4) != 0) return; + if (DayLengthFactor() <= 4 || (_scaled_tick_counter % 4) != 0) return; PerformanceAccumulator framerate(PFE_GL_LANDSCAPE); diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h index 6c501ed22a..d43d9b8f50 100644 --- a/src/linkgraph/linkgraph.h +++ b/src/linkgraph/linkgraph.h @@ -365,7 +365,7 @@ public: */ inline uint Monthly(uint base) const { - return (uint)((static_cast(base) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / std::max((_state_ticks - this->last_compression).base(), DAY_TICKS)); + return (uint)((static_cast(base) * 30 * DAY_TICKS * DayLengthFactor()) / std::max((_state_ticks - this->last_compression).base(), DAY_TICKS)); } NodeID AddNode(const Station *st); diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index b415117004..c643ee9332 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -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); } } diff --git a/src/linkgraph/linkgraphschedule.cpp b/src/linkgraph/linkgraphschedule.cpp index 9f71927b79..e5cde11abd 100644 --- a/src/linkgraph/linkgraphschedule.cpp +++ b/src/linkgraph/linkgraphschedule.cpp @@ -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(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / (SECONDS_PER_DAY * _settings_game.economy.day_length_factor))); + int interval = std::max(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(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / (SECONDS_PER_DAY * _settings_game.economy.day_length_factor))); + interval = std::max(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / (SECONDS_PER_DAY * DayLengthFactor()))); offset = (NowDateTicks() - LinkGraphSchedule::SPAWN_JOIN_TICK).base() % interval; } if (offset == 0) { diff --git a/src/openttd.cpp b/src/openttd.cpp index fc8a702ed6..d7e0cf39d6 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -609,6 +609,7 @@ void MakeNewgameSettingsLive() _settings_game.game_config = new GameConfig(_settings_newgame.game_config); } + UpdateEffectiveDayLengthFactor(); SetupTickRate(); } @@ -2161,7 +2162,7 @@ void StateGameLoop() } RunAuxiliaryTileLoop(); - if (_tick_skip_counter < _settings_game.economy.day_length_factor) { + if (_tick_skip_counter < DayLengthFactor()) { AnimateAnimatedTiles(); RunTileLoop(true); CallVehicleTicks(); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index e0a9367336..8b2abf6a03 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -669,6 +669,8 @@ bool AfterLoadGame() TileIndex map_size = MapSize(); + UpdateEffectiveDayLengthFactor(); + extern TileIndex _cur_tileloop_tile; // From landscape.cpp. /* The LFSR used in RunTileLoop iteration cannot have a zeroed state, make it non-zeroed. */ if (_cur_tileloop_tile == 0) _cur_tileloop_tile = 1; @@ -843,16 +845,17 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_11, 1) || (IsSavegameVersionBefore(SLV_147) && _date_fract > DAY_TICKS)) _date_fract /= 885; if (SlXvIsFeaturePresent(XSLFI_SPRINGPP) || SlXvIsFeaturePresent(XSLFI_JOKERPP) || SlXvIsFeaturePresent(XSLFI_CHILLPP)) { - assert(_settings_game.economy.day_length_factor >= 1); - _tick_skip_counter = _date_fract % _settings_game.economy.day_length_factor; - _date_fract /= _settings_game.economy.day_length_factor; + assert(DayLengthFactor() >= 1); + _tick_skip_counter = _date_fract % DayLengthFactor(); + _date_fract /= DayLengthFactor(); assert(_date_fract < DAY_TICKS); - assert(_tick_skip_counter < _settings_game.economy.day_length_factor); + assert(_tick_skip_counter < DayLengthFactor()); } /* Set day length factor to 1 if loading a pre day length savegame */ if (SlXvIsFeatureMissing(XSLFI_VARIABLE_DAY_LENGTH) && SlXvIsFeatureMissing(XSLFI_SPRINGPP) && SlXvIsFeatureMissing(XSLFI_JOKERPP) && SlXvIsFeatureMissing(XSLFI_CHILLPP)) { _settings_game.economy.day_length_factor = 1; + UpdateEffectiveDayLengthFactor(); if (_file_to_saveload.abstract_ftype != FT_SCENARIO) { /* If this is obviously a vanilla/non-patchpack savegame (and not a scenario), * set the savegame time units to be in days, as they would have been previously. */ @@ -860,7 +863,7 @@ bool AfterLoadGame() } } if (SlXvIsFeatureMissing(XSLFI_VARIABLE_DAY_LENGTH, 3)) { - _scaled_tick_counter = (uint64_t)((_tick_counter * _settings_game.economy.day_length_factor) + _tick_skip_counter); + _scaled_tick_counter = (uint64_t)((_tick_counter * DayLengthFactor()) + _tick_skip_counter); } if (SlXvIsFeaturePresent(XSLFI_VARIABLE_DAY_LENGTH, 1, 3)) { _state_ticks = GetStateTicksFromCurrentDateWithoutOffset() + _state_ticks_offset; @@ -3916,7 +3919,7 @@ bool AfterLoadGame() const StateTicksDelta delta = _state_ticks.base() - (int64_t)_scaled_tick_counter; for (Vehicle *v : Vehicle::Iterate()) { if (v->last_loading_tick != 0) { - if (SlXvIsFeaturePresent(XSLFI_LAST_LOADING_TICK, 1, 1)) v->last_loading_tick = v->last_loading_tick.base() * _settings_game.economy.day_length_factor; + if (SlXvIsFeaturePresent(XSLFI_LAST_LOADING_TICK, 1, 1)) v->last_loading_tick = v->last_loading_tick.base() * DayLengthFactor(); v->last_loading_tick += delta; } } diff --git a/src/script/api/script_date.cpp b/src/script/api/script_date.cpp index ff4991200f..9d168483f5 100644 --- a/src/script/api/script_date.cpp +++ b/src/script/api/script_date.cpp @@ -30,7 +30,7 @@ /* static */ SQInteger ScriptDate::GetDayLengthFactor() { - return _settings_game.economy.day_length_factor; + return DayLengthFactor(); } /* static */ SQInteger ScriptDate::GetYear(ScriptDate::Date date) diff --git a/src/script/api/script_gamesettings.cpp b/src/script/api/script_gamesettings.cpp index e5aa8c306b..cd275e5966 100644 --- a/src/script/api/script_gamesettings.cpp +++ b/src/script/api/script_gamesettings.cpp @@ -14,6 +14,7 @@ #include "../../command_type.h" #include "../../command_func.h" #include "../../economy_func.h" +#include "../../date_func.h" #include @@ -29,7 +30,7 @@ struct CargoScalingProxy { uint64_t scale = this->is_industry ? _settings_game.economy.industry_cargo_scale : _settings_game.economy.town_cargo_scale; CargoScalingMode mode = this->is_industry ? _settings_game.economy.industry_cargo_scale_mode : _settings_game.economy.town_cargo_scale_mode; if (mode == CSM_DAYLENGTH) { - scale *= _settings_game.economy.day_length_factor; + scale *= DayLengthFactor(); } return PercentageToScaleQuantityFactor(scale); } diff --git a/src/settings_type.h b/src/settings_type.h index c023d6b801..c038d1cfa3 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -887,6 +887,11 @@ struct GameSettings { TimeSettings game_time; ///< time display settings. OldEconomySettings old_economy; + + uint8_t EffectiveDayLengthFactor() const + { + return this->economy.day_length_factor; + } }; /** All settings that are only important for the local client. */ diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index c6c73cc7c2..375abb0cb3 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -4472,7 +4472,7 @@ void DeleteStaleLinks(Station *from) Station *to = Station::Get((*lg)[to_id].Station()); assert(to->goods[c].node == to_id); assert(_date >= edge.LastUpdate()); - DateDelta timeout = std::max((LinkGraph::MIN_TIMEOUT_DISTANCE + (DistanceManhattan(from->xy, to->xy) >> 3)) / _settings_game.economy.day_length_factor, 1); + DateDelta timeout = std::max((LinkGraph::MIN_TIMEOUT_DISTANCE + (DistanceManhattan(from->xy, to->xy) >> 3)) / DayLengthFactor(), 1); if (edge.LastAircraftUpdate() != INVALID_DATE && (_date - edge.LastAircraftUpdate()) > timeout) { edge.ClearAircraft(); } @@ -5524,7 +5524,7 @@ void FlowStat::ScaleToMonthly(uint runtime) assert(runtime > 0); uint share = 0; for (iterator i = this->begin(); i != this->end(); ++i) { - share = std::max(share + 1, ClampTo((static_cast(i->first) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / runtime)); + share = std::max(share + 1, ClampTo((static_cast(i->first) * 30 * DAY_TICKS * DayLengthFactor()) / runtime)); if (this->unrestricted == i->first) this->unrestricted = share; i->first = share; } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index d0b10e357f..83244aeef8 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1313,7 +1313,7 @@ void CallVehicleOnNewDay(Vehicle *v) T::From(v)->T::OnNewDay(); /* Vehicle::OnPeriodic is decoupled from Vehicle::OnNewDay at day lengths >= 8 */ - if (_settings_game.economy.day_length_factor < 8) T::From(v)->T::OnPeriodic(); + if (DayLengthFactor() < 8) T::From(v)->T::OnPeriodic(); } /** @@ -1529,7 +1529,7 @@ void CallVehicleTicks() if (_tick_skip_counter == 0) RunVehicleDayProc(); - if (_settings_game.economy.day_length_factor >= 8 && _game_mode == GM_NORMAL) { + if (DayLengthFactor() >= 8 && _game_mode == GM_NORMAL) { /* * Vehicle::OnPeriodic is decoupled from Vehicle::OnNewDay at day lengths >= 8 * Use a fixed interval of 512 ticks (unscaled) instead diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 7830ce7dc1..b888e30c0e 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -693,7 +693,7 @@ public: * Gets the running cost of a vehicle that can be sent into SetDParam for string processing. * @return the vehicle's running cost */ - Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8) * _settings_game.economy.day_length_factor; } + Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8) * DayLengthFactor(); } /** * Gets the profit vehicle had this year. It can be sent into SetDParam for string processing. diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 61f36493d5..5f3cad4434 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1341,7 +1341,7 @@ void TileLoop_Water(TileIndex tile) if (IsTileType(tile, MP_WATER)) AmbientSoundEffect(tile); /* At day lengths > 4, handle flooding in auxiliary tile loop */ - if (_settings_game.economy.day_length_factor > 4 && _game_mode != GM_EDITOR) return; + if (DayLengthFactor() > 4 && _game_mode != GM_EDITOR) return; if (IsNonFloodingWaterTile(tile)) return;