summaryrefslogtreecommitdiff
path: root/player.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-05-06 06:56:30 +0000
committertron <tron@openttd.org>2005-05-06 06:56:30 +0000
commitd17476b058fb877484159bec0b725d1be5a6d68f (patch)
treeec6a2e5ec15ed8e58408a2c562f10913bb6382e8 /player.h
parent203a84dd0b4f1fd7397052d3a645731eaeb5ebd7 (diff)
downloadopenttd-d17476b058fb877484159bec0b725d1be5a6d68f.tar.xz
(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
Diffstat (limited to 'player.h')
-rw-r--r--player.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/player.h b/player.h
index 2fc8fd89b..020e6617f 100644
--- a/player.h
+++ b/player.h
@@ -192,12 +192,18 @@ int64 CalculateCompanyValue(Player *p);
void InvalidatePlayerWindows(Player *p);
void AiDoGameLoop(Player *p);
void UpdatePlayerMoney32(Player *p);
-#define DEREF_PLAYER(i) (&_players[i])
#define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++)
#define MAX_PLAYERS 8
VARDEF Player _players[MAX_PLAYERS];
+#define DEREF_PLAYER(i) (GetPlayer(i))
+static inline Player* GetPlayer(uint i)
+{
+ assert(i < lengthof(_players));
+ return &_players[i];
+}
+
#define IS_HUMAN_PLAYER(p) (!DEREF_PLAYER((byte)(p))->is_ai)
#define IS_INTERACTIVE_PLAYER(p) (((byte)p) == _local_player)