Changeset - r14883:f2e33dc52358
[Not reviewed]
master
0 1 0
alberth - 14 years ago 2010-03-20 17:10:14
alberth@openttd.org
(svn r19489) -Codechange: Introduce a had_success variable in SendAllVehiclesToDepot().
1 file changed with 10 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/vehicle_cmd.cpp
Show inline comments
 
@@ -586,20 +586,23 @@ CommandCost SendAllVehiclesToDepot(Vehic
 
	GenerateVehicleSortList(&list, type, owner, id, vlw_flag);
 

	
 
	/* Send all the vehicles to a depot */
 
	bool had_success = false;
 
	for (uint i = 0; i < list.Length(); i++) {
 
		const Vehicle *v = list[i];
 
		CommandCost ret = DoCommand(v->tile, v->index, (service ? 1 : 0) | DEPOT_DONT_CANCEL, flags, GetCmdSendToDepot(type));
 

	
 
		/* Return 0 if DC_EXEC is not set this is a valid goto depot command)
 
		 * In this case we know that at least one vehicle can be sent to a depot
 
		 * and we will issue the command. We can now safely quit the loop, knowing
 
		 * it will succeed at least once. With DC_EXEC we really need to send them to the depot */
 
		if (ret.Succeeded() && !(flags & DC_EXEC)) {
 
			return CommandCost();
 
		if (ret.Succeeded()) {
 
			had_success = true;
 

	
 
			/* Return 0 if DC_EXEC is not set this is a valid goto depot command)
 
			 * In this case we know that at least one vehicle can be sent to a depot
 
			 * and we will issue the command. We can now safely quit the loop, knowing
 
			 * it will succeed at least once. With DC_EXEC we really need to send them to the depot */
 
			if (!(flags & DC_EXEC)) break;
 
		}
 
	}
 

	
 
	return (flags & DC_EXEC) ? CommandCost() : CMD_ERROR;
 
	return had_success ? CommandCost() : CMD_ERROR;
 
}
 

	
 
/** Give a custom name to your vehicle
0 comments (0 inline, 0 general)