41 if (road == 0xFF) road = 0xFE;
45 if (tram == 0xFF) tram = 0xFE;
51 if (rail == 0xFF) rail = 0xFE;
53 return road | tram << 8 | rail << 16;
74 if (local == 0xFF) local = 0xFE;
75 if (RoadTypeIsRoad(rt)) {
76 return 0xFFFF00 | local;
78 return 0xFF00FF | local << 8;
92 const Town *t =
nullptr;
94 t = Depot::GetByTile(this->
tile)->town;
104 Debug(grf, 1,
"Unhandled road type tile variable 0x{:X}", variable);
113 switch (GetRoadTramType(rt)) {
114 case RTT_ROAD:
return GSF_ROADTYPES;
115 case RTT_TRAM:
return GSF_TRAMTYPES;
151 assert(rtsg < ROTSG_END);
153 if (rti->
group[rtsg] ==
nullptr)
return 0;
157 if (group ==
nullptr || group->num_sprites == 0)
return 0;
159 if (num_results) *num_results = group->num_sprites;
161 return group->sprite;
204 if (grffile ==
nullptr)
return roadtype;
207 if (list->empty())
return roadtype;
213 if (index >= 0)
return index;
219std::vector<LabelObject<RoadTypeLabel>> _roadtype_list;
227 std::vector<RoadType> roadtype_conversion_map;
228 bool needs_conversion =
false;
229 for (
auto it = std::begin(_roadtype_list); it != std::end(_roadtype_list); ++it) {
235 roadtype_conversion_map.push_back(rt);
238 if (it->label != 0 && rt != std::distance(std::begin(_roadtype_list), it)) needs_conversion =
true;
240 if (!needs_conversion)
return;
272 _roadtype_list.clear();
274 _roadtype_list.emplace_back(
GetRoadTypeInfo(rt)->label, GetRoadTramType(rt));
278void ClearRoadTypeLabelList()
280 _roadtype_list.clear();
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
RoadTypeLabel label
Unique 32 bit road type identifier.
const SpriteGroup * group[ROTSG_END]
Sprite groups for resolving sprites.
static Date date
Current date in days (day counter).
Some simple functions to help with accessing containers.
int find_index(Container const &container, typename Container::const_reference item)
Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_...
Functions related to debugging.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Base for all depots (except hangars)
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
@ GSF_INVALID
An invalid spec feature.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
uint32_t GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
TileContext
Context for tile accesses.
uint8_t GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
Perform a reverse railtype lookup to get the GRF internal ID.
NewGRF handling of rail types.
void SetCurrentRoadTypeLabelList()
Populate road type label list with current values.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
void ConvertRoadTypes()
Test if any saved road type labels are different to the currently loaded road types.
uint8_t GetReverseRoadTypeTranslation(RoadType roadtype, const GRFFile *grffile)
Perform a reverse roadtype lookup to get the GRF internal ID.
uint32_t GetTrackTypes(TileIndex tile, const GRFFile *grffile)
Variable 0x45 of road-/tram-/rail-types to query track types on a tile.
RoadType GetRoadTypeTranslation(RoadTramType rtt, uint8_t tracktype, const GRFFile *grffile)
Translate an index to the GRF-local road/tramtype-translation table into a RoadType.
NewGRF handling of road types.
uint8_t GetReverseRoadTypeTranslation(RoadType roadtype, const GRFFile *grffile)
Perform a reverse roadtype lookup to get the GRF internal ID.
uint32_t GetTrackTypes(TileIndex tile, const GRFFile *grffile)
Variable 0x45 of road-/tram-/rail-types to query track types on a tile.
RailType GetTileRailType(Tile tile)
Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
@ INVALID_RAILTYPE
Flag for invalid railtype.
RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels)
Get the road type for a given label.
RoadType GetRoadTypeInfoIndex(const RoadTypeInfo *rti)
Returns the railtype for a Railtype information.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
RoadTypeSpriteGroup
Sprite groups for a roadtype.
bool MayHaveRoad(Tile t)
Test whether a tile can have road/tram types.
void SetRoadTypeRoad(Tile t, RoadType rt)
Set the road road type of a tile.
void SetRoadTypeTram(Tile t, RoadType rt)
Set the tram road type of a tile.
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
static debug_inline bool IsRoadDepotTile(Tile t)
Return whether a tile is a road depot tile.
bool IsCrossingBarred(Tile t)
Check if the level crossing is barred.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ ROADTYPE_ROAD
Basic road type.
@ ROADTYPE_END
Used for iterations.
@ ROADTYPE_BEGIN
Used for iterations.
A number of safeguards to prevent using unsafe methods.
bool IsAnyRoadStop(Tile t)
Is the station at t a road station?
Definition of base types and functions in a cross-platform compatible way.
TimerGameCalendar::Date build_date
Date of construction.
Dynamic data of a loaded NewGRF.
std::vector< RoadTypeLabel > roadtype_list
Roadtype translation table (road)
std::vector< RoadTypeLabel > tramtype_list
Roadtype translation table (tram)
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
Interface for SpriteGroup-s to access the gamestate.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
Resolver object for road types.
RoadTypeScopeResolver roadtype_scope
Resolver for the roadtype scope.
RoadTypeResolverObject(const RoadTypeInfo *rti, TileIndex tile, TileContext context, RoadTypeSpriteGroup rtsg, uint32_t param1=0, uint32_t param2=0)
Resolver object for road types.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
TileContext context
Are we resolving sprites for the upper halftile, or on a bridge?
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
uint32_t GetRandomBits() const override
Get a few random bits.
TileIndex tile
Tracktile. For track on a bridge this is the southern bridgehead.
ResolverObject & ro
Surrounding resolver object.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
static const uint TILE_SIZE
Tile size in world coordinates.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ MP_ROAD
A tile with road (or tram tracks)
@ MP_STATION
A tile of a station.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition of the game-calendar-timer.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
@ TRANSPORT_ROAD
Transport by road vehicle.
Functions that have tunnels and bridges in common.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...