Add method for whether calendar is frozen
This commit is contained in:
10
src/date.cpp
10
src/date.cpp
@@ -275,6 +275,12 @@ EconTime::Date EconTime::ConvertYMDToDate(EconTime::Year year, EconTime::Month m
|
||||
return CalTime::ConvertYMDToDate(year.base(), month, day).base();
|
||||
}
|
||||
|
||||
bool CalTime::IsCalendarFrozen(bool newgame)
|
||||
{
|
||||
GameSettings &settings = (newgame) ? _settings_newgame : _settings_game;
|
||||
return settings.economy.timekeeping_units == TKU_WALLCLOCK && settings.economy.minutes_per_calendar_year == CalTime::FROZEN_MINUTES_PER_YEAR;
|
||||
}
|
||||
|
||||
bool EconTime::UsingWallclockUnits(bool newgame)
|
||||
{
|
||||
if (newgame) return (_settings_newgame.economy.timekeeping_units == TKU_WALLCLOCK);
|
||||
@@ -417,10 +423,10 @@ static void OnNewEconomyDay()
|
||||
static void IncreaseCalendarDate()
|
||||
{
|
||||
/* If calendar day progress is frozen, don't try to advance time. */
|
||||
if (_settings_game.economy.minutes_per_calendar_year == CalTime::FROZEN_MINUTES_PER_YEAR) return;
|
||||
if (CalTime::IsCalendarFrozen()) return;
|
||||
|
||||
/* If we are using a non-default calendar progression speed, we need to check the sub_date_fract before updating date_fract. */
|
||||
if (_settings_game.economy.minutes_per_calendar_year != CalTime::DEF_MINUTES_PER_YEAR) {
|
||||
if (_settings_game.economy.timekeeping_units == TKU_WALLCLOCK && _settings_game.economy.minutes_per_calendar_year != CalTime::DEF_MINUTES_PER_YEAR) {
|
||||
CalTime::Detail::now.sub_date_fract++;
|
||||
|
||||
/* Check if we are ready to increment date_fract */
|
||||
|
@@ -195,6 +195,8 @@ struct CalTime : public DateDetail::BaseTime<struct CalendarTimeTag> {
|
||||
return ConvertYMDToDate(ymd.year, ymd.month, ymd.day);
|
||||
}
|
||||
|
||||
static bool IsCalendarFrozen(bool newgame = false);
|
||||
|
||||
/**
|
||||
* Calculate the year of a given date.
|
||||
* @param date The date to consider.
|
||||
|
@@ -1565,7 +1565,7 @@ void CallVehicleTicks()
|
||||
|
||||
if (TickSkipCounter() == 0) RunVehicleDayProc();
|
||||
|
||||
if (EconTime::UsingWallclockUnits() && _settings_game.economy.minutes_per_calendar_year != CalTime::FROZEN_MINUTES_PER_YEAR && CalTime::Detail::now.sub_date_fract == 0) {
|
||||
if (EconTime::UsingWallclockUnits() && !CalTime::IsCalendarFrozen() && CalTime::Detail::now.sub_date_fract == 0) {
|
||||
RunVehicleCalendarDayProc();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user