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

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


#include "dt_recv.h"
#include "bitbuf.h"
#include "dt.h"

class CStandardSendProxies;

// ------------------------------------------------------------------------------------------ //
// RecvTable functions.
// ------------------------------------------------------------------------------------------ //

// These are the module startup and shutdown routines.
bool		RecvTable_Init( RecvTable **pTables, int nTables );
void		RecvTable_Term( bool clearall = true );

// After calling RecvTable_Init to provide the list of RecvTables, call this
// as the server sends its SendTables over. When bNeedsDecoder is specified,
// it will precalculate the necessary data to actually decode this type of
// SendTable from the server. nDemoProtocol = 0 means current version.
bool		RecvTable_RecvClassInfos( bf_read *pBuf, bool bNeedsDecoder, int nDemoProtocol = 0);


// After ALL the SendTables have been received, call this and it will create CRecvDecoders
// for all the SendTable->RecvTable matches it finds.
// Returns false if there is an unrecoverable error.
//
// bAllowMismatches is true when playing demos back so we can change datatables without breaking demos.
// If pAnyMisMatches is non-null, it will be set to true if the client's recv tables mismatched the server's ones.
bool		RecvTable_CreateDecoders( const CStandardSendProxies *pSendProxies, bool bAllowMismatches, bool *pAnyMismatches=NULL );

// objectID gets passed into proxies and can be used to track data on particular objects.
// NOTE: this function can ONLY decode a buffer outputted from RecvTable_MergeDeltas
//       or RecvTable_CopyEncoding because if the way it follows the exclude prop bits.
bool		RecvTable_Decode( 
	RecvTable *pTable, 
	void *pStruct, 
	bf_read *pIn, 
	int objectID,
	bool updateDTI = true
	);

// This acts like a RecvTable_Decode() call where all properties are written and all their values are zero.
void RecvTable_DecodeZeros( RecvTable *pTable, void *pStruct, int objectID );

// This writes all pNewState properties into pOut.
//
// If pOldState is non-null and contains any properties that aren't in pNewState, then
// those properties are written to the output as well. Returns # of changed props
int RecvTable_MergeDeltas(
	RecvTable *pTable,

	bf_read *pOldState,		// this can be null
	bf_read *pNewState,

	bf_write *pOut,

	int objectID = - 1,
	
	int	*pChangedProps = NULL,

	bool updateDTI = false // enclude merge from newState in the DTI reports
	);


// Just copies the bits from the bf_read into the bf_write (this function is used
// when you don't know the length of the encoded data).
void RecvTable_CopyEncoding( 
	RecvTable *pRecvTable, 
	bf_read *pIn, 
	bf_write *pOut,
	int objectID
	);



// ------------------------------------------------------------------------------------------ //
// Globals
// ------------------------------------------------------------------------------------------ //

// This is incremented each time a property is decoded.
extern int g_nPropsDecoded;


#endif // DATATABLE_RECV_ENG_H