author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 10382 | d1d4452acbfc |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
3 |
/** @file player_base.h Definition of stuff that is very close to a player, like the player struct itself. */ |
6678
6353b8865d42
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6574
diff
changeset
|
4 |
|
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
5 |
#ifndef PLAYER_BASE_H |
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
6 |
#define PLAYER_BASE_H |
0 | 7 |
|
8732
b18f578f7c16
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8725
diff
changeset
|
8 |
#include "road_type.h" |
b18f578f7c16
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8725
diff
changeset
|
9 |
#include "rail_type.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8617
diff
changeset
|
10 |
#include "date_type.h" |
9282
2bb9703aeb39
(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:
9011
diff
changeset
|
11 |
#include "engine_type.h" |
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4574
diff
changeset
|
12 |
#include "livery.h" |
8708
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8636
diff
changeset
|
13 |
#include "autoreplace_type.h" |
8733
9e2d2a2619ff
(svn r11801) -Codechange: remove some unneeded includes from some header files.
rubidium
parents:
8732
diff
changeset
|
14 |
#include "economy_type.h" |
9e2d2a2619ff
(svn r11801) -Codechange: remove some unneeded includes from some header files.
rubidium
parents:
8732
diff
changeset
|
15 |
#include "tile_type.h" |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
16 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
17 |
struct PlayerEconomyEntry { |
7449
5cedaf2c861c
(svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents:
7448
diff
changeset
|
18 |
Money income; |
5cedaf2c861c
(svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents:
7448
diff
changeset
|
19 |
Money expenses; |
0 | 20 |
int32 delivered_cargo; |
6678
6353b8865d42
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6574
diff
changeset
|
21 |
int32 performance_history; ///< player score (scale 0-1000) |
7451
82101e591f90
(svn r10210) -Codechange: make all money related variables 64 bits, so overflowing them should become a little harder.
rubidium
parents:
7449
diff
changeset
|
22 |
Money company_value; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
23 |
}; |
0 | 24 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
25 |
struct Player { |
0 | 26 |
uint32 name_2; |
27 |
uint16 name_1; |
|
8754
5dae65402806
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8750
diff
changeset
|
28 |
char *name; |
0 | 29 |
|
30 |
uint16 president_name_1; |
|
31 |
uint32 president_name_2; |
|
8754
5dae65402806
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8750
diff
changeset
|
32 |
char *president_name; |
0 | 33 |
|
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6001
diff
changeset
|
34 |
PlayerFace face; |
0 | 35 |
|
7451
82101e591f90
(svn r10210) -Codechange: make all money related variables 64 bits, so overflowing them should become a little harder.
rubidium
parents:
7449
diff
changeset
|
36 |
Money player_money; |
7449
5cedaf2c861c
(svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents:
7448
diff
changeset
|
37 |
Money current_loan; |
0 | 38 |
|
39 |
byte player_color; |
|
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4574
diff
changeset
|
40 |
Livery livery[LS_END]; |
0 | 41 |
byte player_money_fraction; |
8732
b18f578f7c16
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8725
diff
changeset
|
42 |
RailTypes avail_railtypes; |
b18f578f7c16
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8725
diff
changeset
|
43 |
RoadTypes avail_roadtypes; |
0 | 44 |
byte block_preview; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
45 |
PlayerByte index; |
0 | 46 |
|
10284
4f4086cd9585
(svn r12816) -Fix: the cargo count in the performance rating window could be wrong.
rubidium
parents:
9282
diff
changeset
|
47 |
uint32 cargo_types; ///< which cargo types were transported the last year |
0 | 48 |
|
49 |
TileIndex location_of_house; |
|
50 |
TileIndex last_build_coordinate; |
|
145 | 51 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
52 |
PlayerByte share_owners[4]; |
145 | 53 |
|
4326
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4289
diff
changeset
|
54 |
Year inaugurated_year; |
0 | 55 |
byte num_valid_stat_ent; |
145 | 56 |
|
0 | 57 |
byte quarters_of_bankrupcy; |
6678
6353b8865d42
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6574
diff
changeset
|
58 |
byte bankrupt_asked; ///< which players were asked about buying it? |
0 | 59 |
int16 bankrupt_timeout; |
7449
5cedaf2c861c
(svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents:
7448
diff
changeset
|
60 |
Money bankrupt_value; |
0 | 61 |
|
62 |
bool is_active; |
|
3345
40dc834caa24
(svn r4129) - CodeChange: Add proper bool type for is_ai as well...it is a bool type.
Darkvater
parents:
3344
diff
changeset
|
63 |
bool is_ai; |
145 | 64 |
|
9011
d5db20f3fc90
(svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents:
8754
diff
changeset
|
65 |
Money yearly_expenses[3][EXPENSES_END]; |
0 | 66 |
PlayerEconomyEntry cur_economy; |
67 |
PlayerEconomyEntry old_economy[24]; |
|
6678
6353b8865d42
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6574
diff
changeset
|
68 |
EngineRenewList engine_renew_list; ///< Defined later |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
69 |
bool engine_renew; |
2617
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2613
diff
changeset
|
70 |
bool renew_keep_length; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
71 |
int16 engine_renew_months; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
72 |
uint32 engine_renew_money; |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10372
diff
changeset
|
73 |
uint16 *num_engines; ///< caches the number of engines of each type the player owns (no need to save this) |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
74 |
}; |
0 | 75 |
|
10372
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
76 |
struct PlayerMoneyBackup { |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
77 |
private: |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
78 |
Money backup_yearly_expenses[EXPENSES_END]; |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
79 |
PlayerEconomyEntry backup_cur_economy; |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
80 |
Player *p; |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
81 |
|
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
82 |
public: |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
83 |
PlayerMoneyBackup(Player *player); |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
84 |
|
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
85 |
void Restore(); |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
86 |
}; |
93844492fdd9
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents:
10284
diff
changeset
|
87 |
|
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
88 |
extern Player _players[MAX_PLAYERS]; |
2952 | 89 |
#define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++) |
0 | 90 |
|
6573 | 91 |
static inline byte ActivePlayerCount() |
4824
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
92 |
{ |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
93 |
const Player *p; |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
94 |
byte count = 0; |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
95 |
|
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
96 |
FOR_ALL_PLAYERS(p) { |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
97 |
if (p->is_active) count++; |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
98 |
} |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
99 |
|
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
100 |
return count; |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
101 |
} |
2944
7c392e7b51c6
(svn r3500) - Workaround the inaccurate count of spectators/companies that can happen in certain border-cases. For now just dynamically get this value when requested so it is always right. To do properly all player/client creation/destruction needs a hook for networking.
Darkvater
parents:
2848
diff
changeset
|
102 |
|
7814
fe643468ad64
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
7813
diff
changeset
|
103 |
static inline Player *GetPlayer(PlayerID i) |
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1576
diff
changeset
|
104 |
{ |
8450
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8424
diff
changeset
|
105 |
assert(IsInsideBS(i, PLAYER_FIRST, lengthof(_players))); |
2425
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
106 |
return &_players[i]; |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
107 |
} |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
108 |
|
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
109 |
Money CalculateCompanyValue(const Player *p); |
4845
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
110 |
|
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
111 |
#endif /* PLAYER_BASE_H */ |