mirror of https://github.com/OpenTTD/OpenTTD
(svn r11214) -Fix [FS#1296]: planes can't use heliports so refuse these orders
parent
0fd7d6257b
commit
8e5480aa16
|
@ -33,20 +33,29 @@ static inline bool IsNormalAircraft(const Vehicle *v)
|
||||||
return v->subtype <= AIR_AIRCRAFT;
|
return v->subtype <= AIR_AIRCRAFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks if an aircraft is buildable at the tile in question
|
/** Checks if an aircraft can use the station in question
|
||||||
* @param engine The engine to test
|
* @param engine The engine to test
|
||||||
* @param tile The tile where the hangar is
|
* @param st The station
|
||||||
* @return true if the aircraft can be build
|
* @return true if the aircraft can use the station
|
||||||
*/
|
*/
|
||||||
static inline bool IsAircraftBuildableAtStation(EngineID engine, TileIndex tile)
|
static inline bool CanAircraftUseStation(EngineID engine, const Station *st)
|
||||||
{
|
{
|
||||||
const Station *st = GetStationByTile(tile);
|
|
||||||
const AirportFTAClass *apc = st->Airport();
|
const AirportFTAClass *apc = st->Airport();
|
||||||
const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
|
const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
|
||||||
|
|
||||||
return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
|
return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Checks if an aircraft can use the station at the tile in question
|
||||||
|
* @param engine The engine to test
|
||||||
|
* @param tile The tile where the station is
|
||||||
|
* @return true if the aircraft can use the station
|
||||||
|
*/
|
||||||
|
static inline bool CanAircraftUseStation(EngineID engine, TileIndex tile)
|
||||||
|
{
|
||||||
|
return CanAircraftUseStation(engine, GetStationByTile(tile));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates cargo capacity based on an aircraft's passenger
|
* Calculates cargo capacity based on an aircraft's passenger
|
||||||
* and mail capacities.
|
* and mail capacities.
|
||||||
|
|
|
@ -282,7 +282,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||||
|
|
||||||
/* Prevent building aircraft types at places which can't handle them */
|
/* Prevent building aircraft types at places which can't handle them */
|
||||||
if (!IsAircraftBuildableAtStation(p1, tile)) return CMD_ERROR;
|
if (!CanAircraftUseStation(p1, tile)) return CMD_ERROR;
|
||||||
|
|
||||||
/* Allocate 2 or 3 vehicle structs, depending on type
|
/* Allocate 2 or 3 vehicle structs, depending on type
|
||||||
* vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
|
* vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
|
||||||
|
|
|
@ -765,7 +765,7 @@ static void GenerateBuildAircraftList(Window *w)
|
||||||
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
|
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
|
||||||
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
|
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
|
||||||
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
|
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
|
||||||
if (w->window_number > VEH_END && !IsAircraftBuildableAtStation(eid, w->window_number)) continue;
|
if (w->window_number > VEH_END && !CanAircraftUseStation(eid, w->window_number)) continue;
|
||||||
|
|
||||||
EngList_Add(&bv->eng_list, eid);
|
EngList_Add(&bv->eng_list, eid);
|
||||||
if (eid == bv->sel_engine) sel_id = eid;
|
if (eid == bv->sel_engine) sel_id = eid;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "vehicle_gui.h"
|
#include "vehicle_gui.h"
|
||||||
#include "cargotype.h"
|
#include "cargotype.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
|
#include "aircraft.h"
|
||||||
|
|
||||||
DEFINE_OLD_POOL_GENERIC(Order, Order)
|
DEFINE_OLD_POOL_GENERIC(Order, Order)
|
||||||
|
|
||||||
|
@ -198,7 +199,9 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_AIRCRAFT:
|
case VEH_AIRCRAFT:
|
||||||
if (!(st->facilities & FACIL_AIRPORT)) return CMD_ERROR;
|
if (!(st->facilities & FACIL_AIRPORT) || !CanAircraftUseStation(v->engine_type, st)) {
|
||||||
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: return CMD_ERROR;
|
default: return CMD_ERROR;
|
||||||
|
@ -239,7 +242,8 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (!CheckOwnership(st->owner) ||
|
if (!CheckOwnership(st->owner) ||
|
||||||
!(st->facilities & FACIL_AIRPORT) ||
|
!(st->facilities & FACIL_AIRPORT) ||
|
||||||
st->Airport()->nof_depots == 0) {
|
st->Airport()->nof_depots == 0 ||
|
||||||
|
!CanAircraftUseStation(v->engine_type, st)) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1038,7 +1042,7 @@ static TileIndex GetStationTileForVehicle(const Vehicle* v, const Station* st)
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case VEH_TRAIN: return st->train_tile;
|
case VEH_TRAIN: return st->train_tile;
|
||||||
case VEH_AIRCRAFT: return st->airport_tile;
|
case VEH_AIRCRAFT: return CanAircraftUseStation(v->engine_type, st) ? st->airport_tile : 0;
|
||||||
case VEH_SHIP: return st->dock_tile;
|
case VEH_SHIP: return st->dock_tile;
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
|
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
|
||||||
|
|
Loading…
Reference in New Issue