2005-07-24 15:12:37 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-01-12 14:10:35 +00:00
|
|
|
/** @file player_base.h Definition of stuff that is very close to a player, like the player struct itself. */
|
2007-03-21 17:42:43 +00:00
|
|
|
|
2008-01-12 14:10:35 +00:00
|
|
|
#ifndef PLAYER_BASE_H
|
|
|
|
#define PLAYER_BASE_H
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2008-01-09 21:05:03 +00:00
|
|
|
#include "road_type.h"
|
|
|
|
#include "rail_type.h"
|
2007-12-26 13:50:40 +00:00
|
|
|
#include "date_type.h"
|
2005-10-31 12:01:41 +00:00
|
|
|
#include "engine.h"
|
2006-09-15 13:27:00 +01:00
|
|
|
#include "livery.h"
|
2008-01-07 09:19:53 +00:00
|
|
|
#include "autoreplace_type.h"
|
2008-01-09 21:27:39 +00:00
|
|
|
#include "economy_type.h"
|
|
|
|
#include "tile_type.h"
|
2004-08-20 10:32:32 +01:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct PlayerEconomyEntry {
|
2007-06-18 22:44:47 +01:00
|
|
|
Money income;
|
|
|
|
Money expenses;
|
2004-08-09 18:04:08 +01:00
|
|
|
int32 delivered_cargo;
|
2007-03-21 17:42:43 +00:00
|
|
|
int32 performance_history; ///< player score (scale 0-1000)
|
2007-06-18 23:49:55 +01:00
|
|
|
Money company_value;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Player {
|
2004-08-09 18:04:08 +01:00
|
|
|
uint32 name_2;
|
|
|
|
uint16 name_1;
|
2008-01-12 19:58:06 +00:00
|
|
|
char *name;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
|
|
|
uint16 president_name_1;
|
|
|
|
uint32 president_name_2;
|
2008-01-12 19:58:06 +00:00
|
|
|
char *president_name;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-03-02 01:17:11 +00:00
|
|
|
PlayerFace face;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-06-18 23:49:55 +01:00
|
|
|
Money player_money;
|
2007-06-18 22:44:47 +01:00
|
|
|
Money current_loan;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
|
|
|
byte player_color;
|
2006-09-15 13:27:00 +01:00
|
|
|
Livery livery[LS_END];
|
2004-08-09 18:04:08 +01:00
|
|
|
byte player_money_fraction;
|
2008-01-09 21:05:03 +00:00
|
|
|
RailTypes avail_railtypes;
|
|
|
|
RoadTypes avail_roadtypes;
|
2004-08-09 18:04:08 +01:00
|
|
|
byte block_preview;
|
2007-01-10 18:56:51 +00:00
|
|
|
PlayerByte index;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
uint16 cargo_types; ///< which cargo types were transported the last year
|
2004-08-09 18:04:08 +01:00
|
|
|
|
|
|
|
TileIndex location_of_house;
|
|
|
|
TileIndex last_build_coordinate;
|
2004-08-31 17:12:52 +01:00
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
PlayerByte share_owners[4];
|
2004-08-31 17:12:52 +01:00
|
|
|
|
2006-08-20 19:40:57 +01:00
|
|
|
Year inaugurated_year;
|
2004-08-09 18:04:08 +01:00
|
|
|
byte num_valid_stat_ent;
|
2004-08-31 17:12:52 +01:00
|
|
|
|
2004-08-09 18:04:08 +01:00
|
|
|
byte quarters_of_bankrupcy;
|
2007-03-21 17:42:43 +00:00
|
|
|
byte bankrupt_asked; ///< which players were asked about buying it?
|
2004-08-09 18:04:08 +01:00
|
|
|
int16 bankrupt_timeout;
|
2007-06-18 22:44:47 +01:00
|
|
|
Money bankrupt_value;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
|
|
|
bool is_active;
|
2006-03-26 23:25:29 +01:00
|
|
|
bool is_ai;
|
2004-08-31 17:12:52 +01:00
|
|
|
|
2007-06-18 23:49:55 +01:00
|
|
|
Money yearly_expenses[3][13];
|
2004-08-09 18:04:08 +01:00
|
|
|
PlayerEconomyEntry cur_economy;
|
|
|
|
PlayerEconomyEntry old_economy[24];
|
2007-03-21 17:42:43 +00:00
|
|
|
EngineRenewList engine_renew_list; ///< Defined later
|
2005-08-06 17:07:22 +01:00
|
|
|
bool engine_renew;
|
2005-11-07 23:20:47 +00:00
|
|
|
bool renew_keep_length;
|
2005-08-06 17:07:22 +01:00
|
|
|
int16 engine_renew_months;
|
|
|
|
uint32 engine_renew_money;
|
2007-03-21 17:42:43 +00:00
|
|
|
uint16 num_engines[TOTAL_NUM_ENGINES]; ///< caches the number of engines of each type the player owns (no need to save this)
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2008-01-12 14:10:35 +00:00
|
|
|
extern Player _players[MAX_PLAYERS];
|
2006-02-01 07:36:15 +00:00
|
|
|
#define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++)
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static inline byte ActivePlayerCount()
|
2006-10-12 12:42:57 +01:00
|
|
|
{
|
|
|
|
const Player *p;
|
|
|
|
byte count = 0;
|
|
|
|
|
|
|
|
FOR_ALL_PLAYERS(p) {
|
|
|
|
if (p->is_active) count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2006-01-31 22:16:15 +00:00
|
|
|
|
2007-07-24 18:01:23 +01:00
|
|
|
static inline Player *GetPlayer(PlayerID i)
|
2005-05-06 07:56:30 +01:00
|
|
|
{
|
2007-11-24 10:38:43 +00:00
|
|
|
assert(IsInsideBS(i, PLAYER_FIRST, lengthof(_players)));
|
2005-09-14 19:03:38 +01:00
|
|
|
return &_players[i];
|
|
|
|
}
|
|
|
|
|
2008-01-12 14:10:35 +00:00
|
|
|
Money CalculateCompanyValue(const Player *p);
|
2006-09-15 13:27:00 +01:00
|
|
|
|
2008-01-12 14:10:35 +00:00
|
|
|
#endif /* PLAYER_BASE_H */
|