src/aircraft_cmd.cpp
changeset 6170 cababf676259
parent 6159 9a782ac72dba
child 6171 42ea86065d8d
equal deleted inserted replaced
6169:31cdbb4845f1 6170:cababf676259
   208 {
   208 {
   209 	int32 value;
   209 	int32 value;
   210 	Vehicle *vl[3];
   210 	Vehicle *vl[3];
   211 	UnitID unit_num;
   211 	UnitID unit_num;
   212 	const AircraftVehicleInfo *avi;
   212 	const AircraftVehicleInfo *avi;
   213 	const AirportFTAClass* ap;
       
   214 
   213 
   215 	if (!IsEngineBuildable(p1, VEH_Aircraft, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
   214 	if (!IsEngineBuildable(p1, VEH_Aircraft, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
   216 
   215 
   217 	value = EstimateAircraftCost(p1);
   216 	value = EstimateAircraftCost(p1);
   218 
   217 
   224 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
   223 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
   225 
   224 
   226 	avi = AircraftVehInfo(p1);
   225 	avi = AircraftVehInfo(p1);
   227 
   226 
   228 	// Prevent building aircraft types at places which can't handle them
   227 	// Prevent building aircraft types at places which can't handle them
   229 	ap = GetAirport(GetStationByTile(tile)->airport_type);
   228 	const Station* st = GetStationByTile(tile);
   230 	if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == ap->acc_planes) {
   229 	const AirportFTAClass* apc = GetAirport(st->airport_type);
       
   230 	if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == apc->acc_planes) {
   231 		return CMD_ERROR;
   231 		return CMD_ERROR;
   232 	}
   232 	}
   233 
   233 
   234 	/* Allocate 2 or 3 vehicle structs, depending on type
   234 	/* Allocate 2 or 3 vehicle structs, depending on type
   235 	 * vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
   235 	 * vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
   346 		/* When we click on hangar we know the tile it is on. By that we know
   346 		/* When we click on hangar we know the tile it is on. By that we know
   347 		 * its position in the array of depots the airport has.....we can search
   347 		 * its position in the array of depots the airport has.....we can search
   348 		 * layout for #th position of depot. Since layout must start with a listing
   348 		 * layout for #th position of depot. Since layout must start with a listing
   349 		 * of all depots, it is simple */
   349 		 * of all depots, it is simple */
   350 		{
   350 		{
   351 			const Station* st = GetStationByTile(tile);
       
   352 			const AirportFTAClass* apc = GetAirport(st->airport_type);
       
   353 			uint i;
   351 			uint i;
   354 
   352 
   355 			for (i = 0; i < apc->nof_depots; i++) {
   353 			for (i = 0; i < apc->nof_depots; i++) {
   356 				if (st->airport_tile + ToTileIndexDiff(apc->airport_depots[i]) == tile) {
   354 				if (st->airport_tile + ToTileIndexDiff(apc->airport_depots[i]) == tile) {
   357 					assert(apc->layout[i].heading == HANGAR);
   355 					assert(apc->layout[i].heading == HANGAR);