src/aircraft_cmd.cpp
changeset 6025 414b34699e87
parent 6024 37e72f8f6a99
child 6027 ff15b8c7c087
equal deleted inserted replaced
6024:37e72f8f6a99 6025:414b34699e87
    72 	uint best = 0;
    72 	uint best = 0;
    73 	StationID index = INVALID_STATION;
    73 	StationID index = INVALID_STATION;
    74 	TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos);
    74 	TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos);
    75 
    75 
    76 	FOR_ALL_STATIONS(st) {
    76 	FOR_ALL_STATIONS(st) {
    77 		if (st->owner == v->owner && st->facilities & FACIL_AIRPORT &&
    77 		if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
    78 				GetAirport(st->airport_type)->nof_depots > 0) {
    78 
    79 			uint distance;
    79 		const AirportFTAClass *afc = GetAirport(st->airport_type);
    80 
    80 		if (afc->nof_depots == 0 || (
    81 			// don't crash the plane if we know it can't land at the airport
    81 					/* don't crash the plane if we know it can't land at the airport */
    82 			if ((AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
    82 					afc->flags & AirportFTAClass::SHORT_STRIP &&
    83 					(st->airport_type == AT_SMALL || st->airport_type == AT_COMMUTER) &&
    83 					AircraftVehInfo(v->engine_type)->subtype & AIR_FAST &&
    84 					!_cheats.no_jetcrash.value)
    84 					!_cheats.no_jetcrash.value
    85 				continue;
    85 				)) {
    86 
    86 			continue;
    87 			// v->tile can't be used here, when aircraft is flying v->tile is set to 0
    87 		}
    88 			distance = DistanceSquare(vtile, st->airport_tile);
    88 
    89 			if (distance < best || index == INVALID_STATION) {
    89 		// v->tile can't be used here, when aircraft is flying v->tile is set to 0
    90 				best = distance;
    90 		uint distance = DistanceSquare(vtile, st->airport_tile);
    91 				index = st->index;
    91 		if (distance < best || index == INVALID_STATION) {
    92 			}
    92 			best = distance;
       
    93 			index = st->index;
    93 		}
    94 		}
    94 	}
    95 	}
    95 	return index;
    96 	return index;
    96 }
    97 }
    97 
    98 
  1366 
  1367 
  1367 	st = GetStation(v->u.air.targetairport);
  1368 	st = GetStation(v->u.air.targetairport);
  1368 
  1369 
  1369 	//FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports
  1370 	//FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports
  1370 	prob = 0x10000 / 1500;
  1371 	prob = 0x10000 / 1500;
  1371 	if (((st->airport_type == AT_SMALL) || (st->airport_type == AT_COMMUTER)) && (AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) && !_cheats.no_jetcrash.value) {
  1372 	if (GetAirport(st->airport_type)->flags & AirportFTAClass::SHORT_STRIP &&
       
  1373 			AircraftVehInfo(v->engine_type)->subtype & AIR_FAST &&
       
  1374 			!_cheats.no_jetcrash.value) {
  1372 		prob = 0x10000 / 20;
  1375 		prob = 0x10000 / 20;
  1373 	}
  1376 	}
  1374 
  1377 
  1375 	if (GB(Random(), 0, 16) > prob) return;
  1378 	if (GB(Random(), 0, 16) > prob) return;
  1376 
  1379