diff --git a/src/economy.cpp b/src/economy.cpp index 09de4a20ed..be8f9c9a77 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1081,7 +1081,7 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n uint amount = std::min(num_pieces, 0xFFFFu - it->waiting); it->waiting += amount; - it->last_accepted = TimerGameCalendar::date; + it->last_accepted = TimerGameEconomy::date; num_pieces -= amount; accepted += amount; diff --git a/src/industry.h b/src/industry.h index 780dbec000..5ab623d7f7 100644 --- a/src/industry.h +++ b/src/industry.h @@ -17,12 +17,13 @@ #include "tilearea_type.h" #include "station_base.h" #include "timer/timer_game_calendar.h" +#include "timer/timer_game_economy.h" typedef Pool IndustryPool; extern IndustryPool _industry_pool; -static const TimerGameCalendar::Year PROCESSING_INDUSTRY_ABANDONMENT_YEARS = 5; ///< If a processing industry doesn't produce for this many consecutive years, it may close. +static const TimerGameEconomy::Year PROCESSING_INDUSTRY_ABANDONMENT_YEARS = 5; ///< If a processing industry doesn't produce for this many consecutive economy years, it may close. /** * Production level maximum, minimum and default values. @@ -86,7 +87,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { struct AcceptedCargo { CargoID cargo; ///< Cargo type uint16_t waiting; ///< Amount of cargo waiting to processed - TimerGameCalendar::Date last_accepted; ///< Last day cargo was accepted by this industry + TimerGameEconomy::Date last_accepted; ///< Last day cargo was accepted by this industry }; using ProducedCargoArray = std::array; @@ -103,7 +104,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { IndustryType type; ///< type of industry. Owner owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE byte random_colour; ///< randomized colour of the industry, for display purpose - TimerGameCalendar::Year last_prod_year; ///< last year of production + TimerGameEconomy::Year last_prod_year; ///< last economy year of production byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry IndustryControlFlags ctlflags; ///< flags overriding standard behaviours diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 1e79ad78e6..a603d5762e 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1783,7 +1783,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, i->counter = GB(r, 4, 12); i->random = initial_random_bits; i->was_cargo_delivered = false; - i->last_prod_year = TimerGameCalendar::year; + i->last_prod_year = TimerGameEconomy::year; i->founder = founder; i->ctlflags = INDCTL_NONE; @@ -2466,7 +2466,7 @@ static void UpdateIndustryStatistics(Industry *i) { for (auto &p : i->produced) { if (IsValidCargoID(p.cargo)) { - if (p.history[THIS_MONTH].production != 0) i->last_prod_year = TimerGameCalendar::year; + if (p.history[THIS_MONTH].production != 0) i->last_prod_year = TimerGameEconomy::year; /* Move history from this month to last month. */ std::rotate(std::rbegin(p.history), std::rbegin(p.history) + 1, std::rend(p.history)); @@ -2889,7 +2889,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) } if (!callback_enabled && (indspec->life_type & INDUSTRYLIFE_PROCESSING)) { - if (TimerGameCalendar::year - i->last_prod_year >= PROCESSING_INDUSTRY_ABANDONMENT_YEARS && Chance16(1, original_economy ? 2 : 180)) { + if (TimerGameEconomy::year - i->last_prod_year >= PROCESSING_INDUSTRY_ABANDONMENT_YEARS && Chance16(1, original_economy ? 2 : 180)) { closeit = true; } } diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 2f37abf5d4..b2db76a431 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -396,7 +396,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(byte param_setID, byte layo case 0xA6: return indspec->grf_prop.local_id; case 0xA7: return this->industry->founder; case 0xA8: return this->industry->random_colour; - case 0xA9: return ClampTo(this->industry->last_prod_year - CalendarTime::ORIGINAL_BASE_YEAR); + case 0xA9: return ClampTo(this->industry->last_prod_year - EconomyTime::ORIGINAL_BASE_YEAR); case 0xAA: return this->industry->counter; case 0xAB: return GB(this->industry->counter, 8, 8); case 0xAC: return this->industry->was_cargo_delivered; @@ -405,7 +405,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(byte param_setID, byte layo case 0xB3: return this->industry->construction_type; // Construction type case 0xB4: { auto it = std::max_element(std::begin(this->industry->accepted), std::end(this->industry->accepted), [](const auto &a, const auto &b) { return a.last_accepted < b.last_accepted; }); - return ClampTo(it->last_accepted - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Date last cargo accepted since 1920 (in days) + return ClampTo(it->last_accepted - EconomyTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Date last cargo accepted since 1920 (in days) } } diff --git a/src/openttd.cpp b/src/openttd.cpp index 6ab67287e9..926970af4e 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -844,7 +844,7 @@ static void OnStartScenario() /* Make sure all industries were built "this year", to avoid too early closures. (#9918) */ for (Industry *i : Industry::Iterate()) { - i->last_prod_year = TimerGameCalendar::year; + i->last_prod_year = TimerGameEconomy::year; } } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index b165cd7f11..4d4ab4ae05 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1437,8 +1437,8 @@ bool AfterLoadGame() for (Station *st : Station::Iterate()) st->build_date += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; for (Waypoint *wp : Waypoint::Iterate()) wp->build_date += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; for (Engine *e : Engine::Iterate()) e->intro_date += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; - for (Company *c : Company::Iterate()) c->inaugurated_year += CalendarTime::ORIGINAL_BASE_YEAR; - for (Industry *i : Industry::Iterate()) i->last_prod_year += CalendarTime::ORIGINAL_BASE_YEAR; + for (Company *c : Company::Iterate()) c->inaugurated_year += EconomyTime::ORIGINAL_BASE_YEAR; + for (Industry *i : Industry::Iterate()) i->last_prod_year += EconomyTime::ORIGINAL_BASE_YEAR; for (Vehicle *v : Vehicle::Iterate()) { v->date_of_last_service += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 1c0b79f5b3..d55549afe4 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -50,12 +50,12 @@ public: /* Old array structure used for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */ static CargoID old_cargo[INDUSTRY_NUM_INPUTS]; static uint16_t old_waiting[INDUSTRY_NUM_INPUTS]; - static TimerGameCalendar::Date old_last_accepted[INDUSTRY_NUM_INPUTS]; + static TimerGameEconomy::Date old_last_accepted[INDUSTRY_NUM_INPUTS]; }; /* static */ CargoID SlIndustryAccepted::old_cargo[INDUSTRY_NUM_INPUTS]; /* static */ uint16_t SlIndustryAccepted::old_waiting[INDUSTRY_NUM_INPUTS]; -/* static */ TimerGameCalendar::Date SlIndustryAccepted::old_last_accepted[INDUSTRY_NUM_INPUTS]; +/* static */ TimerGameEconomy::Date SlIndustryAccepted::old_last_accepted[INDUSTRY_NUM_INPUTS]; class SlIndustryProducedHistory : public DefaultSaveLoadHandler { public: diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 7589e87708..1115be1835 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -844,8 +844,8 @@ static bool LoadOldIndustry(LoadgameState *ls, int num) if (i->type > 0x06) i->type++; // Printing Works were added if (i->type == 0x0A) i->type = 0x12; // Iron Ore Mine has different ID - TimerGameCalendar::YearMonthDay ymd; - TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date, &ymd); + TimerGameEconomy::YearMonthDay ymd; + TimerGameEconomy::ConvertDateToYMD(TimerGameEconomy::date, &ymd); i->last_prod_year = ymd.year; i->random_colour = RemapTTOColour(i->random_colour);