File diff r11907:e9ad0e83ab1e → r11908:0875f47fab11
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -615,25 +615,25 @@ CommandCost CmdAutoreplaceVehicle(TileIn
 
	if (HASBITS(v->vehstatus, VS_CRASHED)) return CMD_ERROR;
 

	
 
	bool free_wagon = false;
 
	if (v->type == VEH_TRAIN) {
 
		if (IsArticulatedPart(v) || IsRearDualheaded(v)) return CMD_ERROR;
 
		free_wagon = !IsFrontEngine(v);
 
		if (free_wagon && IsFrontEngine(v->First())) return CMD_ERROR;
 
	} else {
 
		if (!v->IsPrimaryVehicle()) return CMD_ERROR;
 
	}
 

	
 
	const Company *c = GetCompany(_current_company);
 
	bool wagon_removal = c->renew_keep_length;
 
	bool wagon_removal = c->settings.renew_keep_length;
 

	
 
	/* Test whether any replacement is set, before issuing a whole lot of commands that would end in nothing changed */
 
	Vehicle *w = v;
 
	bool any_replacements = false;
 
	while (w != NULL && !any_replacements) {
 
		any_replacements = (GetNewEngineType(w, c) != INVALID_ENGINE);
 
		w = (!free_wagon && w->type == VEH_TRAIN ? GetNextUnit(w) : NULL);
 
	}
 

	
 
	if (any_replacements) {
 
		bool was_stopped = free_wagon || ((v->vehstatus & VS_STOPPED) != 0);