summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-12-17 21:22:10 +0000
committerfrosch <frosch@openttd.org>2011-12-17 21:22:10 +0000
commitfba9c756c7f19f1cac41502debeccf7ffd8dd58d (patch)
tree1412865c7010d64a5d1a4f3a21554c1b77bf23be /src
parentd0e7b0fd9df6fda297bbfdc9037e730143fe2efc (diff)
downloadopenttd-fba9c756c7f19f1cac41502debeccf7ffd8dd58d.tar.xz
(svn r23581) -Fix (r23518) [FS#4890]: Cloning of vehicles crashed.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle_cmd.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 3dd4943d8..0e4cefc0d 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -207,7 +207,15 @@ CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
return ret;
}
-/** Helper to run the refit cost callback. */
+/**
+ * Helper to run the refit cost callback.
+ * @param v The vehicle we are refitting, can be NULL.
+ * @param engine_type Which engine to refit
+ * @param new_cid Cargo type we are refitting to.
+ * @param new_subtype New cargo subtype.
+ * @param [out] auto_refit_allowed The refit is allowed as an auto-refit.
+ * @return Price for refitting
+ */
static int GetRefitCostFactor(const Vehicle *v, EngineID engine_type, CargoID new_cid, byte new_subtype, bool *auto_refit_allowed)
{
/* Prepare callback param with info about the new cargo type. */
@@ -228,7 +236,7 @@ static int GetRefitCostFactor(const Vehicle *v, EngineID engine_type, CargoID ne
}
*auto_refit_allowed = e->info.refit_cost == 0;
- return (v->cargo_type != new_cid) ? e->info.refit_cost : 0;
+ return (v == NULL || v->cargo_type != new_cid) ? e->info.refit_cost : 0;
}
/**
@@ -237,8 +245,8 @@ static int GetRefitCostFactor(const Vehicle *v, EngineID engine_type, CargoID ne
* @param engine_type Which engine to refit
* @param new_cid Cargo type we are refitting to.
* @param new_subtype New cargo subtype.
+ * @param [out] auto_refit_allowed The refit is allowed as an auto-refit.
* @return Price for refitting
- * @return[out] auto_refit_allowed The refit is allowed as an auto-refit.
*/
static CommandCost GetRefitCost(const Vehicle *v, EngineID engine_type, CargoID new_cid, byte new_subtype, bool *auto_refit_allowed)
{