mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for IndustryTileSpecialFlags.
parent
1916454776
commit
fb70a7fe7e
|
@ -421,7 +421,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca
|
|||
auto accepts_cargo = itspec->accepts_cargo;
|
||||
auto cargo_acceptance = itspec->acceptance;
|
||||
|
||||
if (itspec->special_flags & INDTILE_SPECIAL_ACCEPTS_ALL_CARGO) {
|
||||
if (itspec->special_flags.Test(IndustryTileSpecialFlag::AcceptsAllCargo)) {
|
||||
/* Copy all accepted cargoes from industry itself */
|
||||
for (const auto &a : ind->accepted) {
|
||||
auto pos = std::ranges::find(accepts_cargo, a.cargo);
|
||||
|
|
|
@ -81,12 +81,11 @@ enum class IndustryBehaviour : uint8_t {
|
|||
using IndustryBehaviours = EnumBitSet<IndustryBehaviour, uint32_t>;
|
||||
|
||||
/** Flags for miscellaneous industry tile specialities */
|
||||
enum IndustryTileSpecialFlags : uint8_t {
|
||||
INDTILE_SPECIAL_NONE = 0,
|
||||
INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS = 1 << 0, ///< Callback 0x26 needs random bits
|
||||
INDTILE_SPECIAL_ACCEPTS_ALL_CARGO = 1 << 1, ///< Tile always accepts all cargoes the associated industry accepts
|
||||
enum class IndustryTileSpecialFlag : uint8_t {
|
||||
NextFrameRandomBits = 0, ///< Callback 0x26 needs random bits
|
||||
AcceptsAllCargo = 1, ///< Tile always accepts all cargoes the associated industry accepts
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(IndustryTileSpecialFlags)
|
||||
using IndustryTileSpecialFlags = EnumBitSet<IndustryTileSpecialFlag, uint8_t>;
|
||||
|
||||
/** Definition of one tile in an industry tile layout */
|
||||
struct IndustryTileLayoutTile {
|
||||
|
|
|
@ -3431,7 +3431,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop,
|
|||
break;
|
||||
|
||||
case 0x12: // Special flags
|
||||
tsp->special_flags = (IndustryTileSpecialFlags)buf.ReadByte();
|
||||
tsp->special_flags = IndustryTileSpecialFlags{buf.ReadByte()};
|
||||
break;
|
||||
|
||||
case 0x13: { // variable length cargo acceptance
|
||||
|
@ -3444,7 +3444,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop,
|
|||
for (uint i = 0; i < std::size(tsp->acceptance); i++) {
|
||||
if (i < num_cargoes) {
|
||||
tsp->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur.grffile);
|
||||
/* Tile acceptance can be negative to counteract the INDTILE_SPECIAL_ACCEPTS_ALL_CARGO flag */
|
||||
/* Tile acceptance can be negative to counteract the IndustryTileSpecialFlag::AcceptsAllCargo flag */
|
||||
tsp->acceptance[i] = (int8_t)buf.ReadByte();
|
||||
} else {
|
||||
tsp->accepts_cargo[i] = INVALID_CARGO;
|
||||
|
|
|
@ -270,7 +270,7 @@ void AnimateNewIndustryTile(TileIndex tile)
|
|||
const IndustryTileSpec *itspec = GetIndustryTileSpec(GetIndustryGfx(tile));
|
||||
if (itspec == nullptr) return;
|
||||
|
||||
IndustryAnimationBase::AnimateTile(itspec, Industry::GetByTile(tile), tile, (itspec->special_flags & INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS) != 0);
|
||||
IndustryAnimationBase::AnimateTile(itspec, Industry::GetByTile(tile), tile, itspec->special_flags.Test(IndustryTileSpecialFlag::NextFrameRandomBits));
|
||||
}
|
||||
|
||||
bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random)
|
||||
|
|
|
@ -1533,7 +1533,7 @@ static const IndustrySpec _origin_industry_specs[NEW_INDUSTRYOFFSET] = {
|
|||
*/
|
||||
#define MT(ca1, c1, ca2, c2, ca3, c3, sl, a1, a2, a3) { \
|
||||
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
||||
{ca1, ca2, ca3}, sl, a1, a2, a3, IndustryTileCallbackMasks{}, {0, ANIM_STATUS_NO_ANIMATION, 2, 0}, INDTILE_SPECIAL_NONE, true, GRFFileProps(INVALID_INDUSTRYTILE), {c1, c2, c3} \
|
||||
{ca1, ca2, ca3}, sl, a1, a2, a3, IndustryTileCallbackMasks{}, {0, ANIM_STATUS_NO_ANIMATION, 2, 0}, IndustryTileSpecialFlags{}, true, GRFFileProps(INVALID_INDUSTRYTILE), {c1, c2, c3} \
|
||||
}
|
||||
static const IndustryTileSpec _origin_industry_tile_specs[NEW_INDUSTRYTILEOFFSET] = {
|
||||
/* Coal Mine */
|
||||
|
|
Loading…
Reference in New Issue