Skip to content

Commit

Permalink
Name num_sheltered_sections flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Gymnasiast committed Apr 3, 2021
1 parent ea961ae commit 7c73e27
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
14 changes: 14 additions & 0 deletions src/openrct2/ride/Ride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7347,3 +7347,17 @@ void Ride::SetMaxCarsPerTrain(uint8_t newValue)
min_max_cars_per_train &= ~0x0F;
min_max_cars_per_train |= newValue & 0x0F;
}

uint8_t Ride::GetNumShelteredSections() const
{
return num_sheltered_sections & ShelteredSectionsBits::NumShelteredSectionsMask;
}

void Ride::IncreaseNumShelteredSections()
{
auto newNumShelteredSections = GetNumShelteredSections();
if (newNumShelteredSections != 0x1F)
newNumShelteredSections++;
num_sheltered_sections &= ~ShelteredSectionsBits::NumShelteredSectionsMask;
num_sheltered_sections |= newNumShelteredSections;
}
10 changes: 10 additions & 0 deletions src/openrct2/ride/Ride.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ enum class RideClassification
KioskOrFacility
};

namespace ShelteredSectionsBits
{
constexpr const uint8_t NumShelteredSectionsMask = 0b00011111;
constexpr const uint8_t RotatingWhileSheltered = 0b00100000;
constexpr const uint8_t BankingWhileSheltered = 0b01000000;
}; // namespace ShelteredSectionsBits

struct TrackDesign;
enum class RideMode : uint8_t;

Expand Down Expand Up @@ -453,6 +460,9 @@ struct Ride
uint8_t GetMaxCarsPerTrain() const;
void SetMinCarsPerTrain(uint8_t newValue);
void SetMaxCarsPerTrain(uint8_t newValue);

uint8_t GetNumShelteredSections() const;
void IncreaseNumShelteredSections();
};

#pragma pack(push, 1)
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2/ride/RideRatings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,19 +1326,19 @@ static RatingTuple ride_ratings_get_sheltered_ratings(Ride* ride)
/*eax = (ride->var_11C * 30340) >> 16;*/
/*nausea += eax;*/

if (ride->num_sheltered_sections & 0x40)
if (ride->num_sheltered_sections & ShelteredSectionsBits::BankingWhileSheltered)
{
excitement += 20;
nausea += 15;
}

if (ride->num_sheltered_sections & 0x20)
if (ride->num_sheltered_sections & ShelteredSectionsBits::RotatingWhileSheltered)
{
excitement += 20;
nausea += 15;
}

uint8_t lowerVal = ride->num_sheltered_sections & 0x1F;
uint8_t lowerVal = ride->GetNumShelteredSections();
lowerVal = std::min<uint8_t>(lowerVal, 11);
excitement += (lowerVal * 774516) >> 16;

Expand Down
10 changes: 3 additions & 7 deletions src/openrct2/ride/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1909,20 +1909,16 @@ void Vehicle::UpdateMeasurements()
{
curRide->testing_flags |= RIDE_TESTING_SHELTERED;

uint8_t numShelteredSections = curRide->num_sheltered_sections & 0x1F;
if (numShelteredSections != 0x1F)
numShelteredSections++;
curRide->num_sheltered_sections &= ~0x1F;
curRide->num_sheltered_sections |= numShelteredSections;
curRide->IncreaseNumShelteredSections();

if (vehicle_sprite_type != 0)
{
curRide->num_sheltered_sections |= (1 << 5);
curRide->num_sheltered_sections |= ShelteredSectionsBits::RotatingWhileSheltered;
}

if (bank_rotation != 0)
{
curRide->num_sheltered_sections |= (1 << 6);
curRide->num_sheltered_sections |= ShelteredSectionsBits::BankingWhileSheltered;
}
}

Expand Down

0 comments on commit 7c73e27

Please sign in to comment.