Fix 51bd344f10: Incorrect translation table used for older NewGRFs. (#13131)
Incorrect logic was used to select the default translation table for older GRFs.
This commit is contained in:
@@ -46,14 +46,14 @@ static std::vector<CargoLabel> _default_cargo_labels;
|
||||
* This maps the original 12 cargo slots to their original label. If a climate dependent cargo is not present it will
|
||||
* map to CT_INVALID. For default cargoes this ends up as a 1:1 mapping via climate slot -> label -> cargo ID.
|
||||
*/
|
||||
static std::array<CargoLabel, 12> _v7_cargo_labels;
|
||||
static std::array<CargoLabel, 12> _climate_dependent_cargo_labels;
|
||||
|
||||
/**
|
||||
* Default cargo translation for version 8+ NewGRFs.
|
||||
* This maps the 32 "bitnum" cargo slots to their original label. If a bitnum is not present it will
|
||||
* map to CT_INVALID.
|
||||
*/
|
||||
static std::array<CargoLabel, 32> _v8_cargo_labels;
|
||||
static std::array<CargoLabel, 32> _climate_independent_cargo_labels;
|
||||
|
||||
/**
|
||||
* Set up the default cargo types for the given landscape type.
|
||||
@@ -65,8 +65,8 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
|
||||
_cargo_mask = 0;
|
||||
_default_cargo_labels.clear();
|
||||
_v7_cargo_labels.fill(CT_INVALID);
|
||||
_v8_cargo_labels.fill(CT_INVALID);
|
||||
_climate_dependent_cargo_labels.fill(CT_INVALID);
|
||||
_climate_independent_cargo_labels.fill(CT_INVALID);
|
||||
|
||||
/* Copy from default cargo by label or index. */
|
||||
auto insert = std::begin(CargoSpec::array);
|
||||
@@ -94,8 +94,8 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
if (insert->IsValid()) {
|
||||
SetBit(_cargo_mask, insert->Index());
|
||||
_default_cargo_labels.push_back(insert->label);
|
||||
_v7_cargo_labels[insert->Index()] = insert->label;
|
||||
_v8_cargo_labels[insert->bitnum] = insert->label;
|
||||
_climate_dependent_cargo_labels[insert->Index()] = insert->label;
|
||||
_climate_independent_cargo_labels[insert->bitnum] = insert->label;
|
||||
}
|
||||
++insert;
|
||||
}
|
||||
@@ -107,14 +107,21 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default cargo translation table for a NewGRF, used if the NewGRF does not provide its own.
|
||||
* @param grf_version GRF version of translation table.
|
||||
* Get default climate-dependent cargo translation table for a NewGRF, used if the NewGRF does not provide its own.
|
||||
* @return Default translation table for GRF version.
|
||||
*/
|
||||
std::span<const CargoLabel> GetDefaultCargoTranslationTable(uint8_t grf_version)
|
||||
std::span<const CargoLabel> GetClimateDependentCargoTranslationTable()
|
||||
{
|
||||
if (grf_version < 8) return _v7_cargo_labels;
|
||||
return _v8_cargo_labels;
|
||||
return _climate_dependent_cargo_labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default climate-independent cargo translation table for a NewGRF, used if the NewGRF does not provide its own.
|
||||
* @return Default translation table for GRF version.
|
||||
*/
|
||||
std::span<const CargoLabel> GetClimateIndependentCargoTranslationTable()
|
||||
{
|
||||
return _climate_independent_cargo_labels;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user