summaryrefslogtreecommitdiff
path: root/public/gcsdk/gcconstants.h
blob: bbaf068c39089ec712661b7d74d3093ae5b7874c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: declares a variety of constants
//
// $NoKeywords: $
//=============================================================================

#ifndef GCCONSTANTS_H
#define GCCONSTANTS_H
#ifdef _WIN32
#pragma once
#endif

#include "steam/steamtypes.h"
#include "tier0/t0constants.h"
#include "gamecoordinator/igcsqlquery.h"

namespace GCSDK
{

//-----------------------------------------------------------------------------
// Timing constants
//-----------------------------------------------------------------------------

// How long each frame should last
const int k_cMicroSecPerShellFrame = 50 * k_nThousand;

// How many frames per second should we have
const uint32 k_cFramesPerSec = k_nMillion / k_cMicroSecPerShellFrame;

// Task granularity -- the longest time in microseconds you should spend without yielding
const int k_cMicroSecTaskGranularity = 5 * k_nThousand;

// If a frame runs longer than it's supposed to (which they always will by at least a little),
// we subtract the overage from the next frame.  This is the maximum amount to correct each frame.
const int k_cMicroSecMaxFrameCorrection = 25 * k_nThousand;

// if server time is too far behind, we will start skipping frames to re-synchronize it with real time
const int k_cMicroSecBehindToStartFrameSkipping = (k_nMillion * 2);

// Default Max time to allow a job to be blocked on I/O
const int k_cMicroSecJobPausedTimeout = 20 * k_nMillion;

// How much time a job should run before heartbeating
const int k_cMicroSecJobHeartbeat = k_cMicroSecJobPausedTimeout / 4;

// Default Max number of job heartbeat intervals to allow a job to be blocked on I/O
const int k_cJobHeartbeatsBeforeTimeoutDefault = k_cMicroSecJobPausedTimeout / k_cMicroSecJobHeartbeat;

// Number of seconds to take to cycle through all active sessions
const int k_nUserSessionRunInterval = 5 * k_nMillion;
const int k_nGSSessionRunInterval = 5 * k_nMillion;
const int k_nAccountDetailsRunInterval = 30 * k_nMillion;
const int k_nLocksRunInterval = 120 * k_nMillion;

// Time to keep an unused lock before removing it
const uint64 k_cMicroSecLockLifetime = (uint64)k_nSecondsPerHour * (uint64)k_nMillion;

//-----------------------------------------------------------------------------
// Server types
//-----------------------------------------------------------------------------
// EServerType
// Specifies the type of a specific server
// MUST BE KEPT IN SYNC with g_rgchServerTypeName !!! 
enum EServerType
{
	k_EServerTypeInvalid = -1,

	k_EServerTypeShell = 0,
	k_EServerTypeGC = 1,
	k_EServerTypeGCClient = 2,

	// Must be last!!!
	k_EServerTypeMax = 2,
};
const EServerType k_EServerTypeFirst = k_EServerTypeShell;


//-----------------------------------------------------------------------------
// Alert constants
//-----------------------------------------------------------------------------
enum EAlertType
{
	k_EAlertTypeAssert,
	k_EAlertTypeInfo,
	k_EAlertTypeReport,
};

//-----------------------------------------------------------------------------
// Spew / EmitEvent constants
//-----------------------------------------------------------------------------

#define SPEW_ALWAYS 1
#define SPEW_NEVER 5

#define LOG_ALWAYS 1
#define LOG_NEVER 5


//-----------------------------------------------------------------------------
// string constants
//-----------------------------------------------------------------------------

const char k_rgchUnknown[] = "Unknown";

#ifdef GC
//-----------------------------------------------------------------------------
// SQL constants
//-----------------------------------------------------------------------------

const int k_cSQLObjectNameMax = 128;			// max length of a SQL identifier (column name, index name, table name ... )
const int k_cchSQLStatementTextMax = 8192;		// nominal max length of a SQL statement
const uint32 k_cubRecordMax = 4 * k_nMillion;				// Max size of a single record
const uint32 k_cubVarFieldMax = 1 * k_nMillion;			// Max size of a variable-length field
const int k_cMaxCol = 50;
const uint32 k_cMaxBindParams = 500;				// the largest number of bind parameters allowed in a single query
const uint32 k_cMaxFreeBindParamBuffers = 2000;		// How many bind param buffers should we leave free before we start deleting some
const uint32 k_cMaxFreeBindWebAPIBuffers = 32;		// How many WebAPI buffers should we leave free before we start deleting some

// iTable constants
const int k_iTableNil = -1;		// No table at all
const int k_iFieldNil = -1;		// No field at all


enum EForeignKeyAction
{
	k_EForeignKeyActionNoAction	= 0,
	k_EForeignKeyActionCascade	= 1,
	k_EForeignKeyActionSetNULL	= 2,
};
const char *PchNameFromEForeignKeyAction( EForeignKeyAction eForeignKeyAction );
EForeignKeyAction EForeignKeyActionFromName( const char *pchName );

const char *PchNameFromEGCSQLType( EGCSQLType eForeignKeyAction );

#ifndef SQLRETURN
typedef short SQLRETURN;
#endif // SQLRETURN
#endif // GC


//-----------------------------------------------------------------------------
// WebAPI constants
//-----------------------------------------------------------------------------

const uint32 k_cubWebAPIKey = 16;									// size of the web api key
const uint32 k_cchWebAPIKeyStringMax = (k_cubWebAPIKey * 2) + 1;	// size of string representing web API key (hex encoded so twice the size + NUL)
typedef	unsigned char WebAPIKey_t[ k_cubWebAPIKey ];

// used to revoke WebAPI keys.  Stored in the database... do not reorder.
enum EWebAPIKeyStatus
{
	k_EWebAPIKeyValid = 0,
	k_EWebAPIKeyRevoked = 1,

	k_EWebAPIKeyInvalid = 255,
};


//-----------------------------------------------------------------------------
// Game Server constants
//-----------------------------------------------------------------------------

const uint32 k_cubGameServerToken = 16;									// size of the game server identity token key
const uint32 k_cchGameServerTokenStringMax = (k_cubGameServerToken * 2) + 1;	// size of string representing game server identity token (hex encoded so twice the size + NUL)
typedef	unsigned char GameServerIdentityToken_t[ k_cubGameServerToken ];



//-----------------------------------------------------------------------------
// Other constants
//-----------------------------------------------------------------------------

const int k_cSmallBuff = 255;					// smallish buffer 
const int k_cMedBuff = 1024;					// medium buffer 

const int k_cubMsgSizeSmall = 512;				// small sized packet

const int k_cInitialNetworkBuffers = 10;		// # of network buffers to see the system with

const int k_cubMaxExpectedMsgDataSize = 5 * k_nMegabyte;// the maximum application data that we EXPECT to be sent in a single message

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define FILE_AND_LINE __FILE__ ":" TOSTRING(__LINE__)	

// Default capacity for session hash tables
const int k_cGCUserSessionInit = 10 * k_nThousand;		// Can grow indefinitely by this increment
const int k_cBucketGCUserSession = 100 * k_nThousand;			// Fixed size
const int k_cGCGSSessionInit = 1 * k_nThousand;		// Can grow indefinitely by this increment
const int k_cBucketGCGSSession = 10 * k_nThousand;			// Fixed size
const int k_cAccountDetailsInit = 10 * k_nThousand;		// Can grow indefinitely by this increment
const int k_cBucketAccountDetails = 100 * k_nThousand;			// Fixed size
const int k_cGCLocksInit = 50 * k_nThousand;		// Can grow indefinitely by this increment
const int k_cBucketGCLocks = 500 * k_nThousand;			// Fixed size

const char *PchNameFromEUniverse( EUniverse eUniverse );
EUniverse EUniverseFromName( const char *pchName );

} // namespace GCSDK

#endif // GCCONSTANTS_H