diff options
author | peter1138 <peter1138@openttd.org> | 2006-08-09 21:11:45 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-08-09 21:11:45 +0000 |
commit | 08ae2cf6e57628e1ca3b7c2c20f405001a497417 (patch) | |
tree | bf0463cbcfcf45f33986574818350054e36d87c7 /train_cmd.c | |
parent | e0d82233553a0b808a0353412716c5b8887d2cab (diff) | |
download | openttd-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 'train_cmd.c')
-rw-r--r-- | train_cmd.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/train_cmd.c b/train_cmd.c index 1bcc1bffa..8afe5d75b 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -1227,6 +1227,7 @@ int32 CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) int32 CmdStartStopTrain(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { Vehicle *v; + uint16 callback; if (!IsVehicleIndex(p1)) return CMD_ERROR; @@ -1234,6 +1235,14 @@ int32 CmdStartStopTrain(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; + /* Check if this train 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 (v->vehstatus & VS_STOPPED && v->u.rail.track == 0x80) { DeleteVehicleNews(p1, STR_8814_TRAIN_IS_WAITING_IN_DEPOT); |