networkprotocol.h: remove "u16 command" from doc
[oweals/minetest.git] / src / network / networkprotocol.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser 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.
18 */
19
20 #ifndef NETWORKPROTOCOL_HEADER
21 #define NETWORKPROTOCOL_HEADER
22 #include "util/string.h"
23
24 /*
25         changes by PROTOCOL_VERSION:
26
27         PROTOCOL_VERSION 3:
28                 Base for writing changes here
29         PROTOCOL_VERSION 4:
30                 Add TOCLIENT_MEDIA
31                 Add TOCLIENT_TOOLDEF
32                 Add TOCLIENT_NODEDEF
33                 Add TOCLIENT_CRAFTITEMDEF
34                 Add TOSERVER_INTERACT
35                 Obsolete TOSERVER_CLICK_ACTIVEOBJECT
36                 Obsolete TOSERVER_GROUND_ACTION
37         PROTOCOL_VERSION 5:
38                 Make players to be handled mostly as ActiveObjects
39         PROTOCOL_VERSION 6:
40                 Only non-cached textures are sent
41         PROTOCOL_VERSION 7:
42                 Add TOCLIENT_ITEMDEF
43                 Obsolete TOCLIENT_TOOLDEF
44                 Obsolete TOCLIENT_CRAFTITEMDEF
45                 Compress the contents of TOCLIENT_ITEMDEF and TOCLIENT_NODEDEF
46         PROTOCOL_VERSION 8:
47                 Digging based on item groups
48                 Many things
49         PROTOCOL_VERSION 9:
50                 ContentFeatures and NodeDefManager use a different serialization
51                     format; better for future version cross-compatibility
52                 Many things
53         PROTOCOL_VERSION 10:
54                 TOCLIENT_PRIVILEGES
55                 Version raised to force 'fly' and 'fast' privileges into effect.
56                 Node metadata change (came in later; somewhat incompatible)
57         PROTOCOL_VERSION 11:
58                 TileDef in ContentFeatures
59                 Nodebox drawtype
60                 (some dev snapshot)
61                 TOCLIENT_INVENTORY_FORMSPEC
62                 (0.4.0, 0.4.1)
63         PROTOCOL_VERSION 12:
64                 TOSERVER_INVENTORY_FIELDS
65                 16-bit node ids
66                 TOCLIENT_DETACHED_INVENTORY
67         PROTOCOL_VERSION 13:
68                 InventoryList field "Width" (deserialization fails with old versions)
69         PROTOCOL_VERSION 14:
70                 Added transfer of player pressed keys to the server
71                 Added new messages for mesh and bone animation, as well as attachments
72                 GENERIC_CMD_SET_ANIMATION
73                 GENERIC_CMD_SET_BONE_POSITION
74                 GENERIC_CMD_SET_ATTACHMENT
75         PROTOCOL_VERSION 15:
76                 Serialization format changes
77         PROTOCOL_VERSION 16:
78                 TOCLIENT_SHOW_FORMSPEC
79         PROTOCOL_VERSION 17:
80                 Serialization format change: include backface_culling flag in TileDef
81                 Added rightclickable field in nodedef
82                 TOCLIENT_SPAWN_PARTICLE
83                 TOCLIENT_ADD_PARTICLESPAWNER
84                 TOCLIENT_DELETE_PARTICLESPAWNER
85         PROTOCOL_VERSION 18:
86                 damageGroups added to ToolCapabilities
87                 sound_place added to ItemDefinition
88         PROTOCOL_VERSION 19:
89                 GENERIC_CMD_SET_PHYSICS_OVERRIDE
90         PROTOCOL_VERSION 20:
91                 TOCLIENT_HUDADD
92                 TOCLIENT_HUDRM
93                 TOCLIENT_HUDCHANGE
94                 TOCLIENT_HUD_SET_FLAGS
95         PROTOCOL_VERSION 21:
96                 TOCLIENT_BREATH
97                 TOSERVER_BREATH
98                 range added to ItemDefinition
99                 drowning, leveled and liquid_range added to ContentFeatures
100                 stepheight and collideWithObjects added to object properties
101                 version, heat and humidity transfer in MapBock
102                 automatic_face_movement_dir and automatic_face_movement_dir_offset
103                         added to object properties
104         PROTOCOL_VERSION 22:
105                 add swap_node
106         PROTOCOL_VERSION 23:
107                 TOSERVER_CLIENT_READY
108         PROTOCOL_VERSION 24:
109                 ContentFeatures version 7
110                 ContentFeatures: change number of special tiles to 6 (CF_SPECIAL_COUNT)
111         PROTOCOL_VERSION 25:
112                 Rename TOCLIENT_ACCESS_DENIED to TOCLIENT_ACCESS_DENIED_LEGAGY
113                 Rename TOCLIENT_DELETE_PARTICLESPAWNER to
114                         TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY
115                 Rename TOSERVER_PASSWORD to TOSERVER_PASSWORD_LEGACY
116                 Rename TOSERVER_INIT to TOSERVER_INIT_LEGACY
117                 Rename TOCLIENT_INIT to TOCLIENT_INIT_LEGACY
118                 Add TOCLIENT_ACCESS_DENIED new opcode (0x0A), using error codes
119                         for standard error, keeping customisation possible. This
120                         permit translation
121                 Add TOCLIENT_DELETE_PARTICLESPAWNER (0x53), fixing the u16 read and
122                         reading u32
123                 Add new opcode TOSERVER_INIT for client presentation to server
124                 Add new opcodes TOSERVER_FIRST_SRP, TOSERVER_SRP_BYTES_A,
125                         TOSERVER_SRP_BYTES_M, TOCLIENT_SRP_BYTES_S_B
126                         for the three supported auth mechanisms around srp
127                 Add new opcodes TOCLIENT_ACCEPT_SUDO_MODE and TOCLIENT_DENY_SUDO_MODE
128                         for sudo mode handling (auth mech generic way of changing password).
129                 Add TOCLIENT_HELLO for presenting server to client after client
130                         presentation
131                 Add TOCLIENT_AUTH_ACCEPT to accept connection from client
132                 Rename GENERIC_CMD_SET_ATTACHMENT to GENERIC_CMD_ATTACH_TO
133         PROTOCOL_VERSION 26:
134                 Add TileDef tileable_horizontal, tileable_vertical flags
135 */
136
137 #define LATEST_PROTOCOL_VERSION 26
138
139 // Server's supported network protocol range
140 #define SERVER_PROTOCOL_VERSION_MIN 13
141 #define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
142
143 // Client's supported network protocol range
144 #define CLIENT_PROTOCOL_VERSION_MIN 13
145 #define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
146
147 // Constant that differentiates the protocol from random data and other protocols
148 #define PROTOCOL_ID 0x4f457403
149
150 #define PASSWORD_SIZE 28       // Maximum password length. Allows for
151                                // base64-encoded SHA-1 (27+\0).
152
153 #define FORMSPEC_API_VERSION 1
154 #define FORMSPEC_VERSION_STRING "formspec_version[" TOSTRING(FORMSPEC_API_VERSION) "]"
155
156 #define TEXTURENAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-"
157
158 enum ToClientCommand
159 {
160         TOCLIENT_HELLO = 0x02,
161         /*
162                 Sent after TOSERVER_INIT.
163
164                 u8 deployed serialisation version
165                 u16 deployed network compression mode
166                 u16 deployed protocol version
167                 u32 supported auth methods
168                 std::string username that should be used for legacy hash (for proper casing)
169         */
170         TOCLIENT_AUTH_ACCEPT = 0x03,
171         /*
172                 Message from server to accept auth.
173
174                 v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
175                 u64 map seed
176                 f1000 recommended send interval
177                 u32 : supported auth methods for sudo mode
178                       (where the user can change their password)
179         */
180         TOCLIENT_ACCEPT_SUDO_MODE = 0x04,
181         /*
182                 Sent to client to show it is in sudo mode now.
183         */
184         TOCLIENT_DENY_SUDO_MODE = 0x05,
185         /*
186                 Signals client that sudo mode auth failed.
187         */
188         TOCLIENT_INIT_LEGACY = 0x10,
189         /*
190                 Server's reply to TOSERVER_INIT.
191                 Sent second after connected.
192
193                 [0] u16 TOSERVER_INIT
194                 [2] u8 deployed version
195                 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
196                 [12] u64 map seed (new as of 2011-02-27)
197                 [20] f1000 recommended send interval (in seconds) (new as of 14)
198
199                 NOTE: The position in here is deprecated; position is
200                       explicitly sent afterwards
201         */
202         TOCLIENT_ACCESS_DENIED = 0x0A,
203         /*
204                 u8 reason
205                 std::string custom reason (if needed, otherwise "")
206                 u8 (bool) reconnect
207         */
208         TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
209         TOCLIENT_ADDNODE = 0x21,
210         /*
211                 v3s16 position
212                 serialized mapnode
213                 u8 keep_metadata // Added in protocol version 22
214         */
215         TOCLIENT_REMOVENODE = 0x22,
216
217         TOCLIENT_PLAYERPOS = 0x23, // Obsolete
218         /*
219                 [0] u16 command
220                 // Followed by an arbitary number of these:
221                 // Number is determined from packet length.
222                 [N] u16 peer_id
223                 [N+2] v3s32 position*100
224                 [N+2+12] v3s32 speed*100
225                 [N+2+12+12] s32 pitch*100
226                 [N+2+12+12+4] s32 yaw*100
227         */
228
229         TOCLIENT_PLAYERINFO = 0x24, // Obsolete
230         /*
231                 [0] u16 command
232                 // Followed by an arbitary number of these:
233                 // Number is determined from packet length.
234                 [N] u16 peer_id
235                 [N] char[20] name
236         */
237
238         TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
239
240         TOCLIENT_SECTORMETA = 0x26, // Obsolete
241         /*
242                 [0] u16 command
243                 [2] u8 sector count
244                 [3...] v2s16 pos + sector metadata
245         */
246
247         TOCLIENT_INVENTORY = 0x27,
248         /*
249                 [0] u16 command
250                 [2] serialized inventory
251         */
252
253         TOCLIENT_OBJECTDATA = 0x28, // Obsolete
254         /*
255                 Sent as unreliable.
256
257                 u16 number of player positions
258                 for each player:
259                         u16 peer_id
260                         v3s32 position*100
261                         v3s32 speed*100
262                         s32 pitch*100
263                         s32 yaw*100
264                 u16 count of blocks
265                 for each block:
266                         v3s16 blockpos
267                         block objects
268         */
269
270         TOCLIENT_TIME_OF_DAY = 0x29,
271         /*
272                 u16 time (0-23999)
273                 Added in a later version:
274                 f1000 time_speed
275         */
276
277         // (oops, there is some gap here)
278
279         TOCLIENT_CHAT_MESSAGE = 0x30,
280         /*
281                 u16 length
282                 wstring message
283         */
284
285         TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
286         /*
287                 u16 count of removed objects
288                 for all removed objects {
289                         u16 id
290                 }
291                 u16 count of added objects
292                 for all added objects {
293                         u16 id
294                         u8 type
295                         u32 initialization data length
296                         string initialization data
297                 }
298         */
299
300         TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
301         /*
302                 for all objects
303                 {
304                         u16 id
305                         u16 message length
306                         string message
307                 }
308         */
309
310         TOCLIENT_HP = 0x33,
311         /*
312                 u8 hp
313         */
314
315         TOCLIENT_MOVE_PLAYER = 0x34,
316         /*
317                 v3f1000 player position
318                 f1000 player pitch
319                 f1000 player yaw
320         */
321
322         TOCLIENT_ACCESS_DENIED_LEGACY = 0x35,
323         /*
324                 u16 reason_length
325                 wstring reason
326         */
327
328         TOCLIENT_PLAYERITEM = 0x36, // Obsolete
329         /*
330                 u16 count of player items
331                 for all player items {
332                         u16 peer id
333                         u16 length of serialized item
334                         string serialized item
335                 }
336         */
337
338         TOCLIENT_DEATHSCREEN = 0x37,
339         /*
340                 u8 bool set camera point target
341                 v3f1000 camera point target (to point the death cause or whatever)
342         */
343
344         TOCLIENT_MEDIA = 0x38,
345         /*
346                 u16 total number of texture bunches
347                 u16 index of this bunch
348                 u32 number of files in this bunch
349                 for each file {
350                         u16 length of name
351                         string name
352                         u32 length of data
353                         data
354                 }
355                 u16 length of remote media server url (if applicable)
356                 string url
357         */
358
359         TOCLIENT_TOOLDEF = 0x39,
360         /*
361                 u32 length of the next item
362                 serialized ToolDefManager
363         */
364
365         TOCLIENT_NODEDEF = 0x3a,
366         /*
367                 u32 length of the next item
368                 serialized NodeDefManager
369         */
370
371         TOCLIENT_CRAFTITEMDEF = 0x3b,
372         /*
373                 u32 length of the next item
374                 serialized CraftiItemDefManager
375         */
376
377         TOCLIENT_ANNOUNCE_MEDIA = 0x3c,
378
379         /*
380                 u32 number of files
381                 for each texture {
382                         u16 length of name
383                         string name
384                         u16 length of sha1_digest
385                         string sha1_digest
386                 }
387         */
388
389         TOCLIENT_ITEMDEF = 0x3d,
390         /*
391                 u32 length of next item
392                 serialized ItemDefManager
393         */
394
395         TOCLIENT_PLAY_SOUND = 0x3f,
396         /*
397                 s32 sound_id
398                 u16 len
399                 u8[len] sound name
400                 s32 gain*1000
401                 u8 type (0=local, 1=positional, 2=object)
402                 s32[3] pos_nodes*10000
403                 u16 object_id
404                 u8 loop (bool)
405         */
406
407         TOCLIENT_STOP_SOUND = 0x40,
408         /*
409                 s32 sound_id
410         */
411
412         TOCLIENT_PRIVILEGES = 0x41,
413         /*
414                 u16 number of privileges
415                 for each privilege
416                         u16 len
417                         u8[len] privilege
418         */
419
420         TOCLIENT_INVENTORY_FORMSPEC = 0x42,
421         /*
422                 u32 len
423                 u8[len] formspec
424         */
425
426         TOCLIENT_DETACHED_INVENTORY = 0x43,
427         /*
428                 [0] u16 command
429                 u16 len
430                 u8[len] name
431                 [2] serialized inventory
432         */
433
434         TOCLIENT_SHOW_FORMSPEC = 0x44,
435         /*
436                 [0] u16 command
437                 u32 len
438                 u8[len] formspec
439                 u16 len
440                 u8[len] formname
441         */
442
443         TOCLIENT_MOVEMENT = 0x45,
444         /*
445                 f1000 movement_acceleration_default
446                 f1000 movement_acceleration_air
447                 f1000 movement_acceleration_fast
448                 f1000 movement_speed_walk
449                 f1000 movement_speed_crouch
450                 f1000 movement_speed_fast
451                 f1000 movement_speed_climb
452                 f1000 movement_speed_jump
453                 f1000 movement_liquid_fluidity
454                 f1000 movement_liquid_fluidity_smooth
455                 f1000 movement_liquid_sink
456                 f1000 movement_gravity
457         */
458
459         TOCLIENT_SPAWN_PARTICLE = 0x46,
460         /*
461                 v3f1000 pos
462                 v3f1000 velocity
463                 v3f1000 acceleration
464                 f1000 expirationtime
465                 f1000 size
466                 u8 bool collisiondetection
467                 u8 bool vertical
468                 u32 len
469                 u8[len] texture
470         */
471
472         TOCLIENT_ADD_PARTICLESPAWNER = 0x47,
473         /*
474                 u16 amount
475                 f1000 spawntime
476                 v3f1000 minpos
477                 v3f1000 maxpos
478                 v3f1000 minvel
479                 v3f1000 maxvel
480                 v3f1000 minacc
481                 v3f1000 maxacc
482                 f1000 minexptime
483                 f1000 maxexptime
484                 f1000 minsize
485                 f1000 maxsize
486                 u8 bool collisiondetection
487                 u8 bool vertical
488                 u32 len
489                 u8[len] texture
490                 u32 id
491         */
492
493         TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY = 0x48,
494         /*
495                 u16 id
496         */
497
498         TOCLIENT_HUDADD = 0x49,
499         /*
500                 u32 id
501                 u8 type
502                 v2f1000 pos
503                 u32 len
504                 u8[len] name
505                 v2f1000 scale
506                 u32 len2
507                 u8[len2] text
508                 u32 number
509                 u32 item
510                 u32 dir
511                 v2f1000 align
512                 v2f1000 offset
513                 v3f1000 world_pos
514                 v2s32 size
515         */
516
517         TOCLIENT_HUDRM = 0x4a,
518         /*
519                 u32 id
520         */
521
522         TOCLIENT_HUDCHANGE = 0x4b,
523         /*
524                 u32 id
525                 u8 stat
526                 [v2f1000 data |
527                  u32 len
528                  u8[len] data |
529                  u32 data]
530         */
531
532         TOCLIENT_HUD_SET_FLAGS = 0x4c,
533         /*
534                 u32 flags
535                 u32 mask
536         */
537
538         TOCLIENT_HUD_SET_PARAM = 0x4d,
539         /*
540                 u16 param
541                 u16 len
542                 u8[len] value
543         */
544
545         TOCLIENT_BREATH = 0x4e,
546         /*
547                 u16 breath
548         */
549
550         TOCLIENT_SET_SKY = 0x4f,
551         /*
552                 u8[4] color (ARGB)
553                 u8 len
554                 u8[len] type
555                 u16 count
556                 foreach count:
557                         u8 len
558                         u8[len] param
559         */
560
561         TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO = 0x50,
562         /*
563                 u8 do_override (boolean)
564                 u16 day-night ratio 0...65535
565         */
566
567         TOCLIENT_LOCAL_PLAYER_ANIMATIONS = 0x51,
568         /*
569                 v2s32 stand/idle
570                 v2s32 walk
571                 v2s32 dig
572                 v2s32 walk+dig
573                 f1000 frame_speed
574         */
575
576         TOCLIENT_EYE_OFFSET = 0x52,
577         /*
578                 v3f1000 first
579                 v3f1000 third
580         */
581
582         TOCLIENT_DELETE_PARTICLESPAWNER = 0x53,
583         /*
584                 u32 id
585         */
586
587         TOCLIENT_SRP_BYTES_S_B = 0x60,
588         /*
589                 Belonging to AUTH_MECHANISM_LEGACY_PASSWORD and AUTH_MECHANISM_SRP.
590
591                 std::string bytes_s
592                 std::string bytes_B
593         */
594
595         TOCLIENT_NUM_MSG_TYPES = 0x61,
596 };
597
598 enum ToServerCommand
599 {
600         TOSERVER_INIT = 0x02,
601         /*
602                 Sent first after connected.
603
604                 u8 serialisation version (=SER_FMT_VER_HIGHEST_READ)
605                 u16 supported network compression modes
606                 u16 minimum supported network protocol version
607                 u16 maximum supported network protocol version
608                 std::string player name
609         */
610
611         TOSERVER_INIT_LEGACY = 0x10,
612         /*
613                 Sent first after connected.
614
615                 [0] u16 TOSERVER_INIT_LEGACY
616                 [2] u8 SER_FMT_VER_HIGHEST_READ
617                 [3] u8[20] player_name
618                 [23] u8[28] password (new in some version)
619                 [51] u16 minimum supported network protocol version (added sometime)
620                 [53] u16 maximum supported network protocol version (added later than the previous one)
621         */
622
623         TOSERVER_INIT2 = 0x11,
624         /*
625                 Sent as an ACK for TOCLIENT_INIT.
626                 After this, the server can send data.
627
628                 [0] u16 TOSERVER_INIT2
629         */
630
631         TOSERVER_GETBLOCK=0x20, // Obsolete
632         TOSERVER_ADDNODE = 0x21, // Obsolete
633         TOSERVER_REMOVENODE = 0x22, // Obsolete
634
635         TOSERVER_PLAYERPOS = 0x23,
636         /*
637                 [0] u16 command
638                 [2] v3s32 position*100
639                 [2+12] v3s32 speed*100
640                 [2+12+12] s32 pitch*100
641                 [2+12+12+4] s32 yaw*100
642                 [2+12+12+4+4] u32 keyPressed
643         */
644
645         TOSERVER_GOTBLOCKS = 0x24,
646         /*
647                 [0] u16 command
648                 [2] u8 count
649                 [3] v3s16 pos_0
650                 [3+6] v3s16 pos_1
651                 ...
652         */
653
654         TOSERVER_DELETEDBLOCKS = 0x25,
655         /*
656                 [0] u16 command
657                 [2] u8 count
658                 [3] v3s16 pos_0
659                 [3+6] v3s16 pos_1
660                 ...
661         */
662
663         TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
664         /*
665                 [0] u16 command
666                 [2] v3s16 pos
667                 [8] u16 i
668         */
669
670         TOSERVER_CLICK_OBJECT = 0x27, // Obsolete
671         /*
672                 length: 13
673                 [0] u16 command
674                 [2] u8 button (0=left, 1=right)
675                 [3] v3s16 blockpos
676                 [9] s16 id
677                 [11] u16 item
678         */
679
680         TOSERVER_GROUND_ACTION = 0x28, // Obsolete
681         /*
682                 length: 17
683                 [0] u16 command
684                 [2] u8 action
685                 [3] v3s16 nodepos_undersurface
686                 [9] v3s16 nodepos_abovesurface
687                 [15] u16 item
688                 actions:
689                 0: start digging (from undersurface)
690                 1: place block (to abovesurface)
691                 2: stop digging (all parameters ignored)
692                 3: digging completed
693         */
694
695         TOSERVER_RELEASE = 0x29, // Obsolete
696
697         // (oops, there is some gap here)
698
699         TOSERVER_SIGNTEXT = 0x30, // Old signs, obsolete
700         /*
701                 v3s16 blockpos
702                 s16 id
703                 u16 textlen
704                 textdata
705         */
706
707         TOSERVER_INVENTORY_ACTION = 0x31,
708         /*
709                 See InventoryAction in inventorymanager.h
710         */
711
712         TOSERVER_CHAT_MESSAGE = 0x32,
713         /*
714                 u16 length
715                 wstring message
716         */
717
718         TOSERVER_SIGNNODETEXT = 0x33, // obsolete
719         /*
720                 v3s16 p
721                 u16 textlen
722                 textdata
723         */
724
725         TOSERVER_CLICK_ACTIVEOBJECT = 0x34, // Obsolete
726         /*
727                 length: 7
728                 [0] u16 command
729                 [2] u8 button (0=left, 1=right)
730                 [3] u16 id
731                 [5] u16 item
732         */
733
734         TOSERVER_DAMAGE = 0x35,
735         /*
736                 u8 amount
737         */
738
739         TOSERVER_PASSWORD_LEGACY = 0x36,
740         /*
741                 Sent to change password.
742
743                 [0] u16 TOSERVER_PASSWORD
744                 [2] u8[28] old password
745                 [30] u8[28] new password
746         */
747
748         TOSERVER_PLAYERITEM = 0x37,
749         /*
750                 Sent to change selected item.
751
752                 [0] u16 TOSERVER_PLAYERITEM
753                 [2] u16 item
754         */
755
756         TOSERVER_RESPAWN = 0x38,
757         /*
758                 u16 TOSERVER_RESPAWN
759         */
760
761         TOSERVER_INTERACT = 0x39,
762         /*
763                 [0] u16 command
764                 [2] u8 action
765                 [3] u16 item
766                 [5] u32 length of the next item
767                 [9] serialized PointedThing
768                 actions:
769                 0: start digging (from undersurface) or use
770                 1: stop digging (all parameters ignored)
771                 2: digging completed
772                 3: place block or item (to abovesurface)
773                 4: use item
774
775                 (Obsoletes TOSERVER_GROUND_ACTION and TOSERVER_CLICK_ACTIVEOBJECT.)
776         */
777
778         TOSERVER_REMOVED_SOUNDS = 0x3a,
779         /*
780                 u16 len
781                 s32[len] sound_id
782         */
783
784         TOSERVER_NODEMETA_FIELDS = 0x3b,
785         /*
786                 v3s16 p
787                 u16 len
788                 u8[len] form name (reserved for future use)
789                 u16 number of fields
790                 for each field:
791                         u16 len
792                         u8[len] field name
793                         u32 len
794                         u8[len] field value
795         */
796
797         TOSERVER_INVENTORY_FIELDS = 0x3c,
798         /*
799                 u16 len
800                 u8[len] form name (reserved for future use)
801                 u16 number of fields
802                 for each field:
803                         u16 len
804                         u8[len] field name
805                         u32 len
806                         u8[len] field value
807         */
808
809         TOSERVER_REQUEST_MEDIA = 0x40,
810         /*
811                 u16 number of files requested
812                 for each file {
813                         u16 length of name
814                         string name
815                 }
816          */
817
818         TOSERVER_RECEIVED_MEDIA = 0x41,
819         /*
820                 <no payload data>
821         */
822
823         TOSERVER_BREATH = 0x42,
824         /*
825                 u16 breath
826         */
827
828         TOSERVER_CLIENT_READY = 0x43,
829         /*
830                 u8 major
831                 u8 minor
832                 u8 patch
833                 u8 reserved
834                 u16 len
835                 u8[len] full_version_string
836         */
837
838         TOSERVER_FIRST_SRP = 0x50,
839         /*
840                 Belonging to AUTH_MECHANISM_FIRST_SRP.
841
842                 std::string srp salt
843                 std::string srp verification key
844                 u8 is_empty (=1 if password is empty, 0 otherwise)
845         */
846
847         TOSERVER_SRP_BYTES_A = 0x51,
848         /*
849                 Belonging to AUTH_MECHANISM_LEGACY_PASSWORD and AUTH_MECHANISM_SRP,
850                         depending on current_login_based_on.
851
852                 std::string bytes_A
853                 u8 current_login_based_on : on which version of the password's
854                                             hash this login is based on (0 legacy hash,
855                                             or 1 directly the password)
856         */
857
858         TOSERVER_SRP_BYTES_M = 0x52,
859         /*
860                 Belonging to AUTH_MECHANISM_LEGACY_PASSWORD and AUTH_MECHANISM_SRP.
861
862                 std::string bytes_M
863         */
864
865         TOSERVER_NUM_MSG_TYPES = 0x53,
866 };
867
868 enum AuthMechanism
869 {
870         // reserved
871         AUTH_MECHANISM_NONE = 0,
872
873         // SRP based on the legacy hash
874         AUTH_MECHANISM_LEGACY_PASSWORD = 1 << 0,
875
876         // SRP based on the srp verification key
877         AUTH_MECHANISM_SRP = 1 << 1,
878
879         // Establishes a srp verification key, for first login and password changing
880         AUTH_MECHANISM_FIRST_SRP = 1 << 2,
881 };
882
883 enum AccessDeniedCode {
884         SERVER_ACCESSDENIED_WRONG_PASSWORD,
885         SERVER_ACCESSDENIED_UNEXPECTED_DATA,
886         SERVER_ACCESSDENIED_SINGLEPLAYER,
887         SERVER_ACCESSDENIED_WRONG_VERSION,
888         SERVER_ACCESSDENIED_WRONG_CHARS_IN_NAME,
889         SERVER_ACCESSDENIED_WRONG_NAME,
890         SERVER_ACCESSDENIED_TOO_MANY_USERS,
891         SERVER_ACCESSDENIED_EMPTY_PASSWORD,
892         SERVER_ACCESSDENIED_ALREADY_CONNECTED,
893         SERVER_ACCESSDENIED_SERVER_FAIL,
894         SERVER_ACCESSDENIED_CUSTOM_STRING,
895         SERVER_ACCESSDENIED_SHUTDOWN,
896         SERVER_ACCESSDENIED_CRASH,
897         SERVER_ACCESSDENIED_MAX,
898 };
899
900 enum NetProtoCompressionMode {
901         NETPROTO_COMPRESSION_NONE = 0,
902 };
903
904 const static std::string accessDeniedStrings[SERVER_ACCESSDENIED_MAX] = {
905         "Invalid password",
906         "Your client sent something the server didn't expect.  Try reconnecting or updating your client",
907         "The server is running in simple singleplayer mode.  You cannot connect.",
908         "Your client's version is not supported.\nPlease contact server administrator.",
909         "Player name contains disallowed characters.",
910         "Player name not allowed.",
911         "Too many users.",
912         "Empty passwords are disallowed.  Set a password and try again.",
913         "Another client is connected with this name.  If your client closed unexpectedly, try again in a minute.",
914         "Server authentication failed.  This is likely a server error.",
915         "",
916         "Server shutting down.",
917         "This server has experienced an internal error. You will now be disconnected."
918 };
919
920 #endif