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
35 #define PROTOCOL_VERSION 4
37 #define PROTOCOL_ID 0x4f457403
39 #define PASSWORD_SIZE 28 // Maximum password length. Allows for
40 // base64-encoded SHA-1 (27+\0).
46 Server's reply to TOSERVER_INIT.
47 Sent second after connected.
50 [2] u8 deployed version
51 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
52 [12] u64 map seed (new as of 2011-02-27)
54 NOTE: The position in here is deprecated; position is
55 explicitly sent afterwards
58 TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
59 TOCLIENT_ADDNODE = 0x21,
60 TOCLIENT_REMOVENODE = 0x22,
62 TOCLIENT_PLAYERPOS = 0x23, // Obsolete
65 // Followed by an arbitary number of these:
66 // Number is determined from packet length.
68 [N+2] v3s32 position*100
69 [N+2+12] v3s32 speed*100
70 [N+2+12+12] s32 pitch*100
71 [N+2+12+12+4] s32 yaw*100
74 TOCLIENT_PLAYERINFO = 0x24,
77 // Followed by an arbitary number of these:
78 // Number is determined from packet length.
83 TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
85 TOCLIENT_SECTORMETA = 0x26, // Obsolete
89 [3...] v2s16 pos + sector metadata
92 TOCLIENT_INVENTORY = 0x27,
95 [2] serialized inventory
98 TOCLIENT_OBJECTDATA = 0x28,
103 u16 number of player positions
116 TOCLIENT_TIME_OF_DAY = 0x29,
122 TOCLIENT_CHAT_MESSAGE = 0x30,
129 TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
132 u16 count of removed objects
133 for all removed objects {
136 u16 count of added objects
137 for all added objects {
140 u32 initialization data length
141 string initialization data
145 TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
162 TOCLIENT_MOVE_PLAYER = 0x34,
165 v3f1000 player position
170 TOCLIENT_ACCESS_DENIED = 0x35,
177 TOCLIENT_PLAYERITEM = 0x36,
180 u16 count of player items
181 for all player items {
183 u16 length of serialized item
184 string serialized item
188 TOCLIENT_DEATHSCREEN = 0x37,
191 u8 bool set camera point target
192 v3f1000 camera point target (to point the death cause or whatever)
195 TOCLIENT_TOOLDEF = 0x38,
198 u32 length of the next item
199 serialized ToolDefManager
202 TOCLIENT_TEXTURES = 0x39,
205 u32 number of textures
214 //TOCLIENT_CONTENT_SENDING_MODE = 0x38,
217 u8 mode (0 = off, 1 = on)
225 Sent first after connected.
227 [0] u16 TOSERVER_INIT
228 [2] u8 SER_FMT_VER_HIGHEST
229 [3] u8[20] player_name
230 [23] u8[28] password (new in some version)
231 [51] u16 client network protocol version (new in some version)
234 TOSERVER_INIT2 = 0x11,
236 Sent as an ACK for TOCLIENT_INIT.
237 After this, the server can send data.
239 [0] u16 TOSERVER_INIT2
242 TOSERVER_GETBLOCK=0x20, // Obsolete
243 TOSERVER_ADDNODE = 0x21, // Obsolete
244 TOSERVER_REMOVENODE = 0x22, // Obsolete
246 TOSERVER_PLAYERPOS = 0x23,
249 [2] v3s32 position*100
250 [2+12] v3s32 speed*100
251 [2+12+12] s32 pitch*100
252 [2+12+12+4] s32 yaw*100
255 TOSERVER_GOTBLOCKS = 0x24,
264 TOSERVER_DELETEDBLOCKS = 0x25,
273 TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
280 TOSERVER_CLICK_OBJECT = 0x27,
284 [2] u8 button (0=left, 1=right)
290 TOSERVER_GROUND_ACTION = 0x28,
295 [3] v3s16 nodepos_undersurface
296 [9] v3s16 nodepos_abovesurface
299 0: start digging (from undersurface)
300 1: place block (to abovesurface)
301 2: stop digging (all parameters ignored)
305 TOSERVER_RELEASE = 0x29, // Obsolete
307 TOSERVER_SIGNTEXT = 0x30, // Old signs
316 TOSERVER_INVENTORY_ACTION = 0x31,
318 See InventoryAction in inventory.h
321 TOSERVER_CHAT_MESSAGE = 0x32,
328 TOSERVER_SIGNNODETEXT = 0x33,
336 TOSERVER_CLICK_ACTIVEOBJECT = 0x34,
340 [2] u8 button (0=left, 1=right)
345 TOSERVER_DAMAGE = 0x35,
351 TOSERVER_PASSWORD=0x36,
353 Sent to change password.
355 [0] u16 TOSERVER_PASSWORD
356 [2] u8[28] old password
357 [30] u8[28] new password
360 TOSERVER_PLAYERITEM=0x37,
362 Sent to change selected item.
364 [0] u16 TOSERVER_PLAYERITEM
368 TOSERVER_RESPAWN=0x38,
374 inline SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time)
376 SharedBuffer<u8> data(2+2);
377 writeU16(&data[0], TOCLIENT_TIME_OF_DAY);
378 writeU16(&data[2], time);