Codechange: Increase size of StationType field in map array

Move can station have wires bit to make room
This commit is contained in:
Jonathan G Rennison 2024-04-21 01:08:12 +01:00
parent e8249e9075
commit 7123dfddae
4 changed files with 17 additions and 8 deletions

View File

@ -990,9 +990,9 @@
</table>
</li>
<li>m6 bit 7: rail station / waypoint may have catenary pylons</li>
<li>m6 bit 6: rail station / waypoint may have catenary wires</li>
<li>m6 bits 5..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy, waypoint)</li>
<li>m6 bits 6..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy, waypoint)</li>
<li>m6 bit 2: pbs reservation state for railway stations/waypoints</li>
<li>m6 bit 1: rail station / waypoint may have catenary wires</li>
<li>m6 bit 0: rail station / waypoint is blocked</li>
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road (road stops)</li>

View File

@ -188,7 +188,7 @@ the array so you can quickly see what is used and what is not.
<td class="bits" rowspan=2><span class="used" title="Random bits">XXXX</span> <span class="free">OOOO</span></td>
<td class="bits" rowspan=2><span class="used" title="Custom station specifications ID">XXXX XXXX</span></td>
<td class="bits"><span class="used" title="Graphics index">XXXX XXXX</span></td>
<td class="bits" rowspan=2><span class="used" title="May have pylons">X</span><span class="used" title="May have wires">X</span><span class="used" title="Station type">XXX</span> <span class="used" title="Reserved track">X</span><span class="free">O</span><span class="used" title="Tile is blocked">X</span></td>
<td class="bits" rowspan=2><span class="used" title="May have pylons">X</span><span class="used" title="Station type">XXXX</span> <span class="used" title="Reserved track">X</span><span class="used" title="May have wires">X</span><span class="used" title="Tile is blocked">X</span></td>
<td class="bits" rowspan=2><span class="used" title="Animation frame">XXXX XXXX</span></td>
<td class="bits" rowspan=2><span class="free">OOOO OOOO OO</span><span class="used" title="Railway type">XX XXXX</span></td>
</tr>
@ -201,7 +201,7 @@ the array so you can quickly see what is used and what is not.
<td class="bits"><span class="used" title="Owner of tram">XXXX</span> <span class="free">OOOO</span></td>
<td class="bits"><span class="free">OO</span><span class="used" title="Roadtype for road stop">XX XXXX</span></td>
<td class="bits"><span class="usable" title="Graphics index">OOOO O</span><span class="used" title="Graphics index: 00 (exit towards NE), 01 (exit towards SE), 02 (exit towards SW), 03 (exit towards NW), 04 (drive through X), 05 (drive through Y)">XXX</span></td>
<td class="bits" rowspan=5><span class="free">OO</span><span class="used" title="Station type">XX X</span><span class="free">OOO</span></td>
<td class="bits" rowspan=5><span class="free">O</span><span class="used" title="Station type">XXX X</span><span class="free">OOO</span></td>
<td class="bits"><span class="free">OOO</span><span class="used" title="Owner of road">X XXXX</span></td>
<td class="bits"><span class="free">OOOO</span> <span class="used" title="Tram type">XXXX XX</span> <span class="used" title="Custom road stops specifications ID">XXXXXX</span></td>
</tr>

View File

@ -907,6 +907,15 @@ bool AfterLoadGame()
}
}
if (IsSavegameVersionBeforeOrAt(SLV_VEHICLE_ECONOMY_AGE)) {
/* Expansion of station type field in m6 */
for (auto t : Map::Iterate()) {
if (IsTileType(t, MP_STATION)) {
ClrBit(t.m6(), 6);
}
}
}
for (auto t : Map::Iterate()) {
switch (GetTileType(t)) {
case MP_STATION: {

View File

@ -44,7 +44,7 @@ static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4; ///< The offset for the
inline StationType GetStationType(Tile t)
{
assert(IsTileType(t, MP_STATION));
return (StationType)GB(t.m6(), 3, 3);
return (StationType)GB(t.m6(), 3, 4);
}
/**
@ -362,7 +362,7 @@ inline void SetStationTileBlocked(Tile t, bool b)
inline bool CanStationTileHaveWires(Tile t)
{
assert(HasStationRail(t));
return HasBit(t.m6(), 6);
return HasBit(t.m6(), 1);
}
/**
@ -374,7 +374,7 @@ inline bool CanStationTileHaveWires(Tile t)
inline void SetStationTileHaveWires(Tile t, bool b)
{
assert(HasStationRail(t));
SB(t.m6(), 6, 1, b ? 1 : 0);
SB(t.m6(), 1, 1, b ? 1 : 0);
}
/**
@ -632,7 +632,7 @@ inline void MakeStation(Tile t, Owner o, StationID sid, StationType st, uint8_t
t.m4() = 0;
t.m5() = section;
SB(t.m6(), 2, 1, 0);
SB(t.m6(), 3, 3, st);
SB(t.m6(), 3, 4, st);
t.m7() = 0;
t.m8() = 0;
}