-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClientGameTokenSynch.h
112 lines (83 loc) · 3.16 KB
/
ClientGameTokenSynch.h
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
/*************************************************************************
Crytek Source File.
Copyright (C), Crytek Studios, 2001-2008.
-------------------------------------------------------------------------
$Id$
$DateTime$
Description:
-------------------------------------------------------------------------
History:
- 5:9:2008 13:01 : Created by Marcio Martins
*************************************************************************/
#ifndef __CLIENTGAMETOKENSYNCH_H__
#define __CLIENTGAMETOKENSYNCH_H__
#if _MSC_VER > 1000
# pragma once
#endif
#include <NetHelpers.h>
#include <IGameTokens.h>
typedef string TGameTokenName;
typedef TFlowInputData TGameTokenValue;
typedef TFlowSystemDataTypes TGameTokenValueTypes;
#define DECLARE_MESSAGE(classname) \
class classname: public CSetMsg \
{ \
public: \
classname(int _channelId, TGameTokenName _name, TGameTokenValue &_value); \
EMessageSendResult WritePayload(TSerialize ser, uint32 currentSeq, uint32 basisSeq); \
}; \
struct IGameFramework;
class CServerGameTokenSynch;
class CClientGameTokenSynch:
public CNetMessageSinkHelper<CClientGameTokenSynch, INetMessageSink>
{
public:
CClientGameTokenSynch(IGameTokenSystem *pGTS) { m_pGTS=pGTS; };
virtual ~CClientGameTokenSynch() {};
void Reset() {}; // TODO: implement
void GetMemoryUsage(ICrySizer *pSizer) const ;
// INetMessageSink
virtual void DefineProtocol(IProtocolBuilder *pBuilder);
// ~INetMessageSink
//------------------------------------------------------------------------
class CResetMsg: public INetMessage
{
public:
CResetMsg(int _channelId);
int channelId;
EMessageSendResult WritePayload(TSerialize ser, uint32 currentSeq, uint32 basisSeq);
void UpdateState(uint32 fromSeq, ENetSendableStateUpdate update);
size_t GetSize();
};
//------------------------------------------------------------------------
class CSetMsg: public INetMessage
{
public:
CSetMsg(const SNetMessageDef *pDef, int _channelId, TGameTokenName &_name, TGameTokenValue &_value);
int channelId;
TGameTokenName name;
TGameTokenValue value;
virtual EMessageSendResult WritePayload(TSerialize ser, uint32 currentSeq, uint32 basisSeq);
virtual void UpdateState(uint32 fromSeq, ENetSendableStateUpdate update);
virtual size_t GetSize();
};
static void SerializeGameToken(TSerialize ser, TGameTokenName &name, TGameTokenValue &value, int type);
DECLARE_MESSAGE(CSetIntMsg);
DECLARE_MESSAGE(CSetFloatMsg);
DECLARE_MESSAGE(CSetVec3Msg);
DECLARE_MESSAGE(CSetEntityIdMsg);
DECLARE_MESSAGE(CSetStringMsg);
DECLARE_MESSAGE(CSetBoolMsg);
//------------------------------------------------------------------------
NET_DECLARE_IMMEDIATE_MESSAGE(ResetMsg);
NET_DECLARE_IMMEDIATE_MESSAGE(SetIntMsg);
NET_DECLARE_IMMEDIATE_MESSAGE(SetFloatMsg);
NET_DECLARE_IMMEDIATE_MESSAGE(SetVec3Msg);
NET_DECLARE_IMMEDIATE_MESSAGE(SetEntityIdMsg);
NET_DECLARE_IMMEDIATE_MESSAGE(SetStringMsg);
NET_DECLARE_IMMEDIATE_MESSAGE(SetBoolMsg);
protected:
IGameTokenSystem *m_pGTS;
};
#undef DECLARE_MESSAGE
#endif //__CLIENTGAMETOKENSYNCH_H__