(svn r2384) - Fix: Check selling land and setting player colour. Also an extra map-bounds check for terraforming; inspired by the monkey (and Tron :) )

This commit is contained in:
Darkvater
2005-05-30 15:50:20 +00:00
parent 9c552d1631
commit 2d355e0826
2 changed files with 12 additions and 5 deletions

View File

@@ -238,6 +238,9 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
tile = TILE_FROM_XY(x,y); tile = TILE_FROM_XY(x,y);
/* Make an extra check for map-bounds cause we add tiles to the originating tile */
if (tile + TILE_XY(1,1) > MapSize()) return CMD_ERROR;
if (p1 & 1) { if (p1 & 1) {
if (!TerraformTileHeight(&ts, tile+TILE_XY(1,0), if (!TerraformTileHeight(&ts, tile+TILE_XY(1,0),
TileHeight(tile + TILE_XY(1, 0)) + direction)) TileHeight(tile + TILE_XY(1, 0)) + direction))
@@ -449,8 +452,9 @@ int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
tile = TILE_FROM_XY(x,y); tile = TILE_FROM_XY(x,y);
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) if (!IsTileType(tile, MP_UNMOVABLE) || _map5[tile] != 3) return CMD_ERROR;
return CMD_ERROR; if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
if (!EnsureNoVehicle(tile)) return CMD_ERROR; if (!EnsureNoVehicle(tile)) return CMD_ERROR;

View File

@@ -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) int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{ {
Player *p, *pp; Player *p, *pp;
byte colour = (byte)p2;
if (p2 >= 16) return CMD_ERROR; // max 16 colours
p = GetPlayer(_current_player); p = GetPlayer(_current_player);
/* Ensure no two companies have the same colour */ /* Ensure no two companies have the same colour */
FOR_ALL_PLAYERS(pp) { 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; return CMD_ERROR;
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
_player_colors[_current_player] = (byte)p2; _player_colors[_current_player] = colour;
p->player_color = (byte)p2; p->player_color = colour;
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
return 0; return 0;