(svn r2144) - Fix: AI crash when trying to remove stations with index higher than 256.
This commit is contained in:
11
ai.c
11
ai.c
@@ -3609,16 +3609,18 @@ return_to_loop:;
|
|||||||
static void AiStateRemoveStation(Player *p)
|
static void AiStateRemoveStation(Player *p)
|
||||||
{
|
{
|
||||||
// Remove stations that aren't in use by any vehicle
|
// Remove stations that aren't in use by any vehicle
|
||||||
byte in_use[256], *used;
|
byte *in_use;
|
||||||
|
const byte *used;
|
||||||
const Order *ord;
|
const Order *ord;
|
||||||
Station *st;
|
const Station *st;
|
||||||
uint tile;
|
TileIndex tile;
|
||||||
|
|
||||||
// Go to this state when we're done.
|
// Go to this state when we're done.
|
||||||
p->ai.state = AIS_1;
|
p->ai.state = AIS_1;
|
||||||
|
|
||||||
// Get a list of all stations that are in use by a vehicle
|
// Get a list of all stations that are in use by a vehicle
|
||||||
memset(in_use, 0, sizeof(in_use));
|
in_use = malloc(GetStationPoolSize());
|
||||||
|
memset(in_use, 0, GetStationPoolSize());
|
||||||
FOR_ALL_ORDERS(ord) {
|
FOR_ALL_ORDERS(ord) {
|
||||||
if (ord->type == OT_GOTO_STATION)
|
if (ord->type == OT_GOTO_STATION)
|
||||||
in_use[ord->station] = 1;
|
in_use[ord->station] = 1;
|
||||||
@@ -3638,6 +3640,7 @@ static void AiStateRemoveStation(Player *p)
|
|||||||
used++;
|
used++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(in_use);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AiRemovePlayerRailOrRoad(Player *p, TileIndex tile)
|
static void AiRemovePlayerRailOrRoad(Player *p, TileIndex tile)
|
||||||
|
Reference in New Issue
Block a user