diff --git a/source/game_sa/CarEnterExit.cpp b/source/game_sa/CarEnterExit.cpp index ad7cd820cb..d424f0844c 100644 --- a/source/game_sa/CarEnterExit.cpp +++ b/source/game_sa/CarEnterExit.cpp @@ -97,7 +97,7 @@ bool CCarEnterExit::CarHasOpenableDoor(const CVehicle* vehicle, int32 doorId_Unu // 0x64EE70 bool CCarEnterExit::CarHasPartiallyOpenDoor(const CVehicle* vehicle, int32 doorId) { - auto& veh = const_cast(*vehicle); + auto& veh = const_cast(*vehicle); // TODO: Fix return !veh.IsDoorMissingU32((uint32)doorId) && !veh.IsDoorFullyOpenU32((uint32)doorId) && !veh.IsDoorClosedU32((uint32)doorId); @@ -417,7 +417,7 @@ bool CCarEnterExit::IsCarDoorInUse(const CVehicle* vehicle, int32 firstDoorId, i // 0x64ED90 bool CCarEnterExit::IsCarDoorReady(const CVehicle* vehicle, int32 doorId) { // TODO: Make IsDoorReadyU32 a const member function to avoid const_cast - auto& veh = const_cast(*vehicle); + auto& veh = const_cast(*vehicle); // TODO: Fix return veh.IsDoorReadyU32((uint32)doorId) || veh.IsDoorFullyOpenU32((uint32)doorId); } @@ -470,7 +470,6 @@ bool CCarEnterExit::IsCarSlowJackRequired(const CVehicle* vehicle, int32 doorId) return false; } } - return false; } diff --git a/source/game_sa/Entity/Vehicle/Vehicle.cpp b/source/game_sa/Entity/Vehicle/Vehicle.cpp index 3d87f89526..d49f4453a9 100644 --- a/source/game_sa/Entity/Vehicle/Vehicle.cpp +++ b/source/game_sa/Entity/Vehicle/Vehicle.cpp @@ -208,7 +208,7 @@ void CVehicle::InjectHooks() { // RH_ScopedInstall(RemoveVehicleUpgrade, 0x6DF930); // RH_ScopedInstall(AddUpgrade, 0x6DFA20); // RH_ScopedInstall(UpdateTrailerLink, 0x6DFC50); - RH_ScopedInstall(UpdateTractorLink, 0x6E0050); + // RH_ScopedInstall(UpdateTractorLink, 0x6E0050); // RH_ScopedInstall(ScanAndMarkTargetForHeatSeekingMissile, 0x6E0400); // RH_ScopedInstall(FireHeatSeakingMissile, 0x6E05C0); // RH_ScopedInstall(PossiblyDropFreeFallBombForPlayer, 0x6E07E0); @@ -4242,55 +4242,8 @@ void CVehicle::UpdateTrailerLink(bool arg0, bool arg1) { } // 0x6E0050 -void CVehicle::UpdateTractorLink(bool applyFullVelocityAtHookUp, bool applyDistToSpeed) { - if (!m_pTrailer) { - return; - } - CVector hitchPos{}; - if (!m_pTrailer->GetTowHitchPos(hitchPos, true, this)) { - return; - } - CVector towBarPos{}; - if (!GetTowBarPos(towBarPos, true, m_pTrailer)) { - return; - } - switch (m_nModelIndex) { - case MODEL_TOWTRUCK: - case MODEL_TRACTOR: { - if (AsAutomobile()->m_wMiscComponentAngle > TOWTRUCK_HOIST_DOWN_LIMIT - 100) { - return; - } - } - } - - // 0x6E01EF - auto trailerAngularForce = m_pTrailer->GetSpeed(hitchPos - m_pTrailer->GetPosition()) - GetSpeed(towBarPos - GetPosition()); - if (!applyFullVelocityAtHookUp) { - trailerAngularForce *= (1.f - m_fMass / (m_pTrailer->m_fMass + m_fMass)) / 2.f; - if (applyDistToSpeed) { - const auto distVel = (hitchPos - towBarPos) * (0.1f / std::max(1.f, CTimer::ms_fTimeStep)); - // BUG: //TODO: Pirulax: I'm quite positive this was meant to be += - if constexpr (notsa::IsFixBugs()) { - trailerAngularForce += distVel; - } else { - trailerAngularForce = distVel; - } - } - } - if (m_pTrailer->IsSubTrailer() && m_pTrailer->AsTrailer()->m_fTrailerTowedRatio == -1000.f) { - trailerAngularForce -= trailerAngularForce.ProjectOnToNormal(m_pTrailer->GetMatrix().GetUp()); - } - - // 0x6E03EA - ApplyForce( - trailerAngularForce * GetMass( // 0x6E0354 - towBarPos - GetMatrix().TransformPoint(m_vecCentreOfMass), // NOTE: Same logic here, but less code - trailerAngularForce.Normalized() - ), - towBarPos, - true - ); - m_nFakePhysics = false; +void CVehicle::UpdateTractorLink(bool arg0, bool arg1) { + ((void(__thiscall*)(CVehicle*, bool, bool))0x6E0050)(this, arg0, arg1); } // 0x6E0400 diff --git a/source/game_sa/Events/GroupEventHandler.cpp b/source/game_sa/Events/GroupEventHandler.cpp index 5933221598..885d1e6ed2 100644 --- a/source/game_sa/Events/GroupEventHandler.cpp +++ b/source/game_sa/Events/GroupEventHandler.cpp @@ -419,7 +419,7 @@ CTaskAllocator* CGroupEventHandler::ComputeResponseDraggedOutCar(const CEventDra if (!e.m_CarJacker) { return nullptr; } - assert(!e.m_CarJacker->IsPed()); // Original code just `returns nullptr` in this case, but but since `m_CarJacker` is typed as `CPed*` it *should* be at least a `CPed*` + assert(e.m_CarJacker->IsPed()); // Original code just `returns nullptr` in this case, but but since `m_CarJacker` is typed as `CPed*` it *should* be at least a `CPed*` switch (e.m_taskId) { case TASK_GROUP_KILL_THREATS_BASIC: return e.m_CarJacker->IsPlayer() && originator && originator->GetIntelligence()->Respects(e.m_CarJacker) && !pg->m_bIsMissionGroup diff --git a/source/toolsmenu/DebugModules/PedDebugModule.cpp b/source/toolsmenu/DebugModules/PedDebugModule.cpp index df7679375b..543a761539 100644 --- a/source/toolsmenu/DebugModules/PedDebugModule.cpp +++ b/source/toolsmenu/DebugModules/PedDebugModule.cpp @@ -147,6 +147,8 @@ void PedDebugModule::RenderWindow() { return std::vector{r.begin(), r.end()}; }; + if (!GetPedPool()) return; + auto peds = to_vector( GetPedPool()->GetAllValid() | rng::views::transform([this](CPed& ped) -> std::optional {