summaryrefslogtreecommitdiff
path: root/ship_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
commit8048e8c5bd4ab015715fbdb616c3b7306b396ff0 (patch)
treebf0463cbcfcf45f33986574818350054e36d87c7 /ship_cmd.c
parentacaa043d6f9c45e5d0681dbd1a9f3ddafc4b9b2d (diff)
downloadopenttd-8048e8c5bd4ab015715fbdb616c3b7306b396ff0.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 'ship_cmd.c')
-rw-r--r--ship_cmd.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ship_cmd.c b/ship_cmd.c
index a47882f11..7b5737559 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -24,6 +24,7 @@
#include "yapf/yapf.h"
#include "debug.h"
#include "newgrf_callbacks.h"
+#include "newgrf_text.h"
static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
static const byte _ship_sometracks[4] = {0x19, 0x16, 0x25, 0x2A};
@@ -958,6 +959,7 @@ int32 CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
int32 CmdStartStopShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
+ uint16 callback;
if (!IsVehicleIndex(p1)) return CMD_ERROR;
@@ -965,6 +967,14 @@ int32 CmdStartStopShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->type != VEH_Ship || !CheckOwnership(v->owner)) return CMD_ERROR;
+ /* Check if this ship 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) {
if (IsShipInDepotStopped(v)) {
DeleteVehicleNews(p1, STR_981C_SHIP_IS_WAITING_IN_DEPOT);