--- a/misc_gui.c Sat Oct 14 22:22:48 2006 +0000
+++ b/misc_gui.c Sat Oct 14 22:31:18 2006 +0000
@@ -155,7 +155,7 @@
lid.tile = tile;
lid.town = ClosestTownFromTile(tile, _patches.dist_local_authority);
- p = GetPlayer(_local_player < MAX_PLAYERS ? _local_player : 0);
+ p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : 0);
old_money = p->money64;
p->money64 = p->player_money = 0x7fffffff;
@@ -1306,7 +1306,7 @@
{
/* Check if we are not a specatator who wants to generate a name..
Let's use the name of player #0 for now. */
- const Player *p = GetPlayer(_local_player < MAX_PLAYERS ? _local_player : 0);
+ const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : 0);
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
@@ -1636,9 +1636,9 @@
// p1 player to set to, p2 is -1 or +1 (down/up)
static int32 ClickChangePlayerCheat(int32 p1, int32 p2)
{
- while (p1 >= 0 && p1 < MAX_PLAYERS) {
+ while (IsValidPlayer((PlayerID)p1)) {
if (_players[p1].is_active) {
- _local_player = p1;
+ _local_player = (PlayerID)p1;
MarkWholeScreenDirty();
return _local_player;
}