Add convenience helpers to correctly retrieve goods entry cargo available/totals. Avoids having to check if cargo data is available before accessing it, which was missing for autorefit.
This commit is contained in:
@@ -389,7 +389,7 @@ protected:
|
||||
int diff = 0;
|
||||
|
||||
for (CargoType cargo : SetCargoBitIterator(cargo_filter)) {
|
||||
diff += (a->goods[cargo].HasData() ? a->goods[cargo].GetData().cargo.TotalCount() : 0) - (b->goods[cargo].HasData() ? b->goods[cargo].GetData().cargo.TotalCount() : 0);
|
||||
diff += a->goods[cargo].TotalCount() - b->goods[cargo].TotalCount();
|
||||
}
|
||||
|
||||
return diff < 0;
|
||||
@@ -401,7 +401,7 @@ protected:
|
||||
int diff = 0;
|
||||
|
||||
for (CargoType cargo : SetCargoBitIterator(cargo_filter)) {
|
||||
diff += (a->goods[cargo].HasData() ? a->goods[cargo].GetData().cargo.AvailableCount() : 0) - (b->goods[cargo].HasData() ? b->goods[cargo].GetData().cargo.AvailableCount() : 0);
|
||||
diff += a->goods[cargo].AvailableCount() - b->goods[cargo].AvailableCount();
|
||||
}
|
||||
|
||||
return diff < 0;
|
||||
@@ -561,7 +561,7 @@ public:
|
||||
x -= rating_width + rating_spacing;
|
||||
if (x < tr.left) break;
|
||||
}
|
||||
StationsWndShowStationRating(x, x + rating_width, tr.top, cargo_type, st->goods[cargo_type].HasData() ? st->goods[cargo_type].GetData().cargo.TotalCount() : 0, st->goods[cargo_type].rating);
|
||||
StationsWndShowStationRating(x, x + rating_width, tr.top, cargo_type, st->goods[cargo_type].TotalCount(), st->goods[cargo_type].rating);
|
||||
if (!rtl) {
|
||||
x += rating_width + rating_spacing;
|
||||
if (x > tr.right) break;
|
||||
|
||||
Reference in New Issue
Block a user