1
0
Fork 0

Compare commits

..

No commits in common. "bec36c1f9853000a2814ce4c8b690984339ebc08" and "6d675c8acfe7f854a740118c1aba300b107007b5" have entirely different histories.

6 changed files with 31 additions and 24 deletions

View File

@ -42,6 +42,7 @@ jobs:
liblzma-dev \ liblzma-dev \
liblzo2-dev \ liblzo2-dev \
libsdl2-dev \ libsdl2-dev \
nlohmann-json3-dev \
zlib1g-dev \ zlib1g-dev \
# EOF # EOF
echo "::endgroup::" echo "::endgroup::"

View File

@ -385,8 +385,15 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTri
uint32_t whole_reseed = 0; uint32_t whole_reseed = 0;
/* Bitmask of completely empty cargo types to be matched. */ CargoTypes empty_mask = 0;
CargoTypes empty_mask = (trigger == RSRT_CARGO_TAKEN) ? GetEmptyMask(st) : 0; if (trigger == RSRT_CARGO_TAKEN) {
/* Create a bitmask of completely empty cargo types to be matched */
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (st->goods[i].cargo.TotalCount() == 0) {
SetBit(empty_mask, i);
}
}
}
uint32_t used_triggers = 0; uint32_t used_triggers = 0;
auto process_tile = [&](TileIndex cur_tile) { auto process_tile = [&](TileIndex cur_tile) {

View File

@ -391,7 +391,12 @@ uint32_t Station::GetNewGRFVariable(const ResolverObject &object, byte variable,
{ {
switch (variable) { switch (variable) {
case 0x48: { // Accepted cargo types case 0x48: { // Accepted cargo types
uint32_t value = GetAcceptanceMask(this); CargoID cargo_type;
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;
} }
@ -962,8 +967,15 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan
uint32_t whole_reseed = 0; uint32_t whole_reseed = 0;
ETileArea area = ETileArea(st, trigger_tile, tas[trigger]); ETileArea area = ETileArea(st, trigger_tile, tas[trigger]);
/* Bitmask of completely empty cargo types to be matched. */ CargoTypes empty_mask = 0;
CargoTypes empty_mask = (trigger == SRT_CARGO_TAKEN) ? GetEmptyMask(st) : 0; if (trigger == SRT_CARGO_TAKEN) {
/* Create a bitmask of completely empty cargo types to be matched */
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (st->goods[i].cargo.TotalCount() == 0) {
SetBit(empty_mask, i);
}
}
}
/* Store triggers now for var 5F */ /* Store triggers now for var 5F */
SetBit(st->waiting_triggers, trigger); SetBit(st->waiting_triggers, trigger);

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
*/ */
CargoTypes GetAcceptanceMask(const Station *st) static CargoTypes GetAcceptanceMask(const Station *st)
{ {
CargoTypes mask = 0; CargoTypes mask = 0;
@ -502,21 +502,6 @@ CargoTypes GetAcceptanceMask(const Station *st)
return mask; return mask;
} }
/**
* Get a mask of the cargo types that are empty at the station.
* @param st Station to query
* @return the empty mask
*/
CargoTypes GetEmptyMask(const Station *st)
{
CargoTypes mask = 0;
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (st->goods[i].cargo.TotalCount() == 0) SetBit(mask, i);
}
return mask;
}
/** /**
* Items contains the two cargo names that are to be accepted or rejected. * Items contains the two cargo names that are to be accepted or rejected.
* msg is the string id of the message to display. * msg is the string id of the message to display.

View File

@ -30,8 +30,6 @@ 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);
CargoTypes GetEmptyMask(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,7 +1835,11 @@ 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);
SetDParam(0, GetAcceptanceMask(st)); CargoTypes cargo_mask = 0;
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);
} }