mirror of
https://github.com/rei-kes/Amalgam.git
synced 2024-12-22 20:57:24 +08:00
Add safety checks in core for renderer.
This commit is contained in:
parent
682654fcf8
commit
c95bc96585
@ -8,6 +8,31 @@
|
||||
#include "../Features/Visuals/Visuals.h"
|
||||
#include "../Hooks/Direct3DDevice9_Present.h"
|
||||
|
||||
__forceinline bool CheckRenderIsCompatible()
|
||||
{
|
||||
// Check for if we are running in DXVK mode.
|
||||
if(GetModuleHandleA("dxvk_d3d9.dll"))
|
||||
{
|
||||
MessageBoxA(nullptr, "You are running with graphics options that Amalgam does not support.\n"
|
||||
"Please remove -vulkan from your launch options and reinject.", "Error", MB_ICONERROR);
|
||||
U::Core.bUnload = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for if we are running in DirectX 8.
|
||||
auto cvDXLevel = I::CVar->FindVar("mat_dxlevel");
|
||||
auto iLevel = cvDXLevel->GetInt();
|
||||
if(iLevel < 90)
|
||||
{
|
||||
std::string fmt = std::format("You are running with graphics options that Amalgam does not support.\nPlease remove -dxlevel {} from your launch options and reinject.\0", iLevel);
|
||||
MessageBox(nullptr, fmt.c_str(), "Error", MB_ICONERROR);
|
||||
U::Core.bUnload = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCore::Load()
|
||||
{
|
||||
// Check the DirectX version
|
||||
@ -15,11 +40,16 @@ void CCore::Load()
|
||||
U::Signatures.Initialize();
|
||||
U::Interfaces.Initialize();
|
||||
|
||||
U::ConVars.Initialize();
|
||||
|
||||
if(!CheckRenderIsCompatible())
|
||||
return;
|
||||
|
||||
MH_Initialize();
|
||||
DirectX::Startup();
|
||||
U::Hooks.Initialize();
|
||||
DirectX::bIsReady.store(true);
|
||||
U::ConVars.Initialize();
|
||||
|
||||
F::Materials.LoadMaterials();
|
||||
F::Commands.Initialize();
|
||||
|
||||
@ -31,32 +61,34 @@ void CCore::Load()
|
||||
|
||||
void CCore::Unload()
|
||||
{
|
||||
G::Unload = true;
|
||||
DirectX::bIsReady.store(false);
|
||||
|
||||
U::Hooks.Unload();
|
||||
U::ConVars.Unload();
|
||||
F::Materials.UnloadMaterials();
|
||||
|
||||
F::Visuals.RestoreWorldModulation();
|
||||
Vars::Visuals::World::SkyboxChanger.Value = "Off"; // hooks won't run, remove here
|
||||
if (I::Input->CAM_IsThirdPerson())
|
||||
if(!bUnload)
|
||||
{
|
||||
auto pLocal = H::Entities.GetLocal();
|
||||
if (pLocal)
|
||||
G::Unload = true;
|
||||
DirectX::bIsReady.store(false);
|
||||
|
||||
U::Hooks.Unload();
|
||||
U::ConVars.Unload();
|
||||
F::Materials.UnloadMaterials();
|
||||
|
||||
F::Visuals.RestoreWorldModulation();
|
||||
Vars::Visuals::World::SkyboxChanger.Value = "Off"; // hooks won't run, remove here
|
||||
if(I::Input->CAM_IsThirdPerson())
|
||||
{
|
||||
I::Input->CAM_ToFirstPerson();
|
||||
pLocal->ThirdPersonSwitch();
|
||||
auto pLocal = H::Entities.GetLocal();
|
||||
if(pLocal)
|
||||
{
|
||||
I::Input->CAM_ToFirstPerson();
|
||||
pLocal->ThirdPersonSwitch();
|
||||
}
|
||||
}
|
||||
if(auto cl_wpn_sway_interp = U::ConVars.FindVar("cl_wpn_sway_interp"))
|
||||
cl_wpn_sway_interp->SetValue(0.f);
|
||||
if(auto cl_wpn_sway_scale = U::ConVars.FindVar("cl_wpn_sway_scale"))
|
||||
cl_wpn_sway_scale->SetValue(0.f);
|
||||
|
||||
Sleep(250);
|
||||
}
|
||||
if (auto cl_wpn_sway_interp = U::ConVars.FindVar("cl_wpn_sway_interp"))
|
||||
cl_wpn_sway_interp->SetValue(0.f);
|
||||
if (auto cl_wpn_sway_scale = U::ConVars.FindVar("cl_wpn_sway_scale"))
|
||||
cl_wpn_sway_scale->SetValue(0.f);
|
||||
|
||||
Sleep(250);
|
||||
|
||||
SDK::Output("Amalgam", "Unloaded", { 175, 150, 255, 255 });
|
||||
SDK::Output("Amalgam", "Unloaded", {175, 150, 255, 255});
|
||||
}
|
||||
|
||||
bool CCore::ShouldUnload()
|
||||
|
Loading…
Reference in New Issue
Block a user