mirror of https://github.com/OpenTTD/OpenTTD
(svn r20708) -Fix [FS#4101]: upon company bankruptcy some objects weren't removed properly
parent
b610b1af61
commit
dd2c38ea82
|
@ -331,6 +331,17 @@ static Foundation GetFoundation_Object(TileIndex tile, Slope tileh)
|
||||||
return IsOwnedLand(tile) ? FOUNDATION_NONE : FlatteningFoundation(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)
|
static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
ObjectType type = GetObjectType(tile);
|
ObjectType type = GetObjectType(tile);
|
||||||
|
@ -391,11 +402,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) ReallyClearObjectTile(o);
|
||||||
Object::DecTypeCount(type);
|
|
||||||
TILE_AREA_LOOP(tile_cur, ta) MakeWaterKeepingClass(tile_cur, GetTileOwner(tile_cur));
|
|
||||||
delete o;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
@ -602,12 +609,12 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow
|
||||||
SetBit(t->statues, new_owner);
|
SetBit(t->statues, new_owner);
|
||||||
SetTileOwner(tile, new_owner);
|
SetTileOwner(tile, new_owner);
|
||||||
} else {
|
} else {
|
||||||
DoClearSquare(tile);
|
ReallyClearObjectTile(Object::GetByTile(tile));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
||||||
} else {
|
} else {
|
||||||
DoClearSquare(tile);
|
ReallyClearObjectTile(Object::GetByTile(tile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,14 @@ static void Ptrs_OBJS()
|
||||||
Object *o;
|
Object *o;
|
||||||
FOR_ALL_OBJECTS(o) {
|
FOR_ALL_OBJECTS(o) {
|
||||||
SlObject(o, _object_desc);
|
SlObject(o, _object_desc);
|
||||||
|
if (CheckSavegameVersion(148) && !IsTileType(o->location.tile, MP_OBJECT)) {
|
||||||
|
/* Due to a small bug stale objects could remain. */
|
||||||
|
delete o;
|
||||||
|
} else {
|
||||||
Object::IncTypeCount(GetObjectType(o->location.tile));
|
Object::IncTypeCount(GetObjectType(o->location.tile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Save_OBID()
|
static void Save_OBID()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue