mirror of
https://github.com/elmasas/lcs-recomp
synced 2026-10-20 23:19:46 -04:00
Fix vehicle state check
This commit is contained in:
@@ -10028,10 +10028,11 @@ L_08A97F70:
|
||||
}
|
||||
L_08A97F78:
|
||||
{
|
||||
lcs::lcs_note_vehicle_control_read();
|
||||
const bool driving = lcs::lcs_guest_player_in_vehicle(aot_mem);
|
||||
if (driving) lcs::lcs_note_vehicle_control_read();
|
||||
std::int16_t brake = static_cast<std::int16_t>(
|
||||
aot_mem.aot_load16(ctx.gpr[4] + lcs::lcs_brake_pad_offset()));
|
||||
if (brake == 0 && lcs::lcs_host_brake()) brake = 255;
|
||||
aot_mem.aot_load16(ctx.gpr[4] + (driving ? lcs::lcs_brake_pad_offset() : 38u)));
|
||||
if (driving && brake == 0 && lcs::lcs_host_brake()) brake = 255;
|
||||
ctx.gpr[2] = (static_cast<std::uint32_t>(static_cast<std::int32_t>(brake)));
|
||||
}
|
||||
goto L_08A97F7C;
|
||||
|
||||
@@ -1379,10 +1379,11 @@ L_08A980E8:
|
||||
}
|
||||
L_08A980F0:
|
||||
{
|
||||
lcs::lcs_note_vehicle_control_read();
|
||||
const bool driving = lcs::lcs_guest_player_in_vehicle(aot_mem);
|
||||
if (driving) lcs::lcs_note_vehicle_control_read();
|
||||
std::int16_t accelerate = static_cast<std::int16_t>(
|
||||
aot_mem.aot_load16(ctx.gpr[4] + lcs::lcs_accelerate_pad_offset()));
|
||||
if (accelerate == 0 && lcs::lcs_host_accelerate()) accelerate = 255;
|
||||
aot_mem.aot_load16(ctx.gpr[4] + (driving ? lcs::lcs_accelerate_pad_offset() : 42u)));
|
||||
if (driving && accelerate == 0 && lcs::lcs_host_accelerate()) accelerate = 255;
|
||||
ctx.gpr[2] = (static_cast<std::uint32_t>(static_cast<std::int32_t>(accelerate)));
|
||||
}
|
||||
goto L_08A980F4;
|
||||
|
||||
@@ -19,4 +19,11 @@ void lcs_set_host_drive_inputs(bool accelerate, bool brake) noexcept;
|
||||
void lcs_note_vehicle_control_read() noexcept;
|
||||
[[nodiscard]] bool lcs_player_in_vehicle() noexcept;
|
||||
|
||||
template <typename Memory>
|
||||
[[nodiscard]] bool lcs_guest_player_in_vehicle(Memory &memory) {
|
||||
const std::uint32_t slot = memory.aot_load8(0x08B5E054u);
|
||||
const std::uint32_t ped = memory.aot_load32(0x08B89A10u + slot * 368u);
|
||||
return ped != 0u && memory.aot_load8(ped + 1336u) != 0u;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user