3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
20 #ifndef CLIENTSERVER_HEADER
21 #define CLIENTSERVER_HEADER
25 #define PROTOCOL_VERSION 3
27 #define PROTOCOL_ID 0x4f457403
29 #define PASSWORD_SIZE 28 // Maximum password length. Allows for
30 // base64-encoded SHA-1 (27+\0).
36 Server's reply to TOSERVER_INIT.
37 Sent second after connected.
40 [2] u8 deployed version
41 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
42 [12] u64 map seed (new as of 2011-02-27)
44 NOTE: The position in here is deprecated; position is
45 explicitly sent afterwards
48 TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
49 TOCLIENT_ADDNODE = 0x21,
50 TOCLIENT_REMOVENODE = 0x22,
52 TOCLIENT_PLAYERPOS = 0x23, // Obsolete
55 // Followed by an arbitary number of these:
56 // Number is determined from packet length.
58 [N+2] v3s32 position*100
59 [N+2+12] v3s32 speed*100
60 [N+2+12+12] s32 pitch*100
61 [N+2+12+12+4] s32 yaw*100
64 TOCLIENT_PLAYERINFO = 0x24,
67 // Followed by an arbitary number of these:
68 // Number is determined from packet length.
73 TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
75 TOCLIENT_SECTORMETA = 0x26, // Obsolete
79 [3...] v2s16 pos + sector metadata
82 TOCLIENT_INVENTORY = 0x27,
85 [2] serialized inventory
88 TOCLIENT_OBJECTDATA = 0x28,
93 u16 number of player positions
106 TOCLIENT_TIME_OF_DAY = 0x29,
112 TOCLIENT_CHAT_MESSAGE = 0x30,
119 TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
122 u16 count of removed objects
123 for all removed objects {
126 u16 count of added objects
127 for all added objects {
130 u32 initialization data length
131 string initialization data
135 TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
152 TOCLIENT_MOVE_PLAYER = 0x34,
155 v3f1000 player position
160 TOCLIENT_ACCESS_DENIED = 0x35,
167 TOCLIENT_PLAYERITEM = 0x36,
170 u16 count of player items
171 for all player items {
173 u16 length of serialized item
174 string serialized item
178 TOCLIENT_DEATHSCREEN = 0x37,
181 u8 bool set camera point target
182 v3f1000 camera point target (to point the death cause or whatever)
190 Sent first after connected.
192 [0] u16 TOSERVER_INIT
193 [2] u8 SER_FMT_VER_HIGHEST
194 [3] u8[20] player_name
195 [23] u8[28] password (new in some version)
196 [51] u16 client network protocol version (new in some version)
199 TOSERVER_INIT2 = 0x11,
201 Sent as an ACK for TOCLIENT_INIT.
202 After this, the server can send data.
204 [0] u16 TOSERVER_INIT2
207 TOSERVER_GETBLOCK=0x20, // Obsolete
208 TOSERVER_ADDNODE = 0x21, // Obsolete
209 TOSERVER_REMOVENODE = 0x22, // Obsolete
211 TOSERVER_PLAYERPOS = 0x23,
214 [2] v3s32 position*100
215 [2+12] v3s32 speed*100
216 [2+12+12] s32 pitch*100
217 [2+12+12+4] s32 yaw*100
220 TOSERVER_GOTBLOCKS = 0x24,
229 TOSERVER_DELETEDBLOCKS = 0x25,
238 TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
245 TOSERVER_CLICK_OBJECT = 0x27,
249 [2] u8 button (0=left, 1=right)
255 TOSERVER_GROUND_ACTION = 0x28,
260 [3] v3s16 nodepos_undersurface
261 [9] v3s16 nodepos_abovesurface
264 0: start digging (from undersurface)
265 1: place block (to abovesurface)
266 2: stop digging (all parameters ignored)
270 TOSERVER_RELEASE = 0x29, // Obsolete
272 TOSERVER_SIGNTEXT = 0x30, // Old signs
281 TOSERVER_INVENTORY_ACTION = 0x31,
283 See InventoryAction in inventory.h
286 TOSERVER_CHAT_MESSAGE = 0x32,
293 TOSERVER_SIGNNODETEXT = 0x33,
301 TOSERVER_CLICK_ACTIVEOBJECT = 0x34,
305 [2] u8 button (0=left, 1=right)
310 TOSERVER_DAMAGE = 0x35,
316 TOSERVER_PASSWORD=0x36,
318 Sent to change password.
320 [0] u16 TOSERVER_PASSWORD
321 [2] u8[28] old password
322 [30] u8[28] new password
325 TOSERVER_PLAYERITEM=0x37,
327 Sent to change selected item.
329 [0] u16 TOSERVER_PLAYERITEM
333 TOSERVER_RESPAWN=0x38,
339 inline SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time)
341 SharedBuffer<u8> data(2+2);
342 writeU16(&data[0], TOCLIENT_TIME_OF_DAY);
343 writeU16(&data[2], time);