Add wrappers to get and update the current effective day length factor
This commit is contained in:
@@ -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;
|
||||
|
@@ -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),
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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<uint>(town_scale * _settings_game.economy.day_length_factor, 1, 5000);
|
||||
town_scale = Clamp<uint>(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<uint>(industry_scale * _settings_game.economy.day_length_factor, 5, 3000);
|
||||
industry_scale = Clamp<uint>(industry_scale * DayLengthFactor(), 5, 3000);
|
||||
}
|
||||
_industry_cargo_scaler.SetScale((industry_scale << 16) / 100);
|
||||
_industry_inverse_cargo_scaler.SetScale((100 << 16) / std::max<uint>(1, industry_scale));
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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 };
|
||||
}
|
||||
|
@@ -733,10 +733,10 @@ static std::vector<uint> _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<uint64_t>(1) << (MapLogX() + MapLogY() + 8)) / _settings_game.economy.day_length_factor;
|
||||
uint64_t count_per_tick_fp16 = (static_cast<uint64_t>(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);
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@
|
||||
|
||||
/* static */ SQInteger ScriptDate::GetDayLengthFactor()
|
||||
{
|
||||
return _settings_game.economy.day_length_factor;
|
||||
return DayLengthFactor();
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptDate::GetYear(ScriptDate::Date date)
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "../../command_type.h"
|
||||
#include "../../command_func.h"
|
||||
#include "../../economy_func.h"
|
||||
#include "../../date_func.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
@@ -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. */
|
||||
|
@@ -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<uint>((LinkGraph::MIN_TIMEOUT_DISTANCE + (DistanceManhattan(from->xy, to->xy) >> 3)) / _settings_game.economy.day_length_factor, 1);
|
||||
DateDelta timeout = std::max<uint>((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<uint>((static_cast<uint64_t>(i->first) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / runtime));
|
||||
share = std::max(share + 1, ClampTo<uint>((static_cast<uint64_t>(i->first) * 30 * DAY_TICKS * DayLengthFactor()) / runtime));
|
||||
if (this->unrestricted == i->first) this->unrestricted = share;
|
||||
i->first = share;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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.
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user