changeset 19479:5c205cdec645 draft

(svn r24382) -Fix: Call Vehicle::IsStoppedInDepot only for the first vehicle in a chain (i.e. primary vehicle or free wagon).
author frosch <frosch@openttd.org>
date Sat, 07 Jul 2012 15:35:28 +0000
parents 96a2f0d3d7ba
children 9f04c1f10367
files src/autoreplace_cmd.cpp src/roadveh_cmd.cpp src/train_cmd.cpp src/vehicle_cmd.cpp
diffstat 4 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -702,7 +702,7 @@
 		if (!was_stopped) cost.AddCost(CmdStartStopVehicle(v, true));
 		if (cost.Failed()) return cost;
 
-		assert(v->IsStoppedInDepot());
+		assert(free_wagon || v->IsStoppedInDepot());
 
 		/* We have to construct the new vehicle chain to test whether it is valid.
 		 * Vehicle construction needs random bits, so we have to save the random seeds
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -356,6 +356,8 @@
 	RoadVehicle *v = RoadVehicle::GetIfValid(p1);
 	if (v == NULL) return CMD_ERROR;
 
+	if (!v->IsPrimaryVehicle()) return CMD_ERROR;
+
 	CommandCost ret = CheckOwnership(v->owner);
 	if (ret.Failed()) return ret;
 
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1934,6 +1934,8 @@
 	Train *t = Train::GetIfValid(p1);
 	if (t == NULL) return CMD_ERROR;
 
+	if (!t->IsPrimaryVehicle()) return CMD_ERROR;
+
 	CommandCost ret = CheckOwnership(t->owner);
 	if (ret.Failed()) return ret;
 
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -991,6 +991,7 @@
 
 	Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
 	if (v == NULL) return CMD_ERROR;
+	if (!v->IsPrimaryVehicle()) return CMD_ERROR;
 
 	return v->SendToDepot(flags, (DepotCommand)(p1 & DEPOT_COMMAND_MASK));
 }