1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-23 06:44:38 +01:00

Merge pull request #11998 from hdpoliveira/move_info

Part of #9473: Create GetMoveInfo and GetTrackProgress
This commit is contained in:
Tulio Leao
2020-06-20 00:09:28 -03:00
committed by GitHub
3 changed files with 39 additions and 41 deletions

View File

@@ -229,8 +229,7 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards()
uint16_t trackProgress = track_progress + 1;
const rct_vehicle_info* moveInfo = vehicle_get_move_info(TrackSubposition, track_type, 0);
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
uint16_t trackTotalProgress = GetTrackProgress();
if (trackProgress >= trackTotalProgress)
{
_vehicleVAngleEndF64E36 = TrackDefinitions[trackType].vangle_end;
@@ -257,7 +256,7 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards()
}
track_progress = trackProgress;
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, trackProgress);
const auto moveInfo = GetMoveInfo();
auto unk = CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z } + TrackLocation;
uint8_t bx = 0;
@@ -295,7 +294,6 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards()
for (; remaining_distance < 0; _vehicleUnkF64E10++)
{
uint16_t trackProgress = track_progress - 1;
const rct_vehicle_info* moveInfo;
if (static_cast<int16_t>(trackProgress) == -1)
{
@@ -324,13 +322,11 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards()
_vehicleMotionTrackFlags = VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION;
}
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, 0);
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
uint16_t trackTotalProgress = GetTrackProgress();
trackProgress = trackTotalProgress - 1;
}
track_progress = trackProgress;
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, trackProgress);
const auto moveInfo = GetMoveInfo();
auto unk = CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z } + TrackLocation;
uint8_t bx = 0;

View File

@@ -782,7 +782,7 @@ static bool vehicle_move_info_valid(int32_t trackSubposition, int32_t typeAndDir
return true;
}
const rct_vehicle_info* vehicle_get_move_info(int32_t trackSubposition, int32_t typeAndDirection, int32_t offset)
static const rct_vehicle_info* vehicle_get_move_info(int32_t trackSubposition, int32_t typeAndDirection, int32_t offset)
{
if (!vehicle_move_info_valid(trackSubposition, typeAndDirection, offset))
{
@@ -792,7 +792,12 @@ const rct_vehicle_info* vehicle_get_move_info(int32_t trackSubposition, int32_t
return &gTrackVehicleInfo[trackSubposition][typeAndDirection]->info[offset];
}
uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDirection)
const rct_vehicle_info* Vehicle::GetMoveInfo() const
{
return vehicle_get_move_info(TrackSubposition, track_type, track_progress);
}
static uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDirection)
{
if (!vehicle_move_info_valid(trackSubposition, typeAndDirection, 0))
{
@@ -801,6 +806,11 @@ uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDir
return gTrackVehicleInfo[trackSubposition][typeAndDirection]->size;
}
uint16_t Vehicle::GetTrackProgress() const
{
return vehicle_get_move_info_size(TrackSubposition, track_type);
}
Vehicle* try_get_vehicle(uint16_t spriteIndex)
{
rct_sprite* sprite = try_get_sprite(spriteIndex);
@@ -7613,7 +7623,7 @@ void Vehicle::UpdateHandleWaterSplash() const
*/
void Vehicle::UpdateReverserCarBogies()
{
const auto moveInfo = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
const auto moveInfo = GetMoveInfo();
MoveTo({ TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y, z });
}
@@ -8212,10 +8222,8 @@ loc_6DAEB9:
regs.ax = track_progress + 1;
const rct_vehicle_info* moveInfo = vehicle_get_move_info(TrackSubposition, track_type, 0);
// Track Total Progress is in the two bytes before the move info list
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
uint16_t trackTotalProgress = GetTrackProgress();
if (regs.ax >= trackTotalProgress)
{
UpdateCrossings();
@@ -8234,7 +8242,7 @@ loc_6DAEB9:
UpdateHandleWaterSplash();
// loc_6DB706
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
const auto moveInfo = GetMoveInfo();
trackType = GetTrackType();
{
int16_t curX = TrackLocation.x + moveInfo->x;
@@ -8267,7 +8275,7 @@ loc_6DAEB9:
{
ReverseReverserCar();
const rct_vehicle_info* moveInfo2 = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
const rct_vehicle_info* moveInfo2 = GetMoveInfo();
curX = x + moveInfo2->x;
curY = y + moveInfo2->y;
}
@@ -8500,7 +8508,7 @@ bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, Ride* cu
brake_speed = tileElement->AsTrack()->GetBrakeBoosterSpeed();
// There are two bytes before the move info list
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
uint16_t trackTotalProgress = GetTrackProgress();
*progress = trackTotalProgress - 1;
return true;
}
@@ -8561,7 +8569,7 @@ loc_6DBA33:;
// loc_6DBD42
track_progress = regs.ax;
{
const rct_vehicle_info* moveInfo = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
const rct_vehicle_info* moveInfo = GetMoveInfo();
int16_t curX = TrackLocation.x + moveInfo->x;
int16_t curY = TrackLocation.y + moveInfo->y;
int16_t curZ = TrackLocation.z + moveInfo->z + RideTypeDescriptors[curRide->type].Heights.VehicleZOffset;
@@ -8761,15 +8769,9 @@ loc_6DC476:
mini_golf_flags &= ~(1 << 3);
}
// loc_6DC5B8
// Note: Line below was here as part of
// https://github.com/OpenRCT2/OpenRCT2/pull/2605/files#diff-e6c06ccf59b47239e1e220468e52497dR7736
// but it is not used and overridden later on.
// const rct_vehicle_info* moveInfo = vehicle_get_move_info(TrackSubposition, track_type, 0);
// There are two bytes before the move info list
{
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
uint16_t trackTotalProgress = GetTrackProgress();
if (track_progress + 1 < trackTotalProgress)
{
track_progress += 1;
@@ -8843,7 +8845,7 @@ loc_6DC743:
const rct_vehicle_info* moveInfo;
for (;;)
{
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
moveInfo = GetMoveInfo();
if (moveInfo->x != LOCATION_NULL)
{
break;
@@ -9044,10 +9046,10 @@ loc_6DCA9A:
var_CF = tileElement->AsTrack()->GetSeatRotation() << 1;
// There are two bytes before the move info list
track_progress = vehicle_get_move_info_size(TrackSubposition, track_type);
track_progress = GetTrackProgress();
loc_6DCC2C:
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
moveInfo = GetMoveInfo();
trackPos = { TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y,
TrackLocation.z + moveInfo->z + RideTypeDescriptors[curRide->type].Heights.VehicleZOffset };

View File

@@ -187,6 +187,17 @@ struct GForces
int32_t LateralG{};
};
// Size: 0x09
struct rct_vehicle_info
{
int16_t x; // 0x00
int16_t y; // 0x02
int16_t z; // 0x04
uint8_t direction; // 0x06
uint8_t vehicle_sprite_type; // 0x07
uint8_t bank_rotation; // 0x08
};
struct Vehicle : SpriteBase
{
uint8_t vehicle_sprite_type;
@@ -344,6 +355,8 @@ struct Vehicle : SpriteBase
private:
bool SoundCanPlay() const;
uint16_t GetSoundPriority() const;
const rct_vehicle_info* GetMoveInfo() const;
uint16_t GetTrackProgress() const;
rct_vehicle_sound_params CreateSoundParam(uint16_t priority) const;
void CableLiftUpdate();
bool CableLiftUpdateTrackMotionForwards();
@@ -436,17 +449,6 @@ struct train_ref
Vehicle* tail;
};
// Size: 0x09
struct rct_vehicle_info
{
int16_t x; // 0x00
int16_t y; // 0x02
int16_t z; // 0x04
uint8_t direction; // 0x06
uint8_t vehicle_sprite_type; // 0x07
uint8_t bank_rotation; // 0x08
};
enum : uint32_t
{
VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY = 1
@@ -617,8 +619,6 @@ enum
Vehicle* try_get_vehicle(uint16_t spriteIndex);
void vehicle_update_all();
void vehicle_sounds_update();
const rct_vehicle_info* vehicle_get_move_info(int32_t trackSubposition, int32_t typeAndDirection, int32_t offset);
uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDirection);
extern Vehicle* gCurrentVehicle;
extern StationIndex _vehicleStationIndex;