summaryrefslogtreecommitdiff
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
parent65548c37a840ca48378180df1bf8857b087f7329 (diff)
downloadopenttd-5db883fbe9b8ef6171bfafc145a80932c3920504.tar.xz
Change: Move rail type bits from m3 to m8.
-rw-r--r--docs/landscape.html12
-rw-r--r--docs/landscape_grid.html22
-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
8 files changed, 64 insertions, 25 deletions
diff --git a/docs/landscape.html b/docs/landscape.html
index f60e859fc..55f560254 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -226,7 +226,7 @@
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the tile</li>
<li>m2: see signals</li>
<li>m3 bits 7..4: see signals</li>
- <li>m3 bits 3..0 = <a name="TrackType">track type</a>:
+ <li>m8 bits 3..0 = <a name="TrackType">track type</a>:
<table>
<tr>
<td><tt>0</tt>&nbsp; </td>
@@ -626,7 +626,8 @@
<li>m5 bit 6 set: level crossing
<ul>
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the railway track</li>
- <li>m3 bits 3..0: <a href="#TrackType">railway track type</a></li>
+ <li>m5 bit 5: set if crossing lights are on</li>
+ <li>m5 bit 4: pbs reservation state</li>
<li>m5 bit 0: direction
<table>
<tr>
@@ -639,9 +640,8 @@
</tr>
</table>
</li>
- <li>m5 bit 5: set if crossing lights are on</li>
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
- <li>m5 bit 4: pbs reservation state</li>
+ <li>m8 bits 3..0: <a href="#TrackType">railway track type</a></li>
</ul>
</li>
</ul>
@@ -860,7 +860,6 @@
<li>m2: index into the array of stations</li>
<li>m3 bits 7..4: persistent random data for railway stations/waypoints and airports)</li>
<li>m3 bits 7..4: <a href="#OwnershipInfo">owner</a> of tram tracks (road stop)</li>
- <li>m3 bits 3..0: <a href="#TrackType">track type</a> for railway stations/waypoints</li>
<li>m4: custom station id; 0 means standard graphics</li>
<li>m5: graphics index (range from 0..255 for each station type):
<table>
@@ -979,6 +978,7 @@
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road (road stops)</li>
<li>m7 bits 7..6: present road types (road stops)</li>
<li>m7: animation frame (railway stations/waypoints, airports)</li>
+ <li>m8 bits 3..0: <a href="#TrackType">track type</a> for railway stations/waypoints</li>
</ul>
</td>
</tr>
@@ -1444,7 +1444,6 @@
<ul>
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a></li>
<li>m3 bits 7..4: <a href="#OwnershipInfo">owner</a> of tram</li>
- <li>m3 bits 3..0: <a href="#TrackType">track type</a> for railway</li>
<li>m5 bit 4: pbs reservation state for railway</li>
<li>m5 bits 7 clear: tunnel entrance/exit</li>
<li>m5 bit 7 set: bridge ramp
@@ -1582,6 +1581,7 @@
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road</li>
<li>m7 bit 5 set = on snow or desert</li>
<li>m7 bits 7..6: present road types for road</li>
+ <li>m8 bits 3..0: <a href="#TrackType">track type</a> for railway</li>
</ul>
</td>
</tr>
diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html
index f5404a577..757a57417 100644
--- a/docs/landscape_grid.html
+++ b/docs/landscape_grid.html
@@ -102,12 +102,12 @@ the array so you can quickly see what is used and what is not.
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO</span> XXXX <span class="free">OOOO OOOO</span></td>
- <td class="bits"><span class="free">OOOO</span> XXXX</td>
+ <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO</span> XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
- <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
+ <td class="bits"><span class="free">OOOO OOOO OOOO</span> XXXX</td>
</tr>
<tr>
<td class="caption">rail with signals</td>
@@ -115,7 +115,7 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO</span> XXXX XXXX XXXX</td>
- <td class="bits">XXXX XXXX</td>
+ <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits">XXXX XXXX</td>
<td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
@@ -128,7 +128,7 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX XXXX XXXX XXXX</td>
- <td class="bits"><span class="free">OOOO</span> XXXX</td>
+ <td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO</span> XXXX</td>
<td class="bits">XX<span class="free">O</span>X <span class="free">OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
@@ -155,12 +155,12 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
- <td class="bits">XXXX XXXX</td>
+ <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits">-inherit-</td>
- <td class="bits">XXXX<span class="free"> OOO</span>X</td>
+ <td class="bits">XXXX <span class="free">OOO</span>X</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td>
<td class="bits">XXXX XXXX</td>
- <td class="bits">-inherit-</td>
+ <td class="bits"><span class="free">OOOO OOOO OOOO</span> XXXX</td>
</tr>
<tr>
<td class="caption">road depot</td>
@@ -210,12 +210,12 @@ the array so you can quickly see what is used and what is not.
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">O</span>XXX XXXX</td>
<td class="bits">XXXX XXXX XXXX XXXX</td>
- <td class="bits">XXXX XXXX</td>
+ <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OO</span>XX XX<span class="free">OO</span></td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
+ <td class="bits"><span class="free">OOOO OOOO OOOO</span> XXXX</td>
</tr>
<tr>
<td class="caption">rail waypoint</td>
@@ -356,12 +356,12 @@ the array so you can quickly see what is used and what is not.
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
- <td class="bits">XXXX XXXX</td>
+ <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">X<span class="free">OO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
+ <td class="bits"><span class="free">OOOO OOOO OOOO</span> XXXX</td>
</tr>
<tr>
<td>bridge ramp</td>
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 */