2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
/** @file player.h */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef PLAYER_H
|
|
|
|
#define PLAYER_H
|
|
|
|
|
2006-12-03 17:27:43 +00:00
|
|
|
#include "oldpool.h"
|
2004-08-20 09:32:32 +00:00
|
|
|
#include "aystar.h"
|
2007-12-18 20:58:12 +00:00
|
|
|
#include "rail_type.h"
|
2007-12-18 20:38:16 +00:00
|
|
|
#include "road_func.h"
|
2007-12-21 22:50:51 +00:00
|
|
|
#include "cargo_type.h"
|
|
|
|
#include "command_type.h"
|
2005-10-31 12:01:41 +00:00
|
|
|
#include "engine.h"
|
2006-09-15 12:27:00 +00:00
|
|
|
#include "livery.h"
|
2007-11-11 12:34:44 +00:00
|
|
|
#include "genworld.h"
|
2004-08-20 09:32:32 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct PlayerEconomyEntry {
|
2007-06-18 21:44:47 +00:00
|
|
|
Money income;
|
|
|
|
Money expenses;
|
2004-08-09 17:04:08 +00:00
|
|
|
int32 delivered_cargo;
|
2007-03-21 17:42:43 +00:00
|
|
|
int32 performance_history; ///< player score (scale 0-1000)
|
2007-06-18 22:49:55 +00:00
|
|
|
Money company_value;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct AiBuildRec {
|
2004-08-09 17:04:08 +00:00
|
|
|
TileIndex spec_tile;
|
|
|
|
TileIndex use_tile;
|
|
|
|
byte rand_rng;
|
|
|
|
byte cur_building_rule;
|
|
|
|
byte unk6;
|
|
|
|
byte unk7;
|
|
|
|
byte buildcmd_a;
|
|
|
|
byte buildcmd_b;
|
|
|
|
byte direction;
|
2006-03-26 22:23:32 +00:00
|
|
|
CargoID cargo;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct PlayerAI {
|
2004-08-09 17:04:08 +00:00
|
|
|
byte state;
|
2007-03-21 17:42:43 +00:00
|
|
|
byte tick; ///< Used to determine how often to move
|
|
|
|
uint32 state_counter; ///< Can hold tile index!
|
2004-08-09 17:04:08 +00:00
|
|
|
uint16 timeout_counter;
|
|
|
|
|
|
|
|
byte state_mode;
|
|
|
|
byte banned_tile_count;
|
2007-01-10 18:56:51 +00:00
|
|
|
RailTypeByte railtype_to_use;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-03-26 22:23:32 +00:00
|
|
|
CargoID cargo_type;
|
2004-08-09 17:04:08 +00:00
|
|
|
byte num_wagons;
|
|
|
|
byte build_kind;
|
|
|
|
byte num_build_rec;
|
|
|
|
byte num_loco_to_build;
|
|
|
|
byte num_want_fullload;
|
|
|
|
|
|
|
|
byte route_type_mask;
|
|
|
|
|
|
|
|
TileIndex start_tile_a;
|
|
|
|
TileIndex cur_tile_a;
|
2007-07-24 13:03:24 +00:00
|
|
|
DiagDirectionByte cur_dir_a;
|
|
|
|
DiagDirectionByte start_dir_a;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
TileIndex start_tile_b;
|
|
|
|
TileIndex cur_tile_b;
|
2007-07-24 13:03:24 +00:00
|
|
|
DiagDirectionByte cur_dir_b;
|
|
|
|
DiagDirectionByte start_dir_b;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
Vehicle *cur_veh; ///< only used by some states
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
AiBuildRec src, dst, mid1, mid2;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
VehicleID wagon_list[9];
|
|
|
|
byte order_list_blocks[20];
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
TileIndex banned_tiles[16];
|
|
|
|
byte banned_val[16];
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Ai_PathFinderInfo {
|
2007-03-21 17:42:43 +00:00
|
|
|
TileIndex start_tile_tl; ///< tl = top-left
|
|
|
|
TileIndex start_tile_br; ///< br = bottom-right
|
|
|
|
TileIndex end_tile_tl; ///< tl = top-left
|
|
|
|
TileIndex end_tile_br; ///< br = bottom-right
|
2007-07-24 13:03:24 +00:00
|
|
|
DiagDirection start_direction; ///< 0 to 3 or AI_PATHFINDER_NO_DIRECTION
|
|
|
|
DiagDirection end_direction; ///< 0 to 3 or AI_PATHFINDER_NO_DIRECTION
|
2004-08-20 09:32:32 +00:00
|
|
|
|
|
|
|
TileIndex route[500];
|
2007-03-21 17:42:43 +00:00
|
|
|
byte route_extra[500]; ///< Some extra information about the route like bridge/tunnel
|
2004-08-20 09:32:32 +00:00
|
|
|
int route_length;
|
2007-03-21 17:42:43 +00:00
|
|
|
int position; ///< Current position in the build-path, needed to build the path
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
bool rail_or_road; ///< true = rail, false = road
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-20 09:32:32 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
/* The amount of memory reserved for the AI-special-vehicles */
|
2004-08-31 16:12:52 +00:00
|
|
|
#define AI_MAX_SPECIAL_VEHICLES 100
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Ai_SpecialVehicle {
|
2004-08-31 16:12:52 +00:00
|
|
|
VehicleID veh_id;
|
|
|
|
uint32 flag;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct PlayerAiNew {
|
2004-08-20 09:32:32 +00:00
|
|
|
uint8 state;
|
|
|
|
uint tick;
|
|
|
|
uint idle;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
int temp; ///< A value used in more than one function, but it just temporary
|
|
|
|
///< The use is pretty simple: with this we can 'think' about stuff
|
|
|
|
///< in more than one tick, and more than one AI. A static will not
|
|
|
|
///< do, because they are not saved. This way, the AI is almost human ;)
|
|
|
|
int counter; ///< For the same reason as temp, we have counter. It can count how
|
|
|
|
///< long we are trying something, and just abort if it takes too long
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
/* Pathfinder stuff */
|
2004-08-20 09:32:32 +00:00
|
|
|
Ai_PathFinderInfo path_info;
|
|
|
|
AyStar *pathfinder;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
/* Route stuff */
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2006-03-26 22:23:32 +00:00
|
|
|
CargoID cargo;
|
2007-03-21 17:42:43 +00:00
|
|
|
byte tbt; ///< train/bus/truck 0/1/2 AI_TRAIN/AI_BUS/AI_TRUCK
|
2007-06-21 14:32:27 +00:00
|
|
|
Money new_cost;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-20 09:32:32 +00:00
|
|
|
byte action;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
int last_id; ///< here is stored the last id of the searched city/industry
|
2006-08-15 16:55:40 +00:00
|
|
|
Date last_vehiclecheck_date; // Used in CheckVehicle
|
2007-03-21 17:42:43 +00:00
|
|
|
Ai_SpecialVehicle special_vehicles[AI_MAX_SPECIAL_VEHICLES]; ///< Some vehicles have some special flags
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-20 09:32:32 +00:00
|
|
|
TileIndex from_tile;
|
|
|
|
TileIndex to_tile;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-07-24 13:03:24 +00:00
|
|
|
DiagDirectionByte from_direction;
|
|
|
|
DiagDirectionByte to_direction;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
bool from_deliver; ///< True if this is the station that GIVES cargo
|
2004-08-20 09:32:32 +00:00
|
|
|
bool to_deliver;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-20 09:32:32 +00:00
|
|
|
TileIndex depot_tile;
|
2007-01-10 18:56:51 +00:00
|
|
|
DiagDirectionByte depot_direction;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
byte amount_veh; ///< How many vehicles we are going to build in this route
|
|
|
|
byte cur_veh; ///< How many vehicles did we bought?
|
|
|
|
VehicleID veh_id; ///< Used when bought a vehicle
|
|
|
|
VehicleID veh_main_id; ///< The ID of the first vehicle, for shared copy
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
int from_ic; ///< ic = industry/city. This is the ID of them
|
|
|
|
byte from_type; ///< AI_NO_TYPE/AI_CITY/AI_INDUSTRY
|
2004-08-20 09:32:32 +00:00
|
|
|
int to_ic;
|
|
|
|
byte to_type;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-20 09:32:32 +00:00
|
|
|
|
|
|
|
|
2007-06-14 15:24:34 +00:00
|
|
|
/* The "steps" in loan size, in British Pounds! */
|
|
|
|
enum {
|
|
|
|
LOAN_INTERVAL = 10000,
|
|
|
|
LOAN_INTERVAL_OLD_AI = 50000,
|
|
|
|
};
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Player {
|
2004-08-09 17:04:08 +00:00
|
|
|
uint32 name_2;
|
|
|
|
uint16 name_1;
|
|
|
|
|
|
|
|
uint16 president_name_1;
|
|
|
|
uint32 president_name_2;
|
|
|
|
|
2007-03-02 01:17:11 +00:00
|
|
|
PlayerFace face;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-06-18 22:49:55 +00:00
|
|
|
Money player_money;
|
2007-06-18 21:44:47 +00:00
|
|
|
Money current_loan;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
byte player_color;
|
2006-09-15 12:27:00 +00:00
|
|
|
Livery livery[LS_END];
|
2004-08-09 17:04:08 +00:00
|
|
|
byte player_money_fraction;
|
2005-07-20 22:02:58 +00:00
|
|
|
byte avail_railtypes;
|
2007-05-25 08:13:01 +00:00
|
|
|
byte avail_roadtypes;
|
2004-08-09 17:04:08 +00:00
|
|
|
byte block_preview;
|
2007-01-10 18:56:51 +00:00
|
|
|
PlayerByte index;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 17:42:43 +00:00
|
|
|
uint16 cargo_types; ///< which cargo types were transported the last year
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
TileIndex location_of_house;
|
|
|
|
TileIndex last_build_coordinate;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
PlayerByte share_owners[4];
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2006-08-20 18:40:57 +00:00
|
|
|
Year inaugurated_year;
|
2004-08-09 17:04:08 +00:00
|
|
|
byte num_valid_stat_ent;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-09 17:04:08 +00: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 17:04:08 +00:00
|
|
|
int16 bankrupt_timeout;
|
2007-06-18 21:44:47 +00:00
|
|
|
Money bankrupt_value;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
bool is_active;
|
2006-03-26 22:25:29 +00:00
|
|
|
bool is_ai;
|
2004-08-09 17:04:08 +00:00
|
|
|
PlayerAI ai;
|
2004-08-20 09:32:32 +00:00
|
|
|
PlayerAiNew ainew;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2007-06-18 22:49:55 +00:00
|
|
|
Money yearly_expenses[3][13];
|
2004-08-09 17:04:08 +00: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 16:07:22 +00:00
|
|
|
bool engine_renew;
|
2005-11-07 23:20:47 +00:00
|
|
|
bool renew_keep_length;
|
2005-08-06 16:07:22 +00: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 17:04:08 +00:00
|
|
|
|
2006-08-28 06:21:48 +00:00
|
|
|
uint16 GetDrawStringPlayerColor(PlayerID player);
|
|
|
|
|
2005-09-18 20:56:44 +00:00
|
|
|
void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player);
|
2006-10-14 22:22:48 +00:00
|
|
|
void GetNameOfOwner(Owner owner, TileIndex tile);
|
2007-07-24 17:01:23 +00:00
|
|
|
Money CalculateCompanyValue(const Player *p);
|
|
|
|
void InvalidatePlayerWindows(const Player *p);
|
2006-12-26 12:56:48 +00:00
|
|
|
void SetLocalPlayer(PlayerID new_player);
|
2006-02-01 07:36:15 +00:00
|
|
|
#define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++)
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-08-31 19:49:31 +00:00
|
|
|
VARDEF PlayerByte _local_player;
|
|
|
|
VARDEF PlayerByte _current_player;
|
2005-07-21 19:36:43 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
VARDEF Player _players[MAX_PLAYERS];
|
2007-03-21 17:42:43 +00:00
|
|
|
/* NOSAVE: can be determined from player structs */
|
2005-07-21 19:36:43 +00:00
|
|
|
VARDEF byte _player_colors[MAX_PLAYERS];
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static inline byte ActivePlayerCount()
|
2006-10-12 11:42:57 +00: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 17:01:23 +00:00
|
|
|
static inline Player *GetPlayer(PlayerID i)
|
2005-05-06 06:56:30 +00:00
|
|
|
{
|
2007-11-24 10:38:43 +00:00
|
|
|
assert(IsInsideBS(i, PLAYER_FIRST, lengthof(_players)));
|
2005-09-14 18:03:38 +00:00
|
|
|
return &_players[i];
|
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static inline bool IsLocalPlayer()
|
2005-09-14 18:03:38 +00:00
|
|
|
{
|
|
|
|
return _local_player == _current_player;
|
2005-05-06 06:56:30 +00:00
|
|
|
}
|
|
|
|
|
2006-10-14 22:31:18 +00:00
|
|
|
static inline bool IsValidPlayer(PlayerID pi)
|
|
|
|
{
|
2007-11-24 10:38:43 +00:00
|
|
|
return IsInsideBS(pi, PLAYER_FIRST, MAX_PLAYERS);
|
2006-10-14 22:31:18 +00:00
|
|
|
}
|
|
|
|
|
2005-10-20 17:43:13 +00:00
|
|
|
byte GetPlayerRailtypes(PlayerID p);
|
2007-05-25 08:13:01 +00:00
|
|
|
byte GetPlayerRoadtypes(PlayerID p);
|
2005-07-20 22:02:58 +00:00
|
|
|
|
2007-11-11 12:34:44 +00:00
|
|
|
/** Finds out if a Player has a certain railtype available
|
|
|
|
* @param p Player in question
|
|
|
|
* @param Railtype requested RailType
|
|
|
|
* @return true if player has requested RailType available
|
|
|
|
*/
|
|
|
|
static inline bool HasRailtypeAvail(const Player *p, const RailType Railtype)
|
2005-07-20 22:02:58 +00:00
|
|
|
{
|
2007-11-19 21:02:30 +00:00
|
|
|
return HasBit(p->avail_railtypes, Railtype);
|
2005-07-20 22:02:58 +00:00
|
|
|
}
|
|
|
|
|
2007-11-11 12:34:44 +00:00
|
|
|
/** Finds out, whether given player has all given RoadTypes available
|
|
|
|
* @param PlayerID ID of player
|
|
|
|
* @param rts RoadTypes to test
|
|
|
|
* @return true if player has all requested RoadTypes available
|
|
|
|
*/
|
|
|
|
static inline bool HasRoadTypesAvail(const PlayerID p, const RoadTypes rts)
|
|
|
|
{
|
|
|
|
RoadTypes avail_roadtypes;
|
|
|
|
|
|
|
|
if (p == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
|
|
|
|
avail_roadtypes = ROADTYPES_ROAD;
|
|
|
|
} else {
|
|
|
|
if (!IsValidPlayer(p)) return false;
|
|
|
|
avail_roadtypes = (RoadTypes)GetPlayer(p)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
|
|
|
|
}
|
|
|
|
return (rts & ~avail_roadtypes) == 0;
|
|
|
|
}
|
|
|
|
|
2006-10-14 15:15:56 +00:00
|
|
|
static inline bool IsHumanPlayer(PlayerID pi)
|
|
|
|
{
|
|
|
|
return !GetPlayer(pi)->is_ai;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsInteractivePlayer(PlayerID pi)
|
|
|
|
{
|
|
|
|
return pi == _local_player;
|
|
|
|
}
|
|
|
|
|
2007-01-21 11:49:18 +00:00
|
|
|
void DrawPlayerIcon(PlayerID p, int x, int y);
|
|
|
|
|
2005-07-21 19:36:43 +00:00
|
|
|
/* Validate functions for rail building */
|
2007-11-19 21:02:30 +00:00
|
|
|
static inline bool ValParamRailtype(const uint32 rail) { return HasBit(GetPlayer(_current_player)->avail_railtypes, rail);}
|
2007-11-11 12:34:44 +00:00
|
|
|
|
|
|
|
/* Validate functions for road building */
|
|
|
|
static inline bool ValParamRoadType(const RoadType rt) { return HasRoadTypesAvail(_current_player, RoadTypeToRoadTypes(rt));}
|
2005-07-21 19:36:43 +00:00
|
|
|
|
2005-07-20 22:02:58 +00:00
|
|
|
/** Returns the "best" railtype a player can build.
|
2006-06-27 21:25:53 +00:00
|
|
|
* As the AI doesn't know what the BEST one is, we have our own priority list
|
|
|
|
* here. When adding new railtypes, modify this function
|
|
|
|
* @param p the player "in action"
|
|
|
|
* @return The "best" railtype a player has available
|
|
|
|
*/
|
2007-07-24 17:01:23 +00:00
|
|
|
static inline RailType GetBestRailtype(const Player *p)
|
2005-07-20 22:02:58 +00:00
|
|
|
{
|
|
|
|
if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
|
|
|
|
if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO;
|
2006-03-29 16:30:26 +00:00
|
|
|
if (HasRailtypeAvail(p, RAILTYPE_ELECTRIC)) return RAILTYPE_ELECTRIC;
|
2005-07-20 22:02:58 +00:00
|
|
|
return RAILTYPE_RAIL;
|
|
|
|
}
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct HighScore {
|
2005-01-11 00:54:06 +00:00
|
|
|
char company[100];
|
2007-03-21 17:42:43 +00:00
|
|
|
StringID title; ///< NO_SAVE, has troubles with changing string-numbers.
|
|
|
|
uint16 score; ///< do NOT change type, will break hs.dat
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-01-11 00:54:06 +00:00
|
|
|
|
2005-01-13 16:28:47 +00:00
|
|
|
VARDEF HighScore _highscore_table[5][5]; // 4 difficulty-settings (+ network); top 5
|
2007-03-07 11:47:46 +00:00
|
|
|
void SaveToHighScore();
|
|
|
|
void LoadFromHighScore();
|
2005-01-13 16:28:47 +00:00
|
|
|
int8 SaveHighScoreValue(const Player *p);
|
2007-03-07 11:47:46 +00:00
|
|
|
int8 SaveHighScoreValueNetwork();
|
2005-01-11 00:54:06 +00:00
|
|
|
|
2006-01-12 15:52:18 +00:00
|
|
|
/* Engine Replacement Functions */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all engine replacement settings for the given player.
|
|
|
|
* @param p Player.
|
|
|
|
*/
|
|
|
|
static inline void RemoveAllEngineReplacementForPlayer(Player *p) { RemoveAllEngineReplacement(&p->engine_renew_list); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the engine replacement for the given player and original engine type.
|
|
|
|
* @param p Player.
|
|
|
|
* @param engine Engine type.
|
|
|
|
* @return The engine type to replace with, or INVALID_ENGINE if no
|
|
|
|
* replacement is in the list.
|
|
|
|
*/
|
2007-05-19 09:40:18 +00:00
|
|
|
static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group) { return EngineReplacement(p->engine_renew_list, engine, group); }
|
2006-01-12 15:52:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a player has a replacement set up for the given engine.
|
|
|
|
* @param p Player.
|
|
|
|
* @param engine Engine type to be replaced.
|
|
|
|
* @return true if a replacement was set up, false otherwise.
|
|
|
|
*/
|
2007-05-19 09:40:18 +00:00
|
|
|
static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group) { return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE; }
|
2006-01-12 15:52:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an engine replacement for the player.
|
|
|
|
* @param p Player.
|
|
|
|
* @param old_engine The original engine type.
|
|
|
|
* @param new_engine The replacement engine type.
|
|
|
|
* @param flags The calling command flags.
|
|
|
|
* @return 0 on success, CMD_ERROR on failure.
|
|
|
|
*/
|
2007-06-18 10:48:15 +00:00
|
|
|
static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags) { return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags); }
|
2006-01-12 15:52:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an engine replacement for the player.
|
|
|
|
* @param p Player.
|
|
|
|
* @param engine The original engine type.
|
|
|
|
* @param flags The calling command flags.
|
|
|
|
* @return 0 on success, CMD_ERROR on failure.
|
|
|
|
*/
|
2007-06-18 10:48:15 +00:00
|
|
|
static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags) {return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags); }
|
2005-11-26 16:41:14 +00:00
|
|
|
|
2006-09-15 12:27:00 +00:00
|
|
|
/**
|
|
|
|
* Reset the livery schemes to the player's primary colour.
|
|
|
|
* This is used on loading games without livery information and on new player start up.
|
|
|
|
* @param p Player to reset.
|
|
|
|
*/
|
|
|
|
void ResetPlayerLivery(Player *p);
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#endif /* PLAYER_H */
|