summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-29 14:36:45 +0100
committerfrosch <frosch@openttd.org>2019-12-29 14:36:45 +0100
commit86107028a491052896161f64bd783e06b1231ee1 (patch)
treef44d857da0dd4b347b2773ea81ab3f571ac8359e
parente18f1703d2b235752b41b896f08ee987b9e09403 (diff)
downloadopenttd-86107028a491052896161f64bd783e06b1231ee1.tar.xz
Fix: Allow old NewGRF industries to blank out in/out cargo slots (#7882)
-rw-r--r--src/industry_cmd.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index c6602b087..628e33557 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1822,6 +1822,11 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
break;
}
CargoID cargo = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
+ /* Industries without "unlimited" cargo types support depend on the specific order/slots of cargo types.
+ * They need to be able to blank out specific slots without aborting the callback sequence,
+ * and solve this by returning undefined cargo indexes. Skip these. */
+ if (cargo == CT_INVALID && !(indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED)) continue;
+ /* Verify valid cargo */
if (std::find(indspec->accepts_cargo, endof(indspec->accepts_cargo), cargo) == endof(indspec->accepts_cargo)) {
/* Cargo not in spec, error in NewGRF */
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_INPUT_CARGO_TYPES, res);
@@ -1849,6 +1854,9 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
break;
}
CargoID cargo = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
+ /* Allow older GRFs to skip slots. */
+ if (cargo == CT_INVALID && !(indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED)) continue;
+ /* Verify valid cargo */
if (std::find(indspec->produced_cargo, endof(indspec->produced_cargo), cargo) == endof(indspec->produced_cargo)) {
/* Cargo not in spec, error in NewGRF */
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_OUTPUT_CARGO_TYPES, res);