2022-01-27 03:55:47 +01:00
//=============================================================================//
//
// Purpose: IApplication methods
//
//=============================================================================//
2021-12-25 22:36:38 +01:00
# include "core/stdafx.h"
2022-08-13 20:21:32 +02:00
# include "tier0/commandline.h"
2022-04-09 16:16:40 +02:00
# include "tier1/cvar.h"
2022-04-09 00:59:42 +02:00
# include "vpc/interfaces.h"
2021-12-25 22:36:38 +01:00
# include "launcher/IApplication.h"
# include "ebisusdk/EbisuSDK.h"
2022-05-27 02:08:51 +02:00
# include "engine/cmodel_bsp.h"
2022-01-23 18:26:48 +01:00
# include "engine/sys_engine.h"
# include "engine/sys_dll2.h"
# include "engine/host_cmd.h"
2022-05-20 11:52:19 +02:00
# include "engine/server/sv_main.h"
2022-04-02 12:27:35 +02:00
# include "server/vengineserver_impl.h"
2022-04-14 19:18:59 +02:00
# include "client/cdll_engine_int.h"
2022-04-26 20:24:51 +02:00
# ifndef DEDICATED
# include "gameui/IConsole.h"
# endif // !DEDICATED
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-04-14 19:18:59 +02:00
int CModAppSystemGroup : : Main ( CModAppSystemGroup * pModAppSystemGroup )
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-05-27 02:08:51 +02:00
MOD_GetAllInstalledMaps ( ) ;
2022-01-23 18:26:48 +01:00
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).
2022-04-19 00:00:45 +02:00
return CModAppSystemGroup_Main ( pModAppSystemGroup ) ;
2022-03-07 13:15:45 +01:00
# elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
2022-04-14 19:18:59 +02:00
2022-08-09 11:53:33 +02:00
g_pEngine - > SetQuitting ( IEngine : : QUIT_NOTQUITTING ) ;
2022-04-14 19:18:59 +02:00
if ( g_pEngine - > Load ( pModAppSystemGroup - > IsServerOnly ( ) , g_pEngineParms - > baseDirectory ) )
2022-01-23 18:26:48 +01:00
{
2022-04-14 19:18:59 +02:00
if ( CEngineAPI_MainLoop ( ) )
2022-01-23 18:26:48 +01:00
{
2022-04-14 19:18:59 +02:00
nRunResult = RUN_RESTART ;
2022-01-23 18:26:48 +01:00
}
2022-04-14 19:18:59 +02:00
g_pEngine - > Unload ( ) ;
SV_ShutdownGameDLL ( ) ;
2022-01-23 18:26:48 +01:00
}
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-04-14 19:18:59 +02:00
bool CModAppSystemGroup : : Create ( CModAppSystemGroup * pModAppSystemGroup )
2021-12-25 22:36:38 +01:00
{
2021-12-30 17:20:41 +01:00
# ifdef DEDICATED
2022-04-14 19:18:59 +02:00
pModAppSystemGroup - > SetServerOnly ( ) ;
* 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-04-09 00:59:42 +02:00
g_pFactory - > GetFactoriesFromRegister ( ) ;
2022-04-26 20:24:51 +02:00
# ifndef DEDICATED
2022-07-24 13:40:37 +02:00
g_pClientEntityList = g_pFactory - > GetFactoryPtr ( " VClientEntityList003 " , false ) . RCast < IClientEntityList * > ( ) ;
2022-01-17 23:20:03 +01:00
for ( auto & map : g_pCVar - > DumpToMap ( ) )
{
2022-05-27 02:46:13 +02:00
g_pConsole - > m_vsvCommandBases . push_back (
2022-08-11 11:07:45 +02:00
CSuggest ( map . first , map . second - > GetFlags ( ) ) ) ;
2022-01-17 23:20:03 +01:00
}
2022-08-17 02:02:44 +02:00
# endif // !DEDICATED
2022-08-13 20:21:32 +02:00
if ( CommandLine ( ) - > CheckParm ( " -devsdk " ) )
{
cv - > EnableDevCvars ( ) ;
}
2022-04-14 19:18:59 +02:00
if ( pModAppSystemGroup - > IsServerOnly ( ) )
{
memset ( gHLClient , ' \0 ' , sizeof ( void * ) ) ;
gHLClient = nullptr ;
memset ( g_pHLClient , ' \0 ' , sizeof ( void * ) ) ;
g_pHLClient = nullptr ;
}
2022-01-27 03:55:47 +01:00
2022-04-09 00:59:42 +02:00
g_bAppSystemInit = true ;
2022-04-09 06:05:47 +02:00
return CModAppSystemGroup_Create ( pModAppSystemGroup ) ;
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-04-14 19:18:59 +02:00
DetourAttach ( ( LPVOID * ) & CModAppSystemGroup_Main , & CModAppSystemGroup : : Main ) ;
DetourAttach ( ( LPVOID * ) & CModAppSystemGroup_Create , & CModAppSystemGroup : : Create ) ;
2021-12-25 22:36:38 +01:00
}
void IApplication_Detach ( )
{
2022-04-14 19:18:59 +02:00
DetourDetach ( ( LPVOID * ) & CModAppSystemGroup_Main , & CModAppSystemGroup : : Main ) ;
DetourDetach ( ( LPVOID * ) & CModAppSystemGroup_Create , & CModAppSystemGroup : : Create ) ;
2021-12-25 22:36:38 +01:00
}