summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-02-27 23:36:28 +0000
committerrubidium <rubidium@openttd.org>2007-02-27 23:36:28 +0000
commitb5a997a446424d22ef6b0b2ad1e3e39644826534 (patch)
tree201d8919a041bd0eb12b24c8ba055c4d47310c76
parenta7d9cbc15107609324d7a21bd81295e29d23af1b (diff)
downloadopenttd-b5a997a446424d22ef6b0b2ad1e3e39644826534.tar.xz
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
-rw-r--r--docs/landscape.html26
-rw-r--r--docs/landscape_grid.html2
-rw-r--r--src/elrail.cpp6
-rw-r--r--src/openttd.cpp36
-rw-r--r--src/pathfind.cpp2
-rw-r--r--src/rail.cpp2
-rw-r--r--src/rail_cmd.cpp28
-rw-r--r--src/rail_map.h73
-rw-r--r--src/road_cmd.cpp12
-rw-r--r--src/road_map.h26
-rw-r--r--src/saveload.cpp2
-rw-r--r--src/train_cmd.cpp7
12 files changed, 108 insertions, 114 deletions
diff --git a/docs/landscape.html b/docs/landscape.html
index 518980a09..64862aef4 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -125,7 +125,7 @@
</ul>
</li>
<li>m2 bits 7..4: bit clear = signal shows red; same bits as in m3</li>
- <li>OpenTTD bits in m4:
+ <li>OpenTTD bits in m2:
<table>
<tr><td nowrap valign=top>bits 1..0: </td><td align=left>type of signal:</td></tr>
<tr><td nowrap valign=top><tt>00</tt>: </td><td align=left>normal signals</td></tr>
@@ -138,7 +138,7 @@
</ul>
</li>
<li>m1: <a href="#OwnershipInfo">owner</a> of the track</li>
- <li>m2 bits 0..3:
+ <li>m4 bits 0..3:
<table>
<tr><td nowrap valign=top><tt>0</tt>&nbsp; </td><td align=left>on bare land</td></tr>
<tr><td nowrap valign=top><tt>1</tt>&nbsp; </td><td align=left>on grass, no fences</td></tr>
@@ -165,7 +165,7 @@
</li>
</ul>
</li>
- <li>m5 bits 7 and 6 set: railway depot / checkpoints
+ <li>m5 bit 7 set: railway depot / checkpoints
<ul>
<li>m5 value C0..C3: railway depot
<table>
@@ -177,7 +177,7 @@
<tr><td><tt>03</tt>&nbsp; </td><td>NW</td></tr>
</table>
</li>
- <li>m5 value C4..C5: checkpoint
+ <li>m5 value 80..81: checkpoint
<table>
<tr><td colspan=2>bit 0</td></tr>
<tr><td>clear</td><td>in X direction</td></tr>
@@ -187,7 +187,7 @@
<li>m1: <a href="#OwnershipInfo">owner</a> of the depot / checkpoint</li>
<li>m2: For waypoints, index into the array of waypoints.</li>
<li>m3 bits 0..3 = <a href="#TrackType">track type</a></li>
- <li>m4 bits 0..3 = ground type, as per m2 bits 0..3 for railway tiles.</li>
+ <li>m4 bits 0..3 = ground type, as per m4 bits 0..3 for railway tiles.</li>
</ul>
</li>
</ul>
@@ -210,8 +210,8 @@
</li>
<li>m1: <a href="#OwnershipInfo">owner</a> of the road</li>
<li>m2: Index into the array of towns, 0 for non-town roads</li>
- <li>m4 bits 0..3: counter for the roadworks</li>
- <li>m4 bits 4..6:
+ <li>m3 bits 0..3: counter for the roadworks</li>
+ <li>m3 bits 4..6:
<table>
<tr><td><tt>0</tt>&nbsp; </td><td>on bare land</td></tr>
<tr><td><tt>1</tt>&nbsp; </td><td>on grass</td></tr>
@@ -222,7 +222,7 @@
<tr><td><tt>7</tt>&nbsp; </td><td>paved with road works</td></tr>
</table>
</li>
- <li>m4 bit 7 set = on snow or desert</li>
+ <li>m3 bit 7 set = on snow or desert</li>
</ul>
</li>
<li>m5 bit 4 set, bits 7..5 clear: level crossing
@@ -231,17 +231,17 @@
<li>m5 bit 2: set if crossing lights are on</li>
<li>m1: <a href="#OwnershipInfo">owner</a> of the railway track</li>
<li>m2: Index into the array of towns, 0 for non-town roads</li>
- <li>m3 bits 0..7: <a href="#OwnershipInfo">owner</a> of the road</li>
- <li>m4 bits 3..0: <a href="#TrackType">track type</a></li>
- <li>m4 bits 4..6: <tt>0</tt> - on bare land, <tt>1</tt> - on grass, <tt>2</tt> or higher - paved</li>
- <li>m4 bit 7 set = on snow or desert</li>
+ <li>m4 bits 0..7: <a href="#OwnershipInfo">owner</a> of the road</li>
+ <li>m3 bits 3..0: <a href="#TrackType">track type</a></li>
+ <li>m3 bits 4..6: <tt>0</tt> - on bare land, <tt>1</tt> - on grass, <tt>2</tt> or higher - paved</li>
+ <li>m3 bit 7 set = on snow or desert</li>
</ul>
</li>
<li>m5 bit 5 set: road depot
<ul>
<li>m5 bits 3..0 - direction: exit towards: <tt>0</tt> = NE, <tt>1</tt> = SE, <tt>2</tt> = SW, <tt>3</tt> = NW</li>
<li>m1: <a href="#OwnershipInfo">owner</a> of the depot</li>
- <li>m4 bit 7 set = on snow or desert (not displayed, but set internally)</li>
+ <li>m3 bit 7 set = on snow or desert (not displayed, but set internally)</li>
</ul>
</li>
</ul>
diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html
index 83d7e77fb..2d9196f3b 100644
--- a/docs/landscape_grid.html
+++ b/docs/landscape_grid.html
@@ -135,8 +135,8 @@ 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 OOOO OOOO OOOO</span></td>
- <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">X<span class="free">OOO OOOO</span></td>
+ <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td>
<td class="bits">XX<span class="free">OO OO</span>XX</td>
</tr>
diff --git a/src/elrail.cpp b/src/elrail.cpp
index b6cd15290..73f91a298 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -81,8 +81,8 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
switch (GetRailTileType(t)) {
case RAIL_TILE_NORMAL: case RAIL_TILE_SIGNALS:
return GetTrackBits(t);
- case RAIL_TILE_DEPOT_WAYPOINT:
- if (GetRailTileSubtype(t) == RAIL_SUBTYPE_WAYPOINT) return GetRailWaypointBits(t);
+ case RAIL_TILE_WAYPOINT:
+ return GetRailWaypointBits(t);
default:
return TRACK_BIT_NONE;
}
@@ -103,7 +103,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
case MP_STREET:
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return TRACK_BIT_NONE;
- if (GetRailTypeCrossing(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
+ if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
return GetCrossingRailBits(t);
case MP_STATION:
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 3a8b10df6..e34c30825 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1467,6 +1467,34 @@ bool AfterLoadGame(void)
}
}
+ if (CheckSavegameVersion(48)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ switch (GetTileType(t)) {
+ case MP_RAILWAY:
+ if (IsPlainRailTile(t)) {
+ /* Swap ground type and signal type for plain rail tiles, so the
+ * ground type uses the same bits as for depots and waypoints. */
+ uint tmp = GB(_m[t].m4, 0, 4);
+ SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4));
+ SB(_m[t].m2, 0, 4, tmp);
+ } else if (HASBIT(_m[t].m5, 2)) {
+ /* Split waypoint and depot rail type and remove the subtype. */
+ CLRBIT(_m[t].m5, 2);
+ CLRBIT(_m[t].m5, 6);
+ }
+ break;
+
+ case MP_STREET:
+ /* Swap m3 and m4, so the track type for rail crossings is the
+ * same as for normal rail. */
+ Swap(_m[t].m3, _m[t].m4);
+ break;
+
+ default: break;
+ }
+ }
+ }
+
/* Elrails got added in rev 24 */
if (CheckSavegameVersion(24)) {
Vehicle *v;
@@ -1490,7 +1518,7 @@ bool AfterLoadGame(void)
case MP_STREET:
if (IsLevelCrossing(t)) {
- SetRailTypeCrossing(t, UpdateRailType(GetRailTypeCrossing(t), min_rail));
+ SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
}
break;
@@ -1575,11 +1603,11 @@ bool AfterLoadGame(void)
case MP_RAILWAY:
if (HasSignals(t)) {
// convert PBS signals to combo-signals
- if (HASBIT(_m[t].m4, 2)) SetSignalType(t, SIGTYPE_COMBO);
+ if (HASBIT(_m[t].m2, 2)) SetSignalType(t, SIGTYPE_COMBO);
// move the signal variant back
- SetSignalVariant(t, HASBIT(_m[t].m4, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
- CLRBIT(_m[t].m4, 3);
+ SetSignalVariant(t, HASBIT(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
+ CLRBIT(_m[t].m2, 3);
}
// Clear PBS reservation on track
diff --git a/src/pathfind.cpp b/src/pathfind.cpp
index c5e88e541..431acd317 100644
--- a/src/pathfind.cpp
+++ b/src/pathfind.cpp
@@ -786,7 +786,7 @@ start_at:
// Check that the tile contains exactly one track
if (bits == 0 || KILL_FIRST_BIT(bits) != 0) break;
- if (!HASBIT(tpf->railtypes, IsTileType(tile, MP_STREET) ? GetRailTypeCrossing(tile) : GetRailType(tile))) {
+ if (!HASBIT(tpf->railtypes, GetRailType(tile))) {
bits = TRACK_BIT_NONE;
break;
}
diff --git a/src/rail.cpp b/src/rail.cpp
index dd2674d2d..08670e4fd 100644
--- a/src/rail.cpp
+++ b/src/rail.cpp
@@ -110,7 +110,7 @@ RailType GetTileRailType(TileIndex tile)
case MP_STREET:
/* rail/road crossing */
- if (IsLevelCrossing(tile)) return GetRailTypeCrossing(tile);
+ if (IsLevelCrossing(tile)) return GetRailType(tile);
break;
case MP_STATION:
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 549ef4062..b18fd8805 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -661,7 +661,7 @@ int32 CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
if (!HasSignals(tile)) {
// there are no signals at all on this tile yet
- _m[tile].m5 |= RAIL_TILE_SIGNALS; // change into signals
+ SetHasSignals(tile, true);
_m[tile].m2 |= 0xF0; // all signals are on
_m[tile].m3 &= ~0xF0; // no signals built by default
SetSignalType(tile, SIGTYPE_NORMAL);
@@ -824,7 +824,7 @@ int32 CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* removed last signal from tile? */
if (GB(_m[tile].m3, 4, 4) == 0) {
SB(_m[tile].m2, 4, 4, 0);
- SB(_m[tile].m5, 6, 2, RAIL_TILE_NORMAL >> 6); // XXX >> because the constant is meant for direct application, not use with SB
+ SetHasSignals(tile, false);
SetSignalVariant(tile, SIG_ELECTRIC); // remove any possible semaphores
}
@@ -1004,12 +1004,11 @@ static int32 ClearTile_Track(TileIndex tile, byte flags)
return cost;
}
- case RAIL_TILE_DEPOT_WAYPOINT:
- if (GetRailTileSubtype(tile) == RAIL_SUBTYPE_DEPOT) {
- return RemoveTrainDepot(tile, flags);
- } else {
- return RemoveTrainWaypoint(tile, flags, false);
- }
+ case RAIL_TILE_DEPOT:
+ return RemoveTrainDepot(tile, flags);
+
+ case RAIL_TILE_WAYPOINT:
+ return RemoveTrainWaypoint(tile, flags, false);
default:
return CMD_ERROR;
@@ -1284,7 +1283,7 @@ static void DrawTile_Track(TileInfo *ti)
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
- if (GetRailTileSubtype(ti->tile) == RAIL_SUBTYPE_DEPOT) {
+ if (IsRailDepot(ti->tile)) {
dts = &_depot_gfx_table[GetRailDepotDirection(ti->tile)];
relocation = rti->total_offset;
@@ -1877,7 +1876,7 @@ static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode)
}
return ret;
} else {
- if (GetRailTileSubtype(tile) == RAIL_SUBTYPE_DEPOT) {
+ if (IsRailDepot(tile)) {
return AxisToTrackBits(DiagDirToAxis(GetRailDepotDirection(tile))) * 0x101;
} else {
return GetRailWaypointBits(tile) * 0x101;
@@ -1914,10 +1913,13 @@ static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
break;
}
- case RAIL_TILE_DEPOT_WAYPOINT:
+ case RAIL_TILE_DEPOT:
+ td->str = STR_1023_RAILROAD_TRAIN_DEPOT;
+ break;
+
+ case RAIL_TILE_WAYPOINT:
default:
- td->str = (GetRailTileSubtype(tile) == RAIL_SUBTYPE_DEPOT) ?
- STR_1023_RAILROAD_TRAIN_DEPOT : STR_LANDINFO_WAYPOINT;
+ td->str = STR_LANDINFO_WAYPOINT;
break;
}
}
diff --git a/src/rail_map.h b/src/rail_map.h
index 6efc2824d..20df4e7be 100644
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -9,17 +9,16 @@
typedef enum RailTileType {
- RAIL_TILE_NORMAL = 0x0,
- RAIL_TILE_SIGNALS = 0x40,
- RAIL_TILE_UNUSED = 0x80, /* XXX: Maybe this could become waypoints? */
- RAIL_TILE_DEPOT_WAYPOINT = 0xC0, /* Is really depots and waypoints... */
- RAIL_TILE_TYPE_MASK = 0xC0
+ RAIL_TILE_NORMAL = 0,
+ RAIL_TILE_SIGNALS = 1,
+ RAIL_TILE_WAYPOINT = 2,
+ RAIL_TILE_DEPOT = 3,
} RailTileType;
static inline RailTileType GetRailTileType(TileIndex t)
{
assert(IsTileType(t, MP_RAILWAY));
- return (RailTileType)(_m[t].m5 & RAIL_TILE_TYPE_MASK);
+ return (RailTileType)GB(_m[t].m5, 6, 2);
}
/**
@@ -40,39 +39,25 @@ static inline bool HasSignals(TileIndex tile)
return GetRailTileType(tile) == RAIL_TILE_SIGNALS;
}
-
-/** These specify the subtype when the main rail type is
- * RAIL_TILE_DEPOT_WAYPOINT */
-typedef enum RailTileSubtypes {
- RAIL_SUBTYPE_DEPOT = 0x00,
- RAIL_SUBTYPE_WAYPOINT = 0x04,
- RAIL_SUBTYPE_MASK = 0x3C
-} RailTileSubtype;
-
/**
- * Returns the RailTileSubtype of a given rail tile with type
- * RAIL_TILE_DEPOT_WAYPOINT
+ * Add/remove the 'has signal' bit from the RailTileType
*/
-static inline RailTileSubtype GetRailTileSubtype(TileIndex tile)
+static inline void SetHasSignals(TileIndex tile, bool signals)
{
- assert(GetRailTileType(tile) == RAIL_TILE_DEPOT_WAYPOINT);
- return (RailTileSubtype)(_m[tile].m5 & RAIL_SUBTYPE_MASK);
+ assert(IsPlainRailTile(tile));
+ SB(_m[tile].m5, 6, 1, signals);
}
static inline bool IsRailDepot(TileIndex t)
{
- return
- GetRailTileType(t) == RAIL_TILE_DEPOT_WAYPOINT &&
- GetRailTileSubtype(t) == RAIL_SUBTYPE_DEPOT;
+ return GetRailTileType(t) == RAIL_TILE_DEPOT;
}
static inline bool IsRailWaypoint(TileIndex t)
{
- return
- GetRailTileType(t) == RAIL_TILE_DEPOT_WAYPOINT &&
- GetRailTileSubtype(t) == RAIL_SUBTYPE_WAYPOINT;
+ return GetRailTileType(t) == RAIL_TILE_WAYPOINT;
}
@@ -81,23 +66,11 @@ static inline RailType GetRailType(TileIndex t)
return (RailType)GB(_m[t].m3, 0, 4);
}
-// TODO remove this by moving to the same bits as GetRailType()
-static inline RailType GetRailTypeCrossing(TileIndex t)
-{
- return (RailType)GB(_m[t].m4, 0, 4);
-}
-
static inline void SetRailType(TileIndex t, RailType r)
{
SB(_m[t].m3, 0, 4, r);
}
-// TODO remove this by moving to the same bits as SetRailType()
-static inline void SetRailTypeCrossing(TileIndex t, RailType r)
-{
- SB(_m[t].m4, 0, 4, r);
-}
-
static inline TrackBits GetTrackBits(TileIndex tile)
{
@@ -151,13 +124,13 @@ typedef enum SignalType {
static inline SignalType GetSignalType(TileIndex t)
{
assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
- return (SignalType)GB(_m[t].m4, 0, 2);
+ return (SignalType)GB(_m[t].m2, 0, 2);
}
static inline void SetSignalType(TileIndex t, SignalType s)
{
assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
- SB(_m[t].m4, 0, 2, s);
+ SB(_m[t].m2, 0, 2, s);
}
static inline bool IsPresignalEntry(TileIndex t)
@@ -189,12 +162,12 @@ typedef enum SignalVariant {
static inline SignalVariant GetSignalVariant(TileIndex t)
{
- return (SignalVariant)GB(_m[t].m4, 2, 1);
+ return (SignalVariant)GB(_m[t].m2, 2, 1);
}
static inline void SetSignalVariant(TileIndex t, SignalVariant v)
{
- SB(_m[t].m4, 2, 1, v);
+ SB(_m[t].m2, 2, 1, v);
}
static inline bool IsSignalPresent(TileIndex t, byte signalbit)
@@ -283,18 +256,12 @@ typedef enum RailGroundType {
static inline void SetRailGroundType(TileIndex t, RailGroundType rgt)
{
- if (GetRailTileType(t) == RAIL_TILE_DEPOT_WAYPOINT) {
- SB(_m[t].m4, 0, 4, rgt);
- return;
- }
- SB(_m[t].m2, 0, 4, rgt);
+ SB(_m[t].m4, 0, 4, rgt);
}
static inline RailGroundType GetRailGroundType(TileIndex t)
{
- /* TODO Unify this */
- if (GetRailTileType(t) == RAIL_TILE_DEPOT_WAYPOINT) return (RailGroundType)GB(_m[t].m4, 0, 4);
- return (RailGroundType)GB(_m[t].m2, 0, 4);
+ return (RailGroundType)GB(_m[t].m4, 0, 4);
}
static inline bool IsSnowRailGround(TileIndex t)
@@ -310,7 +277,7 @@ static inline void MakeRailNormal(TileIndex t, Owner o, TrackBits b, RailType r)
_m[t].m2 = 0;
_m[t].m3 = r;
_m[t].m4 = 0;
- _m[t].m5 = RAIL_TILE_NORMAL | b;
+ _m[t].m5 = RAIL_TILE_NORMAL << 6 | b;
}
@@ -321,7 +288,7 @@ static inline void MakeRailDepot(TileIndex t, Owner o, DiagDirection d, RailType
_m[t].m2 = 0;
_m[t].m3 = r;
_m[t].m4 = 0;
- _m[t].m5 = RAIL_TILE_DEPOT_WAYPOINT | RAIL_SUBTYPE_DEPOT | d;
+ _m[t].m5 = RAIL_TILE_DEPOT << 6 | d;
}
@@ -332,7 +299,7 @@ static inline void MakeRailWaypoint(TileIndex t, Owner o, Axis a, RailType r, ui
_m[t].m2 = index;
_m[t].m3 = r;
_m[t].m4 = 0;
- _m[t].m5 = RAIL_TILE_DEPOT_WAYPOINT | RAIL_SUBTYPE_WAYPOINT | a;
+ _m[t].m5 = RAIL_TILE_WAYPOINT << 6 | a;
}
#endif /* RAIL_MAP_H */
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 6266428d5..3d9327950 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -162,7 +162,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
- MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailTypeCrossing(tile));
+ MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile));
MarkTileDirtyByTile(tile);
YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
}
@@ -374,13 +374,13 @@ int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
// not owned by me?
if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
- if (GetRailTypeCrossing(tile) == totype) return CMD_ERROR;
+ if (GetRailType(tile) == totype) return CMD_ERROR;
// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
- if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailTypeCrossing(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
+ if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
if (exec) {
- SetRailTypeCrossing(tile, totype);
+ SetRailType(tile, totype);
MarkTileDirtyByTile(tile);
YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile)));
}
@@ -717,7 +717,7 @@ static void DrawTile_Road(TileInfo *ti)
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
- image = GetRailTypeInfo(GetRailTypeCrossing(ti->tile))->base_sprites.crossing;
+ image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.crossing;
if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
if (IsCrossingBarred(ti->tile)) image += 2;
@@ -733,7 +733,7 @@ static void DrawTile_Road(TileInfo *ti)
}
DrawGroundSprite(image, pal);
- if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
+ if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
break;
}
diff --git a/src/road_map.h b/src/road_map.h
index 258c41e3b..59da6be0e 100644
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -65,13 +65,13 @@ static inline TrackBits GetCrossingRailBits(TileIndex tile)
static inline Owner GetCrossingRoadOwner(TileIndex t)
{
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
- return (Owner)_m[t].m3;
+ return (Owner)_m[t].m4;
}
static inline void SetCrossingRoadOwner(TileIndex t, Owner o)
{
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
- _m[t].m3 = o;
+ _m[t].m4 = o;
}
static inline void UnbarCrossing(TileIndex t)
@@ -95,13 +95,13 @@ static inline bool IsCrossingBarred(TileIndex t)
#define IsOnDesert IsOnSnow
static inline bool IsOnSnow(TileIndex t)
{
- return HASBIT(_m[t].m4, 7);
+ return HASBIT(_m[t].m3, 7);
}
#define ToggleDesert ToggleSnow
static inline void ToggleSnow(TileIndex t)
{
- TOGGLEBIT(_m[t].m4, 7);
+ TOGGLEBIT(_m[t].m3, 7);
}
@@ -117,12 +117,12 @@ typedef enum Roadside {
static inline Roadside GetRoadside(TileIndex tile)
{
- return (Roadside)GB(_m[tile].m4, 4, 3);
+ return (Roadside)GB(_m[tile].m3, 4, 3);
}
static inline void SetRoadside(TileIndex tile, Roadside s)
{
- SB(_m[tile].m4, 4, 3, s);
+ SB(_m[tile].m3, 4, 3, s);
}
static inline bool HasRoadWorks(TileIndex t)
@@ -132,9 +132,9 @@ static inline bool HasRoadWorks(TileIndex t)
static inline bool IncreaseRoadWorksCounter(TileIndex t)
{
- AB(_m[t].m4, 0, 4, 1);
+ AB(_m[t].m3, 0, 4, 1);
- return GB(_m[t].m4, 0, 4) == 15;
+ return GB(_m[t].m3, 0, 4) == 15;
}
static inline void StartRoadWorks(TileIndex t)
@@ -153,7 +153,7 @@ static inline void TerminateRoadWorks(TileIndex t)
assert(HasRoadWorks(t));
SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS));
/* Stop the counter */
- SB(_m[t].m4, 0, 4, 0);
+ SB(_m[t].m3, 0, 4, 0);
}
@@ -183,8 +183,8 @@ static inline void MakeRoadNormal(TileIndex t, Owner owner, RoadBits bits, TownI
SetTileType(t, MP_STREET);
SetTileOwner(t, owner);
_m[t].m2 = town;
- _m[t].m3 = 0;
- _m[t].m4 = 0 << 7 | 0 << 4 | 0;
+ _m[t].m3 = 0 << 7 | 0 << 4 | 0;
+ _m[t].m4 = 0;
_m[t].m5 = ROAD_TILE_NORMAL << 4 | bits;
}
@@ -194,8 +194,8 @@ static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner rail, Axis ro
SetTileType(t, MP_STREET);
SetTileOwner(t, rail);
_m[t].m2 = town;
- _m[t].m3 = road;
- _m[t].m4 = 0 << 7 | 0 << 4 | rt;
+ _m[t].m3 = 0 << 7 | 0 << 4 | rt;
+ _m[t].m4 = road;
_m[t].m5 = ROAD_TILE_CROSSING << 4 | roaddir << 3 | 0 << 2;
}
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 4922419e6..c0b4473e3 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -28,7 +28,7 @@
#include "variables.h"
#include <setjmp.h>
-extern const uint16 SAVEGAME_VERSION = 47;
+extern const uint16 SAVEGAME_VERSION = 48;
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index f9000fdbb..31f7b1700 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -67,7 +67,7 @@ void TrainPowerChanged(Vehicle* v)
/* Power is not added for articulated parts */
if (IsArticulatedPart(u)) continue;
- RailType railtype = (IsLevelCrossingTile(u->tile) ? GetRailTypeCrossing(u->tile) : GetRailType(u->tile));
+ RailType railtype = GetRailType(u->tile);
bool engine_has_power = HasPowerOnRail(u->u.rail.railtype, railtype);
bool wagon_has_power = HasPowerOnRail(v->u.rail.railtype, railtype);
@@ -2705,10 +2705,7 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
return
IsTileOwner(tile, v->owner) && (
!IsFrontEngine(v) ||
- HASBIT(
- v->u.rail.compatible_railtypes,
- IsTileType(tile, MP_STREET) ? GetRailTypeCrossing(tile) : GetRailType(tile)
- )
+ HASBIT(v->u.rail.compatible_railtypes, GetRailType(tile))
);
}