summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2007-01-31 06:25:46 +0000
committertron <tron@openttd.org>2007-01-31 06:25:46 +0000
commitfe1691acce220f6d55a7bcad077020cfbec4bfb5 (patch)
tree0bec7750e40db1990ca2913e337fdb46579835f2
parent6e20c73c336b057e3eb95baf9cb7c3504aec2597 (diff)
downloadopenttd-fe1691acce220f6d55a7bcad077020cfbec4bfb5.tar.xz
(svn r8477) -Fix
-Codechange: Remove the unnecessary attributes Station::{bus,lorry}_tile_obsolete by replacing them with a scan of the map for existing road stops when loading old savegames
-rw-r--r--src/oldloader.cpp7
-rw-r--r--src/openttd.cpp16
-rw-r--r--src/station.h4
-rw-r--r--src/station_cmd.cpp20
4 files changed, 18 insertions, 29 deletions
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 0c9bf6d3b..2c9d045f2 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -312,10 +312,6 @@ static void FixOldStations(void)
if (st->train_tile != 0 && GetRailStationAxis(st->train_tile) != AXIS_X) {
Swap(st->trainst_w, st->trainst_h);
}
-
- /* Check if there is a bus or truck station, and convert to new format */
- if (st->bus_tile_obsolete != 0) st->bus_stops = new RoadStop(st->bus_tile_obsolete);
- if (st->lorry_tile_obsolete != 0) st->truck_stops = new RoadStop(st->lorry_tile_obsolete);
}
}
@@ -578,8 +574,7 @@ static const OldChunks station_chunk[] = {
OCL_SVAR( OC_TILE, Station, xy ),
OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
- OCL_SVAR( OC_TILE, Station, bus_tile_obsolete ),
- OCL_SVAR( OC_TILE, Station, lorry_tile_obsolete ),
+ OCL_NULL( 4 ), // bus/lorry tile
OCL_SVAR( OC_TILE, Station, train_tile ),
OCL_SVAR( OC_TILE, Station, airport_tile ),
OCL_SVAR( OC_TILE, Station, dock_tile ),
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 1f0b6af62..cba18f730 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1282,6 +1282,22 @@ bool AfterLoadGame(void)
// In 5.1, Oilrigs have been moved (again)
if (CheckSavegameVersionOldStyle(5, 1)) UpdateOilRig();
+ /* 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.
+ */
+ if (CheckSavegameVersion(6)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (IsRoadStopTile(t)) {
+ RoadStop *rs = new RoadStop(t);
+ if (rs == NULL) error("Too many road stops in savegame");
+
+ Station *st = GetStationByTile(t);
+ RoadStop **head = IsTruckStop(t) ? &st->truck_stops : &st->bus_stops;
+ *head = rs;
+ }
+ }
+ }
+
/* In version 6.1 we put the town index in the map-array. To do this, we need
* to use m2 (16bit big), so we need to clean m2, and that is where this is
* all about ;) */
diff --git a/src/station.h b/src/station.h
index b4d9d9a88..226eddc0c 100644
--- a/src/station.h
+++ b/src/station.h
@@ -142,10 +142,6 @@ struct Station {
uint16 random_bits;
byte waiting_triggers;
- /* Stuff that is no longer used, but needed for conversion */
- TileIndex bus_tile_obsolete;
- TileIndex lorry_tile_obsolete;
-
StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions
static const int cDebugCtorLevel = 3;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index f59dabcc7..0c2580612 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2841,8 +2841,7 @@ static const SaveLoad _roadstop_desc[] = {
static const SaveLoad _station_desc[] = {
SLE_CONDVAR(Station, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Station, xy, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(Station, bus_tile_obsolete, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(Station, lorry_tile_obsolete, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
+ SLE_CONDNULL(4, 0, 5), // bus/lorry tile
SLE_CONDVAR(Station, train_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Station, train_tile, SLE_UINT32, 6, SL_MAX_VERSION),
SLE_CONDVAR(Station, airport_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
@@ -2972,23 +2971,6 @@ static void Load_STNS(void)
st->trainst_w = w;
st->trainst_h = h;
}
-
- /* In older versions, we had just 1 tile for a bus/lorry, now we have more..
- * convert, if needed */
- if (CheckSavegameVersion(6)) {
- if (st->bus_tile_obsolete != 0) {
- st->bus_stops = new RoadStop(st->bus_tile_obsolete);
- if (st->bus_stops == NULL)
- error("Station: too many busstations in savegame");
-
- }
- if (st->lorry_tile_obsolete != 0) {
- st->truck_stops = new RoadStop(st->lorry_tile_obsolete);
- if (st->truck_stops == NULL)
- error("Station: too many truckstations in savegame");
-
- }
- }
}
/* This is to ensure all pointers are within the limits of _stations_size */