summaryrefslogtreecommitdiff
path: root/aircraft_cmd.c
diff options
context:
space:
mode:
authorrichk <richk@openttd.org>2006-06-23 22:05:40 +0000
committerrichk <richk@openttd.org>2006-06-23 22:05:40 +0000
commit5d2bff0b783f42f724d130faf1c9d94c7c50aaad (patch)
treee99c13a6de64e812b421e6c8a3019920196c8667 /aircraft_cmd.c
parent505565c1ce51d8ce18c56c3f699c35efae2fbc66 (diff)
downloadopenttd-5d2bff0b783f42f724d130faf1c9d94c7c50aaad.tar.xz
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
Commuter airport: Small. 5x4. 3 terminals, 2 helipads. Intercontinental: massive. 9x11. 8 terminals, 2 helipads, 4 runways. Helidepot: a small heliport with a depot for helis only. Helistation: a large heliport with 3 helipads and a depot.
Diffstat (limited to 'aircraft_cmd.c')
-rw-r--r--aircraft_cmd.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 9d3d4a7ec..5a664abdd 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -91,9 +91,8 @@ static bool HaveHangarInOrderList(Vehicle *v)
FOR_VEHICLE_ORDERS(v, order) {
const Station *st = GetStation(order->station);
if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
- // If an airport doesn't have terminals (so no landing space for airports),
- // it surely doesn't have any hangars
- if (GetAirport(st->airport_type)->terminals != NULL)
+ // If an airport doesn't have a hangar, skip it
+ if (GetAirport(st->airport_type)->nof_depots != 0)
return true;
}
}
@@ -197,6 +196,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
Vehicle *vl[3], *v, *u, *w;
UnitID unit_num;
const AircraftVehicleInfo *avi;
+ const Station *st2;
Engine *e;
if (!IsEngineBuildable(p1, VEH_Aircraft)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
@@ -217,6 +217,12 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
}
+ // prevent building of aircraft in helidepot/helistation
+ st2 = GetStationByTile(tile);
+ if ((avi->subtype != 0) && (GetAirport(st2->airport_type)->acc_planes == HELICOPTERS_ONLY)) {
+ return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
+ }
+
unit_num = (HASBIT(p2, 0) == true) ? 0 : GetFreeUnitNumber(VEH_Aircraft);
if (unit_num > _patches.max_aircraft)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
@@ -450,7 +456,7 @@ int32 CmdStartStopAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR;
// cannot stop airplane when in flight, or when taking off / landing
- if (v->u.air.state >= STARTTAKEOFF)
+ if (v->u.air.state >= STARTTAKEOFF && v->u.air.state < TERM7)
return_cmd_error(STR_A017_AIRCRAFT_IS_IN_FLIGHT);
if (flags & DC_EXEC) {
@@ -1082,6 +1088,8 @@ static void HandleCrashedAircraft(Vehicle *v)
// small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc.
// but they all share the same number
CLRBITS(st->airport_flags, RUNWAY_IN_block);
+ CLRBITS(st->airport_flags, RUNWAY_IN_OUT_block); // commuter airport
+ CLRBITS(st->airport_flags, RUNWAY_IN2_block); // intercontinental
BeginVehicleMove(v);
EndVehicleMove(v);
@@ -1272,7 +1280,7 @@ static void MaybeCrashAirplane(Vehicle *v)
//FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports
prob = 0x10000 / 1500;
- if (st->airport_type == AT_SMALL && AircraftVehInfo(v->engine_type)->subtype & AIR_FAST && !_cheats.no_jetcrash.value) {
+ if (((st->airport_type == AT_SMALL) || (st->airport_type == AT_COMMUTER)) && (AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) && !_cheats.no_jetcrash.value) {
prob = 0x10000 / 20;
}
@@ -1669,7 +1677,7 @@ static void AircraftEventHandler_HeliEndLanding(Vehicle *v, const AirportFTAClas
if (v->current_order.type == OT_GOTO_STATION) {
if (AirportFindFreeHelipad(v, Airport)) return;
}
- v->u.air.state = (Airport->terminals != NULL) ? HANGAR : HELITAKEOFF;
+ v->u.air.state = (Airport->nof_depots != 0) ? HANGAR : HELITAKEOFF;
}
typedef void AircraftStateHandler(Vehicle *v, const AirportFTAClass *Airport);
@@ -1693,6 +1701,10 @@ static AircraftStateHandler * const _aircraft_state_handlers[] = {
AircraftEventHandler_EndLanding, // ENDLANDING = 16
AircraftEventHandler_HeliLanding, // HELILANDING = 17
AircraftEventHandler_HeliEndLanding,// HELIENDLANDING = 18
+ AircraftEventHandler_AtTerminal, // TERM7 = 19
+ AircraftEventHandler_AtTerminal, // TERM8 = 20
+ AircraftEventHandler_AtTerminal, // HELIPAD3 = 21
+ AircraftEventHandler_AtTerminal, // HELIPAD4 = 22
};
static void AirportClearBlock(const Vehicle* v, const AirportFTAClass* Airport)
@@ -1796,10 +1808,9 @@ static bool AirportSetBlocks(Vehicle *v, AirportFTA *current_pos, const AirportF
AirportFTA* current;
// if the next position is in another block, check it and wait until it is free
- if (Airport->layout[current_pos->position].block != next->block) {
+ if ((Airport->layout[current_pos->position].block & next->block) != next->block) {
uint32 airport_flags = next->block;
Station* st = GetStation(v->u.air.targetairport);
-
//search for all all elements in the list with the same state, and blocks != N
// this means more blocks should be checked/set
current = current_pos;
@@ -1833,10 +1844,10 @@ static bool FreeTerminal(Vehicle *v, byte i, byte last_terminal)
{
Station *st = GetStation(v->u.air.targetairport);
for (; i < last_terminal; i++) {
- if (!HASBIT(st->airport_flags, i)) {
+ if (!HASBIT(st->airport_flags, _airport_terminal_flag[i])) {
// TERMINAL# HELIPAD#
- v->u.air.state = i + TERM1; // start moving to that terminal/helipad
- SETBIT(st->airport_flags, i); // occupy terminal/helipad
+ v->u.air.state = _airport_terminal_state[i]; // start moving to that terminal/helipad
+ SETBIT(st->airport_flags, _airport_terminal_flag[i]); // occupy terminal/helipad
return true;
}
}