diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /engine/replay_internal.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'engine/replay_internal.cpp')
| -rw-r--r-- | engine/replay_internal.cpp | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/engine/replay_internal.cpp b/engine/replay_internal.cpp new file mode 100644 index 0000000..ae09e48 --- /dev/null +++ b/engine/replay_internal.cpp @@ -0,0 +1,138 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#include "replay_internal.h" +#include "replay/ireplaysystem.h" +#include "replayserver.h" +#include "vgui/ILocalize.h" +#include "server.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//---------------------------------------------------------------------------------------- + +IReplaySystem *g_pReplay = NULL; + +//---------------------------------------------------------------------------------------- + +static CSysModule *gs_hReplayModule = NULL; + +IServerReplayContext *g_pServerReplayContext = NULL; +CreateInterfaceFn g_fnReplayFactory = NULL; + +#if !defined( DEDICATED ) +IReplayManager *g_pReplayManager = NULL; +IReplayMovieRenderer *g_pReplayMovieRenderer = NULL; +IReplayPerformanceManager *g_pReplayPerformanceManager = NULL; +IReplayPerformanceController *g_pReplayPerformanceController = NULL; +IReplayMovieManager *g_pReplayMovieManager = NULL; +#endif + +//---------------------------------------------------------------------------------------- + +ConVar replay_debug( "replay_debug", "0", FCVAR_DONTRECORD ); + +//---------------------------------------------------------------------------------------- + +// If you modify this list, you will also need to add the following line to the game's +// client_*.vpc and server_*.vpc files: +// +// $include "$SRCDIR\vpc_scripts\source_replay.vpc" +// +static const char *s_pSupportedReplayGames[] = +{ + "tf", + "tf_beta", +}; + +//---------------------------------------------------------------------------------------- + +void ReplaySystem_Init( bool bDedicated ) +{ +#if defined( REPLAY_ENABLED ) + COM_TimestampedLog( "Loading replay.dll" ); + + extern IFileSystem *g_pFileSystem; + + // Load the replay DLL + const char *szDllName = "replay" DLL_EXT_STRING; + gs_hReplayModule = g_pFileSystem->LoadModule( szDllName ); + g_fnReplayFactory = Sys_GetFactory( gs_hReplayModule ); + if ( !g_fnReplayFactory ) + { + Error( "Could not load: %s\n", szDllName ); + } + + // Get a ptr to the IReplay instance + g_pReplay = (IReplaySystem *)g_fnReplayFactory( REPLAY_INTERFACE_VERSION, NULL ); + if ( !g_pReplay ) + { + Error( "Could not get IReplay interface %s from %s\n", REPLAY_INTERFACE_VERSION, szDllName ); + } + + // Initialize the replay DLL + COM_TimestampedLog( "g_pReplay->Initialize()" ); + + extern CreateInterfaceFn g_AppSystemFactory; + if ( !g_pReplay->Connect( g_AppSystemFactory ) ) + { + Error( "Connect on replay.dll failed!\n" ); + } + + // Cache some pointers + g_pServerReplayContext = g_pReplay->SV_GetContext(); + + if ( !bDedicated ) + { + // Add replay localization text files + extern vgui::ILocalize *g_pVGuiLocalize; + if ( g_pVGuiLocalize ) + { + g_pVGuiLocalize->AddFile( "resource/replay_%language%.txt", "GAME" ); + g_pVGuiLocalize->AddFile( "resource/youtube_%language%.txt", "GAME" ); + } + } +#endif +} + +//---------------------------------------------------------------------------------------- + +void ReplaySystem_Shutdown() +{ +#if defined( REPLAY_ENABLED ) + if ( g_pReplay ) + { + // Shutdown the DLL + g_pReplay->Shutdown(); + g_pReplay = NULL; + } + + if ( gs_hReplayModule ) + { + // Unload the DLL + Sys_UnloadModule( gs_hReplayModule ); + gs_hReplayModule = NULL; + } +#endif +} + +//---------------------------------------------------------------------------------------- + +bool Replay_IsSupportedModAndPlatform() +{ + if ( !IsPC() ) + return false; + + int nNumSupportedReplayGames = ARRAYSIZE( s_pSupportedReplayGames ); + for ( int i = 0; i < nNumSupportedReplayGames; ++i ) + { + const char *pCurGame = s_pSupportedReplayGames[ i ]; + if ( !Q_stricmp( COM_GetModDirectory(), pCurGame ) ) + return true; + } + return false; +} + +//---------------------------------------------------------------------------------------- |