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
48 Digging based on item groups
51 ContentFeatures and NodeDefManager use a different serialization
52 format; better for future version cross-compatibility
56 Version raised to force 'fly' and 'fast' privileges into effect.
59 #define PROTOCOL_VERSION 10
61 #define PROTOCOL_ID 0x4f457403
63 #define PASSWORD_SIZE 28 // Maximum password length. Allows for
64 // base64-encoded SHA-1 (27+\0).
66 #define TEXTURENAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_."
72 Server's reply to TOSERVER_INIT.
73 Sent second after connected.
76 [2] u8 deployed version
77 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
78 [12] u64 map seed (new as of 2011-02-27)
80 NOTE: The position in here is deprecated; position is
81 explicitly sent afterwards
84 TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
85 TOCLIENT_ADDNODE = 0x21,
86 TOCLIENT_REMOVENODE = 0x22,
88 TOCLIENT_PLAYERPOS = 0x23, // Obsolete
91 // Followed by an arbitary number of these:
92 // Number is determined from packet length.
94 [N+2] v3s32 position*100
95 [N+2+12] v3s32 speed*100
96 [N+2+12+12] s32 pitch*100
97 [N+2+12+12+4] s32 yaw*100
100 TOCLIENT_PLAYERINFO = 0x24, // Obsolete
103 // Followed by an arbitary number of these:
104 // Number is determined from packet length.
109 TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
111 TOCLIENT_SECTORMETA = 0x26, // Obsolete
115 [3...] v2s16 pos + sector metadata
118 TOCLIENT_INVENTORY = 0x27,
121 [2] serialized inventory
124 TOCLIENT_OBJECTDATA = 0x28, // Obsolete
129 u16 number of player positions
142 TOCLIENT_TIME_OF_DAY = 0x29,
146 Added in a later version:
150 // (oops, there is some gap here)
152 TOCLIENT_CHAT_MESSAGE = 0x30,
159 TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
162 u16 count of removed objects
163 for all removed objects {
166 u16 count of added objects
167 for all added objects {
170 u32 initialization data length
171 string initialization data
175 TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
192 TOCLIENT_MOVE_PLAYER = 0x34,
195 v3f1000 player position
200 TOCLIENT_ACCESS_DENIED = 0x35,
207 TOCLIENT_PLAYERITEM = 0x36, // Obsolete
210 u16 count of player items
211 for all player items {
213 u16 length of serialized item
214 string serialized item
218 TOCLIENT_DEATHSCREEN = 0x37,
221 u8 bool set camera point target
222 v3f1000 camera point target (to point the death cause or whatever)
225 TOCLIENT_MEDIA = 0x38,
228 u16 total number of texture bunches
229 u16 index of this bunch
230 u32 number of files in this bunch
239 TOCLIENT_TOOLDEF = 0x39,
242 u32 length of the next item
243 serialized ToolDefManager
246 TOCLIENT_NODEDEF = 0x3a,
249 u32 length of the next item
250 serialized NodeDefManager
253 TOCLIENT_CRAFTITEMDEF = 0x3b,
256 u32 length of the next item
257 serialized CraftiItemDefManager
260 TOCLIENT_ANNOUNCE_MEDIA = 0x3c,
268 u16 length of sha1_digest
273 TOCLIENT_ITEMDEF = 0x3d,
276 u32 length of next item
277 serialized ItemDefManager
280 TOCLIENT_PLAY_SOUND = 0x3f,
287 u8 type (0=local, 1=positional, 2=object)
288 s32[3] pos_nodes*10000
293 TOCLIENT_STOP_SOUND = 0x40,
299 TOCLIENT_PRIVILEGES = 0x41,
302 u16 number of privileges
313 Sent first after connected.
315 [0] u16 TOSERVER_INIT
316 [2] u8 SER_FMT_VER_HIGHEST
317 [3] u8[20] player_name
318 [23] u8[28] password (new in some version)
319 [51] u16 client network protocol version (new in some version)
322 TOSERVER_INIT2 = 0x11,
324 Sent as an ACK for TOCLIENT_INIT.
325 After this, the server can send data.
327 [0] u16 TOSERVER_INIT2
330 TOSERVER_GETBLOCK=0x20, // Obsolete
331 TOSERVER_ADDNODE = 0x21, // Obsolete
332 TOSERVER_REMOVENODE = 0x22, // Obsolete
334 TOSERVER_PLAYERPOS = 0x23,
337 [2] v3s32 position*100
338 [2+12] v3s32 speed*100
339 [2+12+12] s32 pitch*100
340 [2+12+12+4] s32 yaw*100
343 TOSERVER_GOTBLOCKS = 0x24,
352 TOSERVER_DELETEDBLOCKS = 0x25,
361 TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
368 TOSERVER_CLICK_OBJECT = 0x27, // Obsolete
372 [2] u8 button (0=left, 1=right)
378 TOSERVER_GROUND_ACTION = 0x28, // Obsolete
383 [3] v3s16 nodepos_undersurface
384 [9] v3s16 nodepos_abovesurface
387 0: start digging (from undersurface)
388 1: place block (to abovesurface)
389 2: stop digging (all parameters ignored)
393 TOSERVER_RELEASE = 0x29, // Obsolete
395 // (oops, there is some gap here)
397 TOSERVER_SIGNTEXT = 0x30, // Old signs, obsolete
406 TOSERVER_INVENTORY_ACTION = 0x31,
408 See InventoryAction in inventory.h
411 TOSERVER_CHAT_MESSAGE = 0x32,
418 TOSERVER_SIGNNODETEXT = 0x33,
426 TOSERVER_CLICK_ACTIVEOBJECT = 0x34, // Obsolete
430 [2] u8 button (0=left, 1=right)
435 TOSERVER_DAMAGE = 0x35,
441 TOSERVER_PASSWORD=0x36,
443 Sent to change password.
445 [0] u16 TOSERVER_PASSWORD
446 [2] u8[28] old password
447 [30] u8[28] new password
450 TOSERVER_PLAYERITEM=0x37,
452 Sent to change selected item.
454 [0] u16 TOSERVER_PLAYERITEM
458 TOSERVER_RESPAWN=0x38,
463 TOSERVER_INTERACT = 0x39,
468 [5] u32 length of the next item
469 [9] serialized PointedThing
471 0: start digging (from undersurface) or use
472 1: stop digging (all parameters ignored)
474 3: place block or item (to abovesurface)
477 (Obsoletes TOSERVER_GROUND_ACTION and TOSERVER_CLICK_ACTIVEOBJECT.)
480 TOSERVER_REMOVED_SOUNDS = 0x3a,
487 TOSERVER_REQUEST_MEDIA = 0x40,
490 u16 number of files requested
499 inline SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed)
501 SharedBuffer<u8> data(2+2+4);
502 writeU16(&data[0], TOCLIENT_TIME_OF_DAY);
503 writeU16(&data[2], time);
504 writeF1000(&data[4], time_speed);