(svn r9857) -Fix: loading of TTDP savegames with features that OTTD has.
authorrubidium
Wed, 16 May 2007 21:28:23 +0000
changeset 7127 8d8bb32f17f8
parent 7126 1e7994aa1767
child 7128 1f92a89c933e
(svn r9857) -Fix: loading of TTDP savegames with features that OTTD has.
src/oldloader.cpp
--- a/src/oldloader.cpp	Wed May 16 08:20:37 2007 +0000
+++ b/src/oldloader.cpp	Wed May 16 21:28:23 2007 +0000
@@ -329,6 +329,9 @@
 	FOR_ALL_VEHICLES(v) {
 		Vehicle *u;
 
+		/* We haven't used this bit for stations for ages */
+		if (v->type == VEH_ROAD) CLRBIT(v->u.road.state, RVS_IS_STOPPING);
+
 		FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
 			/* If a vehicle has the same orders, add the link to eachother
 			 * in both vehicles */
@@ -621,12 +624,7 @@
 };
 static bool LoadOldStation(LoadgameState *ls, int num)
 {
-	Station *st;
-
-	if (!AddBlockIfNeeded(&_Station_pool, num))
-		error("Stations: failed loading savegame: too many stations");
-
-	st = GetStation(num);
+	Station *st = new (num) Station();
 	_current_station_id = num;
 
 	if (!LoadChunk(ls, st, station_chunk))
@@ -1554,6 +1552,19 @@
 
 	for (i = 0; i < OLD_MAP_SIZE; i ++) {
 		switch (GetTileType(i)) {
+			case MP_STATION:
+				_m[i].m4 = 0; // We do not understand this TTDP station mapping (yet)
+				switch (_m[i].m5) {
+					/* We have drive through stops at a totally different place */
+					case 0x53: case 0x54: _m[i].m5 += GFX_BUS_BASE_EXT   - 0x53; break;
+					case 0x57: case 0x58: _m[i].m5 += GFX_TRUCK_BASE_EXT - 0x57; break;
+					case 0x55: case 0x56: // Bus tram stop
+					case 0x59: case 0x5A: // Truck tram stop
+						DEBUG(oldloader, 0, "Loading failed - we don't support trams (yet)");
+						return false;
+				}
+				break;
+
 			case MP_RAILWAY:
 				/* We save presignals different from TTDPatch, convert them */
 				if (GetRailTileType(i) == RAIL_TILE_SIGNALS) {