]> git.lizzy.rs Git - dragonfireclient.git/blob - src/clientserver.h
Initial files
[dragonfireclient.git] / src / clientserver.h
1 #ifndef CLIENTSERVER_HEADER
2 #define CLIENTSERVER_HEADER
3
4 #define PROTOCOL_ID 0x4f457403
5
6 enum ToClientCommand
7 {
8         TOCLIENT_INIT=0x10,
9         /*
10                 Server's reply to TOSERVER_INIT.
11                 Sent second after connected.
12
13                 [0] u16 TOSERVER_INIT
14                 [2] u8 deployed version
15                 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
16         */
17
18         TOCLIENT_BLOCKDATA=0x20, //TODO: Multiple blocks
19         TOCLIENT_ADDNODE,
20         TOCLIENT_REMOVENODE,
21         
22         TOCLIENT_PLAYERPOS,
23         /*
24                 [0] u16 command
25                 // Followed by an arbitary number of these:
26                 // Number is determined from packet length.
27                 [N] u16 peer_id
28                 [N+2] v3s32 position*100
29                 [N+2+12] v3s32 speed*100
30                 [N+2+12+12] s32 pitch*100
31                 [N+2+12+12+4] s32 yaw*100
32         */
33
34         TOCLIENT_PLAYERINFO,
35         /*
36                 [0] u16 command
37                 // Followed by an arbitary number of these:
38                 // Number is determined from packet length.
39                 [N] u16 peer_id
40                 [N] char[20] name
41         */
42         
43         TOCLIENT_OPT_BLOCK_NOT_FOUND, // Not used
44
45         TOCLIENT_SECTORMETA,
46         /*
47                 [0] u16 command
48                 [2] u8 sector count
49                 [3...] v2s16 pos + sector metadata
50         */
51
52         TOCLIENT_INVENTORY,
53         /*
54                 [0] u16 command
55                 [2] serialized inventory
56         */
57         
58         TOCLIENT_OBJECTDATA,
59         /*
60                 Sent as unreliable.
61
62                 u16 command
63                 u16 number of player positions
64                 for each player:
65                         v3s32 position*100
66                         v3s32 speed*100
67                         s32 pitch*100
68                         s32 yaw*100
69                 u16 count of blocks
70                 for each block:
71                         v3s16 blockpos
72                         block objects
73         */
74 };
75
76 enum ToServerCommand
77 {
78         TOSERVER_INIT=0x10,
79         /*
80                 Sent first after connected.
81
82                 [0] u16 TOSERVER_INIT
83                 [2] u8 SER_FMT_VER_HIGHEST
84                 [3] u8[20] player_name
85         */
86
87         TOSERVER_INIT2,
88         /*
89                 Sent as an ACK for TOCLIENT_INIT.
90                 After this, the server can send data.
91
92                 [0] u16 TOSERVER_INIT2
93         */
94
95         TOSERVER_GETBLOCK=0x20, // Not used
96         TOSERVER_ADDNODE, // Not used
97         TOSERVER_REMOVENODE, // deprecated
98
99         TOSERVER_PLAYERPOS,
100         /*
101                 [0] u16 command
102                 [2] v3s32 position*100
103                 [2+12] v3s32 speed*100
104                 [2+12+12] s32 pitch*100
105                 [2+12+12+4] s32 yaw*100
106         */
107
108         TOSERVER_GOTBLOCKS,
109         /*
110                 [0] u16 command
111                 [2] u8 count
112                 [3] v3s16 pos_0
113                 [3+6] v3s16 pos_1
114                 ...
115         */
116
117         TOSERVER_DELETEDBLOCKS,
118         /*
119                 [0] u16 command
120                 [2] u8 count
121                 [3] v3s16 pos_0
122                 [3+6] v3s16 pos_1
123                 ...
124         */
125
126         TOSERVER_ADDNODE_FROM_INVENTORY, // deprecated
127         /*
128                 [0] u16 command
129                 [2] v3s16 pos
130                 [8] u16 i
131         */
132
133         TOSERVER_CLICK_OBJECT,
134         /*
135                 length: 13
136                 [0] u16 command
137                 [2] u8 button (0=left, 1=right)
138                 [3] v3s16 blockpos
139                 [9] s16 id
140                 [11] u16 item
141         */
142
143         TOSERVER_CLICK_GROUND,
144         /*
145                 length: 17
146                 [0] u16 command
147                 [2] u8 button (0=left, 1=right)
148                 [3] v3s16 nodepos_undersurface
149                 [9] v3s16 nodepos_abovesurface
150                 [15] u16 item
151         */
152         
153         TOSERVER_RELEASE,
154         /*
155                 length: 3
156                 [0] u16 command
157                 [2] u8 button
158         */
159
160         TOSERVER_SIGNTEXT,
161         /*
162                 u16 command
163                 v3s16 blockpos
164                 s16 id
165                 u16 textlen
166                 textdata
167         */
168 };
169
170 // Flags for TOSERVER_GETBLOCK
171 #define TOSERVER_GETBLOCK_FLAG_OPTIONAL (1<<0)
172
173 #endif
174