2021-12-25 22:36:38 +01:00
|
|
|
|
//=============================================================================//
|
|
|
|
|
//
|
|
|
|
|
// Purpose: Main systems initialization file
|
|
|
|
|
//
|
|
|
|
|
//=============================================================================//
|
|
|
|
|
|
|
|
|
|
#include "core/stdafx.h"
|
2022-06-20 15:48:33 +02:00
|
|
|
|
#include "core/logdef.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "core/init.h"
|
2022-04-18 03:46:26 +02:00
|
|
|
|
#include "tier0/jobthread.h"
|
2022-04-30 03:30:16 +02:00
|
|
|
|
#include "tier0/threadtools.h"
|
2022-04-15 04:02:33 +02:00
|
|
|
|
#include "tier0/tslist.h"
|
2022-07-22 16:34:10 +02:00
|
|
|
|
#include "tier0/memstd.h"
|
2022-04-11 01:51:50 +02:00
|
|
|
|
#include "tier0/fasttimer.h"
|
2022-04-11 01:44:30 +02:00
|
|
|
|
#include "tier0/cpu.h"
|
2022-01-10 01:20:44 +01:00
|
|
|
|
#include "tier0/commandline.h"
|
2022-06-20 14:58:53 +02:00
|
|
|
|
#include "tier0/platform_internal.h"
|
2022-04-09 16:16:40 +02:00
|
|
|
|
#include "tier1/cmd.h"
|
|
|
|
|
#include "tier1/IConVar.h"
|
|
|
|
|
#include "tier1/cvar.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "vpc/IAppSystem.h"
|
|
|
|
|
#include "vpc/keyvalues.h"
|
2022-01-18 01:21:24 +01:00
|
|
|
|
#include "vpc/interfaces.h"
|
2022-04-14 19:18:59 +02:00
|
|
|
|
#include "vstdlib/callback.h"
|
2022-04-09 16:16:40 +02:00
|
|
|
|
#include "vstdlib/completion.h"
|
|
|
|
|
#include "vstdlib/keyvaluessystem.h"
|
2022-01-04 12:11:59 +01:00
|
|
|
|
#include "common/opcodes.h"
|
2022-02-19 16:42:40 +01:00
|
|
|
|
#include "common/netmessages.h"
|
2022-02-18 14:00:58 +01:00
|
|
|
|
#include "launcher/prx.h"
|
2022-04-16 00:30:46 +02:00
|
|
|
|
#include "launcher/launcher.h"
|
|
|
|
|
#include "launcher/IApplication.h"
|
2022-04-09 00:59:42 +02:00
|
|
|
|
#include "filesystem/basefilesystem.h"
|
|
|
|
|
#include "filesystem/filesystem.h"
|
2022-04-29 05:30:06 +02:00
|
|
|
|
#include "datacache/mdlcache.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "ebisusdk/EbisuSDK.h"
|
2022-01-05 22:56:49 +01:00
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
#include "milessdk/win64_rrthreads.h"
|
|
|
|
|
#endif // !DEDICATED
|
2022-07-08 00:55:01 +02:00
|
|
|
|
#include "mathlib/mathlib.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "vphysics/QHull.h"
|
|
|
|
|
#include "bsplib/bsplib.h"
|
2022-03-26 01:04:20 +01:00
|
|
|
|
#include "materialsystem/cmaterialsystem.h"
|
2022-04-18 03:46:26 +02:00
|
|
|
|
#ifndef DEDICATED
|
2022-03-26 01:04:20 +01:00
|
|
|
|
#include "materialsystem/cmaterialglue.h"
|
2022-02-19 02:31:16 +01:00
|
|
|
|
#include "vgui/vgui_baseui_interface.h"
|
|
|
|
|
#include "vgui/vgui_debugpanel.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "vgui/vgui_fpspanel.h"
|
|
|
|
|
#include "vguimatsurface/MatSystemSurface.h"
|
|
|
|
|
#endif // !DEDICATED
|
2022-04-14 19:18:59 +02:00
|
|
|
|
#include "client/cdll_engine_int.h"
|
2022-04-02 12:27:35 +02:00
|
|
|
|
#include "client/vengineclient_impl.h"
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#ifndef CLIENT_DLL
|
2022-05-20 11:52:19 +02:00
|
|
|
|
#include "engine/server/server.h"
|
2022-07-08 23:42:28 +02:00
|
|
|
|
#include "server/persistence.h"
|
2022-04-02 12:27:35 +02:00
|
|
|
|
#include "server/vengineserver_impl.h"
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !CLIENT_DLL
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "squirrel/sqinit.h"
|
|
|
|
|
#include "squirrel/sqapi.h"
|
|
|
|
|
#include "squirrel/sqvm.h"
|
2022-05-28 22:02:00 +02:00
|
|
|
|
#include "squirrel/sqscript.h"
|
2022-05-09 21:21:05 +02:00
|
|
|
|
#include "squirrel/sqstdaux.h"
|
2022-02-19 16:42:40 +01:00
|
|
|
|
#include "studiorender/studiorendercontext.h"
|
2021-12-27 16:53:35 +01:00
|
|
|
|
#include "rtech/rtech_game.h"
|
2022-04-19 03:55:20 +02:00
|
|
|
|
#include "rtech/rtech_utils.h"
|
2022-03-23 23:28:12 +01:00
|
|
|
|
#include "rtech/stryder/stryder.h"
|
|
|
|
|
#include "rtech/rui/rui.h"
|
2022-05-20 11:52:19 +02:00
|
|
|
|
#include "engine/client/cl_main.h"
|
|
|
|
|
#include "engine/client/client.h"
|
|
|
|
|
#include "engine/client/clientstate.h"
|
2022-02-19 02:31:16 +01:00
|
|
|
|
#include "engine/common.h"
|
|
|
|
|
#include "engine/cmodel_bsp.h"
|
2022-04-12 02:48:46 +02:00
|
|
|
|
#include "engine/host.h"
|
2021-12-27 16:53:35 +01:00
|
|
|
|
#include "engine/host_cmd.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "engine/host_state.h"
|
2022-02-19 02:31:16 +01:00
|
|
|
|
#include "engine/modelloader.h"
|
2022-02-14 02:33:13 +01:00
|
|
|
|
#include "engine/net.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "engine/net_chan.h"
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#ifndef CLIENT_DLL
|
2022-05-20 11:52:19 +02:00
|
|
|
|
#include "engine/server/sv_main.h"
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !CLIENT_DLL
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "engine/sys_dll.h"
|
|
|
|
|
#include "engine/sys_dll2.h"
|
2022-01-26 23:43:16 +01:00
|
|
|
|
#include "engine/sys_engine.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "engine/sys_utils.h"
|
2022-02-19 16:42:40 +01:00
|
|
|
|
#include "engine/sys_getmodes.h"
|
2022-03-02 01:16:35 +01:00
|
|
|
|
#include "engine/gl_matsysiface.h"
|
2022-02-19 02:31:16 +01:00
|
|
|
|
#include "engine/gl_screen.h"
|
2022-03-02 01:16:35 +01:00
|
|
|
|
#ifndef DEDICATED
|
2022-04-29 20:12:54 +02:00
|
|
|
|
#include "engine/gl_rsurf.h"
|
2022-01-04 12:11:59 +01:00
|
|
|
|
#include "engine/debugoverlay.h"
|
2022-02-19 16:42:40 +01:00
|
|
|
|
#endif // !DEDICATED
|
2022-04-30 18:59:55 +02:00
|
|
|
|
#include "game/shared/animation.h"
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#ifndef CLIENT_DLL
|
2022-02-27 03:15:00 +01:00
|
|
|
|
#include "game/server/ai_node.h"
|
|
|
|
|
#include "game/server/ai_network.h"
|
|
|
|
|
#include "game/server/ai_networkmanager.h"
|
2022-03-18 03:14:07 +01:00
|
|
|
|
#include "game/server/ai_utility.h"
|
|
|
|
|
#include "game/server/detour_impl.h"
|
2022-02-19 16:42:40 +01:00
|
|
|
|
#include "game/server/fairfight_impl.h"
|
2022-02-24 01:51:11 +01:00
|
|
|
|
#include "game/server/gameinterface.h"
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !CLIENT_DLL
|
2022-02-19 16:42:40 +01:00
|
|
|
|
#ifndef DEDICATED
|
2022-07-25 12:46:57 +02:00
|
|
|
|
#include "game/client/view.h"
|
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
#include "public/include/edict.h"
|
|
|
|
|
#ifndef DEDICATED
|
2022-07-12 17:46:47 +02:00
|
|
|
|
#include "public/include/idebugoverlay.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "inputsystem/inputsystem.h"
|
|
|
|
|
#include "windows/id3dx.h"
|
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ██╗███╗ ██╗██╗████████╗██╗ █████╗ ██╗ ██╗███████╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗
|
|
|
|
|
// ██║████╗ ██║██║╚══██╔══╝██║██╔══██╗██║ ██║╚══███╔╝██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║
|
|
|
|
|
// ██║██╔██╗ ██║██║ ██║ ██║███████║██║ ██║ ███╔╝ ███████║ ██║ ██║██║ ██║██╔██╗ ██║
|
|
|
|
|
// ██║██║╚██╗██║██║ ██║ ██║██╔══██║██║ ██║ ███╔╝ ██╔══██║ ██║ ██║██║ ██║██║╚██╗██║
|
|
|
|
|
// ██║██║ ╚████║██║ ██║ ██║██║ ██║███████╗██║███████╗██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║
|
|
|
|
|
// ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void Systems_Init()
|
|
|
|
|
{
|
2022-04-18 03:46:26 +02:00
|
|
|
|
spdlog::info("+-------------------------------------------------------------+\n");
|
2022-04-18 16:45:26 +02:00
|
|
|
|
QuerySystemInfo();
|
2022-04-12 02:48:46 +02:00
|
|
|
|
|
2022-07-08 00:55:01 +02:00
|
|
|
|
CFastTimer initTimer;
|
|
|
|
|
|
2022-07-26 03:00:51 +02:00
|
|
|
|
initTimer.Start();
|
|
|
|
|
DetourInit();
|
2022-04-18 03:46:26 +02:00
|
|
|
|
initTimer.End();
|
2022-07-08 00:55:01 +02:00
|
|
|
|
|
2022-04-18 03:46:26 +02:00
|
|
|
|
spdlog::info("+-------------------------------------------------------------+\n");
|
2022-05-19 02:20:52 +02:00
|
|
|
|
spdlog::info("Detour->Init() '{:10.6f}' seconds ('{:12d}' clocks)\n", initTimer.GetDuration().GetSeconds(), initTimer.GetDuration().GetCycles());
|
2022-04-12 02:48:46 +02:00
|
|
|
|
|
2022-04-18 03:46:26 +02:00
|
|
|
|
initTimer.Start();
|
2022-04-11 01:44:30 +02:00
|
|
|
|
|
2022-07-08 00:55:01 +02:00
|
|
|
|
WS_Init(); // Initialize WinSock.
|
|
|
|
|
MathLib_Init(); // Initialize MathLib.
|
2022-04-11 01:44:30 +02:00
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
// Begin the detour transaction to hook the the process
|
|
|
|
|
DetourTransactionBegin();
|
|
|
|
|
DetourUpdateThread(GetCurrentThread());
|
|
|
|
|
|
|
|
|
|
// Hook functions
|
2022-05-17 23:00:30 +02:00
|
|
|
|
//TSList_Attach();
|
|
|
|
|
|
|
|
|
|
Launcher_Attach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
IApplication_Attach();
|
2022-02-18 14:00:58 +01:00
|
|
|
|
#ifdef DEDICATED
|
2022-02-27 19:47:29 +01:00
|
|
|
|
//PRX_Attach();
|
2022-02-18 14:00:58 +01:00
|
|
|
|
#endif // DEDICATED
|
2021-12-25 22:36:38 +01:00
|
|
|
|
CBaseClient_Attach();
|
|
|
|
|
CBaseFileSystem_Attach();
|
|
|
|
|
|
2022-04-29 05:30:06 +02:00
|
|
|
|
MDLCache_Attach();
|
|
|
|
|
|
2022-03-02 01:16:35 +01:00
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
CMaterialSystem_Attach();
|
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
|
2021-12-28 01:18:08 +01:00
|
|
|
|
QHull_Attach();
|
2022-05-01 01:32:23 +02:00
|
|
|
|
BspLib_Attach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
CEngineVGui_Attach();
|
2022-06-12 17:50:12 +02:00
|
|
|
|
//CFPSPanel_Attach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
CHLClient_Attach();
|
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#if !defined(CLIENT_DLL) && defined (GAMEDLL_S3)
|
2022-01-05 02:07:37 +01:00
|
|
|
|
CServer_Attach(); // S1 and S2 CServer functions require work.
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !CLIENT_DLL && GAMEDLL_S3
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
2022-02-19 02:31:16 +01:00
|
|
|
|
CHostState_Attach();
|
2022-05-04 02:25:27 +02:00
|
|
|
|
|
|
|
|
|
CModelBsp_Attach();
|
2022-04-29 05:30:06 +02:00
|
|
|
|
CModelLoader_Attach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
2022-04-27 16:29:14 +02:00
|
|
|
|
#if !defined(DEDICATED) && defined (GAMEDLL_S3)
|
|
|
|
|
CNetMessages_Attach(); // S1 and S2 require certification.
|
|
|
|
|
#endif // !DEDICATED && GAMEDLL_S3
|
|
|
|
|
|
2022-04-02 02:48:54 +02:00
|
|
|
|
NET_Attach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
ConCommand_Attach();
|
|
|
|
|
IConVar_Attach();
|
|
|
|
|
CKeyValueSystem_Attach();
|
2022-03-23 23:05:43 +01:00
|
|
|
|
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#ifndef CLIENT_DLL
|
2022-07-08 23:42:28 +02:00
|
|
|
|
Persistence_Attach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
IVEngineServer_Attach();
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !CLIENT_DLL
|
2022-03-23 23:05:43 +01:00
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
SQAPI_Attach();
|
|
|
|
|
SQVM_Attach();
|
2022-05-28 22:02:00 +02:00
|
|
|
|
SQScript_Attach();
|
2022-05-09 21:21:05 +02:00
|
|
|
|
SQAUX_Attach();
|
2021-12-27 16:53:35 +01:00
|
|
|
|
|
|
|
|
|
RTech_Game_Attach();
|
2022-06-19 18:07:43 +02:00
|
|
|
|
RTech_Utils_Attach();
|
2022-03-23 23:28:12 +01:00
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
Rui_Attach();
|
|
|
|
|
#endif // !DEDICATED
|
2021-12-27 16:53:35 +01:00
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
SysDll_Attach();
|
2022-04-15 04:02:33 +02:00
|
|
|
|
SysDll2_Attach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
SysUtils_Attach();
|
|
|
|
|
|
2022-02-28 01:01:40 +01:00
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
HCVideoMode_Common_Attach();
|
2022-06-15 01:24:29 +02:00
|
|
|
|
DebugOverlays_Attach();
|
2022-04-29 20:12:54 +02:00
|
|
|
|
RSurf_Attach();
|
2022-02-28 01:01:40 +01:00
|
|
|
|
#endif // !DEDICATED
|
2022-03-23 23:05:43 +01:00
|
|
|
|
|
2022-04-30 18:59:55 +02:00
|
|
|
|
Animation_Attach();
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#ifndef CLIENT_DLL
|
2022-03-18 03:14:07 +01:00
|
|
|
|
CAI_Utility_Attach();
|
2022-04-03 03:10:48 +02:00
|
|
|
|
CAI_Network_Attach();
|
2022-03-20 17:03:46 +01:00
|
|
|
|
CAI_NetworkManager_Attach();
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !#ifndef CLIENT_DLL
|
2021-12-25 22:36:38 +01:00
|
|
|
|
// Patch instructions
|
|
|
|
|
RuntimePtc_Init();
|
|
|
|
|
|
|
|
|
|
// Commit the transaction
|
|
|
|
|
if (DetourTransactionCommit() != NO_ERROR)
|
|
|
|
|
{
|
|
|
|
|
// Failed to hook into the process, terminate
|
|
|
|
|
TerminateProcess(GetCurrentProcess(), 0xBAD0C0DE);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-18 03:46:26 +02:00
|
|
|
|
initTimer.End();
|
2022-05-19 02:20:52 +02:00
|
|
|
|
spdlog::info("Detour->Attach() '{:10.6f}' seconds ('{:12d}' clocks)\n", initTimer.GetDuration().GetSeconds(), initTimer.GetDuration().GetCycles());
|
2022-04-18 03:46:26 +02:00
|
|
|
|
spdlog::info("+-------------------------------------------------------------+\n");
|
|
|
|
|
|
2022-01-09 16:14:17 +01:00
|
|
|
|
g_pConVar->Init();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
|
|
#ifdef DEDICATED
|
|
|
|
|
Dedicated_Init();
|
|
|
|
|
#endif // DEDICATED
|
2022-06-20 15:48:33 +02:00
|
|
|
|
|
|
|
|
|
SpdLog_PostInit();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ███████╗██╗ ██╗██╗ ██╗████████╗██████╗ ██████╗ ██╗ ██╗███╗ ██╗
|
|
|
|
|
// ██╔════╝██║ ██║██║ ██║╚══██╔══╝██╔══██╗██╔═══██╗██║ ██║████╗ ██║
|
|
|
|
|
// ███████╗███████║██║ ██║ ██║ ██║ ██║██║ ██║██║ █╗ ██║██╔██╗ ██║
|
|
|
|
|
// ╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║███╗██║██║╚██╗██║
|
|
|
|
|
// ███████║██║ ██║╚██████╔╝ ██║ ██████╔╝╚██████╔╝╚███╔███╔╝██║ ╚████║
|
|
|
|
|
// ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═══╝
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void Systems_Shutdown()
|
|
|
|
|
{
|
2022-04-18 03:46:26 +02:00
|
|
|
|
CFastTimer shutdownTimer;
|
|
|
|
|
shutdownTimer.Start();
|
|
|
|
|
|
2022-04-11 01:44:30 +02:00
|
|
|
|
// Shutdown WinSock system.
|
|
|
|
|
WS_Shutdown();
|
2022-02-06 15:44:39 +01:00
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
// Begin the detour transaction to unhook the the process
|
|
|
|
|
DetourTransactionBegin();
|
|
|
|
|
DetourUpdateThread(GetCurrentThread());
|
|
|
|
|
|
|
|
|
|
// Unhook functions
|
2022-05-17 23:00:30 +02:00
|
|
|
|
//TSList_Detach();
|
|
|
|
|
|
|
|
|
|
Launcher_Detach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
IApplication_Detach();
|
2022-02-18 14:00:58 +01:00
|
|
|
|
#ifdef DEDICATED
|
2022-02-27 19:47:29 +01:00
|
|
|
|
//PRX_Detach();
|
2022-02-18 14:00:58 +01:00
|
|
|
|
#endif // DEDICATED
|
2021-12-25 22:36:38 +01:00
|
|
|
|
CBaseClient_Detach();
|
|
|
|
|
CBaseFileSystem_Detach();
|
|
|
|
|
|
2022-04-29 05:30:06 +02:00
|
|
|
|
MDLCache_Detach();
|
|
|
|
|
|
2022-03-02 01:16:35 +01:00
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
CMaterialSystem_Detach();
|
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
|
2021-12-28 01:18:08 +01:00
|
|
|
|
QHull_Detach();
|
2022-05-01 01:32:23 +02:00
|
|
|
|
BspLib_Detach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
CEngineVGui_Detach();
|
2022-06-12 17:50:12 +02:00
|
|
|
|
//CFPSPanel_Detach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
CHLClient_Detach();
|
|
|
|
|
#endif // !DEDICATED
|
2022-01-05 02:07:37 +01:00
|
|
|
|
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#if !defined(CLIENT_DLL) && defined (GAMEDLL_S3)
|
2022-01-05 02:07:37 +01:00
|
|
|
|
CServer_Detach(); // S1 and S2 CServer functions require work.
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !CLIENT_DLL && GAMEDLL_S3
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
2022-04-19 00:00:45 +02:00
|
|
|
|
CHostState_Detach();
|
2022-05-04 02:25:27 +02:00
|
|
|
|
|
|
|
|
|
CModelBsp_Detach();
|
2022-04-29 05:30:06 +02:00
|
|
|
|
CModelLoader_Detach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
2022-04-27 16:29:14 +02:00
|
|
|
|
#if !defined(DEDICATED) && defined (GAMEDLL_S3)
|
|
|
|
|
CNetMessages_Detach(); // S1 and S2 require certification.
|
|
|
|
|
#endif // !DEDICATED && GAMEDLL_S3
|
|
|
|
|
|
2022-04-02 02:48:54 +02:00
|
|
|
|
NET_Detach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
ConCommand_Detach();
|
|
|
|
|
IConVar_Detach();
|
|
|
|
|
CKeyValueSystem_Detach();
|
2022-03-23 23:05:43 +01:00
|
|
|
|
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#ifndef CLIENT_DLL
|
2022-07-08 23:42:28 +02:00
|
|
|
|
Persistence_Detach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
IVEngineServer_Detach();
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !CLIENT_DLL
|
2021-12-25 22:36:38 +01:00
|
|
|
|
SQAPI_Detach();
|
|
|
|
|
SQVM_Detach();
|
2022-05-28 22:02:00 +02:00
|
|
|
|
SQScript_Detach();
|
2022-05-09 21:21:05 +02:00
|
|
|
|
SQAUX_Detach();
|
2021-12-27 16:53:35 +01:00
|
|
|
|
|
|
|
|
|
RTech_Game_Detach();
|
2022-06-19 18:07:43 +02:00
|
|
|
|
RTech_Utils_Detach();
|
2022-03-23 23:28:12 +01:00
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
Rui_Detach();
|
|
|
|
|
#endif // !DEDICATED
|
2021-12-27 16:53:35 +01:00
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
SysDll_Detach();
|
2022-04-15 04:02:33 +02:00
|
|
|
|
SysDll2_Detach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
SysUtils_Detach();
|
|
|
|
|
|
2022-02-28 01:01:40 +01:00
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
HCVideoMode_Common_Detach();
|
2022-06-15 01:24:29 +02:00
|
|
|
|
DebugOverlays_Detach();
|
2022-04-29 20:12:54 +02:00
|
|
|
|
RSurf_Detach();
|
2022-02-28 01:01:40 +01:00
|
|
|
|
#endif // !DEDICATED
|
2022-03-23 23:05:43 +01:00
|
|
|
|
|
2022-04-30 18:59:55 +02:00
|
|
|
|
Animation_Detach();
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#ifndef CLIENT_DLL
|
2022-03-18 03:14:07 +01:00
|
|
|
|
CAI_Utility_Detach();
|
2022-04-03 03:10:48 +02:00
|
|
|
|
CAI_Network_Detach();
|
2022-03-20 17:03:46 +01:00
|
|
|
|
CAI_NetworkManager_Detach();
|
2022-03-27 22:17:30 +02:00
|
|
|
|
#endif // !CLIENT_DLL
|
2022-02-28 01:01:40 +01:00
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
// Commit the transaction
|
|
|
|
|
DetourTransactionCommit();
|
2022-04-18 03:46:26 +02:00
|
|
|
|
|
|
|
|
|
shutdownTimer.End();
|
2022-05-19 02:20:52 +02:00
|
|
|
|
spdlog::info("Detour->Detach() '{:10.6f}' seconds ('{:12d}' clocks)\n", shutdownTimer.GetDuration().GetSeconds(), shutdownTimer.GetDuration().GetCycles());
|
2022-04-18 03:46:26 +02:00
|
|
|
|
spdlog::info("+-------------------------------------------------------------+\n");
|
2021-12-25 22:36:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-11 01:44:30 +02:00
|
|
|
|
/////////////////////////////////////////////////////
|
2021-12-25 22:36:38 +01:00
|
|
|
|
//
|
2022-04-11 01:44:30 +02:00
|
|
|
|
// ██╗ ██╗████████╗██╗██╗ ██╗████████╗██╗ ██╗
|
|
|
|
|
// ██║ ██║╚══██╔══╝██║██║ ██║╚══██╔══╝╚██╗ ██╔╝
|
|
|
|
|
// ██║ ██║ ██║ ██║██║ ██║ ██║ ╚████╔╝
|
|
|
|
|
// ██║ ██║ ██║ ██║██║ ██║ ██║ ╚██╔╝
|
|
|
|
|
// ╚██████╔╝ ██║ ██║███████╗██║ ██║ ██║
|
2022-04-18 03:46:26 +02:00
|
|
|
|
// ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝
|
2021-12-25 22:36:38 +01:00
|
|
|
|
//
|
2022-04-11 01:44:30 +02:00
|
|
|
|
/////////////////////////////////////////////////////
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
2022-04-11 01:44:30 +02:00
|
|
|
|
void WS_Init()
|
|
|
|
|
{
|
|
|
|
|
WSAData wsaData{};
|
|
|
|
|
int nError = ::WSAStartup(MAKEWORD(2, 2), &wsaData);
|
|
|
|
|
if (nError != 0)
|
|
|
|
|
{
|
|
|
|
|
std::cerr << "Failed to start Winsock via WSAStartup: (" << NET_ErrorString(WSAGetLastError()) << ")" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void WS_Shutdown()
|
|
|
|
|
{
|
|
|
|
|
int nError = ::WSACleanup();
|
|
|
|
|
if (nError != 0)
|
|
|
|
|
{
|
|
|
|
|
std::cerr << "Failed to stop winsock via WSACleanup: (" << NET_ErrorString(WSAGetLastError()) << ")" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-18 16:45:26 +02:00
|
|
|
|
void QuerySystemInfo()
|
2022-04-11 01:44:30 +02:00
|
|
|
|
{
|
|
|
|
|
const CPUInformation& pi = GetCPUInformation();
|
|
|
|
|
|
2022-04-18 16:45:26 +02:00
|
|
|
|
spdlog::info("CPU model identifier : '{:s}'\n", pi.m_szProcessorBrand);
|
|
|
|
|
spdlog::info("CPU vendor identifier : '{:s}'\n", pi.m_szProcessorID);
|
2022-04-25 03:14:49 +02:00
|
|
|
|
spdlog::info("CPU core count : '{:12d}' ({:s})\n", pi.m_nPhysicalProcessors, "Physical");
|
|
|
|
|
spdlog::info("CPU core count : '{:12d}' ({:s})\n", pi.m_nLogicalProcessors, "Logical");
|
|
|
|
|
spdlog::info("L1 cache (KiB): '{:12d}'\n", pi.m_nL1CacheSizeKb);
|
|
|
|
|
spdlog::info("L1 cache (Dsc): '{:#12x}'\n" , pi.m_nL1CacheDesc);
|
|
|
|
|
spdlog::info("L2 cache (KiB): '{:12d}'\n", pi.m_nL2CacheSizeKb);
|
|
|
|
|
spdlog::info("L2 cache (Dsc): '{:#12x}'\n" , pi.m_nL2CacheDesc);
|
|
|
|
|
spdlog::info("L3 cache (KiB): '{:12d}'\n", pi.m_nL3CacheSizeKb);
|
|
|
|
|
spdlog::info("L3 cache (Dsc): '{:#12x}'\n" , pi.m_nL3CacheDesc);
|
|
|
|
|
spdlog::info("Clock speed (CPS): '{:12d}'\n", pi.m_Speed);
|
2022-04-18 16:45:26 +02:00
|
|
|
|
|
|
|
|
|
MEMORYSTATUSEX statex{};
|
|
|
|
|
statex.dwLength = sizeof(statex);
|
|
|
|
|
|
|
|
|
|
if (GlobalMemoryStatusEx(&statex))
|
|
|
|
|
{
|
2022-04-25 03:14:49 +02:00
|
|
|
|
spdlog::info("Total system memory (MiB): '{:12d}' ({:s})\n", (statex.ullTotalPhys / 1024) / 1024, "Physical");
|
|
|
|
|
spdlog::info("Avail system memory (MiB): '{:12d}' ({:s})\n", (statex.ullAvailPhys / 1024) / 1024, "Physical");
|
|
|
|
|
spdlog::info("Total system memory (MiB): '{:12d}' ({:s})\n", (statex.ullTotalVirtual / 1024) / 1024, "Virtual");
|
|
|
|
|
spdlog::info("Avail system memory (MiB): '{:12d}' ({:s})\n", (statex.ullAvailVirtual / 1024) / 1024, "Virtual");
|
2022-04-18 16:45:26 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
spdlog::error("Unable to retrieve system memory information: {:s}\n",
|
|
|
|
|
std::system_category().message(static_cast<int>(::GetLastError())));
|
|
|
|
|
}
|
2022-07-01 19:51:43 +02:00
|
|
|
|
|
2022-07-08 00:55:01 +02:00
|
|
|
|
if (!s_bMathlibInitialized)
|
2022-07-01 19:51:43 +02:00
|
|
|
|
{
|
2022-07-08 00:55:01 +02:00
|
|
|
|
if (!(pi.m_bSSE && pi.m_bSSE2))
|
2022-07-01 19:51:43 +02:00
|
|
|
|
{
|
2022-07-08 00:55:01 +02:00
|
|
|
|
if (MessageBoxA(NULL, "SSE and SSE2 are required.", "Unsupported CPU", MB_ICONERROR | MB_OK))
|
|
|
|
|
{
|
|
|
|
|
TerminateProcess(GetCurrentProcess(), 0xBAD0C0DE);
|
|
|
|
|
}
|
2022-07-01 19:51:43 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-11 01:44:30 +02:00
|
|
|
|
}
|
2022-04-18 16:45:26 +02:00
|
|
|
|
|
2022-07-26 03:00:51 +02:00
|
|
|
|
void DetourInit() // Run the sigscan
|
|
|
|
|
{
|
|
|
|
|
for (const IDetour* pDetour : vDetour)
|
|
|
|
|
{
|
|
|
|
|
pDetour->GetCon(); // Constants.
|
|
|
|
|
pDetour->GetFun(); // Functions.
|
|
|
|
|
pDetour->GetVar(); // Variables.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void DetourAddress() // Test the sigscan results
|
2021-12-25 22:36:38 +01:00
|
|
|
|
{
|
2022-05-13 14:53:25 +02:00
|
|
|
|
spdlog::debug("+----------------------------------------------------------------+\n");
|
2022-07-26 03:00:51 +02:00
|
|
|
|
for (const IDetour* pDetour : vDetour)
|
2021-12-25 22:36:38 +01:00
|
|
|
|
{
|
2022-04-18 03:46:26 +02:00
|
|
|
|
pDetour->GetAdr();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|