mirror of https://github.com/OpenRCT2/OpenRCT2.git
Part of #9473: Create Vehicle::GetMoveInfo
This commit is contained in:
parent
ea9dd60b91
commit
f33f3c07bd
|
@ -229,7 +229,6 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards()
|
||||||
|
|
||||||
uint16_t trackProgress = track_progress + 1;
|
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 = vehicle_get_move_info_size(TrackSubposition, track_type);
|
||||||
if (trackProgress >= trackTotalProgress)
|
if (trackProgress >= trackTotalProgress)
|
||||||
{
|
{
|
||||||
|
@ -257,7 +256,7 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards()
|
||||||
}
|
}
|
||||||
|
|
||||||
track_progress = trackProgress;
|
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;
|
auto unk = CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z } + TrackLocation;
|
||||||
|
|
||||||
uint8_t bx = 0;
|
uint8_t bx = 0;
|
||||||
|
@ -295,7 +294,6 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards()
|
||||||
for (; remaining_distance < 0; _vehicleUnkF64E10++)
|
for (; remaining_distance < 0; _vehicleUnkF64E10++)
|
||||||
{
|
{
|
||||||
uint16_t trackProgress = track_progress - 1;
|
uint16_t trackProgress = track_progress - 1;
|
||||||
const rct_vehicle_info* moveInfo;
|
|
||||||
|
|
||||||
if (static_cast<int16_t>(trackProgress) == -1)
|
if (static_cast<int16_t>(trackProgress) == -1)
|
||||||
{
|
{
|
||||||
|
@ -324,13 +322,11 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards()
|
||||||
_vehicleMotionTrackFlags = VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION;
|
_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 = vehicle_get_move_info_size(TrackSubposition, track_type);
|
||||||
trackProgress = trackTotalProgress - 1;
|
trackProgress = trackTotalProgress - 1;
|
||||||
}
|
}
|
||||||
track_progress = trackProgress;
|
track_progress = trackProgress;
|
||||||
|
const auto moveInfo = GetMoveInfo();
|
||||||
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, trackProgress);
|
|
||||||
auto unk = CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z } + TrackLocation;
|
auto unk = CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z } + TrackLocation;
|
||||||
|
|
||||||
uint8_t bx = 0;
|
uint8_t bx = 0;
|
||||||
|
|
|
@ -782,7 +782,7 @@ static bool vehicle_move_info_valid(int32_t trackSubposition, int32_t typeAndDir
|
||||||
return true;
|
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))
|
if (!vehicle_move_info_valid(trackSubposition, typeAndDirection, offset))
|
||||||
{
|
{
|
||||||
|
@ -792,6 +792,11 @@ const rct_vehicle_info* vehicle_get_move_info(int32_t trackSubposition, int32_t
|
||||||
return &gTrackVehicleInfo[trackSubposition][typeAndDirection]->info[offset];
|
return &gTrackVehicleInfo[trackSubposition][typeAndDirection]->info[offset];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rct_vehicle_info* Vehicle::GetMoveInfo() const
|
||||||
|
{
|
||||||
|
return vehicle_get_move_info(TrackSubposition, track_type, track_progress);
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDirection)
|
uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDirection)
|
||||||
{
|
{
|
||||||
if (!vehicle_move_info_valid(trackSubposition, typeAndDirection, 0))
|
if (!vehicle_move_info_valid(trackSubposition, typeAndDirection, 0))
|
||||||
|
@ -7625,7 +7630,7 @@ void Vehicle::UpdateHandleWaterSplash() const
|
||||||
*/
|
*/
|
||||||
void Vehicle::UpdateReverserCarBogies()
|
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 });
|
MoveTo({ TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y, z });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8224,8 +8229,6 @@ loc_6DAEB9:
|
||||||
|
|
||||||
regs.ax = track_progress + 1;
|
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
|
// 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 = vehicle_get_move_info_size(TrackSubposition, track_type);
|
||||||
if (regs.ax >= trackTotalProgress)
|
if (regs.ax >= trackTotalProgress)
|
||||||
|
@ -8246,7 +8249,7 @@ loc_6DAEB9:
|
||||||
UpdateHandleWaterSplash();
|
UpdateHandleWaterSplash();
|
||||||
|
|
||||||
// loc_6DB706
|
// loc_6DB706
|
||||||
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
|
const auto moveInfo = GetMoveInfo();
|
||||||
trackType = GetTrackType();
|
trackType = GetTrackType();
|
||||||
{
|
{
|
||||||
int16_t curX = TrackLocation.x + moveInfo->x;
|
int16_t curX = TrackLocation.x + moveInfo->x;
|
||||||
|
@ -8279,7 +8282,7 @@ loc_6DAEB9:
|
||||||
{
|
{
|
||||||
ReverseReverserCar();
|
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;
|
curX = x + moveInfo2->x;
|
||||||
curY = y + moveInfo2->y;
|
curY = y + moveInfo2->y;
|
||||||
}
|
}
|
||||||
|
@ -8573,7 +8576,7 @@ loc_6DBA33:;
|
||||||
// loc_6DBD42
|
// loc_6DBD42
|
||||||
track_progress = regs.ax;
|
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 curX = TrackLocation.x + moveInfo->x;
|
||||||
int16_t curY = TrackLocation.y + moveInfo->y;
|
int16_t curY = TrackLocation.y + moveInfo->y;
|
||||||
int16_t curZ = TrackLocation.z + moveInfo->z + RideTypeDescriptors[curRide->type].Heights.VehicleZOffset;
|
int16_t curZ = TrackLocation.z + moveInfo->z + RideTypeDescriptors[curRide->type].Heights.VehicleZOffset;
|
||||||
|
@ -8773,12 +8776,6 @@ loc_6DC476:
|
||||||
mini_golf_flags &= ~(1 << 3);
|
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
|
// There are two bytes before the move info list
|
||||||
{
|
{
|
||||||
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
|
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
|
||||||
|
@ -8855,7 +8852,7 @@ loc_6DC743:
|
||||||
const rct_vehicle_info* moveInfo;
|
const rct_vehicle_info* moveInfo;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
|
moveInfo = GetMoveInfo();
|
||||||
if (moveInfo->x != LOCATION_NULL)
|
if (moveInfo->x != LOCATION_NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -9059,7 +9056,7 @@ loc_6DCA9A:
|
||||||
track_progress = vehicle_get_move_info_size(TrackSubposition, track_type);
|
track_progress = vehicle_get_move_info_size(TrackSubposition, track_type);
|
||||||
|
|
||||||
loc_6DCC2C:
|
loc_6DCC2C:
|
||||||
moveInfo = vehicle_get_move_info(TrackSubposition, track_type, track_progress);
|
moveInfo = GetMoveInfo();
|
||||||
trackPos = { TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y,
|
trackPos = { TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y,
|
||||||
TrackLocation.z + moveInfo->z + RideTypeDescriptors[curRide->type].Heights.VehicleZOffset };
|
TrackLocation.z + moveInfo->z + RideTypeDescriptors[curRide->type].Heights.VehicleZOffset };
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,17 @@ struct GForces
|
||||||
int32_t LateralG{};
|
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
|
struct Vehicle : SpriteBase
|
||||||
{
|
{
|
||||||
uint8_t vehicle_sprite_type;
|
uint8_t vehicle_sprite_type;
|
||||||
|
@ -344,6 +355,7 @@ struct Vehicle : SpriteBase
|
||||||
private:
|
private:
|
||||||
bool SoundCanPlay() const;
|
bool SoundCanPlay() const;
|
||||||
uint16_t GetSoundPriority() const;
|
uint16_t GetSoundPriority() const;
|
||||||
|
const rct_vehicle_info* GetMoveInfo() const;
|
||||||
rct_vehicle_sound_params CreateSoundParam(uint16_t priority) const;
|
rct_vehicle_sound_params CreateSoundParam(uint16_t priority) const;
|
||||||
void CableLiftUpdate();
|
void CableLiftUpdate();
|
||||||
bool CableLiftUpdateTrackMotionForwards();
|
bool CableLiftUpdateTrackMotionForwards();
|
||||||
|
@ -434,17 +446,6 @@ struct train_ref
|
||||||
Vehicle* tail;
|
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
|
enum : uint32_t
|
||||||
{
|
{
|
||||||
VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY = 1
|
VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY = 1
|
||||||
|
@ -615,7 +616,6 @@ enum
|
||||||
Vehicle* try_get_vehicle(uint16_t spriteIndex);
|
Vehicle* try_get_vehicle(uint16_t spriteIndex);
|
||||||
void vehicle_update_all();
|
void vehicle_update_all();
|
||||||
void vehicle_sounds_update();
|
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);
|
uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDirection);
|
||||||
|
|
||||||
extern Vehicle* gCurrentVehicle;
|
extern Vehicle* gCurrentVehicle;
|
||||||
|
|
Loading…
Reference in New Issue