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