mirror of https://github.com/OpenTTD/OpenTTD
(svn r21939) -Fix (r16357): the check for valid depot wasn't strict enough
parent
0ebc548a89
commit
b15719bbd2
|
@ -28,6 +28,11 @@ Depot::~Depot()
|
||||||
{
|
{
|
||||||
if (CleaningPool()) return;
|
if (CleaningPool()) return;
|
||||||
|
|
||||||
|
if (!IsDepotTile(this->xy) || GetDepotIndex(this->xy) != this->index) {
|
||||||
|
/* It can happen there is no depot here anymore (TTO/TTD savegames) */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear the order backup. */
|
/* Clear the order backup. */
|
||||||
OrderBackup::Reset(this->xy, false);
|
OrderBackup::Reset(this->xy, false);
|
||||||
|
|
||||||
|
@ -40,7 +45,7 @@ Depot::~Depot()
|
||||||
/* Delete the depot list */
|
/* Delete the depot list */
|
||||||
VehicleType vt;
|
VehicleType vt;
|
||||||
switch (GetTileType(this->xy)) {
|
switch (GetTileType(this->xy)) {
|
||||||
default: return; // It can happen there is no depot here anymore (TTO/TTD savegames)
|
default: NOT_REACHED();
|
||||||
case MP_RAILWAY: vt = VEH_TRAIN; break;
|
case MP_RAILWAY: vt = VEH_TRAIN; break;
|
||||||
case MP_ROAD: vt = VEH_ROAD; break;
|
case MP_ROAD: vt = VEH_ROAD; break;
|
||||||
case MP_WATER: vt = VEH_SHIP; break;
|
case MP_WATER: vt = VEH_SHIP; break;
|
||||||
|
|
|
@ -108,7 +108,7 @@ static void FixTTDDepots()
|
||||||
{
|
{
|
||||||
const Depot *d;
|
const Depot *d;
|
||||||
FOR_ALL_DEPOTS_FROM(d, 252) {
|
FOR_ALL_DEPOTS_FROM(d, 252) {
|
||||||
if (!IsRoadDepotTile(d->xy) && !IsRailDepotTile(d->xy) && !IsShipDepotTile(d->xy) && !IsHangarTile(d->xy)) {
|
if (!IsDepotTile(d->xy) || GetDepotIndex(d->xy) != d->index) {
|
||||||
/** Workaround for SVXConverter bug, depots 252-255 could be invalid */
|
/** Workaround for SVXConverter bug, depots 252-255 could be invalid */
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
@ -670,7 +670,10 @@ static bool LoadOldDepot(LoadgameState *ls, int num)
|
||||||
if (!LoadChunk(ls, d, depot_chunk)) return false;
|
if (!LoadChunk(ls, d, depot_chunk)) return false;
|
||||||
|
|
||||||
if (d->xy != 0) {
|
if (d->xy != 0) {
|
||||||
d->town = Town::Get(RemapTownIndex(_old_town_index));
|
/* In some cases, there could be depots referencing invalid town. */
|
||||||
|
Town *t = Town::GetIfValid(RemapTownIndex(_old_town_index));
|
||||||
|
if (t == NULL) t = Town::GetRandom();
|
||||||
|
d->town = t;
|
||||||
} else {
|
} else {
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue