summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-02-01 22:04:53 +0000
committerbjarni <bjarni@openttd.org>2005-02-01 22:04:53 +0000
commit5c43906b2432ff9e2c6aafe29a3a3d81b3e0498a (patch)
tree4eff219ad33c9ae55f91ecff56dc6ccee5905247
parent0be987391b75643fdb27bbe4bccaa2d16a96075d (diff)
downloadopenttd-5c43906b2432ff9e2c6aafe29a3a3d81b3e0498a.tar.xz
(svn r1766) - Feature: Aircrafts will now go to the nearest hangar if the next airport in the orders do not have one (helipads)
- Fix: sometimes aircrafts would not go to the hangar even when they should. They do now
-rw-r--r--aircraft_cmd.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 3b9b97358..52c369b1d 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -443,19 +443,31 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
} else {
+ bool next_airport_has_hangar = true;
next_airport_index = (HASBIT(p2, 17)) ? (int16)p2 : v->u.air.targetairport;
st = GetStation(next_airport_index);
// If an airport doesn't have terminals (so no landing space for airports),
// it surely doesn't have any hangars
- if (st->xy == 0 || st->airport_tile == 0 || GetAirport(st->airport_type)->terminals == NULL)
- return CMD_ERROR;
+ if (st->xy == 0 || st->airport_tile == 0 || GetAirport(st->airport_type)->terminals == NULL) {
+ if (p2 == 0) {
+ // the aircraft have to search for a hangar on it's own
+ next_airport_has_hangar = false;
+ uint32 temp = FindNearestHangar(v);
+ if (HASBIT(temp, 16)) return CMD_ERROR; // the player do not own a hangar
+ st = GetStation(temp);
+ next_airport_index = (uint16)temp;
+ } else {
+ return CMD_ERROR;
+ }
+ }
if (flags & DC_EXEC) {
v->current_order.type = OT_GOTO_DEPOT;
- v->current_order.flags = v->set_for_replacement ? 0 : OF_NON_STOP | OF_FULL_LOAD;
+ v->current_order.flags = HASBIT(p2, 16) ? 0 : OF_NON_STOP | OF_FULL_LOAD;
v->current_order.station = next_airport_index;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
- if (HASBIT(p2, 17)) {
+ if (HASBIT(p2, 17) || (p2 == 0 && v->u.air.state == FLYING && !next_airport_has_hangar)) {
+ // the aircraft is now heading for a different hangar than the next in the orders
AircraftNextAirportPos_and_Order(v);
v->u.air.targetairport = next_airport_index;
}