From 7a698c7f1cdb30a9f6ac71b1276b9013e3bc2700 Mon Sep 17 00:00:00 2001 From: Kaiden Joy Date: Tue, 18 Jun 2024 19:22:43 -0400 Subject: [PATCH] Fix #12365: Company Window now displays proper inauguration year and period while in wallclock mode. --- src/company_base.h | 1 + src/company_cmd.cpp | 1 + src/company_gui.cpp | 11 +++++++++-- src/lang/english.txt | 1 + src/saveload/afterload.cpp | 6 ++++++ src/saveload/saveload.h | 1 + 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/company_base.h b/src/company_base.h index 814665777b..24f9051fc2 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -92,6 +92,7 @@ struct CompanyProperties { TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company. TimerGameEconomy::Year inaugurated_year; ///< Economy year of starting the company. + TimerGameCalendar::Year inaugurated_year_calendar; ///< Calendar year of starting the company. Used to display proper Inauguration year while in wallclock mode. uint8_t months_empty = 0; ///< NOSAVE: Number of months this company has not had a client in multiplayer. uint8_t months_of_bankruptcy; ///< Number of months that the company is unable to pay its debts diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 74ad2893f4..c73febc07e 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -608,6 +608,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 = TimerGameEconomy::year; + c->inaugurated_year_calendar = TimerGameCalendar::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 f7acd9831d..eed9fa3f02 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -2113,7 +2113,7 @@ static constexpr NWidgetPart _nested_company_widgets[] = { NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), - NWidget(WWT_TEXT, COLOUR_GREY, WID_C_DESC_INAUGURATION), SetDataTip(STR_COMPANY_VIEW_INAUGURATED_TITLE, STR_NULL), SetFill(1, 0), + NWidget(WWT_TEXT, COLOUR_GREY, WID_C_DESC_INAUGURATION), SetDataTip(STR_JUST_STRING2, STR_NULL), SetFill(1, 0), NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), NWidget(WWT_LABEL, COLOUR_GREY, WID_C_DESC_COLOUR_SCHEME), SetDataTip(STR_COMPANY_VIEW_COLOUR_SCHEME_TITLE, STR_NULL), NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_DESC_COLOUR_SCHEME_EXAMPLE), SetMinimalSize(30, 0), SetFill(1, 1), @@ -2401,7 +2401,14 @@ struct CompanyWindow : Window break; case WID_C_DESC_INAUGURATION: - SetDParam(0, Company::Get((CompanyID)this->window_number)->inaugurated_year); + if (TimerGameEconomy::UsingWallclockUnits()) { + SetDParam(0, STR_COMPANY_VIEW_INAUGURATED_TITLE_WALLCLOCK); + SetDParam(1, Company::Get(static_cast(this->window_number))->inaugurated_year_calendar); + SetDParam(2, Company::Get(static_cast(this->window_number))->inaugurated_year); + } else { + SetDParam(0, STR_COMPANY_VIEW_INAUGURATED_TITLE); + SetDParam(1, Company::Get(static_cast(this->window_number))->inaugurated_year); + } break; case WID_C_DESC_COMPANY_VALUE: diff --git a/src/lang/english.txt b/src/lang/english.txt index 87a8d3c594..37f3a3df03 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3895,6 +3895,7 @@ STR_COMPANY_VIEW_CAPTION :{WHITE}{COMPANY STR_COMPANY_VIEW_PRESIDENT_MANAGER_TITLE :{WHITE}{PRESIDENT_NAME}{}{GOLD}(Manager) STR_COMPANY_VIEW_INAUGURATED_TITLE :{GOLD}Inaugurated: {WHITE}{NUM} +STR_COMPANY_VIEW_INAUGURATED_TITLE_WALLCLOCK :{GOLD}Inaugurated: {WHITE}{NUM} (period {NUM}) STR_COMPANY_VIEW_COLOUR_SCHEME_TITLE :{GOLD}Colour Scheme: STR_COMPANY_VIEW_VEHICLES_TITLE :{GOLD}Vehicles: STR_COMPANY_VIEW_TRAINS :{WHITE}{COMMA} train{P "" s} diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 06102930b7..b82e88b4e2 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3272,6 +3272,12 @@ bool AfterLoadGame() ScriptObject::InitializeRandomizers(); } + if (IsSavegameVersionBefore(SLV_COMPANY_INAUGURATED_PERIOD)) { + for (Company *c : Company::Iterate()) { + c->inaugurated_year_calendar = _settings_game.game_creation.starting_year; + } + } + for (Company *c : Company::Iterate()) { UpdateCompanyLiveries(c); } diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 9149d42711..c75102bbf9 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -383,6 +383,7 @@ enum SaveLoadVersion : uint16_t { SLV_GROUP_NUMBERS, ///< 336 PR#12297 Add per-company group numbers. SLV_INCREASE_STATION_TYPE_FIELD_SIZE, ///< 337 PR#12572 Increase size of StationType field in map array SLV_ROAD_WAYPOINTS, ///< 338 PR#12572 Road waypoints + SLV_COMPANY_INAUGURATED_PERIOD, ///< 339 PR#12798 Companies show the period inaugurated in wallclock mode. SL_MAX_VERSION, ///< Highest possible saveload version };