Changeset - r27965:3f8e6a8f9dfd
[Not reviewed]
master
0 4 0
Peter Nelson - 15 months ago 2023-09-21 07:38:46
peter1138@openttd.org
Codechange: Use new function to get a bitmask of empty cargo types.
4 files changed with 20 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/newgrf_roadstop.cpp
Show inline comments
 
@@ -385,15 +385,8 @@ void TriggerRoadStopRandomisation(Statio
 

	
 
	uint32_t whole_reseed = 0;
 

	
 
	CargoTypes empty_mask = 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);
 
			}
 
		}
 
	}
 
	/* Bitmask of completely empty cargo types to be matched. */
 
	CargoTypes empty_mask = (trigger == RSRT_CARGO_TAKEN) ? GetEmptyMask(st) : 0;
 

	
 
	uint32_t used_triggers = 0;
 
	auto process_tile = [&](TileIndex cur_tile) {
src/newgrf_station.cpp
Show inline comments
 
@@ -962,15 +962,8 @@ void TriggerStationRandomisation(Station
 
	uint32_t whole_reseed = 0;
 
	ETileArea area = ETileArea(st, trigger_tile, tas[trigger]);
 

	
 
	CargoTypes empty_mask = 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);
 
			}
 
		}
 
	}
 
	/* Bitmask of completely empty cargo types to be matched. */
 
	CargoTypes empty_mask = (trigger == SRT_CARGO_TAKEN) ? GetEmptyMask(st) : 0;
 

	
 
	/* Store triggers now for var 5F */
 
	SetBit(st->waiting_triggers, trigger);
src/station_cmd.cpp
Show inline comments
 
@@ -503,6 +503,21 @@ CargoTypes GetAcceptanceMask(const Stati
 
}
 

	
 
/**
 
 * 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.
 
 * msg is the string id of the message to display.
 
 */
src/station_func.h
Show inline comments
 
@@ -31,6 +31,7 @@ CargoArray GetAcceptanceAroundTiles(Tile
 

	
 
void UpdateStationAcceptance(Station *st, bool show_msg);
 
CargoTypes GetAcceptanceMask(const Station *st);
 
CargoTypes GetEmptyMask(const Station *st);
 

	
 
const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
 
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);
0 comments (0 inline, 0 general)