Changeset - r28705:ff62c6727ae4
[Not reviewed]
master
0 1 0
Peter Nelson - 10 months ago 2024-02-07 12:07:00
peter1138@openttd.org
Fix: Don't issue autoreplace failed news message for command test mode. (#12026)
1 file changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -315,9 +315,10 @@ static CommandCost GetNewEngineType(cons
 
 * @param old_veh A single (articulated/multiheaded) vehicle that shall be replaced.
 
 * @param new_vehicle Returns the newly build and refitted vehicle
 
 * @param part_of_chain The vehicle is part of a train
 
 * @param flags The calling command flags.
 
 * @return cost or error
 
 */
 
static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehicle, bool part_of_chain)
 
static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehicle, bool part_of_chain, DoCommandFlag flags)
 
{
 
	*new_vehicle = nullptr;
 

	
 
@@ -331,7 +332,7 @@ static CommandCost BuildReplacementVehic
 
	/* Does it need to be refitted */
 
	CargoID refit_cargo = GetNewCargoTypeForReplace(old_veh, e, part_of_chain);
 
	if (!IsValidCargoID(refit_cargo)) {
 
		if (!IsLocalCompany()) return CommandCost();
 
		if (!IsLocalCompany() || (flags & DC_EXEC) == 0) return CommandCost();
 

	
 
		VehicleID old_veh_id = (old_veh->type == VEH_TRAIN) ? Train::From(old_veh)->First()->index : old_veh->index;
 
		SetDParam(0, old_veh_id);
 
@@ -456,7 +457,7 @@ static CommandCost ReplaceFreeUnit(Vehic
 

	
 
	/* Build and refit replacement vehicle */
 
	Vehicle *new_v = nullptr;
 
	cost.AddCost(BuildReplacementVehicle(old_v, &new_v, false));
 
	cost.AddCost(BuildReplacementVehicle(old_v, &new_v, false, flags));
 

	
 
	/* Was a new vehicle constructed? */
 
	if (cost.Succeeded() && new_v != nullptr) {
 
@@ -532,7 +533,7 @@ static CommandCost ReplaceChain(Vehicle 
 
		for (Train *w = Train::From(old_head); w != nullptr; w = w->GetNextUnit()) {
 
			ReplaceChainItem &replacement = replacements.emplace_back(w, nullptr, 0);
 

	
 
			CommandCost ret = BuildReplacementVehicle(replacement.old_veh, &replacement.new_veh, true);
 
			CommandCost ret = BuildReplacementVehicle(replacement.old_veh, &replacement.new_veh, true, flags);
 
			cost.AddCost(ret);
 
			if (cost.Failed()) break;
 

	
 
@@ -689,7 +690,7 @@ static CommandCost ReplaceChain(Vehicle 
 
	} else {
 
		/* Build and refit replacement vehicle */
 
		Vehicle *new_head = nullptr;
 
		cost.AddCost(BuildReplacementVehicle(old_head, &new_head, true));
 
		cost.AddCost(BuildReplacementVehicle(old_head, &new_head, true, flags));
 

	
 
		/* Was a new vehicle constructed? */
 
		if (cost.Succeeded() && new_head != nullptr) {
0 comments (0 inline, 0 general)