summaryrefslogtreecommitdiff
path: root/aircraft_cmd.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-08-09 21:11:45 +0000
committerpeter1138 <peter1138@openttd.org>2006-08-09 21:11:45 +0000
commit08ae2cf6e57628e1ca3b7c2c20f405001a497417 (patch)
treebf0463cbcfcf45f33986574818350054e36d87c7 /aircraft_cmd.c
parente0d82233553a0b808a0353412716c5b8887d2cab (diff)
downloadopenttd-08ae2cf6e57628e1ca3b7c2c20f405001a497417.tar.xz
(svn r5822) - NewGRF: add support for callback 31, vehicle start/stop check. This allows a set to disallow a vehicle from being started, i.e. to not be able to leave the depot. This is almost a partner to callback 1D.
Diffstat (limited to 'aircraft_cmd.c')
-rw-r--r--aircraft_cmd.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 3136865e5..4493940ed 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -22,6 +22,7 @@
#include "table/sprites.h"
#include "newgrf_engine.h"
#include "newgrf_callbacks.h"
+#include "newgrf_text.h"
static bool AirportMove(Vehicle *v, const AirportFTAClass *Airport);
static bool AirportSetBlocks(Vehicle *v, AirportFTA *current_pos, const AirportFTAClass *Airport);
@@ -420,6 +421,7 @@ static void DoDeleteAircraft(Vehicle *v)
int32 CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
+ uint16 callback;
if (!IsVehicleIndex(p1)) return CMD_ERROR;
@@ -430,6 +432,14 @@ int32 CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
+ /* Check if this aircraft can be started/stopped. The callback will fail or
+ * return 0xFF if it can. */
+ callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v);
+ if (callback != CALLBACK_FAILED && callback != 0xFF) {
+ StringID error = GetGRFStringID(GetEngineGRFID(v->engine_type), 0xD000 + callback);
+ return_cmd_error(error);
+ }
+
if (flags & DC_EXEC) {
// Invalidate depot
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);