summaryrefslogtreecommitdiff
path: root/unmovable_cmd.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2005-01-30 14:32:52 +0000
committerdarkvater <darkvater@openttd.org>2005-01-30 14:32:52 +0000
commit961ba55e85b44a8a099ca16cee8f1abf1487bc14 (patch)
tree4b7ff0c9b763afb29a838cbdbd6fe2e117503f63 /unmovable_cmd.c
parente8f4b7cf192a55cad0ed587411cea5e1efee22eb (diff)
downloadopenttd-961ba55e85b44a8a099ca16cee8f1abf1487bc14.tar.xz
(svn r1729) - Fix: [ 1112469 ] Clearing land for free by reallocating HQ
Diffstat (limited to 'unmovable_cmd.c')
-rw-r--r--unmovable_cmd.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 21f1c99bc..ce5b46798 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -314,21 +314,29 @@ extern int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint inva
*/
int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- uint tile = TILE_FROM_XY(x,y);
+ TileIndex tile = TILE_FROM_XY(x,y);
Player *p = DEREF_PLAYER(_current_player);
int score;
int32 cost = 0;
SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
- if (CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL) == CMD_ERROR)
+ cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
+
+ if (cost == CMD_ERROR)
return CMD_ERROR;
- if (p1)
- cost = DoCommand(
+ if (p1) {
+ int32 ret = DoCommand(
TileX(p->location_of_house) * 16, TileY(p->location_of_house) * 16,
p1 & 0xFF, 0, flags, CMD_DESTROY_COMPANY_HQ);
+ if (ret == CMD_ERROR)
+ return CMD_ERROR;
+
+ cost += ret;
+ }
+
if (flags & DC_EXEC) {
score = UpdateCompanyRatingAndValue(p, false);