mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for StationSpecFlags.
parent
1f7760dc7a
commit
1a6e7f2162
|
@ -2131,7 +2131,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
|||
break;
|
||||
|
||||
case 0x13: // General flags
|
||||
statspec->flags = buf.ReadByte();
|
||||
statspec->flags = StationSpecFlags{buf.ReadByte()};
|
||||
break;
|
||||
|
||||
case 0x14: { // Overhead wire placement
|
||||
|
|
|
@ -532,7 +532,7 @@ uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &, uint8_t variable, [
|
|||
}
|
||||
}
|
||||
|
||||
if (HasBit(this->station_scope.statspec->flags, SSF_DIV_BY_STATION_SIZE)) cargo /= (st->train_station.w + st->train_station.h);
|
||||
if (this->station_scope.statspec->flags.Test(StationSpecFlag::DivByStationSize)) cargo /= (st->train_station.w + st->train_station.h);
|
||||
cargo = std::min(0xfffu, cargo);
|
||||
|
||||
if (cargo > this->station_scope.statspec->cargo_threshold) {
|
||||
|
@ -608,7 +608,7 @@ StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseSt
|
|||
* @param statspec Station spec
|
||||
* @param st Station (nullptr in GUI)
|
||||
* @param tile Station tile being drawn (INVALID_TILE in GUI)
|
||||
* @param var10 Value to put in variable 10; normally 0; 1 when resolving the groundsprite and SSF_SEPARATE_GROUND is set.
|
||||
* @param var10 Value to put in variable 10; normally 0; 1 when resolving the groundsprite and StationSpecFlag::SeparateGround is set.
|
||||
* @return First sprite of the Action 1 spriteset to use, minus an offset of 0x42D to accommodate for weird NewGRF specs.
|
||||
*/
|
||||
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10)
|
||||
|
@ -808,7 +808,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
|||
|
||||
if (layout != nullptr) {
|
||||
/* Sprite layout which needs preprocessing */
|
||||
bool separate_ground = HasBit(statspec->flags, SSF_SEPARATE_GROUND);
|
||||
bool separate_ground = statspec->flags.Test(StationSpecFlag::SeparateGround);
|
||||
uint32_t var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground);
|
||||
for (uint8_t var10 : SetBitIterator(var10_values)) {
|
||||
uint32_t var10_relocation = GetCustomStationRelocation(statspec, nullptr, INVALID_TILE, var10);
|
||||
|
@ -875,7 +875,7 @@ void AnimateStationTile(TileIndex tile)
|
|||
const StationSpec *ss = GetStationSpec(tile);
|
||||
if (ss == nullptr) return;
|
||||
|
||||
StationAnimationBase::AnimateTile(ss, BaseStation::GetByTile(tile), tile, HasBit(ss->flags, SSF_CB141_RANDOM_BITS));
|
||||
StationAnimationBase::AnimateTile(ss, BaseStation::GetByTile(tile), tile, ss->flags.Test(StationSpecFlag::Cb141RandomBits));
|
||||
}
|
||||
|
||||
void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAnimationTrigger trigger, CargoType cargo_type)
|
||||
|
|
|
@ -93,13 +93,14 @@ enum StationClassID : uint16_t {
|
|||
/** Allow incrementing of StationClassID variables */
|
||||
DECLARE_INCREMENT_DECREMENT_OPERATORS(StationClassID)
|
||||
|
||||
enum StationSpecFlags : uint8_t {
|
||||
SSF_SEPARATE_GROUND, ///< Use different sprite set for ground sprites.
|
||||
SSF_DIV_BY_STATION_SIZE, ///< Divide cargo amount by station size.
|
||||
SSF_CB141_RANDOM_BITS, ///< Callback 141 needs random bits.
|
||||
SSF_CUSTOM_FOUNDATIONS, ///< Draw custom foundations.
|
||||
SSF_EXTENDED_FOUNDATIONS, ///< Extended foundation block instead of simple.
|
||||
enum class StationSpecFlag : uint8_t {
|
||||
SeparateGround = 0, ///< Use different sprite set for ground sprites.
|
||||
DivByStationSize = 1, ///< Divide cargo amount by station size.
|
||||
Cb141RandomBits = 2, ///< Callback 141 needs random bits.
|
||||
CustomFoundations = 3, ///< Draw custom foundations.
|
||||
ExtendedFoundations = 4, ///< Extended foundation block instead of simple.
|
||||
};
|
||||
using StationSpecFlags = EnumBitSet<StationSpecFlag, uint8_t>;
|
||||
|
||||
/** Randomisation triggers for stations */
|
||||
enum StationRandomTrigger : uint8_t {
|
||||
|
@ -158,7 +159,7 @@ struct StationSpec : NewGRFSpecBase<StationClassID> {
|
|||
|
||||
StationCallbackMasks callback_mask; ///< Bitmask of station callbacks that have to be called
|
||||
|
||||
uint8_t flags; ///< Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size
|
||||
StationSpecFlags flags; ///< Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size
|
||||
|
||||
enum class TileFlag : uint8_t {
|
||||
Pylons = 0, ///< Tile should contain catenary pylons.
|
||||
|
|
|
@ -3173,7 +3173,7 @@ static void DrawTile_Station(TileInfo *ti)
|
|||
|
||||
/* don't show foundation for docks */
|
||||
if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile)) {
|
||||
if (statspec != nullptr && HasBit(statspec->flags, SSF_CUSTOM_FOUNDATIONS)) {
|
||||
if (statspec != nullptr && statspec->flags.Test(StationSpecFlag::CustomFoundations)) {
|
||||
/* Station has custom foundations.
|
||||
* Check whether the foundation continues beyond the tile's upper sides. */
|
||||
uint edge_info = 0;
|
||||
|
@ -3183,7 +3183,7 @@ static void DrawTile_Station(TileInfo *ti)
|
|||
SpriteID image = GetCustomStationFoundationRelocation(statspec, st, ti->tile, tile_layout, edge_info);
|
||||
if (image == 0) goto draw_default_foundation;
|
||||
|
||||
if (HasBit(statspec->flags, SSF_EXTENDED_FOUNDATIONS)) {
|
||||
if (statspec->flags.Test(StationSpecFlag::ExtendedFoundations)) {
|
||||
/* Station provides extended foundations. */
|
||||
|
||||
static const uint8_t foundation_parts[] = {
|
||||
|
@ -3277,7 +3277,7 @@ draw_default_foundation:
|
|||
} else {
|
||||
if (layout != nullptr) {
|
||||
/* Sprite layout which needs preprocessing */
|
||||
bool separate_ground = HasBit(statspec->flags, SSF_SEPARATE_GROUND);
|
||||
bool separate_ground = statspec->flags.Test(StationSpecFlag::SeparateGround);
|
||||
uint32_t var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground);
|
||||
for (uint8_t var10 : SetBitIterator(var10_values)) {
|
||||
uint32_t var10_relocation = GetCustomStationRelocation(statspec, st, ti->tile, var10);
|
||||
|
@ -3289,7 +3289,7 @@ draw_default_foundation:
|
|||
} else if (statspec != nullptr) {
|
||||
/* Simple sprite layout */
|
||||
ground_relocation = relocation = GetCustomStationRelocation(statspec, st, ti->tile, 0);
|
||||
if (HasBit(statspec->flags, SSF_SEPARATE_GROUND)) {
|
||||
if (statspec->flags.Test(StationSpecFlag::SeparateGround)) {
|
||||
ground_relocation = GetCustomStationRelocation(statspec, st, ti->tile, 1);
|
||||
}
|
||||
ground_relocation += rti->fallback_railtype;
|
||||
|
|
Loading…
Reference in New Issue