#include "stdafx.h"
#include "openttd.h"
#include "engine.h"
#include "player_func.h"
#include "player_gui.h"
#include "town.h"
#include "station.h"
#include "news.h"
#include "saveload.h"
#include "command_func.h"
#include "network/network.h"
#include "network/network_internal.h"
#include "variables.h"
#include "ai/ai.h"
#include "player_face.h"
#include "group.h"
#include "window_func.h"
#include "tile_map.h"
#include "strings_func.h"
#include "gfx_func.h"
#include "functions.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
#include "string_func.h"
#include "ai/default/default.h"
#include "ai/trolly/trolly.h"
#include "road_func.h"
#include "rail.h"
#include "table/strings.h"
#include "table/sprites.h"
Go to the source code of this file.
Defines | |
#define | COLOR_SWAP(i, j) do { byte t=colors[i];colors[i]=colors[j];colors[j]=t; } while(0) |
#define | LAST_HS_ITEM lengthof(_highscore_table) - 1 |
Functions | |
void | SetLocalPlayer (PlayerID new_player) |
Sets the local player and updates the patch settings that are set on a per-company (player) basis to reflect the core's state in the GUI. | |
bool | IsHumanPlayer (PlayerID pi) |
uint16 | GetDrawStringPlayerColor (PlayerID player) |
void | DrawPlayerIcon (PlayerID p, int x, int y) |
PlayerFace | ConvertFromOldPlayerFace (uint32 face) |
Converts an old player face format to the new player face format. | |
bool | IsValidPlayerFace (PlayerFace pf) |
Checks whether a player's face is a valid encoding. | |
void | InvalidatePlayerWindows (const Player *p) |
bool | CheckPlayerHasMoney (CommandCost cost) |
static void | SubtractMoneyFromAnyPlayer (Player *p, CommandCost cost) |
void | SubtractMoneyFromPlayer (CommandCost cost) |
void | SubtractMoneyFromPlayerFract (PlayerID player, CommandCost cst) |
void | GetNameOfOwner (Owner owner, TileIndex tile) |
bool | CheckOwnership (PlayerID owner) |
bool | CheckTileOwnership (TileIndex tile) |
static void | GenerateCompanyName (Player *p) |
static byte | GeneratePlayerColor () |
static void | GeneratePresidentName (Player *p) |
static Player * | AllocatePlayer () |
void | ResetPlayerLivery (Player *p) |
Reset the livery schemes to the player's primary colour. | |
Player * | DoStartupNewPlayer (bool is_ai) |
Create a new player and sets all player variables default values. | |
void | StartupPlayers () |
static void | MaybeStartNewPlayer () |
void | InitializePlayers () |
void | OnTick_Players () |
void | ShowPlayerFinances (PlayerID player) |
void | PlayersYearlyLoop () |
static void | DeletePlayerStuff (PlayerID pi) |
CommandCost | CmdSetAutoReplace (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Change engine renewal parameters. | |
CommandCost | CmdPlayerCtrl (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Control the players: add, delete, etc. | |
StringID | EndGameGetPerformanceTitleFromValue (uint value) |
static bool | CheatHasBeenUsed () |
Return true if any cheat has been used, false otherwise. | |
int8 | SaveHighScoreValue (const Player *p) |
Save the highscore for the player. | |
static int CDECL | HighScoreSorter (const void *a, const void *b) |
Sort all players given their performance. | |
int8 | SaveHighScoreValueNetwork () |
void | SaveToHighScore () |
Save HighScore table to file. | |
void | LoadFromHighScore () |
Initialize the highscore table to 0 and if any file exists, load in values. | |
static void | SaveLoad_PLYR (Player *p) |
static void | Save_PLYR () |
static void | Load_PLYR () |
Variables | |
Player | _players [MAX_PLAYERS] |
PlayerByte | _local_player |
PlayerByte | _current_player |
byte | _player_colors [MAX_PLAYERS] |
PlayerFace | _player_face |
for player face storage in openttd.cfg | |
HighScore | _highscore_table [5][5] |
static const byte | _color_sort [16] = {2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 1, 1, 1} |
static const byte | _color_similar_1 [16] = {8, 6, 255, 12, 255, 0, 1, 1, 0, 13, 11, 10, 3, 9, 15, 14} |
static const byte | _color_similar_2 [16] = {5, 7, 255, 255, 255, 8, 7, 6, 5, 12, 255, 255, 9, 255, 255, 255} |
static const StringID | _endgame_perf_titles [] |
static const SaveLoad | _player_desc [] |
static const SaveLoad | _player_economy_desc [] |
static const SaveLoad | _player_livery_desc [] |
const ChunkHandler | _player_chunk_handlers [] |
Definition in file players.cpp.
CommandCost CmdPlayerCtrl | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Control the players: add, delete, etc.
tile | unused | |
flags | operation to perform | |
p1 | various functionality
| |
p2 | various functionality, dictated by p1
|
Definition at line 788 of file players.cpp.
References _cmd_text, _networking, _patches_newgame, AddNewsItem(), CMD_CHANGE_PRESIDENT_NAME, CMD_ERROR, CMD_SET_AUTOREPLACE, DC_EXEC, DeletePlayerWindows(), DNC_BANKRUPCY, DoStartupNewPlayer(), GB(), MarkWholeScreenDirty(), NB_BBANKRUPT, NEWS_FLAGS, NM_CALLBACK, NT_COMPANY_INFO, OWNER_NONE, PLAYER_SPECTATOR, and SetLocalPlayer().
CommandCost CmdSetAutoReplace | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Change engine renewal parameters.
tile | unused | |
flags | operation to perform | |
p1 | bits 0-3 command
| |
p2 | value to set if p1 = 0, then:
|
Definition at line 655 of file players.cpp.
References AddEngineReplacementForPlayer(), AIR_CTOL, Clamp(), ClampU(), CMD_ERROR, DC_EXEC, GB(), HasBit(), InvalidateAutoreplaceWindow(), IsAllGroupID(), and RemoveEngineReplacementForPlayer().
PlayerFace ConvertFromOldPlayerFace | ( | uint32 | face | ) |
Converts an old player face format to the new player face format.
Meaning of the bits in the old face (some bits are used in several times):
face | the face in the old format |
Definition at line 109 of file players.cpp.
References ClampU(), ETHNICITY_BLACK, GB(), GE_WF, GE_WM, GENDER_FEMALE, HasBit(), max(), ScalePlayerFaceValue(), SetBit(), and SetPlayerFaceBits().
Player* DoStartupNewPlayer | ( | bool | is_ai | ) |
Create a new player and sets all player variables default values.
is_ai | is a ai player? |
Definition at line 484 of file players.cpp.
References _networking, _patches_newgame, GetPlayerRailtypes(), PLAYER_SPECTATOR, RandomPlayerFaceBits(), and ResetPlayerLivery().
Referenced by CmdPlayerCtrl().
bool IsValidPlayerFace | ( | PlayerFace | pf | ) |
Checks whether a player's face is a valid encoding.
Unused bits are not enforced to be 0.
pf | the fact to check |
Definition at line 165 of file players.cpp.
References ArePlayerFaceBitsValid(), GE_WM, GENDER_FEMALE, GetPlayerFaceBits(), and HasBit().
Referenced by CmdSetPlayerFace().
void ResetPlayerLivery | ( | Player * | p | ) |
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.
p | Player to reset. |
Definition at line 469 of file players.cpp.
Referenced by DoStartupNewPlayer().
void SetLocalPlayer | ( | PlayerID | new_player | ) |
Sets the local player and updates the patch settings that are set on a per-company (player) basis to reflect the core's state in the GUI.
new_player | the new player |
Definition at line 55 of file players.cpp.
References OWNER_NONE, and PLAYER_SPECTATOR.
Referenced by _GenerateWorld(), ClickChangePlayerCheat(), CmdPlayerCtrl(), GenerateWorld(), and StartScenario().
const StringID _endgame_perf_titles[] [static] |
Initial value:
{ STR_0213_BUSINESSMAN, STR_0213_BUSINESSMAN, STR_0213_BUSINESSMAN, STR_0213_BUSINESSMAN, STR_0213_BUSINESSMAN, STR_0214_ENTREPRENEUR, STR_0214_ENTREPRENEUR, STR_0215_INDUSTRIALIST, STR_0215_INDUSTRIALIST, STR_0216_CAPITALIST, STR_0216_CAPITALIST, STR_0217_MAGNATE, STR_0217_MAGNATE, STR_0218_MOGUL, STR_0218_MOGUL, STR_0219_TYCOON_OF_THE_CENTURY }
Definition at line 940 of file players.cpp.
const ChunkHandler _player_chunk_handlers[] |
Initial value:
{
{ 'PLYR', Save_PLYR, Load_PLYR, CH_ARRAY | CH_LAST},
}
const SaveLoad _player_economy_desc[] [static] |
Initial value:
{ SLE_CONDVAR(PlayerEconomyEntry, income, SLE_FILE_I32 | SLE_VAR_I64, 0, 1), SLE_CONDVAR(PlayerEconomyEntry, income, SLE_INT64, 2, SL_MAX_VERSION), SLE_CONDVAR(PlayerEconomyEntry, expenses, SLE_FILE_I32 | SLE_VAR_I64, 0, 1), SLE_CONDVAR(PlayerEconomyEntry, expenses, SLE_INT64, 2, SL_MAX_VERSION), SLE_CONDVAR(PlayerEconomyEntry, company_value, SLE_FILE_I32 | SLE_VAR_I64, 0, 1), SLE_CONDVAR(PlayerEconomyEntry, company_value, SLE_INT64, 2, SL_MAX_VERSION), SLE_VAR(PlayerEconomyEntry, delivered_cargo, SLE_INT32), SLE_VAR(PlayerEconomyEntry, performance_history, SLE_INT32), }
Definition at line 1168 of file players.cpp.
const SaveLoad _player_livery_desc[] [static] |
Initial value:
{ SLE_CONDVAR(Livery, in_use, SLE_BOOL, 34, SL_MAX_VERSION), SLE_CONDVAR(Livery, colour1, SLE_UINT8, 34, SL_MAX_VERSION), SLE_CONDVAR(Livery, colour2, SLE_UINT8, 34, SL_MAX_VERSION), }
Definition at line 1183 of file players.cpp.