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;
|
_standard_cargo_mask = 0;
|
||||||
|
|
||||||
_sorted_standard_cargo_specs_size = 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;
|
if (cargo->classes & CC_SPECIAL) break;
|
||||||
_sorted_standard_cargo_specs_size++;
|
_sorted_standard_cargo_specs_size++;
|
||||||
SetBit(_standard_cargo_mask, cargo->Index());
|
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)
|
#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.
|
* Loop header for iterating over 'real' cargoes, sorted by name. Phony cargoes like regearing cargoes are skipped.
|
||||||
* @param var Reference getting the cargospec.
|
* @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);
|
CargoTypes cmask = args->GetInt64(SCC_CARGO_LIST);
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
const CargoSpec *cs;
|
for (const auto &cs : _sorted_cargo_specs) {
|
||||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
|
||||||
if (!HasBit(cmask, cs->Index())) continue;
|
if (!HasBit(cmask, cs->Index())) continue;
|
||||||
|
|
||||||
if (buff >= last - 2) break; // ',' and ' '
|
if (buff >= last - 2) break; // ',' and ' '
|
||||||
|
|
|
@ -513,8 +513,7 @@ struct RefitWindow : public Window {
|
||||||
|
|
||||||
/* Loop through all cargoes in the refit mask */
|
/* Loop through all cargoes in the refit mask */
|
||||||
int current_index = 0;
|
int current_index = 0;
|
||||||
const CargoSpec *cs;
|
for (const auto &cs : _sorted_cargo_specs) {
|
||||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
|
||||||
CargoID cid = cs->Index();
|
CargoID cid = cs->Index();
|
||||||
/* Skip cargo type if it's not listed */
|
/* Skip cargo type if it's not listed */
|
||||||
if (!HasBit(cmask, cid)) {
|
if (!HasBit(cmask, cid)) {
|
||||||
|
|
Loading…
Reference in New Issue