r5sdk/r5dev/launcher/IApplication.cpp
Kawe Mazidjatari 6a46486e99 See description
* Added 2 new FileSystem pointers with new features in their classes.
* Register all factory instances created by the GameDLL in the SDK.
* Added new command 'fs_mount_vpk' to mount a specified VPK file.
* Renamed 'fs_decompress_pak' to 'fs_unpack_vpk'.
* Some renaming of Factory and VPK types.
* Some light optimizations/cleanup.
2022-04-09 00:59:42 +02:00

87 lines
2.8 KiB
C++

//=============================================================================//
//
// Purpose: IApplication methods
//
//=============================================================================//
#include "core/stdafx.h"
#include "tier0/cvar.h"
#include "vpc/interfaces.h"
#include "launcher/IApplication.h"
#include "ebisusdk/EbisuSDK.h"
#include "engine/sys_engine.h"
#include "engine/sys_dll2.h"
#include "engine/sv_main.h"
#include "engine/host_cmd.h"
#include "server/vengineserver_impl.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int HModAppSystemGroup_Main(CModAppSystemGroup* modAppSystemGroup)
{
int nRunResult = RUN_OK;
HEbisuSDK_Init(); // Not here in retail. We init EbisuSDK here though.
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) // !TODO: rebuild does not work for S1 (CModAppSystemGroup and CEngine member offsets do align with all other builds).
return CModAppSystemGroup_Main(modAppSystemGroup);
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
if (modAppSystemGroup->m_bIsServerOnly()) // This will never be true anyway but we implement it for the sake of it.
{
if (g_pEngine->Load(true, g_pEngineParms->baseDirectory))
{
// Below is vfunc call that is supposed to be used for real dedicated servers. The class instance is sadly stripped to some degree.
//(*(void(__fastcall**)(__int64))(*(_QWORD*)qword_14C119C10 + 72i64))(qword_14C119C10);// dedicated->RunServer()
SV_ShutdownGameDLL();
}
}
else
{
g_pEngine->SetQuitting(EngineDllQuitting_t::QUIT_NOTQUITTING);
if (g_pEngine->Load(false, g_pEngineParms->baseDirectory))
{
if (CEngineAPI_MainLoop())
{
nRunResult = RUN_RESTART;
}
g_pEngine->Unload();
SV_ShutdownGameDLL();
}
}
return nRunResult;
#endif
}
//-----------------------------------------------------------------------------
// Purpose: Instantiate all main libraries
//-----------------------------------------------------------------------------
bool HModAppSystemGroup_Create(CModAppSystemGroup* modAppSystemGroup)
{
#ifdef DEDICATED
* g_bDedicated = true;
#endif // DEDICATED
g_pConCommand->Init();
g_pFactory->GetFactoriesFromRegister();
for (auto& map : g_pCVar->DumpToMap())
{
g_vsvCommandBases.push_back(map.first.c_str());
}
g_bAppSystemInit = true;
return CModAppSystemGroup_Create(modAppSystemGroup);
}
///////////////////////////////////////////////////////////////////////////////
void IApplication_Attach()
{
DetourAttach((LPVOID*)&CModAppSystemGroup_Main, &HModAppSystemGroup_Main);
DetourAttach((LPVOID*)&CModAppSystemGroup_Create, &HModAppSystemGroup_Create);
}
void IApplication_Detach()
{
DetourDetach((LPVOID*)&CModAppSystemGroup_Main, &HModAppSystemGroup_Main);
DetourDetach((LPVOID*)&CModAppSystemGroup_Create, &HModAppSystemGroup_Create);
}