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

Method GetVariable

src/newgrf_railtype.cpp:28–70  ·  view source on GitHub ↗

virtual */

Source from the content-addressed store, hash-verified

26}
27
28/* virtual */ uint32_t RailTypeScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const
29{
30 if (this->tile == INVALID_TILE) {
31 switch (variable) {
32 case 0x40: return 0;
33 case 0x41: return 0;
34 case 0x42: return 0;
35 case 0x43: return TimerGameCalendar::date.base();
36 case 0x44: return to_underlying(HouseZone::TownEdge);
37 case 0x45: {
38 RailType rt = this->rti->Index();
39 uint8_t local = GetReverseRailTypeTranslation(rt, this->ro.grffile);
40 if (local == 0xFF) local = 0xFE;
41 return 0xFFFF | local << 16;
42 }
43 }
44 }
45
46 switch (variable) {
47 case 0x40: return GetTerrainType(this->tile, this->context);
48 case 0x41: return 0;
49 case 0x42: return IsLevelCrossingTile(this->tile) && IsCrossingBarred(this->tile);
50 case 0x43:
51 if (IsRailDepotTile(this->tile)) return Depot::GetByTile(this->tile)->build_date.base();
52 return TimerGameCalendar::date.base();
53 case 0x44: {
54 const Town *t = nullptr;
55 if (IsRailDepotTile(this->tile)) {
56 t = Depot::GetByTile(this->tile)->town;
57 } else if (IsLevelCrossingTile(this->tile)) {
58 t = ClosestTownFromTile(this->tile, UINT_MAX);
59 }
60 return to_underlying(t != nullptr ? GetTownRadiusGroup(t, this->tile) : HouseZone::TownEdge);
61 }
62 case 0x45:
63 return GetTrackTypes(this->tile, ro.grffile);
64 }
65
66 Debug(grf, 1, "Unhandled rail type tile variable 0x{:X}", variable);
67
68 available = false;
69 return UINT_MAX;
70}
71
72GrfSpecFeature RailTypeResolverObject::GetFeature() const
73{

Callers

nothing calls this directly

Calls 11

to_underlyingFunction · 0.85
GetTerrainTypeFunction · 0.85
IsLevelCrossingTileFunction · 0.85
IsCrossingBarredFunction · 0.85
IsRailDepotTileFunction · 0.85
ClosestTownFromTileFunction · 0.85
GetTownRadiusGroupFunction · 0.85
GetTrackTypesFunction · 0.85
baseMethod · 0.45
IndexMethod · 0.45

Tested by

no test coverage detected