r5sdk/r5dev/core/init.cpp
IcePixelx 212eeb87af Squashed commit of the following:
commit 477152b35443246dace6f5b4deccd52ea1cc6e9c
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Fri Dec 31 03:45:48 2021 +0100

    Fix compiler error

commit 5f664d8e6ba9a2e0bd72c29c5f4ba5279e29e75a
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Fri Dec 31 03:41:33 2021 +0100

    Create signatures for all used Dedicated functions

commit 2c7ced128d8c48a5abf8fd64dbb06909dc632f35
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Thu Dec 30 22:13:15 2021 +0100

    Heavy dedicated cleanup

    * Since the material mode is set to '2', all of the render loops and shader loading functions are no longer called. These have all been removed.
    * Added description for patches that missed them
    * Traced root caller/cause for certain patches to skip even more unnecessary code and save more memory.

commit 22c0b5c867664a2524c18d865dbc54ff067dda22
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Thu Dec 30 17:20:41 2021 +0100

    Dedicated server improvements

commit 6d4f7e345f38872ce45751604b40871b969cec8f
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Thu Dec 30 02:47:42 2021 +0100

    Fix a typo

commit 39a8a8fd30612522a274e1474c9a66e5019aeea3
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Thu Dec 30 02:36:43 2021 +0100

    Implement patch to enable 'DrawAllOverlays()'.

commit 83129e88f8a6033f8f4c13e3cac639097068cb3c
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Wed Dec 29 22:59:34 2021 +0100

    Fix LLVM compiler error

commit c48ed7f7a53a9985e3c2642db3639007d7c9129a
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Wed Dec 29 18:06:37 2021 +0100

    Rename dedicated variables

commit d1ba2bd56720a0776824a8e309d7d859704244bc
Author: IcePixelx <41352111+PixieCore@users.noreply.github.com>
Date:   Wed Dec 29 15:35:48 2021 +0100

    Fixed changelevel, needs more research tho.

commit 46950125716c05171f25a12d8805811112e90551
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Wed Dec 29 13:58:03 2021 +0100

    Fix 'C_PropDoor' not spawning properly on the server

commit 6a9a00735a9d4b8c415acc248c83e6e8d6dc2ff1
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Wed Dec 29 13:57:16 2021 +0100

    Rename hooked command callbacks

commit b514f928a69a9c4ac1d3d1e5c662f93a1f0d131d
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Wed Dec 29 02:16:21 2021 +0100

    Use a separate executable for dedicated server

    The dedicated server still has directx dll imports which will cause issues with ReShade or 3DMigoto, or trying to load it on a headless machine with no directx installed. The imports have to be cleared to avoid issues. The most convenient approach is to do this with a separate exe rather then patching it in runtime.

commit bc8f9400d3911e360757059700a31510e329546d
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Wed Dec 29 00:18:56 2021 +0100

    Fix collisions for headless dedicated server

commit 0e36aa647ffb15ca4f8c76b0431f7c3a83741d80
Author: Amos <48657826+Mauler125@users.noreply.github.com>
Date:   Tue Dec 28 20:19:17 2021 +0100

    Dedicated without ShaderApi and DirectX pre-alpha

    The instruction at 'CalcPropStaticFrustumCull' [0x14028F3B0 + 0x5C7] moves RSP + 0x70 into the R13 register.
    RSP + 0x70 seems to contain a pointer to collission data for that particular prop model.
    When running NoShaderApi() and passing the dedicated server the '-noshaderapi' command line parameter, RSP + 0x70 will be a nullptr.
    This has to be fixed to have prop static collissions on the server.
2022-01-03 14:59:32 +01:00

190 lines
7.3 KiB
C++

//=============================================================================//
//
// Purpose: Main systems initialization file
//
//=============================================================================//
#include "core/stdafx.h"
#include "core/init.h"
#include "common/opcodes.h"
#include "tier0/ConCommand.h"
#include "tier0/completion.h"
#include "tier0/cvar.h"
#include "tier0/IConVar.h"
#include "vpc/IAppSystem.h"
#include "vpc/keyvalues.h"
#include "vpc/basefilesystem.h"
#include "vpc/keyvalues.h"
#include "launcher/IApplication.h"
#include "ebisusdk/EbisuSDK.h"
#include "vphysics/QHull.h"
#include "bsplib/bsplib.h"
#ifndef DEDICATED
#include "vgui/CEngineVGui.h"
#include "vgui/vgui_fpspanel.h"
#include "vguimatsurface/MatSystemSurface.h"
#include "client/cdll_engine_int.h"
#endif // !DEDICATED
#include "client/client.h"
#include "client/IVEngineClient.h"
#include "server/server.h"
#include "server/IVEngineServer.h"
#include "squirrel/sqinit.h"
#include "squirrel/sqapi.h"
#include "squirrel/sqvm.h"
#include "rtech/rtech_game.h"
#include "rtech/stryder.h"
#include "engine/baseclient.h"
#include "engine/host_cmd.h"
#include "engine/host_state.h"
#include "engine/net_chan.h"
#include "engine/sys_dll.h"
#include "engine/sys_dll2.h"
#include "engine/sys_utils.h"
#ifndef DEDICATED
#include "inputsystem/inputsystem.h"
#include "windows/id3dx.h"
#endif // !DEDICATED
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// ██╗███╗ ██╗██╗████████╗██╗ █████╗ ██╗ ██╗███████╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗
// ██║████╗ ██║██║╚══██╔══╝██║██╔══██╗██║ ██║╚══███╔╝██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║
// ██║██╔██╗ ██║██║ ██║ ██║███████║██║ ██║ ███╔╝ ███████║ ██║ ██║██║ ██║██╔██╗ ██║
// ██║██║╚██╗██║██║ ██║ ██║██╔══██║██║ ██║ ███╔╝ ██╔══██║ ██║ ██║██║ ██║██║╚██╗██║
// ██║██║ ╚████║██║ ██║ ██║██║ ██║███████╗██║███████╗██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║
// ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
//
/////////////////////////////////////////////////////////////////////////////////////////////////
void Systems_Init()
{
// Begin the detour transaction to hook the the process
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
// Hook functions
IApplication_Attach();
CBaseClient_Attach();
CBaseFileSystem_Attach();
QHull_Attach();
//BspLib_Attach();
#ifndef DEDICATED
CEngineVGui_Attach();
CFPSPanel_Attach();
CHLClient_Attach();
#endif // !DEDICATED
CServer_Attach();
#ifdef DEDICATED
CHostState_Attach(); // Dedicated only for now until backwards compatible with S1.
#endif // DEDICATED
CNetChan_Attach();
ConCommand_Attach();
IConVar_Attach();
CKeyValueSystem_Attach();
IVEngineServer_Attach();
SQAPI_Attach();
SQVM_Attach();
RTech_Game_Attach();
SysDll_Attach();
SysUtils_Attach();
// Patch instructions
RuntimePtc_Init();
// Commit the transaction
if (DetourTransactionCommit() != NO_ERROR)
{
// Failed to hook into the process, terminate
TerminateProcess(GetCurrentProcess(), 0xBAD0C0DE);
}
IConVar_InitConVar();
#ifdef DEDICATED
Dedicated_Init();
#endif // DEDICATED
}
//////////////////////////////////////////////////////////////////////////
//
// ███████╗██╗ ██╗██╗ ██╗████████╗██████╗ ██████╗ ██╗ ██╗███╗ ██╗
// ██╔════╝██║ ██║██║ ██║╚══██╔══╝██╔══██╗██╔═══██╗██║ ██║████╗ ██║
// ███████╗███████║██║ ██║ ██║ ██║ ██║██║ ██║██║ █╗ ██║██╔██╗ ██║
// ╚════██║██╔══██║██║ ██║ ██║ ██║ ██║██║ ██║██║███╗██║██║╚██╗██║
// ███████║██║ ██║╚██████╔╝ ██║ ██████╔╝╚██████╔╝╚███╔███╔╝██║ ╚████║
// ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═══╝
//
//////////////////////////////////////////////////////////////////////////
void Systems_Shutdown()
{
// Begin the detour transaction to unhook the the process
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
// Unhook functions
IApplication_Detach();
CBaseClient_Detach();
CBaseFileSystem_Detach();
QHull_Detach();
//BspLib_Detach();
#ifndef DEDICATED
CEngineVGui_Detach();
CFPSPanel_Detach();
CHLClient_Detach();
#endif // !DEDICATED
CServer_Detach();
#ifdef DEDICATED
CHostState_Detach(); // Dedicated only for now until backwards compatible with S1.
#endif // DEDICATED
CNetChan_Detach();
ConCommand_Detach();
IConVar_Detach();
CKeyValueSystem_Detach();
IVEngineServer_Detach();
SQAPI_Detach();
SQVM_Detach();
RTech_Game_Detach();
SysDll_Detach();
SysUtils_Detach();
// Commit the transaction
DetourTransactionCommit();
}
//////////////////////////////////////////////////////////
//
// ██████╗ ███████╗███████╗██╗ ██╗██╗ ████████╗███████╗
// ██╔══██╗██╔════╝██╔════╝██║ ██║██║ ╚══██╔══╝██╔════╝
// ██████╔╝█████╗ ███████╗██║ ██║██║ ██║ ███████╗
// ██╔══██╗██╔══╝ ╚════██║██║ ██║██║ ██║ ╚════██║
// ██║ ██║███████╗███████║╚██████╔╝███████╗██║ ███████║
// ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚══════╝╚═╝ ╚══════╝
//
//////////////////////////////////////////////////////////
void PrintHAddress() // Test the sigscan results
{
std::cout << "+----------------------------------------------------------------+" << std::endl;
for (IDetour* pdetour : vdetour)
{
pdetour->debugp();
}
}