mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Remove FOR_EACH_SET_CARGO_ID
This commit is contained in:
parent
89ab8b79a5
commit
a543a4b7bb
|
@ -15,6 +15,7 @@
|
|||
#include "gfx_type.h"
|
||||
#include "strings_type.h"
|
||||
#include "landscape_type.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "core/span_type.hpp"
|
||||
#include <vector>
|
||||
|
||||
|
@ -195,6 +196,6 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc)
|
|||
return (CargoSpec::Get(c)->classes & cc) != 0;
|
||||
}
|
||||
|
||||
#define FOR_EACH_SET_CARGO_ID(var, cargo_bits) FOR_EACH_SET_BIT_EX(CargoID, var, CargoTypes, cargo_bits)
|
||||
using SetCargoBitIterator = SetBitIterator<CargoID, CargoTypes>;
|
||||
|
||||
#endif /* CARGOTYPE_H */
|
||||
|
|
|
@ -1480,9 +1480,8 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
|
|||
bool is_auto_refit = new_cid == CT_AUTO_REFIT;
|
||||
if (is_auto_refit) {
|
||||
/* Get a refittable cargo type with waiting cargo for next_station or INVALID_STATION. */
|
||||
CargoID cid;
|
||||
new_cid = v_start->cargo_type;
|
||||
FOR_EACH_SET_CARGO_ID(cid, refit_mask) {
|
||||
for (CargoID cid : SetCargoBitIterator(refit_mask)) {
|
||||
if (st->goods[cid].cargo.HasCargoFor(next_station)) {
|
||||
/* Try to find out if auto-refitting would succeed. In case the refit is allowed,
|
||||
* the returned refit capacity will be greater than zero. */
|
||||
|
|
|
@ -65,8 +65,7 @@ void LinkGraphOverlay::RebuildCache()
|
|||
StationLinkMap &seen_links = this->cached_links[from];
|
||||
|
||||
uint supply = 0;
|
||||
CargoID c;
|
||||
FOR_EACH_SET_CARGO_ID(c, this->cargo_mask) {
|
||||
for (CargoID c : SetCargoBitIterator(this->cargo_mask)) {
|
||||
if (!CargoSpec::Get(c)->IsValid()) continue;
|
||||
if (!LinkGraph::IsValidID(sta->goods[c].link_graph)) continue;
|
||||
const LinkGraph &lg = *LinkGraph::Get(sta->goods[c].link_graph);
|
||||
|
@ -192,8 +191,7 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe
|
|||
*/
|
||||
void LinkGraphOverlay::AddLinks(const Station *from, const Station *to)
|
||||
{
|
||||
CargoID c;
|
||||
FOR_EACH_SET_CARGO_ID(c, this->cargo_mask) {
|
||||
for (CargoID c : SetCargoBitIterator(this->cargo_mask)) {
|
||||
if (!CargoSpec::Get(c)->IsValid()) continue;
|
||||
const GoodsEntry &ge = from->goods[c];
|
||||
if (!LinkGraph::IsValidID(ge.link_graph) ||
|
||||
|
|
|
@ -8902,8 +8902,7 @@ static void CalculateRefitMasks()
|
|||
if (cargo_map_for_first_refittable != nullptr) {
|
||||
/* Use first refittable cargo from cargo translation table */
|
||||
byte best_local_slot = 0xFF;
|
||||
CargoID cargo_type;
|
||||
FOR_EACH_SET_CARGO_ID(cargo_type, ei->refit_mask) {
|
||||
for (CargoID cargo_type : SetCargoBitIterator(ei->refit_mask)) {
|
||||
byte local_slot = cargo_map_for_first_refittable[cargo_type];
|
||||
if (local_slot < best_local_slot) {
|
||||
best_local_slot = local_slot;
|
||||
|
|
|
@ -273,8 +273,7 @@ protected:
|
|||
{
|
||||
int diff = 0;
|
||||
|
||||
CargoID j;
|
||||
FOR_EACH_SET_CARGO_ID(j, cargo_filter) {
|
||||
for (CargoID j : SetCargoBitIterator(cargo_filter)) {
|
||||
diff += a->goods[j].cargo.TotalCount() - b->goods[j].cargo.TotalCount();
|
||||
}
|
||||
|
||||
|
@ -286,8 +285,7 @@ protected:
|
|||
{
|
||||
int diff = 0;
|
||||
|
||||
CargoID j;
|
||||
FOR_EACH_SET_CARGO_ID(j, cargo_filter) {
|
||||
for (CargoID j : SetCargoBitIterator(cargo_filter)) {
|
||||
diff += a->goods[j].cargo.AvailableCount() - b->goods[j].cargo.AvailableCount();
|
||||
}
|
||||
|
||||
|
@ -300,8 +298,7 @@ protected:
|
|||
byte maxr1 = 0;
|
||||
byte maxr2 = 0;
|
||||
|
||||
CargoID j;
|
||||
FOR_EACH_SET_CARGO_ID(j, cargo_filter) {
|
||||
for (CargoID j : SetCargoBitIterator(cargo_filter)) {
|
||||
if (a->goods[j].HasRating()) maxr1 = std::max(maxr1, a->goods[j].rating);
|
||||
if (b->goods[j].HasRating()) maxr2 = std::max(maxr2, b->goods[j].rating);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue