Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

348 lines
12 KiB

  1. //===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef CDLL_CLIENT_INT_H
  8. #define CDLL_CLIENT_INT_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "iclientnetworkable.h"
  13. #include "utllinkedlist.h"
  14. #include "cdll_int.h"
  15. #include "shareddefs.h"
  16. #include "eiface.h"
  17. #include "tier3/tier3.h"
  18. #include "tier2/tier2_logging.h"
  19. #include "videocfg/videocfg.h"
  20. #if defined( INCLUDE_SCALEFORM )
  21. #include "scaleformui/scaleformui.h"
  22. #endif
  23. class IVModelRender;
  24. class IVEngineClient;
  25. class IVModelRender;
  26. class IVEfx;
  27. class IVRenderView;
  28. class IVDebugOverlay;
  29. class IMaterialSystem;
  30. class IMaterialSystemStub;
  31. class IDataCache;
  32. class IMDLCache;
  33. class IVModelInfoClient;
  34. class IEngineVGui;
  35. class ISpatialPartition;
  36. class IBaseClientDLL;
  37. class ISpatialPartition;
  38. class IFileSystem;
  39. class IStaticPropMgrClient;
  40. class IShadowMgr;
  41. class IEngineSound;
  42. class IMatSystemSurface;
  43. class IMaterialSystemHardwareConfig;
  44. class ISharedGameRules;
  45. class IEngineTrace;
  46. class IGameUIFuncs;
  47. class IGameEventManager2;
  48. class IPhysicsGameTrace;
  49. class CGlobalVarsBase;
  50. class IClientTools;
  51. class C_BaseAnimating;
  52. class IColorCorrectionSystem;
  53. class IInputSystem;
  54. class ISceneFileCache;
  55. class IXboxSystem; // Xbox 360 only
  56. class IAvi;
  57. class IBik;
  58. class CSteamAPIContext;
  59. class IReplayHistoryManager;
  60. class ISoundEmitterSystemBase;
  61. class IGameTypes;
  62. class AchievementsAndStatsInterface;
  63. enum CPULevel_t;
  64. enum GPULevel_t;
  65. class IRenderToRTHelper;
  66. class CSVCMsg_UserMessage;
  67. extern IVModelRender *modelrender;
  68. extern IVEngineClient *engine;
  69. extern IVModelRender *modelrender;
  70. extern IVEfx *effects;
  71. extern IVRenderView *render;
  72. extern IVDebugOverlay *debugoverlay;
  73. extern IMaterialSystemStub *materials_stub;
  74. extern IVModelInfoClient *modelinfo;
  75. extern IEngineVGui *enginevgui;
  76. extern ISpatialPartition* partition;
  77. extern IBaseClientDLL *clientdll;
  78. extern IFileSystem *filesystem;
  79. extern IStaticPropMgrClient *staticpropmgr;
  80. extern IShadowMgr *shadowmgr;
  81. extern IEngineSound *enginesound;
  82. extern IEngineTrace *enginetrace;
  83. extern IFileLoggingListener *filelogginglistener;
  84. extern IGameUIFuncs *gameuifuncs;
  85. extern IGameEventManager2 *gameeventmanager;
  86. extern IPhysicsGameTrace *physgametrace;
  87. extern CGlobalVarsBase *gpGlobals;
  88. extern IClientTools *clienttools;
  89. extern IInputSystem *inputsystem;
  90. extern ISceneFileCache *scenefilecache;
  91. extern IXboxSystem *xboxsystem; // Xbox 360 only
  92. extern IAvi *avi;
  93. extern IBik *bik;
  94. extern IUploadGameStats *gamestatsuploader;
  95. #ifndef NO_STEAM
  96. extern CSteamAPIContext *steamapicontext;
  97. #endif
  98. extern ISoundEmitterSystemBase *soundemitterbase;
  99. #include "CegClientWrapper.h"
  100. #if defined( CSTRIKE15 )
  101. extern IGameTypes *g_pGameTypes;
  102. extern IP4 *p4;
  103. #endif
  104. #if defined( INCLUDE_SCALEFORM )
  105. extern IScaleformUI* g_pScaleformUI;
  106. #endif
  107. #ifdef INFESTED_DLL
  108. class IASW_Mission_Chooser;
  109. extern IASW_Mission_Chooser *missionchooser;
  110. #endif
  111. #if defined( REPLAY_ENABLED )
  112. extern IReplayHistoryManager *g_pReplayHistoryManager;
  113. #endif
  114. extern AchievementsAndStatsInterface* g_pAchievementsAndStatsInterface;
  115. extern IRenderToRTHelper *g_pRenderToRTHelper;
  116. // Returns the CPU/GPU level
  117. CPULevel_t GetCPULevel();
  118. // Returns the actual value of the CPU level convar, even on the 360
  119. CPULevel_t GetActualCPULevel();
  120. GPULevel_t GetGPULevel();
  121. void ConfigureCurrentSystemLevel();
  122. // Set to true between LevelInit and LevelShutdown.
  123. extern bool g_bLevelInitialized;
  124. extern bool g_bTextMode;
  125. extern bool g_bEngineIsHLTV;
  126. // Returns true if a new OnDataChanged event is registered for this frame.
  127. bool AddDataChangeEvent( IClientNetworkable *ent, DataUpdateType_t updateType, int *pStoredEvent );
  128. void ClearDataChangedEvent( int iStoredEvent );
  129. void PurgeOnDataChangedEvents();
  130. //-----------------------------------------------------------------------------
  131. // Precaches a material
  132. //-----------------------------------------------------------------------------
  133. void PrecacheMaterial( const char *pMaterialName );
  134. //-----------------------------------------------------------------------------
  135. // Converts a previously precached material into an index
  136. //-----------------------------------------------------------------------------
  137. int GetMaterialIndex( const char *pMaterialName );
  138. //-----------------------------------------------------------------------------
  139. // Converts precached material indices into strings
  140. //-----------------------------------------------------------------------------
  141. const char *GetMaterialNameFromIndex( int nIndex );
  142. //-----------------------------------------------------------------------------
  143. // Precache-related methods for particle systems
  144. //-----------------------------------------------------------------------------
  145. int PrecacheParticleSystem( const char *pParticleSystemName );
  146. int GetParticleSystemIndex( const char *pParticleSystemName );
  147. const char *GetParticleSystemNameFromIndex( int nIndex );
  148. //-----------------------------------------------------------------------------
  149. // Precache-related methods for movies
  150. //-----------------------------------------------------------------------------
  151. void PrecacheMovie( const char *pMovieName );
  152. int GetMovieIndex( const char *pMovieName );
  153. const char *GetMovieNameFromIndex( int nIndex );
  154. //-----------------------------------------------------------------------------
  155. // Precache-related methods for effects
  156. //-----------------------------------------------------------------------------
  157. void PrecacheEffect( const char *pEffectName );
  158. //-----------------------------------------------------------------------------
  159. // Spew application info (primarily for log file data mining)
  160. //-----------------------------------------------------------------------------
  161. void SpewInstallStatus( void );
  162. //-----------------------------------------------------------------------------
  163. // Called during bone setup to test perf
  164. //-----------------------------------------------------------------------------
  165. void TrackBoneSetupEnt( C_BaseAnimating *pEnt );
  166. bool IsEngineThreaded();
  167. class CVGuiScreenSizeSplitScreenPlayerGuard
  168. {
  169. public:
  170. CVGuiScreenSizeSplitScreenPlayerGuard( bool bActive, int slot, int nOldSlot );
  171. CVGuiScreenSizeSplitScreenPlayerGuard( bool bActive, C_BaseEntity *pEntity, int nOldSlot );
  172. ~CVGuiScreenSizeSplitScreenPlayerGuard();
  173. private:
  174. bool m_bNoRestore;
  175. bool m_bOldSetting;
  176. int m_nOldSize[ 2 ];
  177. };
  178. class CSetActiveSplitScreenPlayerGuard : public CVGuiScreenSizeSplitScreenPlayerGuard
  179. {
  180. public:
  181. CSetActiveSplitScreenPlayerGuard( char const *pchContext, int nLine );
  182. CSetActiveSplitScreenPlayerGuard( char const *pchContext, int nLine, int slot, int nOldSlot, bool bSetVguiScreenSize );
  183. CSetActiveSplitScreenPlayerGuard( char const *pchContext, int nLine, C_BaseEntity *pEntity, int nOldSlot, bool bSetVguiScreenSize );
  184. ~CSetActiveSplitScreenPlayerGuard();
  185. private:
  186. bool m_bChanged;
  187. char const *m_pchContext;
  188. int m_nLine;
  189. int m_nSaveSlot;
  190. bool m_bSaveGetLocalPlayerAllowed;
  191. };
  192. class CHackForGetLocalPlayerAccessAllowedGuard
  193. {
  194. public:
  195. CHackForGetLocalPlayerAccessAllowedGuard( char const *pszContext, bool bOldSlot );
  196. ~CHackForGetLocalPlayerAccessAllowedGuard();
  197. private:
  198. bool m_bChanged;
  199. char const *m_pszContext;
  200. bool m_bSaveGetLocalPlayerAllowed;
  201. };
  202. class CVGuiAbsPosSplitScreenPlayerGuard
  203. {
  204. public:
  205. CVGuiAbsPosSplitScreenPlayerGuard( int slot, int nOldSlot, bool bInvert = false );
  206. ~CVGuiAbsPosSplitScreenPlayerGuard();
  207. private:
  208. bool m_bNoRestore;
  209. };
  210. int FirstValidSplitScreenSlot();
  211. int NextValidSplitScreenSlot( int i );
  212. bool IsValidSplitScreenSlot( int i );
  213. void IterateRemoteSplitScreenViewSlots_Push( bool bSet ); //some split screen loops should be made aware of remote views we'd like to use
  214. void IterateRemoteSplitScreenViewSlots_Pop( void );
  215. class C_BasePlayer;
  216. void AddRemoteSplitScreenViewPlayer( C_BasePlayer *pPlayer ); //adds a nonlocal player as a view we'd like to see in split screen
  217. void RemoveRemoteSplitScreenViewPlayer( C_BasePlayer *pPlayer ); //removes a nonlocal player view from split screen
  218. C_BasePlayer *GetSplitScreenViewPlayer( int nSlot ); //allows return of split screen views of nonlocal players
  219. bool IsLocalSplitScreenPlayer( int nSlot ); //true is a full splitscreen player. false is just a view of a remote player
  220. bool BSerializeUserMessageToSVCMSG( CSVCMsg_UserMessage &svcmsg, int nType, const ::google::protobuf::Message &msg );
  221. #if defined( SPLIT_SCREEN_STUBS )
  222. #define VGUI_SCREENSIZE_SPLITSCREEN_GUARD( slot )
  223. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot )
  224. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( entity )
  225. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( slot )
  226. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT_VGUI( entity )
  227. #define HACK_GETLOCALPLAYER_GUARD( desc )
  228. #define VGUI_ABSPOS_SPLITSCREEN_GUARD( slot )
  229. #define VGUI_ABSPOS_SPLITSCREEN_GUARD_INVERT( slot )
  230. #define FOR_EACH_VALID_SPLITSCREEN_PLAYER( iteratorName ) for ( int iteratorName = 0; iteratorName == 0; ++iteratorName )
  231. #define ASSERT_LOCAL_PLAYER_RESOLVABLE()
  232. #define ASSERT_LOCAL_PLAYER_NOT_RESOLVABLE()
  233. #define GET_ACTIVE_SPLITSCREEN_SLOT() ( 0 )
  234. FORCEINLINE uint32 ComputeSplitscreenRenderingFlags( IClientRenderable *pRenderable )
  235. {
  236. return 0xFFFFFFFF;
  237. }
  238. #else
  239. #define VGUI_SCREENSIZE_SPLITSCREEN_GUARD( slot ) CVGuiScreenSizeSplitScreenPlayerGuard s_VGuiSSGuard( slot, engine->GetActiveSplitScreenPlayerSlot() );
  240. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ) CSetActiveSplitScreenPlayerGuard g_SSGuard( __FILE__, __LINE__, slot, engine->GetActiveSplitScreenPlayerSlot(), false ); RANDOM_CEG_TEST_SECRET();
  241. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( entity ) CSetActiveSplitScreenPlayerGuard g_SSEGuard( __FILE__, __LINE__, entity, engine->GetActiveSplitScreenPlayerSlot(), false );
  242. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( slot ) CSetActiveSplitScreenPlayerGuard g_SSGuardNoVgui( __FILE__, __LINE__, slot, engine->GetActiveSplitScreenPlayerSlot(), true );
  243. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT_VGUI( entity ) CSetActiveSplitScreenPlayerGuard g_SSEGuardNoVgui( __FILE__, __LINE__, entity, engine->GetActiveSplitScreenPlayerSlot(), true );
  244. #define HACK_GETLOCALPLAYER_GUARD( desc ) CHackForGetLocalPlayerAccessAllowedGuard g_HackGLPGuard( desc, engine->IsLocalPlayerResolvable() );
  245. #define VGUI_ABSPOS_SPLITSCREEN_GUARD( slot ) CVGuiAbsPosSplitScreenPlayerGuard s_VGuiAbsPosGuard( slot, engine->GetActiveSplitScreenPlayerSlot() );
  246. #define VGUI_ABSPOS_SPLITSCREEN_GUARD_INVERT( slot ) CVGuiAbsPosSplitScreenPlayerGuard s_VGuiAbsPosGuard( slot, engine->GetActiveSplitScreenPlayerSlot(), true );
  247. #define FOR_EACH_VALID_SPLITSCREEN_PLAYER( iteratorName ) \
  248. RANDOM_CEG_TEST_SECRET() \
  249. for ( int iteratorName = FirstValidSplitScreenSlot(); \
  250. iteratorName != -1; \
  251. iteratorName = NextValidSplitScreenSlot( iteratorName ) )
  252. // Uncomment this to be able to look for guard asserts in release builds
  253. // #define SS_SHIPPING_ASSERTS
  254. #if defined( SS_SHIPPING_ASSERTS )
  255. #define ASSERT_LOCAL_PLAYER_RESOLVABLE() _AssertMsg( engine->IsLocalPlayerResolvable(), _T("Assertion Failed: ") _T("engine->IsLocalPlayerResolvable()"), ((void)0), false )
  256. #else
  257. #define ASSERT_LOCAL_PLAYER_RESOLVABLE() Assert( engine->IsLocalPlayerResolvable() );
  258. #endif
  259. #if defined( SS_SHIPPING_ASSERTS )
  260. #define ASSERT_LOCAL_PLAYER_NOT_RESOLVABLE() _AssertMsg( !engine->IsLocalPlayerResolvable(), _T("Assertion Failed: ") _T("!engine->IsLocalPlayerResolvable()"), ((void)0), false )
  261. #else
  262. #define ASSERT_LOCAL_PLAYER_NOT_RESOLVABLE() Assert( !engine->IsLocalPlayerResolvable() );
  263. #endif
  264. #define GET_ACTIVE_SPLITSCREEN_SLOT() engine->GetActiveSplitScreenPlayerSlot()
  265. //-----------------------------------------------------------------------------
  266. // Default implementation of compute splitscreen rendering flags
  267. //-----------------------------------------------------------------------------
  268. FORCEINLINE uint32 ComputeSplitscreenRenderingFlags( IClientRenderable *pRenderable )
  269. {
  270. if ( IsSplitScreenSupported() )
  271. {
  272. int nFlags = 0;
  273. for ( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i )
  274. {
  275. if ( pRenderable->ShouldDrawForSplitScreenUser( i ) )
  276. {
  277. nFlags |= 1 << i;
  278. }
  279. }
  280. return nFlags;
  281. }
  282. return 0xFFFFFFFF;
  283. }
  284. #endif
  285. inline C_BasePlayer *GetSplitScreenViewPlayer( void ) { return GetSplitScreenViewPlayer( GET_ACTIVE_SPLITSCREEN_SLOT() ); };
  286. inline bool IsLocalSplitScreenPlayer( void ) { return IsLocalSplitScreenPlayer( GET_ACTIVE_SPLITSCREEN_SLOT() ); };
  287. // Returns XBX_GetUserId( GET_ACTIVE_SPLITSCREEN_SLOT() )
  288. int XBX_GetActiveUserId();
  289. #ifndef _PS3
  290. #define XBX_GetPrimaryUserId() _Use_XBX_GetActiveUserId_Instead
  291. #endif
  292. #endif // CDLL_CLIENT_INT_H