Merge branch 'master' into jgrpp
# Conflicts: # cmake/CompileFlags.cmake # src/aircraft_cmd.cpp # src/blitter/32bpp_anim.cpp # src/cargopacket.cpp # src/cheat_gui.cpp # src/company_cmd.cpp # src/company_gui.cpp # src/core/pool_func.hpp # src/date.cpp # src/economy.cpp # src/error_gui.cpp # src/ground_vehicle.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/industry_cmd.cpp # src/lang/dutch.txt # src/lang/french.txt # src/lang/german.txt # src/linkgraph/linkgraph_gui.cpp # src/linkgraph/mcf.cpp # src/network/network_content.cpp # src/network/network_server.cpp # src/network/network_udp.cpp # src/newgrf_engine.cpp # src/newgrf_station.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/pathfinder/follow_track.hpp # src/pathfinder/yapf/yapf_common.hpp # src/saveload/saveload.cpp # src/settings_gui.cpp # src/station_cmd.cpp # src/station_kdtree.h # src/string_func.h # src/table/settings.ini # src/tgp.cpp # src/timetable_cmd.cpp # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/train_cmd.cpp # src/train_gui.cpp # src/tree_gui.cpp # src/tunnelbridge_cmd.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/video/sdl2_v.cpp # src/video/sdl_v.cpp # src/video/win32_v.cpp # src/viewport.cpp # src/viewport_sprite_sorter_sse4.cpp # src/window.cpp
This commit is contained in:
@@ -132,6 +132,37 @@ SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSp
|
||||
return group->GetResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate an index to the GRF-local road/tramtype-translation table into a RoadType.
|
||||
* @param rtt Whether to index the road- or tramtype-table.
|
||||
* @param tracktype Index into GRF-local translation table.
|
||||
* @param grffile Originating GRF file.
|
||||
* @return RoadType or INVALID_ROADTYPE if the roadtype is unknown.
|
||||
*/
|
||||
RoadType GetRoadTypeTranslation(RoadTramType rtt, uint8 tracktype, const GRFFile *grffile)
|
||||
{
|
||||
/* Because OpenTTD mixes RoadTypes and TramTypes into the same type,
|
||||
* the mapping of the original road- and tramtypes does not match the default GRF-local mapping.
|
||||
* So, this function cannot provide any similar behavior to GetCargoTranslation() and GetRailTypeTranslation()
|
||||
* when the GRF defines no translation table.
|
||||
* But since there is only one default road/tram-type, this makes little sense anyway.
|
||||
* So for GRF without translation table, we always return INVALID_ROADTYPE.
|
||||
*/
|
||||
|
||||
if (grffile == nullptr) return INVALID_ROADTYPE;
|
||||
|
||||
const auto &list = rtt == RTT_TRAM ? grffile->tramtype_list : grffile->roadtype_list;
|
||||
if (tracktype >= list.size()) return INVALID_ROADTYPE;
|
||||
|
||||
/* Look up roadtype including alternate labels. */
|
||||
RoadType result = GetRoadTypeByLabel(list[tracktype]);
|
||||
|
||||
/* Check whether the result is actually the wanted road/tram-type */
|
||||
if (result != INVALID_ROADTYPE && GetRoadTramType(result) != rtt) return INVALID_ROADTYPE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a reverse roadtype lookup to get the GRF internal ID.
|
||||
* @param roadtype The global (OpenTTD) roadtype.
|
||||
|
Reference in New Issue
Block a user