1
0
Fork 0

Codechange: Use GetAcceptanceMask() instead of duplicating it.

pull/11331/head
Peter Nelson 2023-09-21 08:29:10 +01:00 committed by PeterN
parent 6d675c8acf
commit 69ee38bd43
4 changed files with 4 additions and 12 deletions

View File

@ -391,12 +391,7 @@ uint32_t Station::GetNewGRFVariable(const ResolverObject &object, byte variable,
{ {
switch (variable) { switch (variable) {
case 0x48: { // Accepted cargo types case 0x48: { // Accepted cargo types
CargoID cargo_type; uint32_t value = GetAcceptanceMask(this);
uint32_t value = 0;
for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
if (HasBit(this->goods[cargo_type].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(value, cargo_type);
}
return value; return value;
} }

View File

@ -492,7 +492,7 @@ void ClearAllStationCachedNames()
* @param st Station to query * @param st Station to query
* @return the expected mask * @return the expected mask
*/ */
static CargoTypes GetAcceptanceMask(const Station *st) CargoTypes GetAcceptanceMask(const Station *st)
{ {
CargoTypes mask = 0; CargoTypes mask = 0;

View File

@ -30,6 +30,7 @@ CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad);
CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, CargoTypes *always_accepted = nullptr); CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, CargoTypes *always_accepted = nullptr);
void UpdateStationAcceptance(Station *st, bool show_msg); void UpdateStationAcceptance(Station *st, bool show_msg);
CargoTypes GetAcceptanceMask(const Station *st);
const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx); const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image); void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);

View File

@ -1835,11 +1835,7 @@ struct StationViewWindow : public Window {
const Station *st = Station::Get(this->window_number); const Station *st = Station::Get(this->window_number);
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
CargoTypes cargo_mask = 0; SetDParam(0, GetAcceptanceMask(st));
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(cargo_mask, i);
}
SetDParam(0, cargo_mask);
int bottom = DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO); int bottom = DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);
return CeilDiv(bottom - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL); return CeilDiv(bottom - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL);
} }