-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackets_common.h
131 lines (112 loc) · 1.86 KB
/
packets_common.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
#ifndef PACKETS_COMMON_H
#define PACKETS_COMMON_H
#include <stdint.h>
#define JOIN_QUEUE_REQ (uint16_t)0
#define JOIN_QUEUE_RESP (uint16_t)1
#define LEAVE_QUEUE_REQ (uint16_t)2
#define GAME_READY_RESP (uint16_t)3
#define PLAYER_READY_REQ (uint16_t)4
#define QUEUE_STATUS (uint16_t)5
#define BTN_PRESSED (uint16_t)6
#define INIT_LOCATIONS (uint16_t)7
#define GAME_STATE (uint16_t)8
#define GAME_OVER (uint16_t)9
#define NOTIFICATION (uint16_t)10
#define SCORE_BOARD (uint16_t)11
#pragma pack(push, 1)
struct Header
{
char soh;
int32_t msg_id;
uint16_t msg_type;
int32_t size;
int32_t order;
int32_t player_id;
char stx;
};
struct Footer
{
int32_t checksum;
char end;
};
/* join state */
struct JoinQueueRequest
{
char username[32];
};
struct JoinQueueResponse
{
char success;
};
/* queue state */
struct LeaveQueueRequest
{
};
struct PlayerReadyRequest
{
};
struct PlayerQueueInfo
{
char username[32];
int32_t gamer_id;
char is_ready;
};
struct QueueStatus
{
int32_t players_count;
struct PlayerQueueInfo **players_in_queue;
};
/* queue state */
struct ButtonPressed
{
char all_button_codes[5];
};
struct InitialLocations
{
int32_t map_width;
int32_t map_height;
char *tiles;
};
struct PlayerGameInfo
{
char username[32];
int32_t gamer_id;
float x;
float y;
float score;
};
struct ObjectInfo
{
int32_t id;
char type;
float x;
float y;
};
struct GameState
{
int32_t players_count;
int32_t objects_count;
struct PlayerGameInfo **players;
struct ObjectInfo **objects;
};
struct Notification
{
char message[256];
};
/* after-game state */
struct PlayerScoreboardInfo
{
char username[32];
int32_t gamer_id;
float score;
int32_t stats_count;
/* max stat_info line is 128 */
char *stats_info;
};
struct Scoreboard
{
int32_t players_count;
struct PlayerScoreboardInfo **players;
};
#pragma pack(pop)
#endif