]> git.lizzy.rs Git - minetest.git/blob - src/network/networkprotocol.h
Change error_message from wstring to string
[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 TOSERVER_INIT new opcode (0x02) for client presentation to server
124                 Add TOSERVER_AUTH new opcode (0x03) for client authentication
125                 Add TOCLIENT_HELLO for presenting server to client after client
126                         presentation
127                 Add TOCLIENT_AUTH_ACCEPT to accept connexion from client
128 */
129
130 #define LATEST_PROTOCOL_VERSION 24
131
132 // Server's supported network protocol range
133 #define SERVER_PROTOCOL_VERSION_MIN 13
134 #define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
135
136 // Client's supported network protocol range
137 #define CLIENT_PROTOCOL_VERSION_MIN 13
138 #define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
139
140 // Constant that differentiates the protocol from random data and other protocols
141 #define PROTOCOL_ID 0x4f457403
142
143 #define PASSWORD_SIZE 28       // Maximum password length. Allows for
144                                // base64-encoded SHA-1 (27+\0).
145
146 #define FORMSPEC_API_VERSION 1
147 #define FORMSPEC_VERSION_STRING "formspec_version[" TOSTRING(FORMSPEC_API_VERSION) "]"
148
149 #define TEXTURENAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-"
150
151 enum ToClientCommand
152 {
153         TOCLIENT_HELLO = 0x02,
154         TOCLIENT_AUTH_ACCEPT = 0x03,
155         TOCLIENT_ACCESS_DENIED = 0x0A,
156         /*
157                 u16 command
158                 u16 reason_length
159                 wstring reason
160         */
161
162         TOCLIENT_INIT_LEGACY = 0x10,
163         /*
164                 Server's reply to TOSERVER_INIT.
165                 Sent second after connected.
166
167                 [0] u16 TOSERVER_INIT
168                 [2] u8 deployed version
169                 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
170                 [12] u64 map seed (new as of 2011-02-27)
171                 [20] f1000 recommended send interval (in seconds) (new as of 14)
172
173                 NOTE: The position in here is deprecated; position is
174                       explicitly sent afterwards
175         */
176
177         TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
178         TOCLIENT_ADDNODE = 0x21,
179         /*
180                 u16 command
181                 v3s16 position
182                 serialized mapnode
183                 u8 keep_metadata // Added in protocol version 22
184         */
185         TOCLIENT_REMOVENODE = 0x22,
186
187         TOCLIENT_PLAYERPOS = 0x23, // Obsolete
188         /*
189                 [0] u16 command
190                 // Followed by an arbitary number of these:
191                 // Number is determined from packet length.
192                 [N] u16 peer_id
193                 [N+2] v3s32 position*100
194                 [N+2+12] v3s32 speed*100
195                 [N+2+12+12] s32 pitch*100
196                 [N+2+12+12+4] s32 yaw*100
197         */
198
199         TOCLIENT_PLAYERINFO = 0x24, // Obsolete
200         /*
201                 [0] u16 command
202                 // Followed by an arbitary number of these:
203                 // Number is determined from packet length.
204                 [N] u16 peer_id
205                 [N] char[20] name
206         */
207
208         TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
209
210         TOCLIENT_SECTORMETA = 0x26, // Obsolete
211         /*
212                 [0] u16 command
213                 [2] u8 sector count
214                 [3...] v2s16 pos + sector metadata
215         */
216
217         TOCLIENT_INVENTORY = 0x27,
218         /*
219                 [0] u16 command
220                 [2] serialized inventory
221         */
222
223         TOCLIENT_OBJECTDATA = 0x28, // Obsolete
224         /*
225                 Sent as unreliable.
226
227                 u16 command
228                 u16 number of player positions
229                 for each player:
230                         u16 peer_id
231                         v3s32 position*100
232                         v3s32 speed*100
233                         s32 pitch*100
234                         s32 yaw*100
235                 u16 count of blocks
236                 for each block:
237                         v3s16 blockpos
238                         block objects
239         */
240
241         TOCLIENT_TIME_OF_DAY = 0x29,
242         /*
243                 u16 command
244                 u16 time (0-23999)
245                 Added in a later version:
246                 f1000 time_speed
247         */
248
249         // (oops, there is some gap here)
250
251         TOCLIENT_CHAT_MESSAGE = 0x30,
252         /*
253                 u16 command
254                 u16 length
255                 wstring message
256         */
257
258         TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
259         /*
260                 u16 command
261                 u16 count of removed objects
262                 for all removed objects {
263                         u16 id
264                 }
265                 u16 count of added objects
266                 for all added objects {
267                         u16 id
268                         u8 type
269                         u32 initialization data length
270                         string initialization data
271                 }
272         */
273
274         TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
275         /*
276                 u16 command
277                 for all objects
278                 {
279                         u16 id
280                         u16 message length
281                         string message
282                 }
283         */
284
285         TOCLIENT_HP = 0x33,
286         /*
287                 u16 command
288                 u8 hp
289         */
290
291         TOCLIENT_MOVE_PLAYER = 0x34,
292         /*
293                 u16 command
294                 v3f1000 player position
295                 f1000 player pitch
296                 f1000 player yaw
297         */
298
299         TOCLIENT_ACCESS_DENIED_LEGACY = 0x35,
300         /*
301                 u16 command
302                 u16 reason_length
303                 wstring reason
304         */
305
306         TOCLIENT_PLAYERITEM = 0x36, // Obsolete
307         /*
308                 u16 command
309                 u16 count of player items
310                 for all player items {
311                         u16 peer id
312                         u16 length of serialized item
313                         string serialized item
314                 }
315         */
316
317         TOCLIENT_DEATHSCREEN = 0x37,
318         /*
319                 u16 command
320                 u8 bool set camera point target
321                 v3f1000 camera point target (to point the death cause or whatever)
322         */
323
324         TOCLIENT_MEDIA = 0x38,
325         /*
326                 u16 command
327                 u16 total number of texture bunches
328                 u16 index of this bunch
329                 u32 number of files in this bunch
330                 for each file {
331                         u16 length of name
332                         string name
333                         u32 length of data
334                         data
335                 }
336                 u16 length of remote media server url (if applicable)
337                 string url
338         */
339
340         TOCLIENT_TOOLDEF = 0x39,
341         /*
342                 u16 command
343                 u32 length of the next item
344                 serialized ToolDefManager
345         */
346
347         TOCLIENT_NODEDEF = 0x3a,
348         /*
349                 u16 command
350                 u32 length of the next item
351                 serialized NodeDefManager
352         */
353
354         TOCLIENT_CRAFTITEMDEF = 0x3b,
355         /*
356                 u16 command
357                 u32 length of the next item
358                 serialized CraftiItemDefManager
359         */
360
361         TOCLIENT_ANNOUNCE_MEDIA = 0x3c,
362
363         /*
364                 u16 command
365                 u32 number of files
366                 for each texture {
367                         u16 length of name
368                         string name
369                         u16 length of sha1_digest
370                         string sha1_digest
371                 }
372         */
373
374         TOCLIENT_ITEMDEF = 0x3d,
375         /*
376                 u16 command
377                 u32 length of next item
378                 serialized ItemDefManager
379         */
380
381         TOCLIENT_PLAY_SOUND = 0x3f,
382         /*
383                 u16 command
384                 s32 sound_id
385                 u16 len
386                 u8[len] sound name
387                 s32 gain*1000
388                 u8 type (0=local, 1=positional, 2=object)
389                 s32[3] pos_nodes*10000
390                 u16 object_id
391                 u8 loop (bool)
392         */
393
394         TOCLIENT_STOP_SOUND = 0x40,
395         /*
396                 u16 command
397                 s32 sound_id
398         */
399
400         TOCLIENT_PRIVILEGES = 0x41,
401         /*
402                 u16 command
403                 u16 number of privileges
404                 for each privilege
405                         u16 len
406                         u8[len] privilege
407         */
408
409         TOCLIENT_INVENTORY_FORMSPEC = 0x42,
410         /*
411                 u16 command
412                 u32 len
413                 u8[len] formspec
414         */
415
416         TOCLIENT_DETACHED_INVENTORY = 0x43,
417         /*
418                 [0] u16 command
419                 u16 len
420                 u8[len] name
421                 [2] serialized inventory
422         */
423
424         TOCLIENT_SHOW_FORMSPEC = 0x44,
425         /*
426                 [0] u16 command
427                 u32 len
428                 u8[len] formspec
429                 u16 len
430                 u8[len] formname
431         */
432
433         TOCLIENT_MOVEMENT = 0x45,
434         /*
435                 u16 command
436                 f1000 movement_acceleration_default
437                 f1000 movement_acceleration_air
438                 f1000 movement_acceleration_fast
439                 f1000 movement_speed_walk
440                 f1000 movement_speed_crouch
441                 f1000 movement_speed_fast
442                 f1000 movement_speed_climb
443                 f1000 movement_speed_jump
444                 f1000 movement_liquid_fluidity
445                 f1000 movement_liquid_fluidity_smooth
446                 f1000 movement_liquid_sink
447                 f1000 movement_gravity
448         */
449
450         TOCLIENT_SPAWN_PARTICLE = 0x46,
451         /*
452                 u16 command
453                 v3f1000 pos
454                 v3f1000 velocity
455                 v3f1000 acceleration
456                 f1000 expirationtime
457                 f1000 size
458                 u8 bool collisiondetection
459                 u8 bool vertical
460                 u32 len
461                 u8[len] texture
462         */
463
464         TOCLIENT_ADD_PARTICLESPAWNER = 0x47,
465         /*
466                 u16 command
467                 u16 amount
468                 f1000 spawntime
469                 v3f1000 minpos
470                 v3f1000 maxpos
471                 v3f1000 minvel
472                 v3f1000 maxvel
473                 v3f1000 minacc
474                 v3f1000 maxacc
475                 f1000 minexptime
476                 f1000 maxexptime
477                 f1000 minsize
478                 f1000 maxsize
479                 u8 bool collisiondetection
480                 u8 bool vertical
481                 u32 len
482                 u8[len] texture
483                 u32 id
484         */
485
486         TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY = 0x48,
487         /*
488                 u16 command
489                 u16 id
490         */
491
492         TOCLIENT_HUDADD = 0x49,
493         /*
494                 u16 command
495                 u32 id
496                 u8 type
497                 v2f1000 pos
498                 u32 len
499                 u8[len] name
500                 v2f1000 scale
501                 u32 len2
502                 u8[len2] text
503                 u32 number
504                 u32 item
505                 u32 dir
506                 v2f1000 align
507                 v2f1000 offset
508                 v3f1000 world_pos
509                 v2s32 size
510         */
511
512         TOCLIENT_HUDRM = 0x4a,
513         /*
514                 u16 command
515                 u32 id
516         */
517
518         TOCLIENT_HUDCHANGE = 0x4b,
519         /*
520                 u16 command
521                 u32 id
522                 u8 stat
523                 [v2f1000 data |
524                  u32 len
525                  u8[len] data |
526                  u32 data]
527         */
528
529         TOCLIENT_HUD_SET_FLAGS = 0x4c,
530         /*
531                 u16 command
532                 u32 flags
533                 u32 mask
534         */
535
536         TOCLIENT_HUD_SET_PARAM = 0x4d,
537         /*
538                 u16 command
539                 u16 param
540                 u16 len
541                 u8[len] value
542         */
543
544         TOCLIENT_BREATH = 0x4e,
545         /*
546                 u16 command
547                 u16 breath
548         */
549
550         TOCLIENT_SET_SKY = 0x4f,
551         /*
552                 u16 command
553                 u8[4] color (ARGB)
554                 u8 len
555                 u8[len] type
556                 u16 count
557                 foreach count:
558                         u8 len
559                         u8[len] param
560         */
561
562         TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO = 0x50,
563         /*
564                 u16 command
565                 u8 do_override (boolean)
566                 u16 day-night ratio 0...65535
567         */
568
569         TOCLIENT_LOCAL_PLAYER_ANIMATIONS = 0x51,
570         /*
571                 u16 command
572                 v2s32 stand/idle
573                 v2s32 walk
574                 v2s32 dig
575                 v2s32 walk+dig
576                 f1000 frame_speed
577         */
578
579         TOCLIENT_EYE_OFFSET = 0x52,
580         /*
581                 u16 command
582                 v3f1000 first
583                 v3f1000 third
584         */
585
586         TOCLIENT_DELETE_PARTICLESPAWNER = 0x53,
587         /*
588                 u16 command
589                 u32 id
590         */
591
592         TOCLIENT_NUM_MSG_TYPES = 0x54,
593 };
594
595 enum ToServerCommand
596 {
597         TOSERVER_INIT = 0x02,
598         /*
599                 Sent first after connected.
600
601                 [0] u16 TOSERVER_INIT
602                 [2] u8 SER_FMT_VER_HIGHEST_READ
603                 [3] u8 compression_modes
604         */
605
606         TOSERVER_AUTH = 0x03,
607         /*
608                 Sent first after presentation (INIT).
609                 [0] std::string player_name
610                 [0+*] std::string password (new in some version)
611                 [0+*+*] u16 minimum supported network protocol version (added sometime)
612                 [0+*+*+2] u16 maximum supported network protocol version (added later than the previous one)
613         */
614
615         TOSERVER_INIT_LEGACY = 0x10,
616         /*
617                 Sent first after connected.
618
619                 [0] u16 TOSERVER_INIT
620                 [2] u8 SER_FMT_VER_HIGHEST_READ
621                 [3] u8[20] player_name
622                 [23] u8[28] password (new in some version)
623                 [51] u16 minimum supported network protocol version (added sometime)
624                 [53] u16 maximum supported network protocol version (added later than the previous one)
625         */
626
627         TOSERVER_INIT2 = 0x11,
628         /*
629                 Sent as an ACK for TOCLIENT_INIT.
630                 After this, the server can send data.
631
632                 [0] u16 TOSERVER_INIT2
633         */
634
635         TOSERVER_GETBLOCK=0x20, // Obsolete
636         TOSERVER_ADDNODE = 0x21, // Obsolete
637         TOSERVER_REMOVENODE = 0x22, // Obsolete
638
639         TOSERVER_PLAYERPOS = 0x23,
640         /*
641                 [0] u16 command
642                 [2] v3s32 position*100
643                 [2+12] v3s32 speed*100
644                 [2+12+12] s32 pitch*100
645                 [2+12+12+4] s32 yaw*100
646                 [2+12+12+4+4] u32 keyPressed
647         */
648
649         TOSERVER_GOTBLOCKS = 0x24,
650         /*
651                 [0] u16 command
652                 [2] u8 count
653                 [3] v3s16 pos_0
654                 [3+6] v3s16 pos_1
655                 ...
656         */
657
658         TOSERVER_DELETEDBLOCKS = 0x25,
659         /*
660                 [0] u16 command
661                 [2] u8 count
662                 [3] v3s16 pos_0
663                 [3+6] v3s16 pos_1
664                 ...
665         */
666
667         TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
668         /*
669                 [0] u16 command
670                 [2] v3s16 pos
671                 [8] u16 i
672         */
673
674         TOSERVER_CLICK_OBJECT = 0x27, // Obsolete
675         /*
676                 length: 13
677                 [0] u16 command
678                 [2] u8 button (0=left, 1=right)
679                 [3] v3s16 blockpos
680                 [9] s16 id
681                 [11] u16 item
682         */
683
684         TOSERVER_GROUND_ACTION = 0x28, // Obsolete
685         /*
686                 length: 17
687                 [0] u16 command
688                 [2] u8 action
689                 [3] v3s16 nodepos_undersurface
690                 [9] v3s16 nodepos_abovesurface
691                 [15] u16 item
692                 actions:
693                 0: start digging (from undersurface)
694                 1: place block (to abovesurface)
695                 2: stop digging (all parameters ignored)
696                 3: digging completed
697         */
698
699         TOSERVER_RELEASE = 0x29, // Obsolete
700
701         // (oops, there is some gap here)
702
703         TOSERVER_SIGNTEXT = 0x30, // Old signs, obsolete
704         /*
705                 u16 command
706                 v3s16 blockpos
707                 s16 id
708                 u16 textlen
709                 textdata
710         */
711
712         TOSERVER_INVENTORY_ACTION = 0x31,
713         /*
714                 See InventoryAction in inventorymanager.h
715         */
716
717         TOSERVER_CHAT_MESSAGE = 0x32,
718         /*
719                 u16 command
720                 u16 length
721                 wstring message
722         */
723
724         TOSERVER_SIGNNODETEXT = 0x33, // obsolete
725         /*
726                 u16 command
727                 v3s16 p
728                 u16 textlen
729                 textdata
730         */
731
732         TOSERVER_CLICK_ACTIVEOBJECT = 0x34, // Obsolete
733         /*
734                 length: 7
735                 [0] u16 command
736                 [2] u8 button (0=left, 1=right)
737                 [3] u16 id
738                 [5] u16 item
739         */
740
741         TOSERVER_DAMAGE = 0x35,
742         /*
743                 u16 command
744                 u8 amount
745         */
746
747         TOSERVER_PASSWORD_LEGACY = 0x36,
748         /*
749                 Sent to change password.
750
751                 [0] u16 TOSERVER_PASSWORD
752                 [2] u8[28] old password
753                 [30] u8[28] new password
754         */
755
756         TOSERVER_PLAYERITEM = 0x37,
757         /*
758                 Sent to change selected item.
759
760                 [0] u16 TOSERVER_PLAYERITEM
761                 [2] u16 item
762         */
763
764         TOSERVER_RESPAWN = 0x38,
765         /*
766                 u16 TOSERVER_RESPAWN
767         */
768
769         TOSERVER_INTERACT = 0x39,
770         /*
771                 [0] u16 command
772                 [2] u8 action
773                 [3] u16 item
774                 [5] u32 length of the next item
775                 [9] serialized PointedThing
776                 actions:
777                 0: start digging (from undersurface) or use
778                 1: stop digging (all parameters ignored)
779                 2: digging completed
780                 3: place block or item (to abovesurface)
781                 4: use item
782
783                 (Obsoletes TOSERVER_GROUND_ACTION and TOSERVER_CLICK_ACTIVEOBJECT.)
784         */
785
786         TOSERVER_REMOVED_SOUNDS = 0x3a,
787         /*
788                 u16 command
789                 u16 len
790                 s32[len] sound_id
791         */
792
793         TOSERVER_NODEMETA_FIELDS = 0x3b,
794         /*
795                 u16 command
796                 v3s16 p
797                 u16 len
798                 u8[len] form name (reserved for future use)
799                 u16 number of fields
800                 for each field:
801                         u16 len
802                         u8[len] field name
803                         u32 len
804                         u8[len] field value
805         */
806
807         TOSERVER_INVENTORY_FIELDS = 0x3c,
808         /*
809                 u16 command
810                 u16 len
811                 u8[len] form name (reserved for future use)
812                 u16 number of fields
813                 for each field:
814                         u16 len
815                         u8[len] field name
816                         u32 len
817                         u8[len] field value
818         */
819
820         TOSERVER_PASSWORD = 0x3d,
821         /*
822                 Sent to change password.
823
824                 [0] u16 TOSERVER_PASSWORD
825                 [2] std::string old password
826                 [2+*] std::string new password
827         */
828
829         TOSERVER_REQUEST_MEDIA = 0x40,
830         /*
831                 u16 command
832                 u16 number of files requested
833                 for each file {
834                         u16 length of name
835                         string name
836                 }
837          */
838
839         TOSERVER_RECEIVED_MEDIA = 0x41,
840         /*
841                 u16 command
842         */
843
844         TOSERVER_BREATH = 0x42,
845         /*
846                 u16 command
847                 u16 breath
848         */
849
850         TOSERVER_CLIENT_READY = 0x43,
851         /*
852                 u8 major
853                 u8 minor
854                 u8 patch
855                 u8 reserved
856                 u16 len
857                 u8[len] full_version_string
858         */
859
860         TOSERVER_NUM_MSG_TYPES = 0x44,
861 };
862
863 enum AccessDeniedCode {
864         SERVER_ACCESSDENIED_WRONG_PASSWORD,
865         SERVER_ACCESSDENIED_UNEXPECTED_DATA,
866         SERVER_ACCESSDENIED_SINGLEPLAYER,
867         SERVER_ACCESSDENIED_WRONG_VERSION,
868         SERVER_ACCESSDENIED_WRONG_CHARS_IN_NAME,
869         SERVER_ACCESSDENIED_WRONG_NAME,
870         SERVER_ACCESSDENIED_TOO_MANY_USERS,
871         SERVER_ACCESSDENIED_EMPTY_PASSWORD,
872         SERVER_ACCESSDENIED_ALREADY_CONNECTED,
873         SERVER_ACCESSDENIED_SERVER_FAIL,
874         SERVER_ACCESSDENIED_CUSTOM_STRING,
875         SERVER_ACCESSDENIED_MAX,
876 };
877
878 enum NetProtoCompressionMode {
879         NETPROTO_COMPRESSION_ZLIB = 0,
880 };
881
882 const static std::string accessDeniedStrings[SERVER_ACCESSDENIED_MAX] = {
883         "Invalid password",
884         "Your client sent something the server didn't expect.  Try reconnecting or updating your client",
885         "The server is running in simple singleplayer mode.  You cannot connect.",
886         "Your client's version is not supported.\nPlease contact server administrator.",
887         "Player name contains disallowed characters.",
888         "Player name not allowed.",
889         "Too many users.",
890         "Empty passwords are disallowed.  Set a password and try again.",
891         "Another client is connected with this name.  If your client closed unexpectedly, try again in a minute.",
892         "Server authention failed.  This is likely a server error."
893         "",
894 };
895
896 #endif