summaryrefslogtreecommitdiff
path: root/src/aircraft_cmd.cpp
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-03-06 22:11:58 +0000
committerbjarni <bjarni@openttd.org>2007-03-06 22:11:58 +0000
commit13c72c07d6b509dada6657a50475c2c8c53f7112 (patch)
tree878e2f7dfe1dea81959070b7ca59a854d6b85921 /src/aircraft_cmd.cpp
parent6ab89d0031024a5cb01ddf48c212151ba075839a (diff)
downloadopenttd-13c72c07d6b509dada6657a50475c2c8c53f7112.tar.xz
(svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
This should help ensuring that the build command and the list are consistent in what aircraft are buildable
Diffstat (limited to 'src/aircraft_cmd.cpp')
-rw-r--r--src/aircraft_cmd.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 429b16d4f..ad4b11c32 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -227,7 +227,6 @@ uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi)
}
}
-
/** Build an aircraft.
* @param tile tile of depot where aircraft is built
* @param flags for command
@@ -250,11 +249,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
/* Prevent building aircraft types at places which can't handle them */
- const Station* st = GetStationByTile(tile);
- const AirportFTAClass* apc = st->Airport();
- if (!(apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS))) {
- return CMD_ERROR;
- }
+ if (!IsAircraftBuildableAtStation(p1, tile)) return CMD_ERROR;
/* Allocate 2 or 3 vehicle structs, depending on type
* vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
@@ -367,6 +362,9 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* layout for #th position of depot. Since layout must start with a listing
* of all depots, it is simple */
for (uint i = 0;; i++) {
+ const Station *st = GetStationByTile(tile);
+ const AirportFTAClass *apc = st->Airport();
+
assert(i != apc->nof_depots);
if (st->airport_tile + ToTileIndexDiff(apc->airport_depots[i]) == tile) {
assert(apc->layout[i].heading == HANGAR);