1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-29 07:04:35 +01:00

(svn r17417) [0.7] -Backport from trunk:

- Fix: Incomplete check on validity of industry type when building industries (r17413)
- Fix: [Squirrel] Guard against Squirrel stack overflows (r17403)
- Fix: [NoAI] During every save a few slots on the Squirrel stack were leaked (r17402)
- Fix: [NoAI] Several AITile::* functions did not check whether their parameters were valid (r17378)
This commit is contained in:
rubidium
2009-09-04 20:40:15 +00:00
parent 0a4299bdfd
commit a442343076
5 changed files with 33 additions and 5 deletions

View File

@@ -1642,7 +1642,10 @@ static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCo
*/
CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
const IndustrySpec *indspec = GetIndustrySpec(GB(p1, 0, 16));
IndustryType it = GB(p1, 0, 16);
if (it >= NUM_INDUSTRYTYPES) return CMD_ERROR;
const IndustrySpec *indspec = GetIndustrySpec(it);
const Industry *ind = NULL;
/* Check if the to-be built/founded industry is available for this climate. */
@@ -1681,7 +1684,8 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
} else {
int count = indspec->num_table;
const IndustryTileTable * const *itt = indspec->table;
int num = Clamp(GB(p1, 16, 16), 0, count - 1);
int num = GB(p1, 16, 16);
if (num >= count) return CMD_ERROR;
_error_message = STR_0239_SITE_UNSUITABLE;
do {