9724
|
1 |
/* $Id$ */
|
|
2 |
|
|
3 |
/** @file player_base.h Definition of stuff that is very close to a player, like the player struct itself. */
|
|
4 |
|
|
5 |
#ifndef PLAYER_BASE_H
|
|
6 |
#define PLAYER_BASE_H
|
|
7 |
|
|
8 |
#include "road_type.h"
|
|
9 |
#include "rail_type.h"
|
|
10 |
#include "date_type.h"
|
|
11 |
#include "engine.h"
|
|
12 |
#include "livery.h"
|
|
13 |
#include "autoreplace_type.h"
|
|
14 |
#include "economy_type.h"
|
|
15 |
#include "tile_type.h"
|
|
16 |
|
|
17 |
struct PlayerEconomyEntry {
|
|
18 |
Money income;
|
|
19 |
Money expenses;
|
|
20 |
int32 delivered_cargo;
|
|
21 |
int32 performance_history; ///< player score (scale 0-1000)
|
|
22 |
Money company_value;
|
|
23 |
};
|
|
24 |
|
|
25 |
struct Player {
|
|
26 |
uint32 name_2;
|
|
27 |
uint16 name_1;
|
|
28 |
char *name;
|
|
29 |
|
|
30 |
uint16 president_name_1;
|
|
31 |
uint32 president_name_2;
|
|
32 |
char *president_name;
|
|
33 |
|
|
34 |
PlayerFace face;
|
|
35 |
|
|
36 |
Money player_money;
|
|
37 |
Money current_loan;
|
|
38 |
|
|
39 |
byte player_color;
|
|
40 |
Livery livery[LS_END];
|
|
41 |
byte player_money_fraction;
|
|
42 |
RailTypes avail_railtypes;
|
|
43 |
RoadTypes avail_roadtypes;
|
|
44 |
byte block_preview;
|
|
45 |
PlayerByte index;
|
|
46 |
|
|
47 |
uint16 cargo_types; ///< which cargo types were transported the last year
|
|
48 |
|
|
49 |
TileIndex location_of_house;
|
|
50 |
TileIndex last_build_coordinate;
|
|
51 |
|
|
52 |
PlayerByte share_owners[4];
|
|
53 |
|
|
54 |
Year inaugurated_year;
|
|
55 |
byte num_valid_stat_ent;
|
|
56 |
|
|
57 |
byte quarters_of_bankrupcy;
|
|
58 |
byte bankrupt_asked; ///< which players were asked about buying it?
|
|
59 |
int16 bankrupt_timeout;
|
|
60 |
Money bankrupt_value;
|
|
61 |
|
|
62 |
bool is_active;
|
|
63 |
bool is_ai;
|
|
64 |
bool is_noai; ///< This is a NoAI player (for loading old savegames properly). Part of the NoAI 'hack' to retain savegame compatability with trunk
|
|
65 |
|
9732
|
66 |
Money yearly_expenses[3][EXPENSES_END];
|
9724
|
67 |
PlayerEconomyEntry cur_economy;
|
|
68 |
PlayerEconomyEntry old_economy[24];
|
|
69 |
EngineRenewList engine_renew_list; ///< Defined later
|
|
70 |
bool engine_renew;
|
|
71 |
bool renew_keep_length;
|
|
72 |
int16 engine_renew_months;
|
|
73 |
uint32 engine_renew_money;
|
|
74 |
uint16 num_engines[TOTAL_NUM_ENGINES]; ///< caches the number of engines of each type the player owns (no need to save this)
|
|
75 |
};
|
|
76 |
|
|
77 |
extern Player _players[MAX_PLAYERS];
|
|
78 |
#define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++)
|
|
79 |
|
|
80 |
static inline byte ActivePlayerCount()
|
|
81 |
{
|
|
82 |
const Player *p;
|
|
83 |
byte count = 0;
|
|
84 |
|
|
85 |
FOR_ALL_PLAYERS(p) {
|
|
86 |
if (p->is_active) count++;
|
|
87 |
}
|
|
88 |
|
|
89 |
return count;
|
|
90 |
}
|
|
91 |
|
|
92 |
static inline Player *GetPlayer(PlayerID i)
|
|
93 |
{
|
|
94 |
assert(IsInsideBS(i, PLAYER_FIRST, lengthof(_players)));
|
|
95 |
return &_players[i];
|
|
96 |
}
|
|
97 |
|
|
98 |
Money CalculateCompanyValue(const Player *p);
|
|
99 |
|
|
100 |
#endif /* PLAYER_BASE_H */
|