author | glx |
Thu, 22 Mar 2007 02:32:43 +0000 | |
branch | noai |
changeset 9505 | 9711235f5693 |
parent 9374 | 61379e9b2393 |
child 9598 | b73018a5ffc0 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9505 | 3 |
/** @file player.h */ |
4 |
||
0 | 5 |
#ifndef PLAYER_H |
6 |
#define PLAYER_H |
|
7 |
||
5216
d581e4db95b6
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
5077
diff
changeset
|
8 |
#include "oldpool.h" |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
9 |
#include "aystar.h" |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
10 |
#include "rail.h" |
2573
1950c5c3aab5
(svn r3110) Replace another 256 with TOTAL_NUM_ENGINES.
peter1138
parents:
2544
diff
changeset
|
11 |
#include "engine.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" |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
13 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
14 |
struct PlayerEconomyEntry { |
0 | 15 |
int32 income; |
16 |
int32 expenses; |
|
17 |
int32 delivered_cargo; |
|
9505 | 18 |
int32 performance_history; ///< player score (scale 0-1000) |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
147
diff
changeset
|
19 |
int64 company_value; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
20 |
}; |
0 | 21 |
|
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6001
diff
changeset
|
22 |
typedef uint32 PlayerFace; |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
23 |
|
9374
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9359
diff
changeset
|
24 |
enum { |
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9359
diff
changeset
|
25 |
/** The stepping in pounds for loans */ |
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9359
diff
changeset
|
26 |
LOAN_INTERVAL = 10000, |
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9359
diff
changeset
|
27 |
}; |
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9359
diff
changeset
|
28 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
29 |
struct Player { |
0 | 30 |
uint32 name_2; |
31 |
uint16 name_1; |
|
32 |
||
33 |
uint16 president_name_1; |
|
34 |
uint32 president_name_2; |
|
35 |
||
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6001
diff
changeset
|
36 |
PlayerFace face; |
0 | 37 |
|
38 |
int32 player_money; |
|
39 |
int32 current_loan; |
|
9505 | 40 |
int64 money64; ///< internal 64-bit version of the money. the 32-bit field will be clamped to plus minus 2 billion |
0 | 41 |
|
42 |
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
|
43 |
Livery livery[LS_END]; |
0 | 44 |
byte player_money_fraction; |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
45 |
byte avail_railtypes; |
0 | 46 |
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
|
47 |
PlayerByte index; |
0 | 48 |
|
9505 | 49 |
uint16 cargo_types; ///< which cargo types were transported the last year |
0 | 50 |
|
51 |
TileIndex location_of_house; |
|
52 |
TileIndex last_build_coordinate; |
|
145 | 53 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
54 |
PlayerByte share_owners[4]; |
145 | 55 |
|
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
|
56 |
Year inaugurated_year; |
0 | 57 |
byte num_valid_stat_ent; |
145 | 58 |
|
0 | 59 |
byte quarters_of_bankrupcy; |
9505 | 60 |
byte bankrupt_asked; ///< which players were asked about buying it? |
0 | 61 |
int16 bankrupt_timeout; |
62 |
int32 bankrupt_value; |
|
63 |
||
64 |
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
|
65 |
bool is_ai; |
145 | 66 |
|
0 | 67 |
int64 yearly_expenses[3][13]; |
68 |
PlayerEconomyEntry cur_economy; |
|
69 |
PlayerEconomyEntry old_economy[24]; |
|
9505 | 70 |
EngineRenewList engine_renew_list; ///< Defined later |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
71 |
bool engine_renew; |
2617
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2613
diff
changeset
|
72 |
bool renew_keep_length; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
73 |
int16 engine_renew_months; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
74 |
uint32 engine_renew_money; |
9505 | 75 |
uint16 num_engines[TOTAL_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
|
76 |
}; |
0 | 77 |
|
4428
0b0ee542d5b6
(svn r6183) Move GetDrawStringPlayerColor() out of gfx.[ch]
tron
parents:
4344
diff
changeset
|
78 |
uint16 GetDrawStringPlayerColor(PlayerID player); |
0b0ee542d5b6
(svn r6183) Move GetDrawStringPlayerColor() out of gfx.[ch]
tron
parents:
4344
diff
changeset
|
79 |
|
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
80 |
void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player); |
4849
9a3c3ae7f62f
(svn r6775) -Codechange: Use some more proper types, especially Owner and PlayerID as
Darkvater
parents:
4848
diff
changeset
|
81 |
void GetNameOfOwner(Owner owner, TileIndex tile); |
2475 | 82 |
int64 CalculateCompanyValue(const Player* p); |
83 |
void InvalidatePlayerWindows(const Player* p); |
|
0 | 84 |
void UpdatePlayerMoney32(Player *p); |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5216
diff
changeset
|
85 |
void SetLocalPlayer(PlayerID new_player); |
2952 | 86 |
#define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++) |
0 | 87 |
|
2425
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
88 |
VARDEF PlayerID _local_player; |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
89 |
VARDEF PlayerID _current_player; |
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
90 |
|
0 | 91 |
VARDEF Player _players[MAX_PLAYERS]; |
9505 | 92 |
/* NOSAVE: can be determined from player structs */ |
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
93 |
VARDEF byte _player_colors[MAX_PLAYERS]; |
0 | 94 |
|
6573 | 95 |
static inline byte ActivePlayerCount() |
4824
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
96 |
{ |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
97 |
const Player *p; |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
98 |
byte count = 0; |
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 |
FOR_ALL_PLAYERS(p) { |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
101 |
if (p->is_active) count++; |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
102 |
} |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
103 |
|
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
104 |
return count; |
ddbd525a04d0
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4603
diff
changeset
|
105 |
} |
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
|
106 |
|
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
107 |
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
|
108 |
{ |
5980
cec1cfd00d1e
(svn r8272) -Fix (r8038): signed/unsigned change - PlayerID is now enum (signed) and was byte so test for PlayerID validity needed to be updated (Darkvater)
KUDr
parents:
5838
diff
changeset
|
109 |
assert(IS_INSIDE_1D(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
|
110 |
return &_players[i]; |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
111 |
} |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
112 |
|
6573 | 113 |
static inline bool IsLocalPlayer() |
2425
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
114 |
{ |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
115 |
return _local_player == _current_player; |
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
|
116 |
} |
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
|
117 |
|
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4849
diff
changeset
|
118 |
static inline bool IsValidPlayer(PlayerID pi) |
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4849
diff
changeset
|
119 |
{ |
5980
cec1cfd00d1e
(svn r8272) -Fix (r8038): signed/unsigned change - PlayerID is now enum (signed) and was byte so test for PlayerID validity needed to be updated (Darkvater)
KUDr
parents:
5838
diff
changeset
|
120 |
return IS_INSIDE_1D(pi, PLAYER_FIRST, MAX_PLAYERS); |
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4849
diff
changeset
|
121 |
} |
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4849
diff
changeset
|
122 |
|
2544 | 123 |
byte GetPlayerRailtypes(PlayerID p); |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
124 |
|
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4428
diff
changeset
|
125 |
/** Finds out if a Player has a certain railtype available */ |
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
126 |
static inline bool HasRailtypeAvail(const Player *p, RailType Railtype) |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
127 |
{ |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
128 |
return HASBIT(p->avail_railtypes, Railtype); |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
129 |
} |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
130 |
|
4845
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
131 |
static inline bool IsHumanPlayer(PlayerID pi) |
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
132 |
{ |
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
133 |
return !GetPlayer(pi)->is_ai; |
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
134 |
} |
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
135 |
|
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
136 |
static inline bool IsInteractivePlayer(PlayerID pi) |
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
137 |
{ |
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
138 |
return pi == _local_player; |
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
139 |
} |
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4824
diff
changeset
|
140 |
|
6001
1e4c5406cd1a
(svn r8300) -Codechange: Add a prototype for DrawPlayerIcon to players.h and include that
maedhros
parents:
5980
diff
changeset
|
141 |
void DrawPlayerIcon(PlayerID p, int x, int y); |
1e4c5406cd1a
(svn r8300) -Codechange: Add a prototype for DrawPlayerIcon to players.h and include that
maedhros
parents:
5980
diff
changeset
|
142 |
|
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
143 |
/* Validate functions for rail building */ |
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
144 |
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);} |
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
145 |
|
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
146 |
/** Returns the "best" railtype a player can build. |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3355
diff
changeset
|
147 |
* As the AI doesn't know what the BEST one is, we have our own priority list |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3355
diff
changeset
|
148 |
* here. When adding new railtypes, modify this function |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3355
diff
changeset
|
149 |
* @param p the player "in action" |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3355
diff
changeset
|
150 |
* @return The "best" railtype a player has available |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3355
diff
changeset
|
151 |
*/ |
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2475
diff
changeset
|
152 |
static inline RailType GetBestRailtype(const Player* p) |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
153 |
{ |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
154 |
if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV; |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
155 |
if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3345
diff
changeset
|
156 |
if (HasRailtypeAvail(p, RAILTYPE_ELECTRIC)) return RAILTYPE_ELECTRIC; |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
157 |
return RAILTYPE_RAIL; |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
158 |
} |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
159 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
160 |
struct HighScore { |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
161 |
char company[100]; |
9505 | 162 |
StringID title; ///< NO_SAVE, has troubles with changing string-numbers. |
163 |
uint16 score; ///< do NOT change type, will break hs.dat |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
164 |
}; |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
165 |
|
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
990
diff
changeset
|
166 |
VARDEF HighScore _highscore_table[5][5]; // 4 difficulty-settings (+ network); top 5 |
6573 | 167 |
void SaveToHighScore(); |
168 |
void LoadFromHighScore(); |
|
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
990
diff
changeset
|
169 |
int8 SaveHighScoreValue(const Player *p); |
6573 | 170 |
int8 SaveHighScoreValueNetwork(); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
171 |
|
2848 | 172 |
/* Engine Replacement Functions */ |
173 |
||
174 |
/** |
|
175 |
* Remove all engine replacement settings for the given player. |
|
176 |
* @param p Player. |
|
177 |
*/ |
|
178 |
static inline void RemoveAllEngineReplacementForPlayer(Player *p) { RemoveAllEngineReplacement(&p->engine_renew_list); } |
|
179 |
||
180 |
/** |
|
181 |
* Retrieve the engine replacement for the given player and original engine type. |
|
182 |
* @param p Player. |
|
183 |
* @param engine Engine type. |
|
184 |
* @return The engine type to replace with, or INVALID_ENGINE if no |
|
185 |
* replacement is in the list. |
|
186 |
*/ |
|
187 |
static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine) { return EngineReplacement(p->engine_renew_list, engine); } |
|
188 |
||
189 |
/** |
|
190 |
* Check if a player has a replacement set up for the given engine. |
|
191 |
* @param p Player. |
|
192 |
* @param engine Engine type to be replaced. |
|
193 |
* @return true if a replacement was set up, false otherwise. |
|
194 |
*/ |
|
195 |
static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine) { return EngineReplacementForPlayer(p, engine) != INVALID_ENGINE; } |
|
196 |
||
197 |
/** |
|
198 |
* Add an engine replacement for the player. |
|
199 |
* @param p Player. |
|
200 |
* @param old_engine The original engine type. |
|
201 |
* @param new_engine The replacement engine type. |
|
202 |
* @param flags The calling command flags. |
|
203 |
* @return 0 on success, CMD_ERROR on failure. |
|
204 |
*/ |
|
205 |
static inline int32 AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, uint32 flags) { return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, flags); } |
|
206 |
||
207 |
/** |
|
208 |
* Remove an engine replacement for the player. |
|
209 |
* @param p Player. |
|
210 |
* @param engine The original engine type. |
|
211 |
* @param flags The calling command flags. |
|
212 |
* @return 0 on success, CMD_ERROR on failure. |
|
213 |
*/ |
|
214 |
static inline int32 RemoveEngineReplacementForPlayer(Player *p, EngineID engine, uint32 flags) {return RemoveEngineReplacement(&p->engine_renew_list, engine, flags); } |
|
2697
c7b1a950c4cf
(svn r3239) - Codechange: Introduce and use helper functions for engine replacement code.
peter1138
parents:
2617
diff
changeset
|
215 |
|
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
|
216 |
/** |
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
|
217 |
* Reset the livery schemes to the player's primary colour. |
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
|
218 |
* This is used on loading games without livery information and on new player start up. |
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
|
219 |
* @param p Player to reset. |
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
|
220 |
*/ |
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
|
221 |
void ResetPlayerLivery(Player *p); |
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
|
222 |
|
0 | 223 |
#endif /* PLAYER_H */ |