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.

176 lines
6.8 KiB

  1. //========= Copyright �, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose: declares a variety of constants
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #ifndef GCCONSTANTS_H
  8. #define GCCONSTANTS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "steam/steamtypes.h"
  13. #include "tier0/t0constants.h"
  14. namespace GCSDK
  15. {
  16. //-----------------------------------------------------------------------------
  17. // Timing constants
  18. //-----------------------------------------------------------------------------
  19. // How long each frame should last
  20. const int k_cMicroSecPerShellFrame = 50 * k_nThousand;
  21. // How many frames per second should we have
  22. const uint32 k_cFramesPerSec = k_nMillion / k_cMicroSecPerShellFrame;
  23. // Task granularity -- the longest time in microseconds you should spend without yielding
  24. const int k_cMicroSecTaskGranularity = 5 * k_nThousand;
  25. // If a frame runs longer than it's supposed to (which they always will by at least a little),
  26. // we subtract the overage from the next frame. This is the maximum amount to correct each frame.
  27. const int k_cMicroSecMaxFrameCorrection = 25 * k_nThousand;
  28. // if server time is too far behind, we will start skipping frames to re-synchronize it with real time
  29. const int k_cMicroSecBehindToStartFrameSkipping = (k_nMillion * 2);
  30. // Default Max time to allow a job to be blocked on I/O
  31. const int k_cMicroSecJobPausedTimeout = 20 * k_nMillion;
  32. // How much time a job should run before heartbeating
  33. const int k_cMicroSecJobHeartbeat = k_cMicroSecJobPausedTimeout / 4;
  34. // Default Max number of job heartbeat intervals to allow a job to be blocked on I/O
  35. const int k_cJobHeartbeatsBeforeTimeoutDefault = k_cMicroSecJobPausedTimeout / k_cMicroSecJobHeartbeat;
  36. // Number of seconds to take to cycle through all active sessions
  37. const int k_nUserSessionRunInterval = 5 * k_nMillion;
  38. const int k_nGSSessionRunInterval = 5 * k_nMillion;
  39. const int k_nAccountDetailsRunInterval = 30 * k_nMillion;
  40. const int k_nLocksRunInterval = 120 * k_nMillion;
  41. //-----------------------------------------------------------------------------
  42. // Spew / EmitEvent constants
  43. //-----------------------------------------------------------------------------
  44. #define SPEW_ALWAYS 1
  45. #define SPEW_NEVER 5
  46. #define LOG_ALWAYS 1
  47. #define LOG_NEVER 5
  48. //-----------------------------------------------------------------------------
  49. // string constants
  50. //-----------------------------------------------------------------------------
  51. const char k_rgchUnknown[] = "Unknown";
  52. #ifdef GC
  53. //-----------------------------------------------------------------------------
  54. // SQL constants
  55. //-----------------------------------------------------------------------------
  56. const int k_cSQLObjectNameMax = 128; // max length of a SQL identifier (column name, index name, table name ... )
  57. const int k_cchSQLStatementTextMax = 8192; // nominal max length of a SQL statement
  58. const uint32 k_cubRecordMax = 4 * k_nMillion; // Max size of a single record
  59. const uint32 k_cubVarFieldMax = 1 * k_nMillion; // Max size of a variable-length field
  60. const int k_cMaxCol = 50;
  61. const uint32 k_cMaxBindParams = 500; // the largest number of bind parameters allowed in a single query
  62. // iTable constants
  63. const int k_iTableNil = -1; // No table at all
  64. const int k_iFieldNil = -1; // No field at all
  65. enum EForeignKeyAction
  66. {
  67. k_EForeignKeyActionNoAction = 0,
  68. k_EForeignKeyActionCascade = 1,
  69. k_EForeignKeyActionSetNULL = 2,
  70. };
  71. const char *PchNameFromEForeignKeyAction( EForeignKeyAction eForeignKeyAction );
  72. EForeignKeyAction EForeignKeyActionFromName( const char *pchName );
  73. const char *PchNameFromEGCSQLType( EGCSQLType eForeignKeyAction );
  74. #ifndef SQLRETURN
  75. typedef short SQLRETURN;
  76. #endif // SQLRETURN
  77. #endif // GC
  78. //-----------------------------------------------------------------------------
  79. // WebAPI constants
  80. //-----------------------------------------------------------------------------
  81. const uint32 k_cubWebAPIKey = 16; // size of the web api key
  82. const uint32 k_cchWebAPIKeyStringMax = (k_cubWebAPIKey * 2) + 1; // size of string representing web API key (hex encoded so twice the size + NUL)
  83. typedef unsigned char WebAPIKey_t[ k_cubWebAPIKey ];
  84. // used to revoke WebAPI keys. Stored in the database... do not reorder.
  85. enum EWebAPIKeyStatus
  86. {
  87. k_EWebAPIKeyValid = 0,
  88. k_EWebAPIKeyRevoked = 1,
  89. k_EWebAPIKeyInvalid = 255,
  90. };
  91. //-----------------------------------------------------------------------------
  92. // Game Server constants
  93. //-----------------------------------------------------------------------------
  94. const uint32 k_cubGameServerToken = 16; // size of the game server identity token key
  95. const uint32 k_cchGameServerTokenStringMax = (k_cubGameServerToken * 2) + 1; // size of string representing game server identity token (hex encoded so twice the size + NUL)
  96. typedef unsigned char GameServerIdentityToken_t[ k_cubGameServerToken ];
  97. //-----------------------------------------------------------------------------
  98. // Account linkage (constants from Steam)
  99. //-----------------------------------------------------------------------------
  100. const uint32 k_unInvalidPerfectWorldID = 0;
  101. //-----------------------------------------------------------------------------
  102. // Other constants
  103. //-----------------------------------------------------------------------------
  104. const int k_cSmallBuff = 255; // smallish buffer
  105. const int k_cMedBuff = 1024; // medium buffer
  106. const int k_cubMsgSizeSmall = 512; // small sized packet
  107. const int k_cInitialNetworkBuffers = 10; // # of network buffers to see the system with
  108. const int k_cubMaxExpectedMsgDataSize = 5 * k_nMegabyte;// the maximum application data that we EXPECT to be sent in a single message
  109. #ifndef STRINGIFY
  110. #define STRINGIFY(x) #x
  111. #endif // CS:GO already defines STRINGIFY appropriately, no reason to redefine here
  112. #define TOSTRING(x) STRINGIFY(x)
  113. #define FILE_AND_LINE __FILE__ ":" TOSTRING(__LINE__)
  114. // Default capacity for session hash tables
  115. const int k_cGCUserSessionInit = 10 * k_nThousand; // Can grow indefinitely by this increment
  116. const int k_cBucketGCUserSession = 100 * k_nThousand; // Fixed size
  117. const int k_cGCGSSessionInit = 5 * k_nThousand; // Can grow indefinitely by this increment
  118. const int k_cBucketGCGSSession = 50 * k_nThousand; // Fixed size
  119. const int k_cAccountDetailsInit = 10 * k_nThousand; // Can grow indefinitely by this increment
  120. const int k_cBucketAccountDetails = 100 * k_nThousand; // Fixed size
  121. const int k_cPersonaNamesInit = 50 * k_nThousand; // Can grow indefinitely by this increment
  122. const int k_cBucketPersonaNames = 250 * k_nThousand; // Fixed size
  123. const int k_cGCLocksInit = 50 * k_nThousand; // Can grow indefinitely by this increment
  124. const int k_cBucketGCLocks = 500 * k_nThousand; // Fixed size
  125. const char *PchNameFromEUniverse( EUniverse eUniverse );
  126. EUniverse EUniverseFromName( const char *pchName );
  127. } // namespace GCSDK
  128. #endif // GCCONSTANTS_H