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 Add TOCLIENT_CRAFTITEMDEF
36 Obsolete TOSERVER_CLICK_ACTIVEOBJECT
37 Obsolete TOSERVER_GROUND_ACTION
39 Make players to be handled mostly as ActiveObjects
41 Only non-cached textures are sent
44 Obsolete TOCLIENT_TOOLDEF
45 Obsolete TOCLIENT_CRAFTITEMDEF
46 Compress the contents of TOCLIENT_ITEMDEF and TOCLIENT_NODEDEF
49 #define PROTOCOL_VERSION 7
51 #define PROTOCOL_ID 0x4f457403
53 #define PASSWORD_SIZE 28 // Maximum password length. Allows for
54 // base64-encoded SHA-1 (27+\0).
56 #define TEXTURENAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_."
62 Server's reply to TOSERVER_INIT.
63 Sent second after connected.
66 [2] u8 deployed version
67 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
68 [12] u64 map seed (new as of 2011-02-27)
70 NOTE: The position in here is deprecated; position is
71 explicitly sent afterwards
74 TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
75 TOCLIENT_ADDNODE = 0x21,
76 TOCLIENT_REMOVENODE = 0x22,
78 TOCLIENT_PLAYERPOS = 0x23, // Obsolete
81 // Followed by an arbitary number of these:
82 // Number is determined from packet length.
84 [N+2] v3s32 position*100
85 [N+2+12] v3s32 speed*100
86 [N+2+12+12] s32 pitch*100
87 [N+2+12+12+4] s32 yaw*100
90 TOCLIENT_PLAYERINFO = 0x24, // Obsolete
93 // Followed by an arbitary number of these:
94 // Number is determined from packet length.
99 TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
101 TOCLIENT_SECTORMETA = 0x26, // Obsolete
105 [3...] v2s16 pos + sector metadata
108 TOCLIENT_INVENTORY = 0x27,
111 [2] serialized inventory
114 TOCLIENT_OBJECTDATA = 0x28, // Obsolete
119 u16 number of player positions
132 TOCLIENT_TIME_OF_DAY = 0x29,
138 // (oops, there is some gap here)
140 TOCLIENT_CHAT_MESSAGE = 0x30,
147 TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
150 u16 count of removed objects
151 for all removed objects {
154 u16 count of added objects
155 for all added objects {
158 u32 initialization data length
159 string initialization data
163 TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
180 TOCLIENT_MOVE_PLAYER = 0x34,
183 v3f1000 player position
188 TOCLIENT_ACCESS_DENIED = 0x35,
195 TOCLIENT_PLAYERITEM = 0x36,
198 u16 count of player items
199 for all player items {
201 u16 length of serialized item
202 string serialized item
206 TOCLIENT_DEATHSCREEN = 0x37,
209 u8 bool set camera point target
210 v3f1000 camera point target (to point the death cause or whatever)
213 TOCLIENT_TEXTURES = 0x38,
216 u16 total number of texture bunches
217 u16 index of this bunch
218 u32 number of textures in this bunch
227 TOCLIENT_TOOLDEF = 0x39,
230 u32 length of the next item
231 serialized ToolDefManager
234 TOCLIENT_NODEDEF = 0x3a,
237 u32 length of the next item
238 serialized NodeDefManager
241 TOCLIENT_CRAFTITEMDEF = 0x3b,
244 u32 length of the next item
245 serialized CraftiItemDefManager
248 TOCLIENT_ANNOUNCE_TEXTURES = 0x3c,
252 u32 number of textures
256 u16 length of sha1_digest
261 TOCLIENT_ITEMDEF = 0x3d,
264 u32 length of next item
265 serialized ItemDefManager
274 Sent first after connected.
276 [0] u16 TOSERVER_INIT
277 [2] u8 SER_FMT_VER_HIGHEST
278 [3] u8[20] player_name
279 [23] u8[28] password (new in some version)
280 [51] u16 client network protocol version (new in some version)
283 TOSERVER_INIT2 = 0x11,
285 Sent as an ACK for TOCLIENT_INIT.
286 After this, the server can send data.
288 [0] u16 TOSERVER_INIT2
291 TOSERVER_GETBLOCK=0x20, // Obsolete
292 TOSERVER_ADDNODE = 0x21, // Obsolete
293 TOSERVER_REMOVENODE = 0x22, // Obsolete
295 TOSERVER_PLAYERPOS = 0x23,
298 [2] v3s32 position*100
299 [2+12] v3s32 speed*100
300 [2+12+12] s32 pitch*100
301 [2+12+12+4] s32 yaw*100
304 TOSERVER_GOTBLOCKS = 0x24,
313 TOSERVER_DELETEDBLOCKS = 0x25,
322 TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
329 TOSERVER_CLICK_OBJECT = 0x27, // Obsolete
333 [2] u8 button (0=left, 1=right)
339 TOSERVER_GROUND_ACTION = 0x28, // Obsolete
344 [3] v3s16 nodepos_undersurface
345 [9] v3s16 nodepos_abovesurface
348 0: start digging (from undersurface)
349 1: place block (to abovesurface)
350 2: stop digging (all parameters ignored)
354 TOSERVER_RELEASE = 0x29, // Obsolete
356 // (oops, there is some gap here)
358 TOSERVER_SIGNTEXT = 0x30, // Old signs, obsolete
367 TOSERVER_INVENTORY_ACTION = 0x31,
369 See InventoryAction in inventory.h
372 TOSERVER_CHAT_MESSAGE = 0x32,
379 TOSERVER_SIGNNODETEXT = 0x33,
387 TOSERVER_CLICK_ACTIVEOBJECT = 0x34, // Obsolete
391 [2] u8 button (0=left, 1=right)
396 TOSERVER_DAMAGE = 0x35,
402 TOSERVER_PASSWORD=0x36,
404 Sent to change password.
406 [0] u16 TOSERVER_PASSWORD
407 [2] u8[28] old password
408 [30] u8[28] new password
411 TOSERVER_PLAYERITEM=0x37,
413 Sent to change selected item.
415 [0] u16 TOSERVER_PLAYERITEM
419 TOSERVER_RESPAWN=0x38,
424 TOSERVER_INTERACT = 0x39,
429 [5] u32 length of the next item
430 [9] serialized PointedThing
432 0: start digging (from undersurface) or use
433 1: stop digging (all parameters ignored)
435 3: place block or item (to abovesurface)
438 (Obsoletes TOSERVER_GROUND_ACTION and TOSERVER_CLICK_ACTIVEOBJECT.)
441 TOSERVER_REQUEST_TEXTURES = 0x40,
445 u16 number of textures requested
454 inline SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time)
456 SharedBuffer<u8> data(2+2);
457 writeU16(&data[0], TOCLIENT_TIME_OF_DAY);
458 writeU16(&data[2], time);