summaryrefslogtreecommitdiff
path: root/engine/net_synctags.h
blob: f4cec039da4767a8b0e0229eb3b6655bdd3ca3be (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

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

#ifdef _DEBUG

#include <bitbuf.h>

extern ConVar net_synctags;

// SyncTags are used as a debugging tool. If net_synctags is set to 1, then the tags
// are put into the bit streams and verified on the client.
inline void SyncTag_Write( bf_write *pBuf, const char *pTag )
{
	if ( net_synctags.GetInt() )
	{
		pBuf->WriteString( pTag );
	}
}

inline void SyncTag_Read( bf_read *pBuf, const char *pWantedTag )
{
	if ( net_synctags.GetInt() )
	{
		char testTag[512];
		pBuf->ReadString( testTag, sizeof( testTag ) );
		
		if ( stricmp( testTag, pWantedTag ) != 0 )
		{
			Error( "SyncTag_Read: out-of-sync at tag %s", pWantedTag );
		}
	}	
}

#else

	inline void SyncTag_Write( bf_write *pBuf, const char *pTag ) {}
	inline void SyncTag_Read( bf_read *pBuf, const char *pWantedTag ) {}

#endif




#endif // NET_SYNCTAGS_H