summaryrefslogtreecommitdiff
path: root/unmovable_cmd.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-05-11 16:29:33 +0000
committerDarkvater <Darkvater@openttd.org>2005-05-11 16:29:33 +0000
commit24e34f022b3174c76692daec8c7395b23911d6d6 (patch)
tree292156f9856a380559237ded947648a8f3a31430 /unmovable_cmd.c
parent5693f22f187fc3a909ff6ac8ee41a56f5c4957f6 (diff)
downloadopenttd-24e34f022b3174c76692daec8c7395b23911d6d6.tar.xz
(svn r2295) - Fix: you were still able to delete any tile if you were not careful with CmdDestroyCompanyHQ. Fixed this; thanks HackyKid.
Diffstat (limited to 'unmovable_cmd.c')
-rw-r--r--unmovable_cmd.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 2e934a9e6..3d4d33129 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -366,13 +366,14 @@ int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
*/
int32 CmdDestroyCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TILE_FROM_XY(x,y);
+ TileIndex tile;
Player *p;
SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
/* Find player that has HQ flooded, and reset their location_of_house */
if (_current_player == OWNER_WATER) {
+ tile = TILE_FROM_XY(x,y);
bool dodelete = false;
FOR_ALL_PLAYERS(p) {
if (p->location_of_house == tile) {
@@ -381,15 +382,17 @@ int32 CmdDestroyCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
}
if (!dodelete) return CMD_ERROR;
- } else /* Destruction was initiated by player */
+ } else /* Destruction was initiated by player */
p = DEREF_PLAYER(_current_player);
+ if (p->location_of_house == 0) return CMD_ERROR;
+
if (flags & DC_EXEC) {
+ DoClearSquare(p->location_of_house + TILE_XY(0,0));
+ DoClearSquare(p->location_of_house + TILE_XY(0,1));
+ DoClearSquare(p->location_of_house + TILE_XY(1,0));
+ DoClearSquare(p->location_of_house + TILE_XY(1,1));
p->location_of_house = 0; // reset HQ position
- DoClearSquare(tile + TILE_XY(0,0));
- DoClearSquare(tile + TILE_XY(0,1));
- DoClearSquare(tile + TILE_XY(1,0));
- DoClearSquare(tile + TILE_XY(1,1));
InvalidateWindow(WC_COMPANY, (int)p->index);
}