1
/* $Id: company_base.h 15903 2009-03-30 23:15:05Z rubidium $ */
3
/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */
8
#include "company_type.h"
10
#include "road_type.h"
11
#include "rail_type.h"
12
#include "date_type.h"
13
#include "engine_type.h"
15
#include "autoreplace_type.h"
16
#include "economy_type.h"
17
#include "tile_type.h"
19
struct CompanyEconomyEntry {
22
int32 delivered_cargo;
23
int32 performance_history; ///< company score (scale 0-1000)
27
/* The third parameter and the number after >> MUST be the same,
28
* otherwise more (or less) companies will be allowed to be
29
* created than what MAX_COMPANIES specifies!
31
DECLARE_OLD_POOL(Company, Company, 1, (MAX_COMPANIES + 1) >> 1)
33
struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
34
Company(uint16 name_1 = 0, bool is_ai = false);
41
uint16 president_name_1;
42
uint32 president_name_2;
45
CompanyManagerFace face;
52
Livery livery[LS_END];
53
RailTypes avail_railtypes;
54
RoadTypes avail_roadtypes;
57
uint32 cargo_types; ///< which cargo types were transported the last year
59
TileIndex location_of_HQ; ///< northern tile of HQ ; INVALID_TILE when there is none
60
TileIndex last_build_coordinate;
62
OwnerByte share_owners[4];
64
Year inaugurated_year;
65
byte num_valid_stat_ent;
67
byte quarters_of_bankrupcy;
68
CompanyMask bankrupt_asked; ///< which companies were asked about buying it?
69
int16 bankrupt_timeout;
74
class AIInstance *ai_instance;
75
class AIInfo *ai_info;
77
Money yearly_expenses[3][EXPENSES_END];
78
CompanyEconomyEntry cur_economy;
79
CompanyEconomyEntry old_economy[24];
80
EngineRenewList engine_renew_list; ///< Defined later
82
bool renew_keep_length;
83
int16 engine_renew_months;
84
uint32 engine_renew_money;
85
uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this)
87
inline bool IsValid() const { return this->name_1 != 0; }
90
static inline bool IsValidCompanyID(CompanyID company)
92
return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
95
#define FOR_ALL_COMPANIES_FROM(d, start) for (d = GetCompany(start); d != NULL; d = (d->index + 1U < GetCompanyPoolSize()) ? GetCompany(d->index + 1U) : NULL) if (d->IsValid())
96
#define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0)
98
static inline byte ActiveCompanyCount()
103
FOR_ALL_COMPANIES(c) count++;
108
Money CalculateCompanyValue(const Company *c);
110
extern uint _next_competitor_start;
111
extern uint _cur_company_tick_index;
113
#endif /* COMPANY_BASE_H */