mirror of
https://github.com/rei-kes/Amalgam.git
synced 2024-12-23 02:37:25 +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 "../Features/Visuals/Visuals.h"
|
||||||
#include "../Hooks/Direct3DDevice9_Present.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()
|
void CCore::Load()
|
||||||
{
|
{
|
||||||
// Check the DirectX version
|
// Check the DirectX version
|
||||||
@ -15,11 +40,16 @@ void CCore::Load()
|
|||||||
U::Signatures.Initialize();
|
U::Signatures.Initialize();
|
||||||
U::Interfaces.Initialize();
|
U::Interfaces.Initialize();
|
||||||
|
|
||||||
|
U::ConVars.Initialize();
|
||||||
|
|
||||||
|
if(!CheckRenderIsCompatible())
|
||||||
|
return;
|
||||||
|
|
||||||
MH_Initialize();
|
MH_Initialize();
|
||||||
DirectX::Startup();
|
DirectX::Startup();
|
||||||
U::Hooks.Initialize();
|
U::Hooks.Initialize();
|
||||||
DirectX::bIsReady.store(true);
|
DirectX::bIsReady.store(true);
|
||||||
U::ConVars.Initialize();
|
|
||||||
F::Materials.LoadMaterials();
|
F::Materials.LoadMaterials();
|
||||||
F::Commands.Initialize();
|
F::Commands.Initialize();
|
||||||
|
|
||||||
@ -31,32 +61,34 @@ void CCore::Load()
|
|||||||
|
|
||||||
void CCore::Unload()
|
void CCore::Unload()
|
||||||
{
|
{
|
||||||
G::Unload = true;
|
if(!bUnload)
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
auto pLocal = H::Entities.GetLocal();
|
G::Unload = true;
|
||||||
if (pLocal)
|
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();
|
auto pLocal = H::Entities.GetLocal();
|
||||||
pLocal->ThirdPersonSwitch();
|
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"))
|
SDK::Output("Amalgam", "Unloaded", {175, 150, 255, 255});
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCore::ShouldUnload()
|
bool CCore::ShouldUnload()
|
||||||
|
Loading…
Reference in New Issue
Block a user