summaryrefslogtreecommitdiff
path: root/src/object_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-09-01 06:15:26 +0000
committerrubidium <rubidium@openttd.org>2010-09-01 06:15:26 +0000
commitdd2c38ea82df715422c1f62ee71dcd48b3c41cd7 (patch)
tree0743ba8837b67d217c137f0554179b6401bf1758 /src/object_cmd.cpp
parentb610b1af616f1c2ca4e16a7cbee27b46c6534eb8 (diff)
downloadopenttd-dd2c38ea82df715422c1f62ee71dcd48b3c41cd7.tar.xz
(svn r20708) -Fix [FS#4101]: upon company bankruptcy some objects weren't removed properly
Diffstat (limited to 'src/object_cmd.cpp')
-rw-r--r--src/object_cmd.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index bd9f6b184..c878fceb3 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -331,6 +331,17 @@ static Foundation GetFoundation_Object(TileIndex tile, Slope tileh)
return IsOwnedLand(tile) ? FOUNDATION_NONE : FlatteningFoundation(tileh);
}
+/**
+ * Perform the actual removal of the object from the map.
+ * @param o The object to really clear.
+ */
+static void ReallyClearObjectTile(Object *o)
+{
+ Object::DecTypeCount(GetObjectType(o->location.tile));
+ TILE_AREA_LOOP(tile_cur, o->location) MakeWaterKeepingClass(tile_cur, GetTileOwner(tile_cur));
+ delete o;
+}
+
static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
{
ObjectType type = GetObjectType(tile);
@@ -391,11 +402,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
break;
}
- if (flags & DC_EXEC) {
- Object::DecTypeCount(type);
- TILE_AREA_LOOP(tile_cur, ta) MakeWaterKeepingClass(tile_cur, GetTileOwner(tile_cur));
- delete o;
- }
+ if (flags & DC_EXEC) ReallyClearObjectTile(o);
return cost;
}
@@ -602,12 +609,12 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow
SetBit(t->statues, new_owner);
SetTileOwner(tile, new_owner);
} else {
- DoClearSquare(tile);
+ ReallyClearObjectTile(Object::GetByTile(tile));
}
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
} else {
- DoClearSquare(tile);
+ ReallyClearObjectTile(Object::GetByTile(tile));
}
}