|
@@ -773,29 +773,36 @@ bool AfterLoadGame()
|
|
|
|
|
|
/* Set up station spread */
|
|
|
bst->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
|
|
|
|
|
|
/* Waypoints don't have road stops/oil rigs in the old format */
|
|
|
if (!Station::IsExpected(bst)) break;
|
|
|
Station *st = Station::From(bst);
|
|
|
|
|
|
switch (GetStationType(t)) {
|
|
|
case STATION_TRUCK:
|
|
|
case STATION_BUS:
|
|
|
if (IsSavegameVersionBefore(6)) {
|
|
|
/* Before version 5 you could not have more than 250 stations.
|
|
|
* Version 6 adds large maps, so you could only place 253*253
|
|
|
* road stops on a map (no freeform edges) = 64009. So, yes
|
|
|
* someone could in theory create such a full map to trigger
|
|
|
* this assertion, it's safe to assume that's only something
|
|
|
* theoretical and does not happen in normal games. */
|
|
|
assert(RoadStop::CanAllocateItem());
|
|
|
|
|
|
/* From this version on there can be multiple road stops of the
|
|
|
* same type per station. Convert the existing stops to the new
|
|
|
* internal data structure. */
|
|
|
RoadStop *rs = new RoadStop(t);
|
|
|
if (rs == NULL) error("Too many road stops in savegame");
|
|
|
|
|
|
RoadStop **head =
|
|
|
IsTruckStop(t) ? &st->truck_stops : &st->bus_stops;
|
|
|
*head = rs;
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case STATION_OILRIG: {
|
|
|
/* Very old savegames sometimes have phantom oil rigs, i.e.
|
|
|
* an oil rig which got shut down, but not completly removed from
|
|
|
* the map
|
|
|
*/
|
|
@@ -1919,24 +1926,30 @@ bool AfterLoadGame()
|
|
|
} else {
|
|
|
uint offset = _m[t].m3;
|
|
|
|
|
|
/* Also move the animation state. */
|
|
|
_m[t].m3 = GB(_m[t].m6, 2, 4);
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
|
|
|
|
|
if (offset == 0) {
|
|
|
/* No offset, so make the object. */
|
|
|
ObjectType type = GetObjectType(t);
|
|
|
int size = type == OBJECT_HQ ? 2 : 1;
|
|
|
|
|
|
if (!Object::CanAllocateItem()) {
|
|
|
/* Nice... you managed to place 64k lighthouses and
|
|
|
* antennae on the map... boohoo. */
|
|
|
SlError(STR_ERROR_TOO_MANY_OBJECTS);
|
|
|
}
|
|
|
|
|
|
Object *o = new Object();
|
|
|
o->location.tile = t;
|
|
|
o->location.w = size;
|
|
|
o->location.h = size;
|
|
|
o->build_date = _date;
|
|
|
o->town = type == OBJECT_STATUE ? Town::Get(_m[t].m2) : CalcClosestTownFromTile(t, UINT_MAX);
|
|
|
_m[t].m2 = o->index;
|
|
|
Object::IncTypeCount(type);
|
|
|
} else {
|
|
|
/* We're at an offset, so get the ID from our "root". */
|
|
|
TileIndex northern_tile = t - TileXY(GB(offset, 0, 4), GB(offset, 4, 4));
|
|
|
assert(IsTileType(northern_tile, MP_OBJECT));
|
|
@@ -2015,24 +2028,28 @@ bool AfterLoadGame()
|
|
|
}
|
|
|
|
|
|
/* We didn't store cargo payment yet, so make them for vehicles that are
|
|
|
* currently at a station and loading/unloading. If they don't get any
|
|
|
* payment anymore they just removed in the next load/unload cycle.
|
|
|
* However, some 0.7 versions might have cargo payment. For those we just
|
|
|
* add cargopayment for the vehicles that don't have it.
|
|
|
*/
|
|
|
Station *st;
|
|
|
FOR_ALL_STATIONS(st) {
|
|
|
std::list<Vehicle *>::iterator iter;
|
|
|
for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
|
|
|
/* There are always as many CargoPayments as Vehicles. We need to make the
|
|
|
* assert() in Pool::GetNew() happy by calling CanAllocateItem(). */
|
|
|
assert_compile(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
|
|
|
assert(CargoPayment::CanAllocateItem());
|
|
|
Vehicle *v = *iter;
|
|
|
if (v->cargo_payment == NULL) v->cargo_payment = new CargoPayment(v);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (IsSavegameVersionBefore(122)) {
|
|
|
/* Animated tiles would sometimes not be actually animated or
|
|
|
* in case of old savegames duplicate. */
|
|
|
|
|
|
extern TileIndex *_animated_tile_list;
|
|
|
extern uint _animated_tile_count;
|