-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage-example.cpp
More file actions
52 lines (39 loc) · 906 Bytes
/
Copy pathmessage-example.cpp
File metadata and controls
52 lines (39 loc) · 906 Bytes
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
#include <iostream>
#include "net_common/net_message.hpp"
enum class SystemMessage : uint32_t
{
FireBullet,
MovePlayer
};
int main()
{
net::message<SystemMessage> msg;
msg.header.id = SystemMessage::MovePlayer;
std::cout << msg << std::endl;
int a = 1;
bool b = false;
float c = 3.1415f;
struct
{
float x, y;
} d[5];
for (size_t i = 0; i < 5; i++)
{
d[i].x = (i + 1) * 10;
d[i].y = (i + 1) * 10 + 5;
}
msg << a << b << c << d;
std::cout << msg << std::endl;
std::cout << sizeof(int) + sizeof(bool) + sizeof(float) + sizeof(float) * 10 << std::endl;
a = 99;
b = true;
c = 99.f;
msg >> d >> c >> b >> a;
std::cout << msg << std::endl;
std::cout << "a: " << a << ", b: " << b << ", c: " << c << std::endl;
for (size_t i = 0; i < 5; i++)
{
std::cout << "d[" << i << +"]: " << d[i].x << "," << d[i].y << std::endl;
}
return 0;
}