Team Fortress 2 Source Code as on 22/4/2020
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.

175 lines
5.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #if !defined( HOST_H )
  10. #define HOST_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "convar.h"
  15. #include "steam/steamclientpublic.h"
  16. #define SCRIPT_DIR "scripts/"
  17. struct model_t;
  18. struct AudioState_t;
  19. class CCommonHostState
  20. {
  21. public:
  22. model_t *worldmodel; // cl_entitites[0].model
  23. struct worldbrushdata_t *worldbrush;
  24. float interval_per_tick; // Tick interval for game
  25. void SetWorldModel( model_t *pModel );
  26. };
  27. extern CCommonHostState host_state;
  28. //=============================================================================
  29. // the host system specifies the base of the directory tree, the mod + base mod
  30. // and the amount of memory available for the program to use
  31. struct engineparms_t
  32. {
  33. char *basedir; // Executable directory ("c:/program files/half-life 2", for example)
  34. char *mod; // Mod name ("cstrike", for example)
  35. char *game; // Root game name ("hl2", for example, in the case of cstrike)
  36. unsigned int memsize;
  37. };
  38. extern engineparms_t host_parms;
  39. //-----------------------------------------------------------------------------
  40. // Human readable methods to get at engineparms info
  41. //-----------------------------------------------------------------------------
  42. inline const char *GetCurrentMod()
  43. {
  44. return host_parms.mod;
  45. }
  46. inline const char *GetCurrentGame()
  47. {
  48. return host_parms.game;
  49. }
  50. inline const char *GetBaseDirectory()
  51. {
  52. return host_parms.basedir;
  53. }
  54. //=============================================================================
  55. //
  56. // host
  57. // FIXME, move all this crap somewhere else
  58. //
  59. extern ConVar developer;
  60. extern bool host_initialized; // true if into command execution
  61. extern float host_frametime;
  62. extern float host_frametime_unbounded;
  63. extern float host_frametime_stddeviation;
  64. extern int host_framecount; // incremented every frame, never reset
  65. extern double realtime; // not bounded in any way, changed at
  66. // start of every frame, never reset
  67. void Host_Error (PRINTF_FORMAT_STRING const char *error, ...) FMTFUNCTION( 1, 2 );
  68. void Host_EndGame (bool bShowMainMenu, PRINTF_FORMAT_STRING const char *message, ...) FMTFUNCTION( 2, 3 );
  69. // user message
  70. #define MAX_USER_MSG_DATA 255
  71. // build info
  72. // day counter from Sep 30 2003
  73. extern int build_number( void );
  74. // Choke local client's/server's packets?
  75. extern ConVar host_limitlocal;
  76. // Print a debug message when the client or server cache is missed
  77. extern ConVar host_showcachemiss;
  78. extern bool g_bInEditMode;
  79. extern bool g_bInCommentaryMode;
  80. extern bool g_bAllowSecureServers;
  81. extern bool g_bLowViolence;
  82. // Returns true if host is not single stepping/pausing through code/
  83. // FIXME: Remove from final, retail version of code.
  84. bool Host_ShouldRun( void );
  85. void Host_FreeToLowMark( bool server );
  86. void Host_FreeStateAndWorld( bool server );
  87. void Host_Disconnect( bool bShowMainMenu, const char *pszReason = "" );
  88. void Host_RunFrame( float time );
  89. void Host_DumpMemoryStats( void );
  90. void Host_UpdateMapList( void );
  91. float Host_GetSoundDuration( const char *pSample );
  92. bool Host_IsSinglePlayerGame( void );
  93. int Host_GetServerCount( void );
  94. bool Host_AllowQueuedMaterialSystem( bool bAllow );
  95. bool Host_IsSecureServerAllowed();
  96. void FORCEINLINE Host_DisallowSecureServers()
  97. {
  98. #if !defined(SWDS)
  99. g_bAllowSecureServers = false;
  100. #endif
  101. }
  102. bool Host_AllowLoadModule( const char *pFilename, const char *pPathID, bool bAllowUnknown, bool bIsServerOnly = false );
  103. // Force the voice stuff to send a packet out.
  104. // bFinal is true when the user is done talking.
  105. void CL_SendVoicePacket(bool bFinal);
  106. // Accumulated filtered time on machine ( i.e., host_framerate can alter host_time )
  107. extern float host_time;
  108. class NET_SetConVar;
  109. void Host_BuildConVarUpdateMessage( NET_SetConVar *cvarMsg, int flags, bool nonDefault );
  110. char const *Host_CleanupConVarStringValue( char const *invalue );
  111. void Host_SetAudioState( const AudioState_t &audioState );
  112. void Host_DefaultMapFileName( const char *pFullMapName, /* out */ char *pDiskName, unsigned int nDiskNameSize );
  113. bool CheckVarRange_Generic( ConVar *pVar, int minVal, int maxVal );
  114. // Total ticks run
  115. extern int host_tickcount;
  116. // Number of ticks being run this frame
  117. extern int host_frameticks;
  118. // Which tick are we currently on for this frame
  119. extern int host_currentframetick;
  120. // PERFORMANCE INFO
  121. #define MIN_FPS 0.1 // Host minimum fps value for maxfps.
  122. #define MAX_FPS 1000.0 // Upper limit for maxfps.
  123. #define MAX_FRAMETIME 0.1
  124. #define MIN_FRAMETIME 0.001
  125. #define TIME_TO_TICKS( dt ) ( (int)( 0.5f + (float)(dt) / host_state.interval_per_tick ) )
  126. #define TICKS_TO_TIME( dt ) ( host_state.interval_per_tick * (float)(dt) )
  127. // Normally, this is off, and it keeps the VCR file size smaller, but it can help
  128. // to turn it on when tracking down out-of-sync errors, because it verifies that more
  129. // things are the same during playback.
  130. extern ConVar vcr_verbose;
  131. // Set by the game DLL to tell us to do the same timing tricks as timedemo.
  132. extern bool g_bDedicatedServerBenchmarkMode;
  133. extern uint GetSteamAppID();
  134. extern EUniverse GetSteamUniverse();
  135. #define STEAMREMOTESTORAGE_CLOUD_OFF 0
  136. #define STEAMREMOTESTORAGE_CLOUD_ON 1
  137. #endif // HOST_H