mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Track the company age in economy years
parent
fc77d6d094
commit
1e98680bf6
|
@ -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?
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue