From 1e98680bf646ca4303177a31293472e145556630 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sat, 29 Apr 2023 11:38:17 -0400 Subject: [PATCH] Codechange: Track the company age in economy years --- src/company_base.h | 4 ++-- src/company_cmd.cpp | 2 +- src/company_gui.cpp | 8 ++++---- src/saveload/afterload.cpp | 6 +++--- src/saveload/oldloader_sl.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/company_base.h b/src/company_base.h index eea9974089..a752e215a3 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -14,7 +14,7 @@ #include "livery.h" #include "autoreplace_type.h" #include "tile_type.h" -#include "timer/timer_game_calendar.h" +#include "timer/timer_game_economy.h" #include "settings_type.h" #include "group.h" @@ -74,7 +74,7 @@ struct CompanyProperties { TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none. TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company. - TimerGameCalendar::Year inaugurated_year; ///< Year of starting the company. + TimerGameEconomy::Year inaugurated_year; ///< Economy year of starting the company. byte months_of_bankruptcy; ///< Number of months that the company is unable to pay its debts CompanyMask bankrupt_asked; ///< which companies were asked about buying it? diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index b3f3db23d6..d8d9e4351e 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -565,7 +565,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY) c->avail_railtypes = GetCompanyRailTypes(c->index); c->avail_roadtypes = GetCompanyRoadTypes(c->index); - c->inaugurated_year = TimerGameCalendar::year; + c->inaugurated_year = TimerGameEconomy::year; /* If starting a player company in singleplayer and a favorite company manager face is selected, choose it. Otherwise, use a random face. * In a network game, we'll choose the favorite face later in CmdCompanyCtrl to sync it to all clients. */ diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 24c4552a43..64d328c7ce 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -22,7 +22,7 @@ #include "newgrf.h" #include "company_manager_face.h" #include "strings_func.h" -#include "timer/timer_game_calendar.h" +#include "timer/timer_game_economy.h" #include "widgets/dropdown_type.h" #include "tilehighlight_func.h" #include "company_base.h" @@ -255,7 +255,7 @@ static Money DrawYearCategory(const Rect &r, int start_y, const ExpensesList &li * @param tbl Reference to table of amounts for \a year. * @note The environment must provide padding at the left and right of \a r. */ -static void DrawYearColumn(const Rect &r, TimerGameCalendar::Year year, const Expenses &tbl) +static void DrawYearColumn(const Rect &r, TimerGameEconomy::Year year, const Expenses &tbl) { int y = r.top; Money sum; @@ -421,10 +421,10 @@ struct CompanyFinancesWindow : Window { case WID_CF_EXPS_PRICE2: case WID_CF_EXPS_PRICE3: { const Company *c = Company::Get((CompanyID)this->window_number); - auto age = std::min(TimerGameCalendar::year - c->inaugurated_year, TimerGameCalendar::Year(2)); + auto age = std::min(TimerGameEconomy::year - c->inaugurated_year, TimerGameEconomy::Year(2)); int wid_offset = widget - WID_CF_EXPS_PRICE1; if (wid_offset <= age) { - DrawYearColumn(r, TimerGameCalendar::year - (age - wid_offset), c->yearly_expenses[(age - wid_offset).base()]); + DrawYearColumn(r, TimerGameEconomy::year - (age - wid_offset), c->yearly_expenses[(age - wid_offset).base()]); } break; } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 4d4ab4ae05..3a4467add4 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -261,8 +261,8 @@ static void InitializeWindowsAndCaches() /* For each company, verify (while loading a scenario) that the inauguration date is the current year and set it * accordingly if it is not the case. No need to set it on companies that are not been used already, * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */ - if (_file_to_saveload.abstract_ftype == FT_SCENARIO && c->inaugurated_year != CalendarTime::MIN_YEAR) { - c->inaugurated_year = TimerGameCalendar::year; + if (_file_to_saveload.abstract_ftype == FT_SCENARIO && c->inaugurated_year != EconomyTime::MIN_YEAR) { + c->inaugurated_year = TimerGameEconomy::year; } } @@ -1437,7 +1437,7 @@ 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 += EconomyTime::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()) { diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 1115be1835..8d057e3226 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -1020,7 +1020,7 @@ static bool LoadOldCompany(LoadgameState *ls, int num) } _company_colours[num] = (Colours)c->colour; - c->inaugurated_year -= CalendarTime::ORIGINAL_BASE_YEAR; + c->inaugurated_year -= EconomyTime::ORIGINAL_BASE_YEAR; return true; }