summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2008-03-28 22:59:43 +0000
committerbjarni <bjarni@openttd.org>2008-03-28 22:59:43 +0000
commit8837c7dcd544ec7843b76f188e6ae7d171ed43cd (patch)
treec1d00aa398a0386479d43cd3fad7ed54bbe264a5
parentd5faf2b47eca2d5cffa40d0b4f6ef26990d44a80 (diff)
downloadopenttd-8837c7dcd544ec7843b76f188e6ae7d171ed43cd.tar.xz
(svn r12482) -Fix: [build train] we don't need to have a depot in order to just check the price of a rail vehicle so don't check for compatible rails on the tile either
also wagons will only need tracks they can drive on in order to be build so there is no reason to check for power in the depot
-rw-r--r--src/train_cmd.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index e10843c77..7998a621f 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -548,6 +548,9 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 fla
uint num_vehicles = 1 + CountArticulatedParts(engine, false);
if (!(flags & DC_QUERY_COST)) {
+ /* Check that the wagon can drive on the track in question */
+ if (!IsCompatibleRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
+
/* Allow for the wagon and the articulated parts, plus one to "terminate" the list. */
Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1));
memset(vl, 0, sizeof(*vl) * (num_vehicles + 1));
@@ -702,10 +705,6 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
const RailVehicleInfo *rvi = RailVehInfo(p1);
- /* Check if depot and new engine uses the same kind of tracks */
- /* We need to see if the engine got power on the tile to avoid eletric engines in non-electric depots */
- if (!HasPowerOnRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
-
if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags);
CommandCost value = EstimateTrainCost(p1, rvi);
@@ -715,6 +714,10 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
CountArticulatedParts(p1, false);
if (!(flags & DC_QUERY_COST)) {
+ /* Check if depot and new engine uses the same kind of tracks *
+ * We need to see if the engine got power on the tile to avoid eletric engines in non-electric depots */
+ if (!HasPowerOnRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
+
/* Allow for the dual-heads and the articulated parts, plus one to "terminate" the list. */
Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1));
memset(vl, 0, sizeof(*vl) * (num_vehicles + 1));