mirror of https://github.com/OpenTTD/OpenTTD
(svn r19489) -Codechange: Introduce a had_success variable in SendAllVehiclesToDepot().
parent
c9b0e9d25f
commit
8b785ccb8a
|
@ -586,20 +586,23 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool s
|
||||||
GenerateVehicleSortList(&list, type, owner, id, vlw_flag);
|
GenerateVehicleSortList(&list, type, owner, id, vlw_flag);
|
||||||
|
|
||||||
/* Send all the vehicles to a depot */
|
/* Send all the vehicles to a depot */
|
||||||
|
bool had_success = false;
|
||||||
for (uint i = 0; i < list.Length(); i++) {
|
for (uint i = 0; i < list.Length(); i++) {
|
||||||
const Vehicle *v = list[i];
|
const Vehicle *v = list[i];
|
||||||
CommandCost ret = DoCommand(v->tile, v->index, (service ? 1 : 0) | DEPOT_DONT_CANCEL, flags, GetCmdSendToDepot(type));
|
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)
|
if (ret.Succeeded()) {
|
||||||
* In this case we know that at least one vehicle can be sent to a depot
|
had_success = true;
|
||||||
* 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 */
|
/* Return 0 if DC_EXEC is not set this is a valid goto depot command)
|
||||||
if (ret.Succeeded() && !(flags & DC_EXEC)) {
|
* In this case we know that at least one vehicle can be sent to a depot
|
||||||
return CommandCost();
|
* 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
|
/** Give a custom name to your vehicle
|
||||||
|
|
Loading…
Reference in New Issue