1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2025-12-23 13:12:40 +01:00

Codefix: Clear m6 more thoroughly when making tiles.

m6 bits 6-7 were previously used to be for bridge above state, but should now be cleared.
This commit is contained in:
Peter Nelson
2025-10-25 17:49:10 +01:00
committed by Peter Nelson
parent 66b6d71e32
commit 00cdf1bc56
10 changed files with 17 additions and 14 deletions

View File

@@ -135,6 +135,7 @@ inline void MakeBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection
t.m4() = 0;
t.m5() = 1 << 7 | tt << 2 | d;
SB(t.m6(), 2, 4, bridgetype);
SB(t.m6(), 6, 2, 0);
t.m7() = 0;
t.m8() = 0;
}

View File

@@ -274,7 +274,7 @@ inline void MakeField(Tile t, uint field_type, IndustryID industry)
t.m3() = field_type;
t.m4() = 0 << 5 | 0 << 2;
SetClearGroundDensity(t, CLEAR_FIELDS, 3);
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
t.m8() = 0;
}

View File

@@ -285,6 +285,7 @@ inline void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8_t rand
SetIndustryGfx(t, gfx); // m5, part of m6
SetIndustryRandomTriggers(t, {}); // rest of m6
SetWaterClass(t, wc);
SB(t.m6(), 6, 2, 0);
t.m7() = 0;
}

View File

@@ -80,7 +80,7 @@ inline void MakeObject(Tile t, Owner o, ObjectID index, WaterClass wc, uint8_t r
t.m3() = random;
t.m4() = 0;
t.m5() = index.base() >> 16;
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
}

View File

@@ -524,7 +524,7 @@ inline void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
t.m3() = 0;
t.m4() = 0;
t.m5() = RAIL_TILE_NORMAL << 6 | b;
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
t.m8() = r;
}
@@ -557,7 +557,7 @@ inline void MakeRailDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirectio
tile.m3() = 0;
tile.m4() = 0;
tile.m5() = RAIL_TILE_DEPOT << 6 | dir;
SB(tile.m6(), 2, 4, 0);
SB(tile.m6(), 2, 6, 0);
tile.m7() = 0;
tile.m8() = rail_type;
}

View File

@@ -619,7 +619,7 @@ inline void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tra
t.m2() = town.base();
t.m3() = (tram_rt != INVALID_ROADTYPE ? bits : 0);
t.m5() = (road_rt != INVALID_ROADTYPE ? bits : 0) | ROAD_TILE_NORMAL << 6;
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
SetRoadTypes(t, road_rt, tram_rt);
SetRoadOwner(t, RTT_TRAM, tram);
@@ -645,7 +645,7 @@ inline void MakeRoadCrossing(Tile t, Owner road, Owner tram, Owner rail, Axis ro
t.m3() = 0;
t.m4() = INVALID_ROADTYPE;
t.m5() = ROAD_TILE_CROSSING << 6 | roaddir;
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = road.base();
t.m8() = INVALID_ROADTYPE << 6 | rat;
SetRoadTypes(t, road_rt, tram_rt);
@@ -679,7 +679,7 @@ inline void MakeRoadDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirectio
tile.m3() = 0;
tile.m4() = INVALID_ROADTYPE;
tile.m5() = ROAD_TILE_DEPOT << 6 | dir;
SB(tile.m6(), 2, 4, 0);
SB(tile.m6(), 2, 6, 0);
tile.m7() = owner.base();
tile.m8() = INVALID_ROADTYPE << 6;
SetRoadType(tile, GetRoadTramType(rt), rt);

View File

@@ -726,6 +726,7 @@ inline void MakeStation(Tile t, Owner o, StationID sid, StationType st, uint8_t
t.m5() = section;
SB(t.m6(), 2, 1, 0);
SB(t.m6(), 3, 4, to_underlying(st));
SB(t.m6(), 7, 1, 0);
t.m7() = 0;
t.m8() = 0;
}

View File

@@ -250,7 +250,7 @@ inline void MakeTree(Tile t, TreeType type, uint count, TreeGrowthStage growth,
t.m3() = type;
t.m4() = 0 << 5 | 0 << 2;
t.m5() = count << 6 | static_cast<uint>(growth);
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
}

View File

@@ -55,7 +55,7 @@ inline void MakeRoadTunnel(Tile t, Owner o, DiagDirection d, RoadType road_rt, R
t.m3() = 0;
t.m4() = 0;
t.m5() = TRANSPORT_ROAD << 2 | d;
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
t.m8() = 0;
SetRoadOwner(t, RTT_ROAD, o);
@@ -78,7 +78,7 @@ inline void MakeRailTunnel(Tile t, Owner o, DiagDirection d, RailType r)
t.m3() = 0;
t.m4() = 0;
t.m5() = TRANSPORT_RAIL << 2 | d;
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
t.m8() = 0;
SetRailType(t, r);

View File

@@ -391,7 +391,7 @@ inline void MakeShore(Tile t)
t.m4() = 0;
t.m5() = 0;
SetWaterTileType(t, WATER_TILE_COAST);
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
}
@@ -413,7 +413,7 @@ inline void MakeWater(Tile t, Owner o, WaterClass wc, uint8_t random_bits)
t.m4() = random_bits;
t.m5() = 0;
SetWaterTileType(t, WATER_TILE_CLEAR);
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
}
@@ -468,7 +468,7 @@ inline void MakeShipDepot(Tile t, Owner o, DepotID did, DepotPart part, Axis a,
t.m4() = 0;
t.m5() = part << WBL_DEPOT_PART | a << WBL_DEPOT_AXIS;
SetWaterTileType(t, WATER_TILE_DEPOT);
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
}
@@ -492,7 +492,7 @@ inline void MakeLockTile(Tile t, Owner o, LockPart part, DiagDirection dir, Wate
t.m4() = 0;
t.m5() = part << WBL_LOCK_PART_BEGIN | dir << WBL_LOCK_ORIENT_BEGIN;
SetWaterTileType(t, WATER_TILE_LOCK);
SB(t.m6(), 2, 4, 0);
SB(t.m6(), 2, 6, 0);
t.m7() = 0;
}