Skip to content

Instantly share code, notes, and snippets.

@nielsmh nielsmh/cbflag.diff Secret
Created Jul 25, 2018

Embed
What would you like to do?
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 916b322..0019de9 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1725,8 +1725,10 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
}
if (HasBit(indspec->callback_mask, CBM_IND_INPUT_CARGO_TYPES)) {
- for (uint j = 0; j < lengthof(i->accepts_cargo); j++) i->accepts_cargo[j] = CT_INVALID;
- for (uint j = 0; j < lengthof(i->accepts_cargo); j++) {
+ uint maxcargoes = 3;
+ if (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) maxcargoes = lengthof(i->accepts_cargo);
+ for (uint j = 0; j < maxcargoes; j++) i->accepts_cargo[j] = CT_INVALID;
+ for (uint j = 0; j < maxcargoes; j++) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break;
if (indspec->grf_prop.grffile->grf_version >= 8 && res >= 0x100) {
@@ -1738,8 +1740,10 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
}
if (HasBit(indspec->callback_mask, CBM_IND_OUTPUT_CARGO_TYPES)) {
- for (uint j = 0; j < lengthof(i->produced_cargo); j++) i->produced_cargo[j] = CT_INVALID;
- for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
+ uint maxcargoes = 2;
+ if (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) maxcargoes = lengthof(i->produced_cargo);
+ for (uint j = 0; j < maxcargoes; j++) i->produced_cargo[j] = CT_INVALID;
+ for (uint j = 0; j < maxcargoes; j++) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break;
if (indspec->grf_prop.grffile->grf_version >= 8 && res >= 0x100) {
diff --git a/src/industrytype.h b/src/industrytype.h
index 563e4cd..0f50dc6 100644
--- a/src/industrytype.h
+++ b/src/industrytype.h
@@ -80,6 +80,7 @@ enum IndustryBehaviour {
INDUSTRYBEH_PRODCALLBACK_RANDOM = 1 << 15, ///< Production callback needs random bits in var 10
INDUSTRYBEH_NOBUILT_MAPCREATION = 1 << 16, ///< Do not force one instance of this type to appear on map generation
INDUSTRYBEH_CANCLOSE_LASTINSTANCE = 1 << 17, ///< Allow closing down the last instance of this type
+ INDUSTRYBEH_CARGOTYPES_UNLIMITED = 1 << 18, ///< Allow produced/accepted cargoes callbacks to supply more than 2 and 3 types
};
DECLARE_ENUM_AS_BIT_SET(IndustryBehaviour)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.