2022-01-27 03:55:47 +01:00
//=============================================================================//
//
// Purpose: IApplication methods
//
//=============================================================================//
2021-12-25 22:36:38 +01:00
# include "core/stdafx.h"
2022-01-17 23:20:03 +01:00
# include "tier0/cvar.h"
2021-12-25 22:36:38 +01:00
# include "launcher/IApplication.h"
# include "ebisusdk/EbisuSDK.h"
2022-01-23 18:26:48 +01:00
# include "engine/sys_engine.h"
# include "engine/sys_dll2.h"
# include "engine/sv_main.h"
# include "engine/host_cmd.h"
2022-01-26 23:43:16 +01:00
# include "server/IVEngineServer.h"
2021-12-25 22:36:38 +01:00
//-----------------------------------------------------------------------------
2022-01-26 23:43:16 +01:00
// Purpose:
2021-12-25 22:36:38 +01:00
//-----------------------------------------------------------------------------
2022-02-19 16:42:40 +01:00
int HModAppSystemGroup_Main ( CModAppSystemGroup * modAppSystemGroup )
2021-12-25 22:36:38 +01:00
{
2022-02-22 02:45:40 +01:00
int nRunResult = RUN_OK ;
2022-01-23 18:26:48 +01:00
HEbisuSDK_Init ( ) ; // Not here in retail. We init EbisuSDK here though.
2022-03-07 13:15:45 +01:00
# 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)
2022-01-23 18:26:48 +01:00
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.
2022-01-26 23:43:16 +01:00
//(*(void(__fastcall**)(__int64))(*(_QWORD*)qword_14C119C10 + 72i64))(qword_14C119C10);// dedicated->RunServer()
2022-01-23 18:26:48 +01:00
SV_ShutdownGameDLL ( ) ;
}
}
else
{
g_pEngine - > SetQuitting ( EngineDllQuitting_t : : QUIT_NOTQUITTING ) ;
if ( g_pEngine - > Load ( false , g_pEngineParms - > baseDirectory ) )
{
if ( CEngineAPI_MainLoop ( ) )
{
2022-02-22 02:45:40 +01:00
nRunResult = RUN_RESTART ;
2022-01-23 18:26:48 +01:00
}
g_pEngine - > Unload ( ) ;
SV_ShutdownGameDLL ( ) ;
}
}
return nRunResult ;
2022-03-07 13:15:45 +01:00
# endif
2021-12-25 22:36:38 +01:00
}
//-----------------------------------------------------------------------------
2022-01-26 23:43:16 +01:00
// Purpose: Instantiate all main libraries
2021-12-25 22:36:38 +01:00
//-----------------------------------------------------------------------------
2022-02-19 16:42:40 +01:00
bool HModAppSystemGroup_Create ( CModAppSystemGroup * modAppSystemGroup )
2021-12-25 22:36:38 +01:00
{
2021-12-30 17:20:41 +01:00
# ifdef DEDICATED
2022-01-26 23:43:16 +01:00
* g_bDedicated = true ;
2021-12-30 17:20:41 +01:00
# endif // DEDICATED
2022-01-19 23:46:14 +01:00
g_pConCommand - > Init ( ) ;
2022-01-17 23:20:03 +01:00
for ( auto & map : g_pCVar - > DumpToMap ( ) )
{
2022-02-23 21:11:35 +01:00
g_vsvCommandBases . push_back ( map . first . c_str ( ) ) ;
2022-01-17 23:20:03 +01:00
}
2022-01-27 03:55:47 +01:00
g_bAppSystemInit = true ;
2022-02-19 16:42:40 +01:00
return CModAppSystemGroup_Create ( modAppSystemGroup ) ;
2021-12-25 22:36:38 +01:00
}
2022-02-19 16:42:40 +01:00
///////////////////////////////////////////////////////////////////////////////
2021-12-25 22:36:38 +01:00
void IApplication_Attach ( )
{
2022-02-19 16:42:40 +01:00
DetourAttach ( ( LPVOID * ) & CModAppSystemGroup_Main , & HModAppSystemGroup_Main ) ;
DetourAttach ( ( LPVOID * ) & CModAppSystemGroup_Create , & HModAppSystemGroup_Create ) ;
2021-12-25 22:36:38 +01:00
}
void IApplication_Detach ( )
{
2022-02-19 16:42:40 +01:00
DetourDetach ( ( LPVOID * ) & CModAppSystemGroup_Main , & HModAppSystemGroup_Main ) ;
DetourDetach ( ( LPVOID * ) & CModAppSystemGroup_Create , & HModAppSystemGroup_Create ) ;
2021-12-25 22:36:38 +01:00
}