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
26 changes by PROTOCOL_VERSION:
29 Base for writing changes here
34 #define PROTOCOL_VERSION 4
36 #define PROTOCOL_ID 0x4f457403
38 #define PASSWORD_SIZE 28 // Maximum password length. Allows for
39 // base64-encoded SHA-1 (27+\0).
45 Server's reply to TOSERVER_INIT.
46 Sent second after connected.
49 [2] u8 deployed version
50 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
51 [12] u64 map seed (new as of 2011-02-27)
53 NOTE: The position in here is deprecated; position is
54 explicitly sent afterwards
57 TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
58 TOCLIENT_ADDNODE = 0x21,
59 TOCLIENT_REMOVENODE = 0x22,
61 TOCLIENT_PLAYERPOS = 0x23, // Obsolete
64 // Followed by an arbitary number of these:
65 // Number is determined from packet length.
67 [N+2] v3s32 position*100
68 [N+2+12] v3s32 speed*100
69 [N+2+12+12] s32 pitch*100
70 [N+2+12+12+4] s32 yaw*100
73 TOCLIENT_PLAYERINFO = 0x24,
76 // Followed by an arbitary number of these:
77 // Number is determined from packet length.
82 TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
84 TOCLIENT_SECTORMETA = 0x26, // Obsolete
88 [3...] v2s16 pos + sector metadata
91 TOCLIENT_INVENTORY = 0x27,
94 [2] serialized inventory
97 TOCLIENT_OBJECTDATA = 0x28,
102 u16 number of player positions
115 TOCLIENT_TIME_OF_DAY = 0x29,
121 TOCLIENT_CHAT_MESSAGE = 0x30,
128 TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
131 u16 count of removed objects
132 for all removed objects {
135 u16 count of added objects
136 for all added objects {
139 u32 initialization data length
140 string initialization data
144 TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
161 TOCLIENT_MOVE_PLAYER = 0x34,
164 v3f1000 player position
169 TOCLIENT_ACCESS_DENIED = 0x35,
176 TOCLIENT_PLAYERITEM = 0x36,
179 u16 count of player items
180 for all player items {
182 u16 length of serialized item
183 string serialized item
187 TOCLIENT_DEATHSCREEN = 0x37,
190 u8 bool set camera point target
191 v3f1000 camera point target (to point the death cause or whatever)
194 TOCLIENT_TOOLDEF = 0x38,
197 u32 length of the next item
198 serialized ToolDefManager
201 //TOCLIENT_CONTENT_SENDING_MODE = 0x38,
204 u8 mode (0 = off, 1 = on)
212 Sent first after connected.
214 [0] u16 TOSERVER_INIT
215 [2] u8 SER_FMT_VER_HIGHEST
216 [3] u8[20] player_name
217 [23] u8[28] password (new in some version)
218 [51] u16 client network protocol version (new in some version)
221 TOSERVER_INIT2 = 0x11,
223 Sent as an ACK for TOCLIENT_INIT.
224 After this, the server can send data.
226 [0] u16 TOSERVER_INIT2
229 TOSERVER_GETBLOCK=0x20, // Obsolete
230 TOSERVER_ADDNODE = 0x21, // Obsolete
231 TOSERVER_REMOVENODE = 0x22, // Obsolete
233 TOSERVER_PLAYERPOS = 0x23,
236 [2] v3s32 position*100
237 [2+12] v3s32 speed*100
238 [2+12+12] s32 pitch*100
239 [2+12+12+4] s32 yaw*100
242 TOSERVER_GOTBLOCKS = 0x24,
251 TOSERVER_DELETEDBLOCKS = 0x25,
260 TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
267 TOSERVER_CLICK_OBJECT = 0x27,
271 [2] u8 button (0=left, 1=right)
277 TOSERVER_GROUND_ACTION = 0x28,
282 [3] v3s16 nodepos_undersurface
283 [9] v3s16 nodepos_abovesurface
286 0: start digging (from undersurface)
287 1: place block (to abovesurface)
288 2: stop digging (all parameters ignored)
292 TOSERVER_RELEASE = 0x29, // Obsolete
294 TOSERVER_SIGNTEXT = 0x30, // Old signs
303 TOSERVER_INVENTORY_ACTION = 0x31,
305 See InventoryAction in inventory.h
308 TOSERVER_CHAT_MESSAGE = 0x32,
315 TOSERVER_SIGNNODETEXT = 0x33,
323 TOSERVER_CLICK_ACTIVEOBJECT = 0x34,
327 [2] u8 button (0=left, 1=right)
332 TOSERVER_DAMAGE = 0x35,
338 TOSERVER_PASSWORD=0x36,
340 Sent to change password.
342 [0] u16 TOSERVER_PASSWORD
343 [2] u8[28] old password
344 [30] u8[28] new password
347 TOSERVER_PLAYERITEM=0x37,
349 Sent to change selected item.
351 [0] u16 TOSERVER_PLAYERITEM
355 TOSERVER_RESPAWN=0x38,
361 inline SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time)
363 SharedBuffer<u8> data(2+2);
364 writeU16(&data[0], TOCLIENT_TIME_OF_DAY);
365 writeU16(&data[2], time);