summaryrefslogtreecommitdiff
path: root/misc_cmd.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-05-30 15:50:20 +0000
committerDarkvater <darkvater@openttd.org>2005-05-30 15:50:20 +0000
commit0cd53574ec659e283a0029f6cd037ffd66999e60 (patch)
tree2f98d00f629f6505e2bc649b087f6dafbdfd584b /misc_cmd.c
parent00cf2eae388135fcd9e7fd21cfa0f7b561fa1ddb (diff)
downloadopenttd-0cd53574ec659e283a0029f6cd037ffd66999e60.tar.xz
(svn r2384) - Fix: Check selling land and setting player colour. Also an extra map-bounds check for terraforming; inspired by the monkey (and Tron :) )
Diffstat (limited to 'misc_cmd.c')
-rw-r--r--misc_cmd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/misc_cmd.c b/misc_cmd.c
index eeae8e0c1..5a49a0c67 100644
--- a/misc_cmd.c
+++ b/misc_cmd.c
@@ -33,18 +33,21 @@ int32 CmdSetPlayerFace(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Player *p, *pp;
+ byte colour = (byte)p2;
+
+ if (p2 >= 16) return CMD_ERROR; // max 16 colours
p = GetPlayer(_current_player);
/* Ensure no two companies have the same colour */
FOR_ALL_PLAYERS(pp) {
- if (pp->is_active && pp != p && pp->player_color == (byte)p2)
+ if (pp->is_active && pp != p && pp->player_color == colour)
return CMD_ERROR;
}
if (flags & DC_EXEC) {
- _player_colors[_current_player] = (byte)p2;
- p->player_color = (byte)p2;
+ _player_colors[_current_player] = colour;
+ p->player_color = colour;
MarkWholeScreenDirty();
}
return 0;