From 5a86b502c2f553096f88d7f84241e0f3e581fcb2 Mon Sep 17 00:00:00 2001 From: bjarni Date: Sat, 2 Sep 2006 22:47:45 +0000 Subject: [PATCH] (svn r6352) -Fix: FS#322 Send to depot bug now vehicles can't be sent to a depot when they are already inside a depot before they would remember the order and try to turn around when leaving the depot --- aircraft_cmd.c | 2 +- roadveh_cmd.c | 2 ++ ship_cmd.c | 2 ++ train_cmd.c | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/aircraft_cmd.c b/aircraft_cmd.c index f6c9910440..795a085409 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -509,7 +509,7 @@ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2 v = GetVehicle(p1); - if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR; + if (v->type != VEH_Aircraft || !CheckOwnership(v->owner) || IsAircraftInHangar(v)) return CMD_ERROR; if (v->current_order.type == OT_GOTO_DEPOT && !(p2 & DEPOT_LOCATE_HANGAR)) { if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) { diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 70dadb89be..0b37503e4f 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -380,6 +380,8 @@ int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (v->vehstatus & VS_CRASHED) return CMD_ERROR; + if (IsRoadVehInDepot(v)) return CMD_ERROR; + /* If the current orders are already goto-depot */ if (v->current_order.type == OT_GOTO_DEPOT) { if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) { diff --git a/ship_cmd.c b/ship_cmd.c index 7cd4ddccd4..68ce0073a5 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -1018,6 +1018,8 @@ int32 CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (v->vehstatus & VS_CRASHED) return CMD_ERROR; + if (IsShipInDepot(v)) return CMD_ERROR; + /* If the current orders are already goto-depot */ if (v->current_order.type == OT_GOTO_DEPOT) { if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) { diff --git a/train_cmd.c b/train_cmd.c index 3e69da86c8..79457b5d2c 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -1973,6 +1973,10 @@ int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) return 0; } + /* check if at a standstill (not stopped only) in a depot + * the check is down here to make it possible to alter stop/service for trains entering the depot */ + if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && v->cur_speed == 0) return CMD_ERROR; + tfdd = FindClosestTrainDepot(v, 0); if (tfdd.best_length == (uint)-1) return_cmd_error(STR_883A_UNABLE_TO_FIND_ROUTE_TO);