Add wrappers to get and update the current effective day length factor
This commit is contained in:
@@ -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),
|
||||
|
Reference in New Issue
Block a user