mirror of https://github.com/OpenTTD/OpenTTD.git
Cleanup: Replace FOR_ALL_SORTED_CARGOSPECS macro with range iterator.
This commit is contained in:
parent
de81afdf4b
commit
20ac0b4148
|
@ -181,7 +181,7 @@ void InitializeSortedCargoSpecs()
|
|||
_standard_cargo_mask = 0;
|
||||
|
||||
_sorted_standard_cargo_specs_size = 0;
|
||||
FOR_ALL_SORTED_CARGOSPECS(cargo) {
|
||||
for (const auto &cargo : _sorted_cargo_specs) {
|
||||
if (cargo->classes & CC_SPECIAL) break;
|
||||
_sorted_standard_cargo_specs_size++;
|
||||
SetBit(_standard_cargo_mask, cargo->Index());
|
||||
|
|
|
@ -156,13 +156,6 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc)
|
|||
|
||||
#define FOR_EACH_SET_CARGO_ID(var, cargo_bits) FOR_EACH_SET_BIT_EX(CargoID, var, CargoTypes, cargo_bits)
|
||||
|
||||
/**
|
||||
* Loop header for iterating over cargoes, sorted by name. This includes phony cargoes like regearing cargoes.
|
||||
* @param var Reference getting the cargospec.
|
||||
* @see CargoSpec
|
||||
*/
|
||||
#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; index < _sorted_cargo_specs.size() && (var = _sorted_cargo_specs[index], true) ; index++)
|
||||
|
||||
/**
|
||||
* Loop header for iterating over 'real' cargoes, sorted by name. Phony cargoes like regearing cargoes are skipped.
|
||||
* @param var Reference getting the cargospec.
|
||||
|
|
|
@ -1171,8 +1171,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
|||
CargoTypes cmask = args->GetInt64(SCC_CARGO_LIST);
|
||||
bool first = true;
|
||||
|
||||
const CargoSpec *cs;
|
||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
||||
for (const auto &cs : _sorted_cargo_specs) {
|
||||
if (!HasBit(cmask, cs->Index())) continue;
|
||||
|
||||
if (buff >= last - 2) break; // ',' and ' '
|
||||
|
|
|
@ -513,8 +513,7 @@ struct RefitWindow : public Window {
|
|||
|
||||
/* Loop through all cargoes in the refit mask */
|
||||
int current_index = 0;
|
||||
const CargoSpec *cs;
|
||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
||||
for (const auto &cs : _sorted_cargo_specs) {
|
||||
CargoID cid = cs->Index();
|
||||
/* Skip cargo type if it's not listed */
|
||||
if (!HasBit(cmask, cid)) {
|
||||
|
|
Loading…
Reference in New Issue