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

Function BuildCargoTranslationMap

src/newgrf.cpp:537–548  ·  view source on GitHub ↗

* Construct the Cargo Mapping * @note This is the reverse of a cargo translation table */

Source from the content-addressed store, hash-verified

535 * @note This is the reverse of a cargo translation table
536 */
537static void BuildCargoTranslationMap()
538{
539 _cur_gps.grffile->cargo_map.fill(UINT8_MAX);
540
541 auto cargo_list = GetCargoTranslationTable(*_cur_gps.grffile);
542
543 for (const CargoSpec *cs : CargoSpec::Iterate()) {
544 /* Check the translation table for this cargo's label */
545 int idx = find_index(cargo_list, cs->label);
546 if (idx >= 0) _cur_gps.grffile->cargo_map[cs->Index()] = idx;
547 }
548}
549
550/**
551 * Prepare loading a NewGRF file with its config

Callers 1

LoadNewGRFFunction · 0.85

Calls 4

GetCargoTranslationTableFunction · 0.85
find_indexFunction · 0.85
fillMethod · 0.80
IndexMethod · 0.45

Tested by

no test coverage detected