OpenTTD
Public Member Functions | Static Public Member Functions | Data Fields
Company Struct Reference
Inheritance diagram for Company:
Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool > CompanyProperties

Public Member Functions

 Company (uint16 name_1=0, bool is_ai=false)
 Constructor. More...
 
 ~Company ()
 Destructor. More...
 
- Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >
void * operator new (size_t size)
 Allocates space for new Titem. More...
 
void * operator new (size_t size, size_t index)
 Allocates space for new Titem with given index. More...
 
void * operator new (size_t size, void *ptr)
 Allocates space for new Titem at given memory address. More...
 
void operator delete (void *p)
 Marks Titem as free. More...
 

Static Public Member Functions

static bool IsValidAiID (size_t index)
 Is this company a valid company, controlled by the computer (a NoAI program)? More...
 
static bool IsValidHumanID (size_t index)
 Is this company a valid company, not controlled by a NoAI program? More...
 
static bool IsHumanID (size_t index)
 Is this company a company not controlled by a NoAI program? More...
 
static void PostDestructor (size_t index)
 Invalidating some stuff after removing item from the pool. More...
 
- Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >
static bool CanAllocateItem (size_t n=1)
 Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() More...
 
static bool CleaningPool ()
 Returns current state of pool cleaning - yes or no. More...
 
static bool IsValidID (size_t index)
 Tests whether given index can be used to get valid (non-NULL) Titem. More...
 
static Titem * Get (size_t index)
 Returns Titem with given index. More...
 
static Titem * GetIfValid (size_t index)
 Returns Titem with given index. More...
 
static size_t GetPoolSize ()
 Returns first unused index. More...
 
static size_t GetNumItems ()
 Returns number of valid items in the pool. More...
 
static void PostDestructor (size_t index)
 Dummy function called after destructor of each member. More...
 

Data Fields

Livery livery [LS_END]
 
RoadTypes avail_roadtypes
 Road types available to this company.
 
class AIInstanceai_instance
 
class AIInfoai_info
 
EngineRenewList engine_renew_list
 Engine renewals of this company.
 
CompanySettings settings
 settings specific for each company
 
GroupStatistics group_all [VEH_COMPANY_END]
 NOSAVE: Statistics for the ALL_GROUP group.
 
GroupStatistics group_default [VEH_COMPANY_END]
 NOSAVE: Statistics for the DEFAULT_GROUP group.
 
CompanyInfrastructure infrastructure
 NOSAVE: Counts of company owned infrastructure.
 
- Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >
Tindex index
 Index of this pool item.
 
- Data Fields inherited from CompanyProperties
uint32 name_2
 Parameter of name_1.
 
StringID name_1
 Name of the company if the user did not change it.
 
char * name
 Name of the company if the user changed it.
 
StringID president_name_1
 Name of the president if the user did not change it.
 
uint32 president_name_2
 Parameter of president_name_1.
 
char * president_name
 Name of the president if the user changed it.
 
CompanyManagerFace face
 Face description of the president.
 
Money money
 Money owned by the company.
 
byte money_fraction
 Fraction of money of the company, too small to represent in money.
 
Money current_loan
 Amount of money borrowed from the bank.
 
byte colour
 Company colour.
 
RailTypes avail_railtypes
 Rail types available to the company.
 
byte block_preview
 Number of quarters that the company is not allowed to get new exclusive engine previews (see CompaniesGenStatistics).
 
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.
 
OwnerByte share_owners [4]
 Owners of the 4 shares of the company. INVALID_OWNER if nobody has bought them yet.
 
Year inaugurated_year
 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?
 
int16 bankrupt_timeout
 If bigger than 0, amount of time to wait for an answer on an offer to buy this company.
 
Money bankrupt_value
 
uint32 terraform_limit
 Amount of tileheights we can (still) terraform (times 65536).
 
uint32 clear_limit
 Amount of tiles we can (still) clear (times 65536).
 
uint32 tree_limit
 Amount of trees we can (still) plant (times 65536).
 
bool is_ai
 If true, the company is (also) controlled by the computer (a NoAI program). More...
 
Money yearly_expenses [3][EXPENSES_END]
 Expenses of the company for the last three years, in every #Expenses category.
 
CompanyEconomyEntry cur_economy
 Economic data of the company of this quarter.
 
CompanyEconomyEntry old_economy [MAX_HISTORY_QUARTERS]
 Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
 
byte num_valid_stat_ent
 Number of valid statistical entries in old_economy.
 

Detailed Description

Definition at line 110 of file company_base.h.

Constructor & Destructor Documentation

◆ Company()

Company::Company ( uint16  name_1 = 0,
bool  is_ai = false 
)

◆ ~Company()

Company::~Company ( )

Member Function Documentation

◆ IsHumanID()

static bool Company::IsHumanID ( size_t  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 157 of file company_base.h.

References _cur_company_tick_index, _next_competitor_start, CalculateCompanyValue(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get().

◆ IsValidAiID()

static bool Company::IsValidAiID ( size_t  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 132 of file company_base.h.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), and CompanyProperties::is_ai.

Referenced by AIDebugWindow::IsDead(), AIDebugWindow::IsValidDebugCompany(), AI::NewEvent(), AIDebugWindow::OnInvalidateData(), AIDebugWindow::OnPaint(), and AI::ResetConfig().

◆ IsValidHumanID()

static bool Company::IsValidHumanID ( size_t  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 144 of file company_base.h.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), and CompanyProperties::is_ai.

Referenced by NetworkServerSetCompanyPassword().

◆ 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 86 of file company_cmd.cpp.

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


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