forked from rosebudai/OpenRCT2-Web
Deduplicate vehicle helper functions (#26164)
* Move common enum values * Deduplicate PitchAndRollStart and GetAccelerationDecrease2
This commit is contained in:
1 parent
3bddf6161d
commit
ea9752f1f2
7 files changed
+32
-59
No files matched your search
@@ -928,6 +928,9 @@ enum : ImageIndex
|
||||
SPR_CREDITS_LOGO_SMALL = 23213,
|
||||
SPR_CREDITS_CHRIS_SAWYER_SMALL = 23214,
|
||||
|
||||
SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE = 22164,
|
||||
SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE = 22165,
|
||||
|
||||
SPR_NEW_RIDE_MASK = 29013,
|
||||
|
||||
SPR_SPLASH_EFFECT_1_NE_0 = 29014,
|
||||
|
||||
@@ -26,9 +26,6 @@ static constexpr TunnelGroup kTunnelGroup = TunnelGroup::Square;
|
||||
|
||||
enum
|
||||
{
|
||||
SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE = 22164,
|
||||
SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE = 22165,
|
||||
|
||||
SPR_AIR_POWERED_VERTICAL_RC_FLAT_SW_NE = 22226,
|
||||
SPR_AIR_POWERED_VERTICAL_RC_FLAT_NW_SE = 22227,
|
||||
SPR_AIR_POWERED_VERTICAL_RC_STATION_SW_NE = 22228,
|
||||
|
||||
@@ -28,8 +28,6 @@ enum
|
||||
{
|
||||
SPR_REVERSE_FREEFALL_RC_STATION_SW_NE = 22162,
|
||||
SPR_REVERSE_FREEFALL_RC_STATION_NW_SE = 22163,
|
||||
SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE = 22164,
|
||||
SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE = 22165,
|
||||
SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE = 22166,
|
||||
SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE = 22167,
|
||||
SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW = 22168,
|
||||
|
||||
@@ -32,13 +32,6 @@ using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::RideVehicle;
|
||||
using namespace OpenRCT2::TrackMetadata;
|
||||
|
||||
static PitchAndRoll PitchAndRollStart(bool useInvertedSprites, TileElement* tileElement)
|
||||
{
|
||||
auto trackType = tileElement->AsTrack()->GetTrackType();
|
||||
const auto& ted = GetTrackElementDescriptor(trackType);
|
||||
return PitchAndRoll{ ted.definition.pitchStart, TrackGetActualBank3(useInvertedSprites, tileElement) };
|
||||
}
|
||||
|
||||
void RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const TrackElemType trackType)
|
||||
{
|
||||
const auto& ted = GetTrackElementDescriptor(trackType);
|
||||
@@ -645,24 +638,6 @@ void Vehicle::Loc6DCE02(const Ride& curRide)
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr int32_t GetAccelerationDecrease2(const int32_t velocity, const int32_t totalMass)
|
||||
{
|
||||
int32_t accelerationDecrease2 = velocity >> 8;
|
||||
accelerationDecrease2 *= accelerationDecrease2;
|
||||
if (velocity < 0)
|
||||
{
|
||||
accelerationDecrease2 = -accelerationDecrease2;
|
||||
}
|
||||
accelerationDecrease2 >>= 4;
|
||||
// OpenRCT2: vehicles from different track types can have 0 mass.
|
||||
if (totalMass != 0)
|
||||
{
|
||||
return accelerationDecrease2 / totalMass;
|
||||
}
|
||||
|
||||
return accelerationDecrease2;
|
||||
}
|
||||
|
||||
int32_t Vehicle::UpdateTrackMotionMiniGolfCalculateAcceleration(const CarEntry& carEntry)
|
||||
{
|
||||
int32_t sumAcceleration = 0;
|
||||
|
||||
@@ -325,17 +325,6 @@ static void BlockBrakesOpenPreviousSection(const Ride& ride, const CoordsXYZ& ve
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006DB38B
|
||||
*/
|
||||
static PitchAndRoll PitchAndRollStart(bool useInvertedSprites, TileElement* tileElement)
|
||||
{
|
||||
auto trackType = tileElement->AsTrack()->GetTrackType();
|
||||
const auto& ted = GetTrackElementDescriptor(trackType);
|
||||
return PitchAndRoll{ ted.definition.pitchStart, TrackGetActualBank3(useInvertedSprites, tileElement) };
|
||||
}
|
||||
|
||||
void Vehicle::UpdateGoKartAttemptSwitchLanes()
|
||||
{
|
||||
uint16_t probability = 0x8000;
|
||||
@@ -1284,24 +1273,6 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr int32_t GetAccelerationDecrease2(const int32_t velocity, const int32_t totalMass)
|
||||
{
|
||||
int32_t accelerationDecrease2 = velocity >> 8;
|
||||
accelerationDecrease2 *= accelerationDecrease2;
|
||||
if (velocity < 0)
|
||||
{
|
||||
accelerationDecrease2 = -accelerationDecrease2;
|
||||
}
|
||||
accelerationDecrease2 >>= 4;
|
||||
// OpenRCT2: vehicles from different track types can have 0 mass.
|
||||
if (totalMass != 0)
|
||||
{
|
||||
return accelerationDecrease2 / totalMass;
|
||||
}
|
||||
|
||||
return accelerationDecrease2;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006DC1E4
|
||||
|
||||
@@ -82,6 +82,31 @@ uint8_t _vehicleF64E2C;
|
||||
Vehicle* _vehicleFrontVehicle;
|
||||
CoordsXYZ _vehicleCurPosition;
|
||||
|
||||
PitchAndRoll PitchAndRollStart(bool useInvertedSprites, TileElement* tileElement)
|
||||
{
|
||||
auto trackType = tileElement->AsTrack()->GetTrackType();
|
||||
const auto& ted = GetTrackElementDescriptor(trackType);
|
||||
return PitchAndRoll{ ted.definition.pitchStart, TrackGetActualBank3(useInvertedSprites, tileElement) };
|
||||
}
|
||||
|
||||
int32_t GetAccelerationDecrease2(const int32_t velocity, const int32_t totalMass)
|
||||
{
|
||||
int32_t accelerationDecrease2 = velocity >> 8;
|
||||
accelerationDecrease2 *= accelerationDecrease2;
|
||||
if (velocity < 0)
|
||||
{
|
||||
accelerationDecrease2 = -accelerationDecrease2;
|
||||
}
|
||||
accelerationDecrease2 >>= 4;
|
||||
// OpenRCT2: vehicles from different track types can have 0 mass.
|
||||
if (totalMass != 0)
|
||||
{
|
||||
return accelerationDecrease2 / totalMass;
|
||||
}
|
||||
|
||||
return accelerationDecrease2;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool EntityBase::Is<Vehicle>() const
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "../core/FlagHolder.hpp"
|
||||
#include "../entity/EntityBase.h"
|
||||
#include "../ride/RideTypes.h"
|
||||
#include "../ride/Track.h"
|
||||
#include "../world/Location.hpp"
|
||||
#include "Angles.h"
|
||||
#include "CarEntry.h"
|
||||
@@ -556,6 +557,9 @@ enum class SoundRange : uint8_t
|
||||
constexpr uint8_t kVehicleSeatPairFlag = 0x80;
|
||||
constexpr uint8_t kVehicleSeatNumMask = 0x7F;
|
||||
|
||||
OpenRCT2::TrackMetadata::PitchAndRoll PitchAndRollStart(bool useInvertedSprites, OpenRCT2::TileElement* tileElement);
|
||||
int32_t GetAccelerationDecrease2(const int32_t velocity, const int32_t totalMass);
|
||||
|
||||
Vehicle* TryGetVehicle(EntityId spriteIndex);
|
||||
void VehicleUpdateAll();
|
||||
void VehicleSoundsUpdate();
|
||||
|
||||
Reference in new issue
Block a user