-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessageStructs.h
66 lines (56 loc) · 907 Bytes
/
MessageStructs.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
#ifndef MESSAGE_STRUCTS_H
#define MESSAGE_STRUCTS_H
#include <string>
#include <string.h>
#include <iostream>
struct Message
{
int type;
virtual ~Message() {}
};
struct NewClientMessage : Message
{
NewClientMessage()
{
type = 0;
}
std::string name;
};
struct GameBeginMessage : Message
{
GameBeginMessage()
{
type = 1;
}
std::string opponentName;
};
struct GameUpdateMessage : Message
{
GameUpdateMessage()
{
type = 2;
}
int x, y, velX, velY, moveFactor, money, points;
float health;
};
struct GameEndMessage : Message
{
GameEndMessage()
{
type = 3;
}
int points;
int money;
float health;
};
struct GameResultMessage : Message
{
GameResultMessage()
{
type = 4;
}
bool won;
};
int serialize(Message *msg, char *data);
Message *deserialize(char *data);
#endif