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

Function GetTrackTypes

src/newgrf_roadtype.cpp:34–54  ·  view source on GitHub ↗

* Variable 0x45 of road-/tram-/rail-types to query track types on a tile. * * Format: __RRttrr * - rr: Translated roadtype. * - tt: Translated tramtype. * - RR: Translated railtype. * * Special values for rr, tt, RR: * - 0xFF: Track not present on tile. * - 0xFE: Track present, but no matching entry in translation table. */

Source from the content-addressed store, hash-verified

32 * - 0xFE: Track present, but no matching entry in translation table.
33 */
34uint32_t GetTrackTypes(TileIndex tile, const GRFFile *grffile)
35{
36 uint8_t road = 0xFF;
37 uint8_t tram = 0xFF;
38 if (MayHaveRoad(tile)) {
39 if (auto tt = GetRoadTypeRoad(tile); tt != INVALID_ROADTYPE) {
40 road = GetReverseRoadTypeTranslation(tt, grffile);
41 if (road == 0xFF) road = 0xFE;
42 }
43 if (auto tt = GetRoadTypeTram(tile); tt != INVALID_ROADTYPE) {
44 tram = GetReverseRoadTypeTranslation(tt, grffile);
45 if (tram == 0xFF) tram = 0xFE;
46 }
47 }
48 uint8_t rail = 0xFF;
49 if (auto tt = GetTileRailType(tile); tt != INVALID_RAILTYPE) {
50 rail = GetReverseRailTypeTranslation(tt, grffile);
51 if (rail == 0xFF) rail = 0xFE;
52 }
53 return road | tram << 8 | rail << 16;
54}
55
56/* virtual */ uint32_t RoadTypeScopeResolver::GetRandomBits() const
57{

Callers 2

GetVariableMethod · 0.85
GetVariableMethod · 0.85

Calls 6

MayHaveRoadFunction · 0.85
GetRoadTypeRoadFunction · 0.85
GetRoadTypeTramFunction · 0.85
GetTileRailTypeFunction · 0.85

Tested by

no test coverage detected