This repository has been archived by the owner on Nov 15, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
PacketType.h
131 lines (101 loc) · 1.95 KB
/
PacketType.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#pragma once
#define MAX_CHAT_LEN 256
#define MAX_NAME_LEN 30
#define MAX_COMMENT_LEN 40
enum PacketTypes
{
PKT_NONE = 0,
PKT_CS_LOGIN = 1,
PKT_SC_LOGIN = 2,
PKT_CS_CHAT = 11,
PKT_SC_CHAT = 12,
PKT_CS_MOVE = 21,
PKT_SC_MOVE = 22,
PKT_MAX = 1024
} ;
#pragma pack(push, 1)
struct PacketHeader
{
PacketHeader() : mSize(0), mType(PKT_NONE) {}
short mSize ;
short mType ;
} ;
struct LoginRequest : public PacketHeader
{
LoginRequest()
{
mSize = sizeof(LoginRequest) ;
mType = PKT_CS_LOGIN ;
mPlayerId = -1 ;
}
int mPlayerId ;
} ;
struct LoginResult : public PacketHeader
{
LoginResult()
{
mSize = sizeof(LoginResult) ;
mType = PKT_SC_LOGIN ;
mPlayerId = -1 ;
memset(mName, 0, MAX_NAME_LEN) ;
}
int mPlayerId ;
float mPosX ;
float mPosY ;
char mName[MAX_NAME_LEN] ;
} ;
struct ChatBroadcastRequest : public PacketHeader
{
ChatBroadcastRequest()
{
mSize = sizeof(ChatBroadcastRequest) ;
mType = PKT_CS_CHAT ;
mPlayerId = -1 ;
memset(mChat, 0, MAX_CHAT_LEN) ;
}
int mPlayerId ;
char mChat[MAX_CHAT_LEN] ;
} ;
struct ChatBroadcastResult : public PacketHeader
{
ChatBroadcastResult()
{
mSize = sizeof(ChatBroadcastResult) ;
mType = PKT_SC_CHAT ;
mPlayerId = -1 ;
memset(mName, 0, MAX_NAME_LEN) ;
memset(mChat, 0, MAX_CHAT_LEN) ;
}
int mPlayerId ;
char mName[MAX_NAME_LEN] ;
char mChat[MAX_CHAT_LEN] ;
} ;
struct MoveRequest : public PacketHeader
{
MoveRequest()
{
mSize = sizeof(MoveRequest);
mType = PKT_CS_MOVE;
mPlayerId = -1;
mPosX = 0;
mPosY = 0;
}
int mPlayerId;
float mPosX;
float mPosY;
};
struct MoveBroadcastResult : public PacketHeader
{
MoveBroadcastResult()
{
mSize = sizeof(MoveBroadcastResult);
mType = PKT_SC_MOVE;
mPlayerId = -1;
mPosX = 0;
mPosY = 0;
}
int mPlayerId;
float mPosX;
float mPosY;
};
#pragma pack(pop)