summaryrefslogtreecommitdiff
path: root/src/autoreplace_cmd.cpp
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2008-01-19 23:34:52 +0000
committerbjarni <bjarni@openttd.org>2008-01-19 23:34:52 +0000
commit9fdf784b7c87567d43546152367c89909ff753c4 (patch)
tree7afaef32fd8a76ab03791943c4a87e2a8a5d3413 /src/autoreplace_cmd.cpp
parent52e5f50158d6e58e47ba5df53bff16a7db82eea9 (diff)
downloadopenttd-9fdf784b7c87567d43546152367c89909ff753c4.tar.xz
(svn r11929) -Fix (r9981)[FS#1624]: [autoreplace] fixed a case where a single headed locomotive caused an assert when being replaced to a dualheaded one
This triggered if the player had enough money to replace and refit one of them but not enough to refit the last one as well
Diffstat (limited to 'src/autoreplace_cmd.cpp')
-rw-r--r--src/autoreplace_cmd.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index ef5e0d70f..b451be8de 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -21,6 +21,7 @@
#include "functions.h"
#include "variables.h"
#include "autoreplace_func.h"
+#include "articulated_vehicles.h"
#include "table/strings.h"
@@ -175,7 +176,10 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
if (replacement_cargo_type != CT_NO_REFIT) {
/* add refit cost */
CommandCost refit_cost = GetRefitCost(new_engine_type);
- if (old_v->type == VEH_TRAIN && IsMultiheaded(old_v)) refit_cost.AddCost(refit_cost); // pay for both ends
+ if (old_v->type == VEH_TRAIN && RailVehInfo(new_engine_type)->railveh_type == RAILVEH_MULTIHEAD) {
+ /* Since it's a dualheaded engine we have to pay once more because the rear end is being refitted too. */
+ refit_cost.AddCost(refit_cost);
+ }
cost.AddCost(refit_cost);
}