MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FixTTDMapArray

Function FixTTDMapArray

src/saveload/oldloader_sl.cpp:52–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52static void FixTTDMapArray()
53{
54 for (auto tile : Map::Iterate()) {
55 switch (GetTileType(tile)) {
56 case MP_STATION:
57 tile.m4() = 0; // We do not understand this TTDP station mapping (yet)
58 switch (tile.m5()) {
59 /* We have drive through stops at a totally different place */
60 case 0x53: case 0x54: tile.m5() += 170 - 0x53; break; // Bus drive through
61 case 0x57: case 0x58: tile.m5() += 168 - 0x57; break; // Truck drive through
62 case 0x55: case 0x56: tile.m5() += 170 - 0x55; break; // Bus tram stop
63 case 0x59: case 0x5A: tile.m5() += 168 - 0x59; break; // Truck tram stop
64 default: break;
65 }
66 break;
67
68 case MP_RAILWAY:
69 /* We save presignals different from TTDPatch, convert them */
70 if (GB(tile.m5(), 6, 2) == 1) { // RailTileType::Signals
71 /* This byte is always zero in TTD for this type of tile */
72 if (tile.m4()) { // Convert the presignals to our own format
73 tile.m4() = (tile.m4() >> 1) & 7;
74 }
75 }
76 /* TTDPatch stores PBS things in L6 and all elsewhere; so we'll just
77 * clear it for ourselves and let OTTD's rebuild PBS itself */
78 tile.m4() &= 0xF; // Only keep the lower four bits; upper four is PBS
79 break;
80
81 case MP_WATER:
82 /* if water class == 3, make river there */
83 if (GB(tile.m3(), 0, 2) == 3) {
84 SetTileType(tile, MP_WATER);
85 SetTileOwner(tile, OWNER_WATER);
86 tile.m2() = 0;
87 tile.m3() = 2; // WaterClass::River
88 tile.m4() = Random();
89 tile.m5() = 0;
90 }
91 break;
92
93 default:
94 break;
95 }
96 }
97
98 FixOldMapArray();
99}
100
101static void FixTTDDepots()
102{

Callers 1

LoadTTDMainFunction · 0.85

Calls 6

GetTileTypeFunction · 0.85
GBFunction · 0.85
SetTileTypeFunction · 0.85
SetTileOwnerFunction · 0.85
FixOldMapArrayFunction · 0.85
RandomFunction · 0.50

Tested by

no test coverage detected