]> git.lizzy.rs Git - minetest.git/blob - src/clientserver.h
4526083dabe4972a4954e1f0442be5554f6be86e
[minetest.git] / src / clientserver.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef CLIENTSERVER_HEADER
21 #define CLIENTSERVER_HEADER
22
23 #define PROTOCOL_ID 0x4f457403
24
25 enum ToClientCommand
26 {
27         TOCLIENT_INIT = 0x10,
28         /*
29                 Server's reply to TOSERVER_INIT.
30                 Sent second after connected.
31
32                 [0] u16 TOSERVER_INIT
33                 [2] u8 deployed version
34                 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
35         */
36
37         TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
38         TOCLIENT_ADDNODE = 0x21,
39         TOCLIENT_REMOVENODE = 0x22,
40         
41         TOCLIENT_PLAYERPOS = 0x23,
42         /*
43                 [0] u16 command
44                 // Followed by an arbitary number of these:
45                 // Number is determined from packet length.
46                 [N] u16 peer_id
47                 [N+2] v3s32 position*100
48                 [N+2+12] v3s32 speed*100
49                 [N+2+12+12] s32 pitch*100
50                 [N+2+12+12+4] s32 yaw*100
51         */
52
53         TOCLIENT_PLAYERINFO = 0x24,
54         /*
55                 [0] u16 command
56                 // Followed by an arbitary number of these:
57                 // Number is determined from packet length.
58                 [N] u16 peer_id
59                 [N] char[20] name
60         */
61         
62         TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Not used
63
64         TOCLIENT_SECTORMETA = 0x26, // Not used
65         /*
66                 [0] u16 command
67                 [2] u8 sector count
68                 [3...] v2s16 pos + sector metadata
69         */
70
71         TOCLIENT_INVENTORY = 0x27,
72         /*
73                 [0] u16 command
74                 [2] serialized inventory
75         */
76         
77         TOCLIENT_OBJECTDATA = 0x28,
78         /*
79                 Sent as unreliable.
80
81                 u16 command
82                 u16 number of player positions
83                 for each player:
84                         v3s32 position*100
85                         v3s32 speed*100
86                         s32 pitch*100
87                         s32 yaw*100
88                 u16 count of blocks
89                 for each block:
90                         v3s16 blockpos
91                         block objects
92         */
93 };
94
95 enum ToServerCommand
96 {
97         TOSERVER_INIT=0x10,
98         /*
99                 Sent first after connected.
100
101                 [0] u16 TOSERVER_INIT
102                 [2] u8 SER_FMT_VER_HIGHEST
103                 [3] u8[20] player_name
104         */
105
106         TOSERVER_INIT2 = 0x11,
107         /*
108                 Sent as an ACK for TOCLIENT_INIT.
109                 After this, the server can send data.
110
111                 [0] u16 TOSERVER_INIT2
112         */
113
114         TOSERVER_GETBLOCK=0x20, // Not used
115         TOSERVER_ADDNODE = 0x21, // Not used
116         TOSERVER_REMOVENODE = 0x22, // deprecated
117
118         TOSERVER_PLAYERPOS = 0x23,
119         /*
120                 [0] u16 command
121                 [2] v3s32 position*100
122                 [2+12] v3s32 speed*100
123                 [2+12+12] s32 pitch*100
124                 [2+12+12+4] s32 yaw*100
125         */
126
127         TOSERVER_GOTBLOCKS = 0x24,
128         /*
129                 [0] u16 command
130                 [2] u8 count
131                 [3] v3s16 pos_0
132                 [3+6] v3s16 pos_1
133                 ...
134         */
135
136         TOSERVER_DELETEDBLOCKS = 0x25,
137         /*
138                 [0] u16 command
139                 [2] u8 count
140                 [3] v3s16 pos_0
141                 [3+6] v3s16 pos_1
142                 ...
143         */
144
145         TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // deprecated
146         /*
147                 [0] u16 command
148                 [2] v3s16 pos
149                 [8] u16 i
150         */
151
152         TOSERVER_CLICK_OBJECT = 0x27,
153         /*
154                 length: 13
155                 [0] u16 command
156                 [2] u8 button (0=left, 1=right)
157                 [3] v3s16 blockpos
158                 [9] s16 id
159                 [11] u16 item
160         */
161
162         TOSERVER_GROUND_ACTION = 0x28,
163         /*
164                 length: 17
165                 [0] u16 command
166                 [2] u8 action
167                 [3] v3s16 nodepos_undersurface
168                 [9] v3s16 nodepos_abovesurface
169                 [15] u16 item
170                 actions:
171                 0: start digging (from undersurface)
172                 1: place block (to abovesurface)
173                 2: stop digging (all parameters ignored)
174         */
175         
176         TOSERVER_RELEASE = 0x29, // Not used
177
178         TOSERVER_SIGNTEXT = 0x30,
179         /*
180                 u16 command
181                 v3s16 blockpos
182                 s16 id
183                 u16 textlen
184                 textdata
185         */
186 };
187
188 // Flags for TOSERVER_GETBLOCK
189 #define TOSERVER_GETBLOCK_FLAG_OPTIONAL (1<<0)
190
191 #endif
192