summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2018-07-22 23:47:15 +0100
committerPeterN <peter@fuzzle.org>2018-07-26 13:27:40 +0100
commit5db883fbe9b8ef6171bfafc145a80932c3920504 (patch)
treede3ec131897c708f3fd960e9bc7cb1865d32fe7e /src
parent65548c37a840ca48378180df1bf8857b087f7329 (diff)
downloadopenttd-5db883fbe9b8ef6171bfafc145a80932c3920504.tar.xz
Change: Move rail type bits from m3 to m8.
Diffstat (limited to 'src')
-rw-r--r--src/bridge_map.h3
-rw-r--r--src/rail_map.h10
-rw-r--r--src/road_map.h3
-rw-r--r--src/saveload/afterload.cpp32
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/tunnel_map.h4
6 files changed, 47 insertions, 8 deletions
diff --git a/src/bridge_map.h b/src/bridge_map.h
index 74c6974db..75b20498d 100644
--- a/src/bridge_map.h
+++ b/src/bridge_map.h
@@ -131,11 +131,12 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, D
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
_m[t].m2 = 0;
- _m[t].m3 = rt;
+ _m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = 1 << 7 | tt << 2 | d;
SB(_me[t].m6, 2, 4, bridgetype);
_me[t].m7 = 0;
+ _me[t].m8 = rt;
}
/**
diff --git a/src/rail_map.h b/src/rail_map.h
index 2431a7920..bd580d32a 100644
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -115,7 +115,7 @@ static inline bool IsRailDepotTile(TileIndex t)
*/
static inline RailType GetRailType(TileIndex t)
{
- return (RailType)GB(_m[t].m3, 0, 4);
+ return (RailType)GB(_me[t].m8, 0, 4);
}
/**
@@ -125,7 +125,7 @@ static inline RailType GetRailType(TileIndex t)
*/
static inline void SetRailType(TileIndex t, RailType r)
{
- SB(_m[t].m3, 0, 4, r);
+ SB(_me[t].m8, 0, 4, r);
}
@@ -522,11 +522,12 @@ static inline void MakeRailNormal(TileIndex t, Owner o, TrackBits b, RailType r)
SetTileType(t, MP_RAILWAY);
SetTileOwner(t, o);
_m[t].m2 = 0;
- _m[t].m3 = r;
+ _m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = RAIL_TILE_NORMAL << 6 | b;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = 0;
+ _me[t].m8 = r;
}
@@ -535,11 +536,12 @@ static inline void MakeRailDepot(TileIndex t, Owner o, DepotID did, DiagDirectio
SetTileType(t, MP_RAILWAY);
SetTileOwner(t, o);
_m[t].m2 = did;
- _m[t].m3 = r;
+ _m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = RAIL_TILE_DEPOT << 6 | d;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = 0;
+ _me[t].m8 = r;
}
#endif /* RAIL_MAP_H */
diff --git a/src/road_map.h b/src/road_map.h
index 693730294..5b3e6b090 100644
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -579,11 +579,12 @@ static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner r
SetTileType(t, MP_ROAD);
SetTileOwner(t, rail);
_m[t].m2 = town;
- _m[t].m3 = rat;
+ _m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = ROAD_TILE_CROSSING << 6 | roaddir;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = rot << 6 | road;
+ _me[t].m8 = rat;
SetRoadOwner(t, ROADTYPE_TRAM, tram);
}
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 33c49fb61..cca9ad328 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1214,6 +1214,38 @@ bool AfterLoadGame()
}
}
+ /* Railtype moved from m3 to m8 in version 200. */
+ if (IsSavegameVersionBefore(200)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ switch (GetTileType(t)) {
+ case MP_RAILWAY:
+ SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
+ break;
+
+ case MP_ROAD:
+ if (IsLevelCrossing(t)) {
+ SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
+ }
+ break;
+
+ case MP_STATION:
+ if (HasStationRail(t)) {
+ SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
+ }
+ break;
+
+ case MP_TUNNELBRIDGE:
+ if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
+ SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
/* Elrails got added in rev 24 */
if (IsSavegameVersionBefore(24)) {
RailType min_rail = RAILTYPE_ELECTRIC;
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 692f73cf2..d02dfcbc6 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -267,8 +267,9 @@
* 197 27978 1.8.x
* 198
* 199
+ * 200
*/
-extern const uint16 SAVEGAME_VERSION = 199; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 200; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading
FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop.
diff --git a/src/tunnel_map.h b/src/tunnel_map.h
index e200a1275..d6f475d05 100644
--- a/src/tunnel_map.h
+++ b/src/tunnel_map.h
@@ -58,6 +58,7 @@ static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTyp
_m[t].m5 = TRANSPORT_ROAD << 2 | d;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = 0;
+ _me[t].m8 = 0;
SetRoadOwner(t, ROADTYPE_ROAD, o);
if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o);
SetRoadTypes(t, r);
@@ -75,11 +76,12 @@ static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailTyp
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
_m[t].m2 = 0;
- _m[t].m3 = r;
+ _m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = TRANSPORT_RAIL << 2 | d;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = 0;
+ _me[t].m8 = r;
}
#endif /* TUNNEL_MAP_H */