mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Codechange: Use reference for always_accepted output parameter of AddAcceptedCargo. (#12854)
This parameter should always present (see tile_cmd.h:186), so use a reference to ensure it is.
This commit is contained in:
parent
60c3913a99
commit
93eb27d8df
@ -409,7 +409,7 @@ static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh)
|
||||
return FlatteningFoundation(tileh);
|
||||
}
|
||||
|
||||
static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted)
|
||||
static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, CargoTypes &always_accepted)
|
||||
{
|
||||
IndustryGfx gfx = GetIndustryGfx(tile);
|
||||
const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
|
||||
@ -459,13 +459,13 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca
|
||||
acceptance[a] += cargo_acceptance[i];
|
||||
|
||||
/* Maybe set 'always accepted' bit (if it's not set already) */
|
||||
if (HasBit(*always_accepted, a)) continue;
|
||||
if (HasBit(always_accepted, a)) continue;
|
||||
|
||||
/* Test whether the industry itself accepts the cargo type */
|
||||
if (ind->IsCargoAccepted(a)) continue;
|
||||
|
||||
/* If the industry itself doesn't accept this cargo, set 'always accepted' bit */
|
||||
SetBit(*always_accepted, a);
|
||||
SetBit(always_accepted, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
||||
return cost;
|
||||
}
|
||||
|
||||
static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted)
|
||||
static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, CargoTypes &always_accepted)
|
||||
{
|
||||
if (!IsObjectType(tile, OBJECT_HQ)) return;
|
||||
|
||||
@ -632,7 +632,7 @@ static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, Carg
|
||||
CargoID pass = GetCargoIDByLabel(CT_PASSENGERS);
|
||||
if (IsValidCargoID(pass)) {
|
||||
acceptance[pass] += std::max(1U, level);
|
||||
SetBit(*always_accepted, pass);
|
||||
SetBit(always_accepted, pass);
|
||||
}
|
||||
|
||||
/* Top town building generates 4, HQ can make up to 8. The
|
||||
@ -642,7 +642,7 @@ static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, Carg
|
||||
CargoID mail = GetCargoIDByLabel(CT_MAIL);
|
||||
if (IsValidCargoID(mail)) {
|
||||
acceptance[mail] += std::max(1U, level / 2);
|
||||
SetBit(*always_accepted, mail);
|
||||
SetBit(always_accepted, mail);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlag flags);
|
||||
* @param acceptance Storage destination of the cargo acceptance in 1/8
|
||||
* @param always_accepted Bitmask of always accepted cargo types
|
||||
*/
|
||||
typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted);
|
||||
typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, CargoTypes &always_accepted);
|
||||
|
||||
/**
|
||||
* Tile callback function signature for obtaining a tile description
|
||||
@ -184,7 +184,7 @@ inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, CargoTypes
|
||||
AddAcceptedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_accepted_cargo_proc;
|
||||
if (proc == nullptr) return;
|
||||
CargoTypes dummy = 0; // use dummy bitmask so there don't need to be several 'always_accepted != nullptr' checks
|
||||
proc(tile, acceptance, always_accepted == nullptr ? &dummy : always_accepted);
|
||||
proc(tile, acceptance, always_accepted == nullptr ? dummy : *always_accepted);
|
||||
}
|
||||
|
||||
inline void AddProducedCargo(TileIndex tile, CargoArray &produced)
|
||||
|
@ -771,14 +771,21 @@ static void AddProducedCargo_Town(TileIndex tile, CargoArray &produced)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void AddAcceptedCargoSetMask(CargoID cargo, uint amount, CargoArray &acceptance, CargoTypes *always_accepted)
|
||||
/**
|
||||
* Fill cargo acceptance array and always_accepted mask, if cargo ID is valid.
|
||||
* @param cargo Cargo type to add.
|
||||
* @param amount Amount of cargo to add.
|
||||
* @param[out] acceptance Output array containing amount of cargo accepted.
|
||||
* @param[out] always_accepted Output mask of accepted cargo types.
|
||||
*/
|
||||
static void AddAcceptedCargoSetMask(CargoID cargo, uint amount, CargoArray &acceptance, CargoTypes &always_accepted)
|
||||
{
|
||||
if (!IsValidCargoID(cargo) || amount == 0) return;
|
||||
acceptance[cargo] += amount;
|
||||
SetBit(*always_accepted, cargo);
|
||||
SetBit(always_accepted, cargo);
|
||||
}
|
||||
|
||||
static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted)
|
||||
static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, CargoTypes &always_accepted)
|
||||
{
|
||||
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
|
||||
CargoID accepts[lengthof(hs->accepts_cargo)];
|
||||
|
Loading…
Reference in New Issue
Block a user