mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use new function to get a bitmask of empty cargo types.
parent
69ee38bd43
commit
398c7e5f9d
|
@ -385,15 +385,8 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTri
|
||||||
|
|
||||||
uint32_t whole_reseed = 0;
|
uint32_t whole_reseed = 0;
|
||||||
|
|
||||||
CargoTypes empty_mask = 0;
|
/* Bitmask of completely empty cargo types to be matched. */
|
||||||
if (trigger == RSRT_CARGO_TAKEN) {
|
CargoTypes empty_mask = (trigger == RSRT_CARGO_TAKEN) ? GetEmptyMask(st) : 0;
|
||||||
/* 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) {
|
||||||
|
|
|
@ -962,15 +962,8 @@ 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]);
|
||||||
|
|
||||||
CargoTypes empty_mask = 0;
|
/* Bitmask of completely empty cargo types to be matched. */
|
||||||
if (trigger == SRT_CARGO_TAKEN) {
|
CargoTypes empty_mask = (trigger == SRT_CARGO_TAKEN) ? GetEmptyMask(st) : 0;
|
||||||
/* 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);
|
||||||
|
|
|
@ -502,6 +502,21 @@ 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.
|
||||||
|
|
|
@ -31,6 +31,7 @@ CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, Cargo
|
||||||
|
|
||||||
void UpdateStationAcceptance(Station *st, bool show_msg);
|
void UpdateStationAcceptance(Station *st, bool show_msg);
|
||||||
CargoTypes GetAcceptanceMask(const Station *st);
|
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);
|
||||||
|
|
Loading…
Reference in New Issue