From 2ac7077571ebf4b9781dc4c934869bdf77f5e9be Mon Sep 17 00:00:00 2001 From: darkvater Date: Sun, 3 Apr 2005 13:57:39 +0000 Subject: (svn r2144) - Fix: AI crash when trying to remove stations with index higher than 256. --- ai.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ai.c') diff --git a/ai.c b/ai.c index f740cb28d..52c607b20 100644 --- a/ai.c +++ b/ai.c @@ -3609,23 +3609,25 @@ return_to_loop:; static void AiStateRemoveStation(Player *p) { // Remove stations that aren't in use by any vehicle - byte in_use[256], *used; + byte *in_use; + const byte *used; const Order *ord; - Station *st; - uint tile; + const Station *st; + TileIndex tile; // Go to this state when we're done. p->ai.state = AIS_1; // 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) { if (ord->type == OT_GOTO_STATION) in_use[ord->station] = 1; } // Go through all stations and delete those that aren't in use - used=in_use; + used = in_use; FOR_ALL_STATIONS(st) { if (st->xy != 0 && st->owner == _current_player && !*used && ( (st->bus_stops != NULL && (tile = st->bus_stops->xy) != 0) || @@ -3638,6 +3640,7 @@ static void AiStateRemoveStation(Player *p) used++; } + free(in_use); } static void AiRemovePlayerRailOrRoad(Player *p, TileIndex tile) -- cgit v1.2.3-54-g00ecf