author | rubidium |
Thu, 18 Dec 2008 12:23:08 +0000 | |
changeset 10436 | 8d3a9fbe8f19 |
parent 10208 | 72c00af5c95d |
permissions | -rw-r--r-- |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
2 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
3 |
/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */ |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
4 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
5 |
#ifndef COMPANY_BASE_H |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
6 |
#define COMPANY_BASE_H |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
7 |
|
10208
72c00af5c95d
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents:
10207
diff
changeset
|
8 |
#include "company_type.h" |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
9 |
#include "oldpool.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
10 |
#include "road_type.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
11 |
#include "rail_type.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
12 |
#include "date_type.h" |
8786
1823ff88a054
(svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents:
8515
diff
changeset
|
13 |
#include "engine_type.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
14 |
#include "livery.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
15 |
#include "autoreplace_type.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
16 |
#include "economy_type.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
17 |
#include "tile_type.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
18 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
19 |
struct CompanyEconomyEntry { |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
20 |
Money income; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
21 |
Money expenses; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
22 |
int32 delivered_cargo; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
23 |
int32 performance_history; ///< company score (scale 0-1000) |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
24 |
Money company_value; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
25 |
}; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
26 |
|
9890
d78e15f4ac71
(svn r14038) -Fix [FS#2211] (r13731): company limit was not properly enforced for CMD_PLAYER_CTRL.
rubidium
parents:
9661
diff
changeset
|
27 |
/* The third parameter and the number after >> MUST be the same, |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
28 |
* otherwise more (or less) companies will be allowed to be |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
29 |
* created than what MAX_COMPANIES specifies! |
9890
d78e15f4ac71
(svn r14038) -Fix [FS#2211] (r13731): company limit was not properly enforced for CMD_PLAYER_CTRL.
rubidium
parents:
9661
diff
changeset
|
30 |
*/ |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
31 |
DECLARE_OLD_POOL(Company, Company, 1, MAX_COMPANIES >> 1) |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
32 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
33 |
struct Company : PoolItem<Company, CompanyByte, &_Company_pool> { |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
34 |
Company(uint16 name_1 = 0, bool is_ai = false); |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
35 |
~Company(); |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
36 |
|
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
37 |
uint32 name_2; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
38 |
uint16 name_1; |
8258
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8254
diff
changeset
|
39 |
char *name; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
40 |
|
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
41 |
uint16 president_name_1; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
42 |
uint32 president_name_2; |
8258
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8254
diff
changeset
|
43 |
char *president_name; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
44 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
45 |
CompanyManagerFace face; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
46 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
47 |
Money money; |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
48 |
byte money_fraction; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
49 |
Money current_loan; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
50 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
51 |
byte colour; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
52 |
Livery livery[LS_END]; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
53 |
RailTypes avail_railtypes; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
54 |
RoadTypes avail_roadtypes; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
55 |
byte block_preview; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
56 |
|
9017
3d422fffe39c
(svn r12816) -Fix: the cargo count in the performance rating window could be wrong.
rubidium
parents:
8786
diff
changeset
|
57 |
uint32 cargo_types; ///< which cargo types were transported the last year |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
58 |
|
10010
09ff8bd74b87
(svn r14169) -Codechange: rename location_of_house for location_of_HQ, which is more exact and less subject to interpretation
belugas
parents:
9930
diff
changeset
|
59 |
TileIndex location_of_HQ; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
60 |
TileIndex last_build_coordinate; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
61 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
62 |
OwnerByte share_owners[4]; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
63 |
|
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
64 |
Year inaugurated_year; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
65 |
byte num_valid_stat_ent; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
66 |
|
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
67 |
byte quarters_of_bankrupcy; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
68 |
byte bankrupt_asked; ///< which companies were asked about buying it? |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
69 |
int16 bankrupt_timeout; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
70 |
Money bankrupt_value; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
71 |
|
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
72 |
bool is_ai; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
73 |
|
8515
20b5c6e8415e
(svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents:
8258
diff
changeset
|
74 |
Money yearly_expenses[3][EXPENSES_END]; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
75 |
CompanyEconomyEntry cur_economy; |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
76 |
CompanyEconomyEntry old_economy[24]; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
77 |
EngineRenewList engine_renew_list; ///< Defined later |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
78 |
bool engine_renew; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
79 |
bool renew_keep_length; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
80 |
int16 engine_renew_months; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
81 |
uint32 engine_renew_money; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
82 |
uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this) |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
83 |
|
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
84 |
inline bool IsValid() const { return this->name_1 != 0; } |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
85 |
}; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
86 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
87 |
static inline bool IsValidCompanyID(CompanyID company) |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
88 |
{ |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
89 |
return (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid(); |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
90 |
} |
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
91 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
92 |
#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()) |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
93 |
#define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0) |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9070
diff
changeset
|
94 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
95 |
static inline byte ActiveCompanyCount() |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
96 |
{ |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
97 |
const Company *c; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
98 |
byte count = 0; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
99 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
100 |
FOR_ALL_COMPANIES(c) count++; |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
101 |
|
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
102 |
return count; |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
103 |
} |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
104 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
105 |
Money CalculateCompanyValue(const Company *c); |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
diff
changeset
|
106 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10010
diff
changeset
|
107 |
#endif /* COMPANY_BASE_H */ |