blob: 703de9a812285969571c4bf6ec82fcbfb7d0f216 (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef PREDICTABLEID_H
#define PREDICTABLEID_H
#ifdef _WIN32
#pragma once
#endif
#if !defined( NO_ENTITY_PREDICTION )
//-----------------------------------------------------------------------------
// Purpose: Wraps 32bit predictID to allow access and creation
//-----------------------------------------------------------------------------
class CPredictableId
{
public:
// Construction
CPredictableId( void );
static void ResetInstanceCounters( void );
// Is the Id being used
bool IsActive( void ) const;
// Call this to set from data
void Init( int player, int command, const char *classname, const char *module, int line );
// Get player index
int GetPlayer( void ) const;
// Get hash value
int GetHash( void ) const;
// Get index number
int GetInstanceNumber( void ) const;
// Get command number
int GetCommandNumber( void ) const;
// Check command number
// bool IsCommandNumberEqual( int testNumber ) const;
// Client only
void SetAcknowledged( bool ack );
bool GetAcknowledged( void ) const;
// For conversion to/from integer
int GetRaw( void ) const;
void SetRaw( int raw );
char const *Describe( void ) const;
// Equality test
bool operator ==( const CPredictableId& other ) const;
bool operator !=( const CPredictableId& other ) const;
private:
void SetCommandNumber( int commandNumber );
void SetPlayer( int playerIndex );
void SetInstanceNumber( int counter );
// Encoding bits, should total 32
struct bitfields
{
unsigned int ack : 1; // 1
unsigned int player : 5; // 6
unsigned int command : 10; // 16
unsigned int hash : 12; // 28
unsigned int instance : 4; // 32
} m_PredictableID;
};
// This can be empty, the class has a proper constructor
FORCEINLINE void NetworkVarConstruct( CPredictableId &x ) {}
#endif
#endif // PREDICTABLEID_H
|