From d8f8909f859eb900ceaf8897537b2f46d970b308 Mon Sep 17 00:00:00 2001 From: frosch Date: Tue, 8 Nov 2011 17:24:43 +0000 Subject: (svn r23142) -Change: [NewGRF v8] Unify the return values of callbacks returning D0xx texts. --- src/vehicle_cmd.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/vehicle_cmd.cpp') diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index a237b1941..089fb0ec4 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -491,12 +491,30 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, default: return CMD_ERROR; } - /* Check if this vehicle can be started/stopped. The callback will fail or - * return 0xFF if it can. */ - uint16 callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); - if (callback != CALLBACK_FAILED && GB(callback, 0, 8) != 0xFF && HasBit(p2, 0)) { - StringID error = GetGRFStringID(v->GetGRFID(), 0xD000 + callback); - return_cmd_error(error); + if (HasBit(p2, 0)) { + /* Check if this vehicle can be started/stopped. Failure means 'allow'. */ + uint16 callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); + StringID error = STR_NULL; + if (callback != CALLBACK_FAILED) { + if (v->GetGRF()->grf_version < 8) { + /* 8 bit result 0xFF means 'allow' */ + if (callback < 0x400 && GB(callback, 0, 8) != 0xFF) error = GetGRFStringID(v->GetGRFID(), 0xD000 + callback); + } else { + if (callback < 0x400) { + error = GetGRFStringID(v->GetGRFID(), 0xD000 + callback); + } else { + switch (callback) { + case 0x400: // allow + break; + + default: // unknown reason -> disallow + error = STR_ERROR_INCOMPATIBLE_RAIL_TYPES; + break; + } + } + } + } + if (error != STR_NULL) return_cmd_error(error); } if (flags & DC_EXEC) { -- cgit v1.2.3-54-g00ecf