From ebc5d382e8398f234cb81b644e9aeeba780d23d2 Mon Sep 17 00:00:00 2001 From: Viceroy <97338859+Viceroyy@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:30:36 +0300 Subject: [PATCH] Fix font loading, Fix PS2Inator running after chams, Turn on Warnings Also adds an unused CL_DispatchSound hook --- Fusion/Fusion.vcxproj | 2 +- Fusion/src/Core/Core.cpp | 3 ++ Fusion/src/Hooks/CL_DispatchSound.cpp | 42 +++++++++++++++++++ .../Hooks/ModelRender_DrawModelExecute.cpp | 8 ++-- 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 Fusion/src/Hooks/CL_DispatchSound.cpp diff --git a/Fusion/Fusion.vcxproj b/Fusion/Fusion.vcxproj index 68163f6..73fe39d 100644 --- a/Fusion/Fusion.vcxproj +++ b/Fusion/Fusion.vcxproj @@ -181,7 +181,7 @@ - TurnOffAllWarnings + Level3 true true false diff --git a/Fusion/src/Core/Core.cpp b/Fusion/src/Core/Core.cpp index ef0302f..34319c4 100644 --- a/Fusion/src/Core/Core.cpp +++ b/Fusion/src/Core/Core.cpp @@ -113,6 +113,9 @@ void CCore::Load() F::EventListener.Setup({ "item_pickup" }); F::Configs.LoadConfig(F::Configs.sCurrentConfig, false); + + Sleep(150); + H::Fonts.Reload(); F::Menu.ConfigLoaded = true; diff --git a/Fusion/src/Hooks/CL_DispatchSound.cpp b/Fusion/src/Hooks/CL_DispatchSound.cpp new file mode 100644 index 0000000..e1ea87d --- /dev/null +++ b/Fusion/src/Hooks/CL_DispatchSound.cpp @@ -0,0 +1,42 @@ +// We use S_StartDynamicSound for the far esp, I did this because I was bored, also the origin pos seems to be wrong here +#include "../SDK/SDK.h" + +struct SoundInfo_t +{ + int nSequenceNumber; + int nEntityIndex; + int nChannel; + const char* pszName; // UNDONE: Make this a FilenameHandle_t to avoid bugs with arrays of these + Vector vOrigin; + Vector vDirection; + float fVolume; + soundlevel_t Soundlevel; + bool bLooping; + int nPitch; + int nSpecialDSP; + Vector vListenerOrigin; + int nFlags; + int nSoundNum; + float fDelay; + bool bIsSentence; + bool bIsAmbient; + int nSpeakerEntity; +}; + +MAKE_SIGNATURE(CL_DispatchSound, "engine.dll", "48 8B C4 48 89 78 ? 55 48 8D 68", 0x0); + +MAKE_HOOK(CL_DispatchSound, S::CL_DispatchSound(), int, __fastcall, + const SoundInfo_t& sound) +{ + if (sound.nEntityIndex <= 0) + return CALL_ORIGINAL(sound); + + Vector vOrigin = sound.vOrigin; + const int iEntIndex = sound.nEntityIndex; + auto pEntity = I::ClientEntityList->GetClientEntity(iEntIndex); + + if (pEntity && iEntIndex != I::EngineClient->GetLocalPlayer() && pEntity->IsDormant() && pEntity->GetClassID() == ETFClassID::CTFPlayer) + G::DormancyMap[iEntIndex] = { vOrigin, I::EngineClient->Time() }; + + return CALL_ORIGINAL(sound); +} \ No newline at end of file diff --git a/Fusion/src/Hooks/ModelRender_DrawModelExecute.cpp b/Fusion/src/Hooks/ModelRender_DrawModelExecute.cpp index 3d7ae0f..426b27c 100644 --- a/Fusion/src/Hooks/ModelRender_DrawModelExecute.cpp +++ b/Fusion/src/Hooks/ModelRender_DrawModelExecute.cpp @@ -26,6 +26,9 @@ MAKE_HOOK(ModelRender_DrawModelExecute, U::Memory.GetVFunc(I::ModelRender, 19), if (Vars::Visuals::Removals::Cosmetics.Value && pEntity && pEntity->GetClassID() == ETFClassID::CTFWearable) return; + if (Vars::Visuals::Other::ThePS2Inator.Value) + *const_cast(&pState.m_lod) = 7; + if (F::Chams.bRendering) return F::Chams.RenderHandler(pState, pInfo, pBoneToWorld); if (F::Glow.bRendering) @@ -41,9 +44,6 @@ MAKE_HOOK(ModelRender_DrawModelExecute, U::Memory.GetVFunc(I::ModelRender, 19), return; } - if (Vars::Visuals::Other::ThePS2Inator.Value) - *const_cast(&pState.m_lod) = 7; - CALL_ORIGINAL(ecx, pState, pInfo, pBoneToWorld); } @@ -53,7 +53,7 @@ MAKE_HOOK(CBaseAnimating_DrawModel, S::CBaseAnimating_DrawModel(), int, __fastca static const auto dwDrawModel = S::ViewmodelAttachment_DrawModel(); const auto dwRetAddr = std::uintptr_t(_ReturnAddress()); - if (Vars::Visuals::UI::CleanScreenshots.Value && I::EngineClient->IsTakingScreenshot() || G::Unload) + if (I::EngineVGui->IsGameUIVisible() || Vars::Visuals::UI::CleanScreenshots.Value && I::EngineClient->IsTakingScreenshot() || G::Unload) return CALL_ORIGINAL(ecx, flags); if (dwRetAddr == dwDrawModel && flags & STUDIO_RENDER)