OpenTTD Source 20250312-master-gcdcc6b491d
Company Struct Reference
Inheritance diagram for Company:
CompanyProperties Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >

Public Member Functions

 Company (StringID name_1=STR_NULL, bool is_ai=false)
 Constructor.
 
 ~Company ()
 Destructor.
 
Money GetMaxLoan () const
 Calculate the max allowed loan for this company.
 
- Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >
void * operator new (size_t size)
 Allocates space for new Titem.
 
void * operator new (size_t size, Tindex index)
 Allocates space for new Titem with given index.
 
void * operator new (size_t, void *ptr)
 Allocates space for new Titem at given memory address.
 
void operator delete (void *p, size_t size)
 Marks Titem as free.
 

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.
 
- Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >
static bool CanAllocateItem (size_t n=1)
 Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
 
static bool CleaningPool ()
 Returns current state of pool cleaning - yes or no.
 
static bool IsValidID (auto index)
 Tests whether given index can be used to get valid (non-nullptr) Titem.
 
static Titem * Get (auto index)
 Returns Titem with given index.
 
static Titem * GetIfValid (auto index)
 Returns Titem with given index.
 
static size_t GetPoolSize ()
 Returns first unused index.
 
static size_t GetNumItems ()
 Returns number of valid items in the pool.
 
static void PostDestructor (size_t index)
 Dummy function called after destructor of each member.
 
static Pool::IterateWrapper< Titem > Iterate (size_t from=0)
 Returns an iterable ensemble of all valid Titem.
 

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.
 
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
 
- Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >
Tindex index
 Index of this pool item.
 

Additional Inherited Members

- Public Types inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache > Pool
 Type of the pool this item is going to be part of.
 

Detailed Description

Definition at line 125 of file company_base.h.

Constructor & Destructor Documentation

◆ Company()

Company::Company ( StringID  name_1 = STR_NULL,
bool  is_ai = false 
)

◆ ~Company()

Member Function Documentation

◆ GetMaxLoan()

Money Company::GetMaxLoan ( ) const

Calculate the max allowed loan for this company.

Returns
the max loan amount.

Definition at line 104 of file company_cmd.cpp.

References CompanyProperties::max_loan, and Economy::max_loan.

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

◆ IsHumanID()

static 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 176 of file company_base.h.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::index.

Referenced by DisasterTick_Big_Ufo(), and GetFirstPlayableCompanyID().

◆ IsValidAiID()

◆ IsValidHumanID()

static 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 163 of file company_base.h.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::index, 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 90 of file company_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::index, 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 134 of file company_base.h.

◆ ai_info

class AIInfo* Company::ai_info = nullptr

Definition at line 133 of file company_base.h.

◆ ai_instance

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

Definition at line 132 of file company_base.h.

◆ avail_railtypes

RailTypes Company::avail_railtypes {}

Rail types available to this company.

Definition at line 129 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 130 of file company_base.h.

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

◆ freegroups

FreeUnitIDGenerator Company::freegroups {}

Definition at line 142 of file company_base.h.

◆ freeunits

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

Definition at line 141 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 136 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 137 of file company_base.h.

Referenced by GroupStatistics::UpdateAutoreplace().

◆ infrastructure


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