From 12125bad826b534e1a2f46cb76be9f2a2f7ceb58 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 12 Apr 2024 23:07:07 +0100 Subject: [PATCH] Fix 3de8853e: Industry cargo types callback no longer functioned due to container change. (#12489) Use defined INDUSTRY_NUM_INPUTS/INDUSTRY_NUM_OUTPUTS values instead of container size, which is now empty at this point. --- src/industry_cmd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index fbb056c162..1382d86556 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1876,7 +1876,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, /* Clear all input cargo types */ i->accepted.clear(); /* Query actual types */ - uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast(i->accepted.size()) : 3; + uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? INDUSTRY_NUM_INPUTS : 3; for (uint j = 0; j < maxcargoes; j++) { uint16_t res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE); if (res == CALLBACK_FAILED || GB(res, 0, 8) == UINT8_MAX) break; @@ -1914,7 +1914,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, /* Clear all output cargo types */ i->produced.clear(); /* Query actual types */ - uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast(i->produced.size()) : 2; + uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? INDUSTRY_NUM_OUTPUTS : 2; for (uint j = 0; j < maxcargoes; j++) { uint16_t res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE); if (res == CALLBACK_FAILED || GB(res, 0, 8) == UINT8_MAX) break;