diff --git a/src/industry_type.h b/src/industry_type.h --- a/src/industry_type.h +++ b/src/industry_type.h @@ -28,6 +28,8 @@ static const IndustryType NEW_INDUSTRYOF static const IndustryType NUM_INDUSTRYTYPES = 64; ///< total number of industry types, new and old static const IndustryType INVALID_INDUSTRYTYPE = NUM_INDUSTRYTYPES; ///< one above amount is considered invalid +static const IndustryGfx NUM_INDUSTRYTILES_PER_GRF = 255; ///< Maximum number of industry tiles per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on. + static const IndustryGfx INDUSTRYTILE_NOANIM = 0xFF; ///< flag to mark industry tiles as having no animation static const IndustryGfx NEW_INDUSTRYTILEOFFSET = 175; ///< original number of tiles static const IndustryGfx NUM_INDUSTRYTILES = 512; ///< total number of industry tiles, new and old diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2977,14 +2977,14 @@ static ChangeInfoResult IndustrytilesCha { ChangeInfoResult ret = CIR_SUCCESS; - if (indtid + numinfo > NUM_INDUSTRYTILES) { - grfmsg(1, "IndustryTilesChangeInfo: Too many industry tiles loaded (%u), max (%u). Ignoring.", indtid + numinfo, NUM_INDUSTRYTILES); + if (indtid + numinfo > NUM_INDUSTRYTILES_PER_GRF) { + grfmsg(1, "IndustryTilesChangeInfo: Too many industry tiles loaded (%u), max (%u). Ignoring.", indtid + numinfo, NUM_INDUSTRYTILES_PER_GRF); return CIR_INVALID_ID; } /* Allocate industry tile specs if they haven't been allocated already. */ if (_cur.grffile->indtspec == NULL) { - _cur.grffile->indtspec = CallocT(NUM_INDUSTRYTILES); + _cur.grffile->indtspec = CallocT(NUM_INDUSTRYTILES_PER_GRF); } for (int i = 0; i < numinfo; i++) { @@ -7866,7 +7866,7 @@ static void ResetCustomIndustries() } if (indtspec == NULL) continue; - for (uint i = 0; i < NUM_INDUSTRYTILES; i++) { + for (uint i = 0; i < NUM_INDUSTRYTILES_PER_GRF; i++) { free(indtspec[i]); } @@ -8519,7 +8519,7 @@ static void FinaliseIndustriesArray() } if (indtspec != NULL) { - for (int i = 0; i < NUM_INDUSTRYTILES; i++) { + for (int i = 0; i < NUM_INDUSTRYTILES_PER_GRF; i++) { IndustryTileSpec *indtsp = indtspec[i]; if (indtsp != NULL) { _industile_mngr.SetEntitySpec(indtsp);