diff --git a/r5dev/engine/sys_dll2.cpp b/r5dev/engine/sys_dll2.cpp index ffc5e5b5..adf56dc9 100644 --- a/r5dev/engine/sys_dll2.cpp +++ b/r5dev/engine/sys_dll2.cpp @@ -79,10 +79,6 @@ static void InitVPKSystem() InitReturnVal_t CEngineAPI::VInit(CEngineAPI* pEngineAPI) { - ConCommand::InitShipped(); - ConCommand::PurgeShipped(); - ConVar::InitShipped(); - ConVar::PurgeShipped(); return CEngineAPI_Init(pEngineAPI); } diff --git a/r5dev/launcher/IApplication.cpp b/r5dev/launcher/IApplication.cpp index e12c35cd..c573f345 100644 --- a/r5dev/launcher/IApplication.cpp +++ b/r5dev/launcher/IApplication.cpp @@ -33,6 +33,27 @@ #endif // !DEDICATED #include "public/idebugoverlay.h" +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CSourceAppSystemGroup::PreInit(CSourceAppSystemGroup* pSourceAppSystemGroup) +{ + ConVar::InitShipped(); + ConVar::PurgeShipped(); + ConCommand::Init(); + ConCommand::InitShipped(); + ConCommand::PurgeShipped(); + return CSourceAppSystemGroup__PreInit(pSourceAppSystemGroup); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CSourceAppSystemGroup::Create(CSourceAppSystemGroup* pSourceAppSystemGroup) +{ + return CSourceAppSystemGroup__Create(pSourceAppSystemGroup); +} + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -67,7 +88,6 @@ int CModAppSystemGroup::Main(CModAppSystemGroup* pModAppSystemGroup) //----------------------------------------------------------------------------- bool CModAppSystemGroup::Create(CModAppSystemGroup* pModAppSystemGroup) { - ConCommand::Init(); #ifdef DEDICATED pModAppSystemGroup->SetServerOnly(); *m_bIsDedicated = true; diff --git a/r5dev/launcher/IApplication.h b/r5dev/launcher/IApplication.h index 24254194..a6e89ff5 100644 --- a/r5dev/launcher/IApplication.h +++ b/r5dev/launcher/IApplication.h @@ -2,6 +2,16 @@ #include "public/appframework/IAppSystem.h" #include "public/appframework/IAppSystemGroup.h" +//------------------------------------------------------------------------- +// +//------------------------------------------------------------------------- +class CSourceAppSystemGroup : public CAppSystemGroup +{ +public: + static bool PreInit(CSourceAppSystemGroup* pSourceAppSystemGroup); + static bool Create(CSourceAppSystemGroup* pSourceAppSystemGroup); +}; + //------------------------------------------------------------------------- // //------------------------------------------------------------------------- @@ -36,10 +46,10 @@ inline CMemory p_CModAppSystemGroup_Create; inline auto CModAppSystemGroup_Create = p_CModAppSystemGroup_Create.RCast(); inline CMemory p_CSourceAppSystemGroup__PreInit; -inline auto CSourceAppSystemGroup__PreInit = p_CSourceAppSystemGroup__PreInit.RCast(); +inline auto CSourceAppSystemGroup__PreInit = p_CSourceAppSystemGroup__PreInit.RCast(); inline CMemory p_CSourceAppSystemGroup__Create; -inline auto CSourceAppSystemGroup__Create = p_CSourceAppSystemGroup__Create.RCast(); +inline auto CSourceAppSystemGroup__Create = p_CSourceAppSystemGroup__Create.RCast(); inline bool g_bAppSystemInit = false; @@ -68,21 +78,27 @@ class VApplication : public IDetour #endif p_CSourceAppSystemGroup__PreInit = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 55 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ??"); - CModAppSystemGroup_Main = p_CModAppSystemGroup_Main.RCast(); /*40 53 48 83 EC 20 80 B9 ?? ?? ?? ?? ?? BB ?? ?? ?? ??*/ - CModAppSystemGroup_Create = p_CModAppSystemGroup_Create.RCast(); /*48 8B C4 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60*/ - CSourceAppSystemGroup__PreInit = p_CSourceAppSystemGroup__PreInit.RCast(); /*48 89 74 24 ?? 55 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ??*/ - CSourceAppSystemGroup__Create = p_CSourceAppSystemGroup__Create.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 E8 ?? ?? ?? ?? 33 C9*/ + CModAppSystemGroup_Main = p_CModAppSystemGroup_Main.RCast(); /*40 53 48 83 EC 20 80 B9 ?? ?? ?? ?? ?? BB ?? ?? ?? ??*/ + CModAppSystemGroup_Create = p_CModAppSystemGroup_Create.RCast(); /*48 8B C4 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60*/ + CSourceAppSystemGroup__PreInit = p_CSourceAppSystemGroup__PreInit.RCast(); /*48 89 74 24 ?? 55 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ??*/ + CSourceAppSystemGroup__Create = p_CSourceAppSystemGroup__Create.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 E8 ?? ?? ?? ?? 33 C9*/ } virtual void GetVar(void) const { } virtual void GetCon(void) const { } virtual void Attach(void) const { + DetourAttach((LPVOID*)&CSourceAppSystemGroup__PreInit, &CSourceAppSystemGroup::PreInit); + DetourAttach((LPVOID*)&CSourceAppSystemGroup__Create, &CSourceAppSystemGroup::Create); + DetourAttach((LPVOID*)&CModAppSystemGroup_Main, &CModAppSystemGroup::Main); DetourAttach((LPVOID*)&CModAppSystemGroup_Create, &CModAppSystemGroup::Create); } virtual void Detach(void) const { + DetourDetach((LPVOID*)&CSourceAppSystemGroup__PreInit, &CSourceAppSystemGroup::PreInit); + DetourDetach((LPVOID*)&CSourceAppSystemGroup__Create, &CSourceAppSystemGroup::Create); + DetourDetach((LPVOID*)&CModAppSystemGroup_Main, &CModAppSystemGroup::Main); DetourDetach((LPVOID*)&CModAppSystemGroup_Create, &CModAppSystemGroup::Create); }