Changeset - r9855:7cff0ec982fd
[Not reviewed]
master
0 1 0
rubidium - 16 years ago 2008-08-04 22:31:49
rubidium@openttd.org
(svn r13999) -Fix [FS#2190]: crash when the AI tries to find the depot of an airport that doesn't have a depot.
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/ai/default/default.cpp
Show inline comments
 
@@ -3565,24 +3565,25 @@ static void AiStateBuildAircraftVehicles
 
		const AiBuildRec *aib = (&_players_ai[p->index].src) + _players_ai[p->index].order_list_blocks[i];
 
		const Station *st = GetStationByTile(aib->use_tile);
 

	
 
		if (st == NULL || !(st->facilities & FACIL_AIRPORT)) continue;
 

	
 
		AirportFTAClass::Flags flags = st->Airport()->flags;
 
		if (!(flags & AirportFTAClass::AIRPLANES)) forbidden |= AIR_CTOL | AIR_FAST; // no planes for heliports / oil rigs
 
		if (flags & AirportFTAClass::SHORT_STRIP) forbidden |= AIR_FAST; // no fast planes for small airports
 
	}
 

	
 
	veh = AiChooseAircraftToBuild(p->player_money, forbidden);
 
	if (veh == INVALID_ENGINE) return;
 
	if (GetStationByTile(tile)->Airport()->nof_depots == 0) return;
 

	
 
	/* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type
 
	 * and offset to the FIRST depot because the AI picks the st->xy tile */
 
	tile += ToTileIndexDiff(GetStationByTile(tile)->Airport()->airport_depots[0]);
 
	if (CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return;
 
	loco_id = _new_vehicle_id;
 

	
 
	for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) {
 
		AiBuildRec *aib = (&_players_ai[p->index].src) + _players_ai[p->index].order_list_blocks[i];
 
		bool is_pass = (_players_ai[p->index].cargo_type == CT_PASSENGERS || _players_ai[p->index].cargo_type == CT_MAIL);
 
		Order order;
 

	
0 comments (0 inline, 0 general)