OpenTTD: Company Struct Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Static Public Member Functions | Data Fields
Company Struct Reference
Inheritance diagram for Company:

## Public Member Functions
| Company (uint16 name_1=0, bool is_ai=false)
| Constructor.
| ~Company ()
| Destructor.
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.
void * | operator new (size_t size, size_t index)
| Allocates space for new Titem with given index.
void * | operator new (size_t size, void *ptr)
| Allocates space for new Titem at given memory address.
void | operator delete (void *p)
| Marks Titem as free.

## Static Public Member Functions
static bool | IsValidAiID (size_t index)
| Is this company a valid company, controlled by the computer (a NoAI program)?
static bool | IsValidHumanID (size_t index)
| Is this company a valid company, not controlled by a NoAI program?
static bool | IsHumanID (size_t 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, 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()
static bool | CleaningPool ()
| Returns current state of pool cleaning - yes or no.
static bool | IsValidID (size_t index)
| Tests whether given index can be used to get valid (non-NULL) Titem.
static Titem * | Get (size_t index)
| Returns Titem with given index.
static Titem * | GetIfValid (size_t 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.

## Data Fields
Livery | livery [LS_END]
RoadTypes | avail_roadtypes
| Road types available to this company.
class AIInstance * | ai_instance
class AIInfo * | ai_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).
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 | ( | uint16 | name_1 = `0`,
|  | bool | is_ai = `false`
| ) |  |

Constructor.

Parameters

  name_1 | Name of the company.
  is_ai | A computer program is running for this company.

Definition at line 61 of file company_cmd.cpp.

References _settings_game, ConstructionSettings::clear_frame_burst, COMPANY_SPECTATOR, GameSettings::construction, INVALID_COMPANY, INVALID_TILE, InvalidateWindowData(), ConstructionSettings::terraform_frame_burst, ConstructionSettings::tree_frame_burst, and WC_PERFORMANCE_DETAIL.

Company::~Company | ( |  | ) |

Destructor.

Definition at line 75 of file company_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::CleaningPool(), DeleteCompanyWindows(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::index.

## Member Function Documentation

static bool Company::IsHumanID | ( | size_t | index | ) |
| inlinestatic

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

Parameters

  index | Index 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 Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get().

Referenced by DisasterTick_Big_Ufo().

static bool Company::IsValidAiID | ( | size_t | index | ) |
| inlinestatic

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

Parameters

  index | Index 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 AI::GameLoop(), GetCompanyInfo(), AIDebugWindow::IsDead(), AIDebugWindow::IsValidDebugCompany(), AI::NewEvent(), AIDebugWindow::OnInvalidateData(), AIDebugWindow::OnPaint(), AI::ResetConfig(), and AIDebugWindow::SetStringParameters().

static bool Company::IsValidHumanID | ( | size_t | index | ) |
| inlinestatic

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

Parameters

  index | Index 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 AIConfigWindow::DrawWidget(), FormatString(), AIConfigWindow::IsEditable(), NetworkServerSetCompanyPassword(), ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(), and ServerNetworkGameSocketHandler::Receive_CLIENT_MOVE().

void Company::PostDestructor | ( | size_t | index | ) |
| static

Invalidating some stuff after removing item from the pool.

Parameters

  index | index of deleted item

Reimplemented from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >.

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:

- src/company_base.h
- src/company_cmd.cpp