(svn r9981) -Fix: fixed a rare event that could cause autoreplace to run out of money and generate an error (spotted by elmex and UndernotBuilder)
authorbjarni
Tue, 29 May 2007 20:06:06 +0000
changeset 6746 ec46969766e3
parent 6745 238ec04a86d4
child 6747 5c696ce73fb3
(svn r9981) -Fix: fixed a rare event that could cause autoreplace to run out of money and generate an error (spotted by elmex and UndernotBuilder)
This happened if the new engine was a dualheaded engine and there was money to replace and refit the front, but not the rear
It also adds the cost of refitting the rear end of dualheaded engines to the cost animations (display only)
src/autoreplace_cmd.cpp
--- a/src/autoreplace_cmd.cpp	Tue May 29 19:01:38 2007 +0000
+++ b/src/autoreplace_cmd.cpp	Tue May 29 20:06:06 2007 +0000
@@ -171,7 +171,12 @@
 		return cost;
 	}
 
-	if (replacement_cargo_type != CT_NO_REFIT) cost += GetRefitCost(new_engine_type); // add refit cost
+	if (replacement_cargo_type != CT_NO_REFIT) {
+		/* add refit cost */
+		int32 refit_cost = GetRefitCost(new_engine_type);
+		if (old_v->type == VEH_TRAIN && IsMultiheaded(old_v)) refit_cost += refit_cost; // pay for both ends
+		cost += refit_cost;
+	}
 
 	if (flags & DC_EXEC) {
 		new_v = GetVehicle(_new_vehicle_id);