OpenTTD Source 20260206-master-g4d4e37dbf1
Company Struct Reference
Inheritance diagram for Company:
CompanyProperties

Public Member Functions

 Company (CompanyID index, StringID name_1={}, bool is_ai=false)
 Constructor.
 ~Company ()
 Destructor.
Money GetMaxLoan () const
 Calculate the max allowed loan for this company.
uint8_t GetCompanyRecolourOffset (LiveryScheme livery_scheme, bool use_secondary=true) const
 Get offset for recolour palette of specific company.

Static Public Member Functions

static bool IsValidAiID (auto index)
 Is this company a valid company, controlled by the computer (a NoAI program)?
static bool IsValidHumanID (auto index)
 Is this company a valid company, not controlled by a NoAI program?
static bool IsHumanID (auto index)
 Is this company a company not controlled by a NoAI program?
static void PostDestructor (size_t index)
 Invalidating some stuff after removing item from the pool.

Data Fields

RailTypes avail_railtypes {}
 Rail types available to this company.
RoadTypes avail_roadtypes {}
 Road types available to this company.
std::unique_ptr< class AIInstanceai_instance {}
class AIInfoai_info = nullptr
std::unique_ptr< class AIConfigai_config {}
std::array< GroupStatistics, VEH_COMPANY_ENDgroup_all {}
 NOSAVE: Statistics for the ALL_GROUP group.
std::array< GroupStatistics, VEH_COMPANY_ENDgroup_default {}
 NOSAVE: Statistics for the DEFAULT_GROUP group.
CompanyInfrastructure infrastructure {}
 NOSAVE: Counts of company owned infrastructure.
std::array< FreeUnitIDGenerator, VEH_COMPANY_ENDfreeunits {}
FreeUnitIDGenerator freegroups {}
Data Fields inherited from CompanyProperties
uint32_t name_2 = 0
 Parameter of name_1.
StringID name_1 = INVALID_STRING_ID
 Name of the company if the user did not change it.
std::string name {}
 Name of the company if the user changed it.
StringID president_name_1 = INVALID_STRING_ID
 Name of the president if the user did not change it.
uint32_t president_name_2 = 0
 Parameter of president_name_1.
std::string president_name {}
 Name of the president if the user changed it.
NetworkAuthorizedKeys allow_list {}
 Public keys of clients that are allowed to join this company.
CompanyManagerFace face {}
 Face description of the president.
Money money = 0
 Money owned by the company.
uint8_t money_fraction = 0
 Fraction of money of the company, too small to represent in money.
Money current_loan = 0
 Amount of money borrowed from the bank.
Money max_loan = COMPANY_MAX_LOAN_DEFAULT
 Max allowed amount of the loan or COMPANY_MAX_LOAN_DEFAULT.
Colours colour = COLOUR_BEGIN
 Company colour.
uint8_t block_preview = 0
 Number of quarters that the company is not allowed to get new exclusive engine previews (see CompaniesGenStatistics).
TileIndex location_of_HQ = INVALID_TILE
 Northern tile of HQ; INVALID_TILE when there is none.
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 = 0
 Number of months that the company is unable to pay its debts.
CompanyMask bankrupt_asked {}
 which companies were asked about buying it?
int16_t bankrupt_timeout = 0
 If bigger than 0, amount of time to wait for an answer on an offer to buy this company.
Money bankrupt_value = 0
uint32_t terraform_limit = 0
 Amount of tileheights we can (still) terraform (times 65536).
uint32_t clear_limit = 0
 Amount of tiles we can (still) clear (times 65536).
uint32_t tree_limit = 0
 Amount of trees we can (still) plant (times 65536).
uint32_t build_object_limit = 0
 Amount of tiles we can (still) build objects on (times 65536). Also applies to buying land and placing houses.
bool is_ai = false
 If true, the company is (also) controlled by the computer (a NoAI program).
std::array< Expenses, 3 > yearly_expenses {}
 Expenses of the company for the last three years.
CompanyEconomyEntry cur_economy {}
 Economic data of the company of this quarter.
std::array< CompanyEconomyEntry, MAX_HISTORY_QUARTERSold_economy {}
 Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
uint8_t num_valid_stat_ent = 0
 Number of valid statistical entries in old_economy.
std::array< Livery, LS_END > livery {}
EngineRenewList engine_renew_list = nullptr
 Engine renewals of this company.
CompanySettings settings {}
 settings specific for each company

Detailed Description

Definition at line 127 of file company_base.h.

Constructor & Destructor Documentation

◆ Company()

Company::Company ( CompanyID index,
StringID name_1 = {},
bool is_ai = false )

Constructor.

Parameters
indexThe unique pool identifier of this company.
name_1Name of the company.
is_aiA computer program is running for this company.

Definition at line 70 of file company_cmd.cpp.

References _settings_game, CompanyProperties::build_object_limit, CompanyProperties::clear_limit, Company(), InvalidateWindowData(), CompanyProperties::is_ai, CompanyProperties::name_1, CompanyProperties::terraform_limit, CompanyProperties::tree_limit, and WC_PERFORMANCE_DETAIL.

Referenced by Company(), IsValidAiID(), and IsValidHumanID().

◆ ~Company()

Company::~Company ( )

Destructor.

Definition at line 83 of file company_cmd.cpp.

References CloseCompanyWindows().

Member Function Documentation

◆ GetCompanyRecolourOffset()

uint8_t Company::GetCompanyRecolourOffset ( LiveryScheme livery_scheme,
bool use_secondary = true ) const
inline

Get offset for recolour palette of specific company.

Parameters
livery_schemeScheme to use for recolour.
use_secondarySpecify whether to add secondary colour offset to the result.
Returns
palette offset.

Definition at line 189 of file company_base.h.

References Livery::colour1, and Livery::colour2.

Referenced by IndustriesScopeResolver::GetVariable(), and UpdateObjectColours().

◆ GetMaxLoan()

Money Company::GetMaxLoan ( ) const

Calculate the max allowed loan for this company.

Returns
the max loan amount.

Definition at line 108 of file company_cmd.cpp.

References CompanyProperties::max_loan.

Referenced by CmdIncreaseLoan(), CompanyCheckBankrupt(), CompanyFinancesWindow::GetWidgetString(), and CompanyFinancesWindow::OnPaint().

◆ IsHumanID()

bool Company::IsHumanID ( auto index)
inlinestatic

Is this company a company not controlled by a NoAI program?

Parameters
indexIndex in the pool.
Returns
true if it is a human controlled company, else false.
Precondition
index must be a valid CompanyID.
Note
If you don't know whether index refers to a valid company, you should use IsValidHumanID() instead.

Definition at line 178 of file company_base.h.

Referenced by DisasterTick_Big_Ufo(), and GetFirstPlayableCompanyID().

◆ IsValidAiID()

bool Company::IsValidAiID ( auto index)
inlinestatic

Is this company a valid company, controlled by the computer (a NoAI program)?

Parameters
indexIndex in the pool.
Returns
true if it is a valid, computer controlled company, else false.

Definition at line 153 of file company_base.h.

References Company(), and CompanyProperties::is_ai.

Referenced by GetCompanyInfo(), AIConfigWindow::GetSlotColour(), ScriptDebugWindow::GetWidgetString(), ScriptDebugWindow::IsDead(), ScriptDebugWindow::IsValidDebugCompany(), AIPLChunkHandler::Load(), AI::NewEvent(), AIConfigWindow::OnInvalidateData(), AI::ResetConfig(), StartScripts(), and ScriptDebugWindow::UpdateAIButtonsState().

◆ IsValidHumanID()

bool Company::IsValidHumanID ( auto index)
inlinestatic

Is this company a valid company, not controlled by a NoAI program?

Parameters
indexIndex in the pool.
Returns
true if it is a valid, human controlled company, else false.
Note
If you know that index refers to a valid company, you can use IsHumanID() instead.

Definition at line 165 of file company_base.h.

References Company(), and CompanyProperties::is_ai.

Referenced by FormatString(), AIConfigWindow::GetSlotText(), ServerNetworkGameSocketHandler::Receive_CLIENT_IDENTIFY(), and ServerNetworkGameSocketHandler::Receive_CLIENT_MOVE().

◆ PostDestructor()

void Company::PostDestructor ( size_t index)
static

Invalidating some stuff after removing item from the pool.

Parameters
indexindex of deleted item

Definition at line 94 of file company_cmd.cpp.

References InvalidateWindowData(), WC_COMPANY_LEAGUE, WC_ERRMSG, WC_GRAPH_LEGEND, WC_LINKGRAPH_LEGEND, and WC_PERFORMANCE_DETAIL.

Field Documentation

◆ ai_config

std::unique_ptr<class AIConfig> Company::ai_config {}

Definition at line 136 of file company_base.h.

◆ ai_info

class AIInfo* Company::ai_info = nullptr

Definition at line 135 of file company_base.h.

◆ ai_instance

std::unique_ptr<class AIInstance> Company::ai_instance {}

Definition at line 134 of file company_base.h.

◆ avail_railtypes

RailTypes Company::avail_railtypes {}

Rail types available to this company.

Definition at line 131 of file company_base.h.

Referenced by DisableEngineForCompany(), DoStartupNewCompany(), EnableEngineForCompany(), GetRailTypeDropDownList(), and IsEngineBuildable().

◆ avail_roadtypes

RoadTypes Company::avail_roadtypes {}

Road types available to this company.

Definition at line 132 of file company_base.h.

Referenced by DisableEngineForCompany(), DoStartupNewCompany(), EnableEngineForCompany(), HasRoadTypeAvail(), and IsEngineBuildable().

◆ freegroups

FreeUnitIDGenerator Company::freegroups {}

Definition at line 144 of file company_base.h.

◆ freeunits

std::array<FreeUnitIDGenerator, VEH_COMPANY_END> Company::freeunits {}

Definition at line 143 of file company_base.h.

◆ group_all

std::array<GroupStatistics, VEH_COMPANY_END> Company::group_all {}

NOSAVE: Statistics for the ALL_GROUP group.

Definition at line 138 of file company_base.h.

Referenced by CheckTakeoverVehicleLimit(), GetFreeUnitNumber(), and GroupStatistics::UpdateAutoreplace().

◆ group_default

std::array<GroupStatistics, VEH_COMPANY_END> Company::group_default {}

NOSAVE: Statistics for the DEFAULT_GROUP group.

Definition at line 139 of file company_base.h.

Referenced by GroupStatistics::UpdateAutoreplace().

◆ infrastructure


The documentation for this struct was generated from the following files: