]> git.lizzy.rs Git - dragonfireclient.git/blob - src/clientserver.h
Include backface_culling flag in serialization format for TileDefs
[dragonfireclient.git] / src / clientserver.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 CLIENTSERVER_HEADER
21 #define CLIENTSERVER_HEADER
22
23 #include "util/pointer.h"
24
25 SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed);
26
27 /*
28         changes by PROTOCOL_VERSION:
29
30         PROTOCOL_VERSION 3:
31                 Base for writing changes here
32         PROTOCOL_VERSION 4:
33                 Add TOCLIENT_MEDIA
34                 Add TOCLIENT_TOOLDEF
35                 Add TOCLIENT_NODEDEF
36                 Add TOCLIENT_CRAFTITEMDEF
37                 Add TOSERVER_INTERACT
38                 Obsolete TOSERVER_CLICK_ACTIVEOBJECT
39                 Obsolete TOSERVER_GROUND_ACTION
40         PROTOCOL_VERSION 5:
41                 Make players to be handled mostly as ActiveObjects
42         PROTOCOL_VERSION 6:
43                 Only non-cached textures are sent
44         PROTOCOL_VERSION 7:
45                 Add TOCLIENT_ITEMDEF
46                 Obsolete TOCLIENT_TOOLDEF
47                 Obsolete TOCLIENT_CRAFTITEMDEF
48                 Compress the contents of TOCLIENT_ITEMDEF and TOCLIENT_NODEDEF
49         PROTOCOL_VERSION 8:
50                 Digging based on item groups
51                 Many things
52         PROTOCOL_VERSION 9:
53                 ContentFeatures and NodeDefManager use a different serialization
54                     format; better for future version cross-compatibility
55                 Many things
56         PROTOCOL_VERSION 10:
57                 TOCLIENT_PRIVILEGES
58                 Version raised to force 'fly' and 'fast' privileges into effect.
59                 Node metadata change (came in later; somewhat incompatible)
60         PROTOCOL_VERSION 11:
61                 TileDef in ContentFeatures
62                 Nodebox drawtype
63                 (some dev snapshot)
64                 TOCLIENT_INVENTORY_FORMSPEC
65                 (0.4.0, 0.4.1)
66         PROTOCOL_VERSION 12:
67                 TOSERVER_INVENTORY_FIELDS
68                 16-bit node ids
69                 TOCLIENT_DETACHED_INVENTORY
70         PROTOCOL_VERSION 13:
71                 InventoryList field "Width" (deserialization fails with old versions)
72         PROTOCOL_VERSION 14:
73                 Added transfer of player pressed keys to the server
74                 Added new messages for mesh and bone animation, as well as attachments
75                 GENERIC_CMD_SET_ANIMATION
76                 GENERIC_CMD_SET_BONE_POSITION
77                 GENERIC_CMD_SET_ATTACHMENT
78         PROTOCOL_VERSION 15:
79                 Serialization format changes
80         PROTOCOL_VERSION 16:
81                 TOCLIENT_SHOW_FORMSPEC
82         PROTOCOL_VERSION 17:
83                 Serialization format change: include backface_culling flag in TileDef
84 */
85
86 #define LATEST_PROTOCOL_VERSION 17
87
88 // Server's supported network protocol range
89 #define SERVER_PROTOCOL_VERSION_MIN 13
90 #define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
91
92 // Client's supported network protocol range
93 #define CLIENT_PROTOCOL_VERSION_MIN 13
94 #define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
95
96 // Constant that differentiates the protocol from random data and other protocols
97 #define PROTOCOL_ID 0x4f457403
98
99 #define PASSWORD_SIZE 28       // Maximum password length. Allows for
100                                // base64-encoded SHA-1 (27+\0).
101
102 #define TEXTURENAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_."
103
104 enum ToClientCommand
105 {
106         TOCLIENT_INIT = 0x10,
107         /*
108                 Server's reply to TOSERVER_INIT.
109                 Sent second after connected.
110
111                 [0] u16 TOSERVER_INIT
112                 [2] u8 deployed version
113                 [3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd 
114                 [12] u64 map seed (new as of 2011-02-27)
115                 [20] f1000 recommended send interval (in seconds) (new as of 14)
116
117                 NOTE: The position in here is deprecated; position is
118                       explicitly sent afterwards
119         */
120
121         TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
122         TOCLIENT_ADDNODE = 0x21,
123         TOCLIENT_REMOVENODE = 0x22,
124         
125         TOCLIENT_PLAYERPOS = 0x23, // Obsolete
126         /*
127                 [0] u16 command
128                 // Followed by an arbitary number of these:
129                 // Number is determined from packet length.
130                 [N] u16 peer_id
131                 [N+2] v3s32 position*100
132                 [N+2+12] v3s32 speed*100
133                 [N+2+12+12] s32 pitch*100
134                 [N+2+12+12+4] s32 yaw*100
135         */
136
137         TOCLIENT_PLAYERINFO = 0x24, // Obsolete
138         /*
139                 [0] u16 command
140                 // Followed by an arbitary number of these:
141                 // Number is determined from packet length.
142                 [N] u16 peer_id
143                 [N] char[20] name
144         */
145         
146         TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
147
148         TOCLIENT_SECTORMETA = 0x26, // Obsolete
149         /*
150                 [0] u16 command
151                 [2] u8 sector count
152                 [3...] v2s16 pos + sector metadata
153         */
154
155         TOCLIENT_INVENTORY = 0x27,
156         /*
157                 [0] u16 command
158                 [2] serialized inventory
159         */
160         
161         TOCLIENT_OBJECTDATA = 0x28, // Obsolete
162         /*
163                 Sent as unreliable.
164
165                 u16 command
166                 u16 number of player positions
167                 for each player:
168                         u16 peer_id
169                         v3s32 position*100
170                         v3s32 speed*100
171                         s32 pitch*100
172                         s32 yaw*100
173                 u16 count of blocks
174                 for each block:
175                         v3s16 blockpos
176                         block objects
177         */
178
179         TOCLIENT_TIME_OF_DAY = 0x29,
180         /*
181                 u16 command
182                 u16 time (0-23999)
183                 Added in a later version:
184                 f1000 time_speed
185         */
186
187         // (oops, there is some gap here)
188
189         TOCLIENT_CHAT_MESSAGE = 0x30,
190         /*
191                 u16 command
192                 u16 length
193                 wstring message
194         */
195
196         TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
197         /*
198                 u16 command
199                 u16 count of removed objects
200                 for all removed objects {
201                         u16 id
202                 }
203                 u16 count of added objects
204                 for all added objects {
205                         u16 id
206                         u8 type
207                         u32 initialization data length
208                         string initialization data
209                 }
210         */
211         
212         TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
213         /*
214                 u16 command
215                 for all objects
216                 {
217                         u16 id
218                         u16 message length
219                         string message
220                 }
221         */
222
223         TOCLIENT_HP = 0x33,
224         /*
225                 u16 command
226                 u8 hp
227         */
228
229         TOCLIENT_MOVE_PLAYER = 0x34,
230         /*
231                 u16 command
232                 v3f1000 player position
233                 f1000 player pitch
234                 f1000 player yaw
235         */
236
237         TOCLIENT_ACCESS_DENIED = 0x35,
238         /*
239                 u16 command
240                 u16 reason_length
241                 wstring reason
242         */
243
244         TOCLIENT_PLAYERITEM = 0x36, // Obsolete
245         /*
246                 u16 command
247                 u16 count of player items
248                 for all player items {
249                         u16 peer id
250                         u16 length of serialized item
251                         string serialized item
252                 }
253         */
254
255         TOCLIENT_DEATHSCREEN = 0x37,
256         /*
257                 u16 command
258                 u8 bool set camera point target
259                 v3f1000 camera point target (to point the death cause or whatever)
260         */
261
262         TOCLIENT_MEDIA = 0x38,
263         /*
264                 u16 command
265                 u16 total number of texture bunches
266                 u16 index of this bunch
267                 u32 number of files in this bunch
268                 for each file {
269                         u16 length of name
270                         string name
271                         u32 length of data
272                         data
273                 }
274                 u16 length of remote media server url (if applicable)
275                 string url
276         */
277         
278         TOCLIENT_TOOLDEF = 0x39,
279         /*
280                 u16 command
281                 u32 length of the next item
282                 serialized ToolDefManager
283         */
284         
285         TOCLIENT_NODEDEF = 0x3a,
286         /*
287                 u16 command
288                 u32 length of the next item
289                 serialized NodeDefManager
290         */
291         
292         TOCLIENT_CRAFTITEMDEF = 0x3b,
293         /*
294                 u16 command
295                 u32 length of the next item
296                 serialized CraftiItemDefManager
297         */
298
299         TOCLIENT_ANNOUNCE_MEDIA = 0x3c,
300
301         /*
302                 u16 command
303                 u32 number of files
304                 for each texture {
305                         u16 length of name
306                         string name
307                         u16 length of sha1_digest
308                         string sha1_digest
309                 }
310         */
311
312         TOCLIENT_ITEMDEF = 0x3d,
313         /*
314                 u16 command
315                 u32 length of next item
316                 serialized ItemDefManager
317         */
318         
319         TOCLIENT_PLAY_SOUND = 0x3f,
320         /*
321                 u16 command
322                 s32 sound_id
323                 u16 len
324                 u8[len] sound name
325                 s32 gain*1000
326                 u8 type (0=local, 1=positional, 2=object)
327                 s32[3] pos_nodes*10000
328                 u16 object_id
329                 u8 loop (bool)
330         */
331
332         TOCLIENT_STOP_SOUND = 0x40,
333         /*
334                 u16 command
335                 s32 sound_id
336         */
337
338         TOCLIENT_PRIVILEGES = 0x41,
339         /*
340                 u16 command
341                 u16 number of privileges
342                 for each privilege
343                         u16 len
344                         u8[len] privilege
345         */
346
347         TOCLIENT_INVENTORY_FORMSPEC = 0x42,
348         /*
349                 u16 command
350                 u32 len
351                 u8[len] formspec
352         */
353
354         TOCLIENT_DETACHED_INVENTORY = 0x43,
355         /*
356                 [0] u16 command
357                 u16 len
358                 u8[len] name
359                 [2] serialized inventory
360         */
361         TOCLIENT_SHOW_FORMSPEC = 0x44,
362         /*
363                 [0] u16 command
364                 u32 len
365                 u8[len] formspec
366                 u16 len
367                 u8[len] formname
368         */
369
370         TOCLIENT_MOVEMENT = 0x45,
371         /*
372                 u16 command
373                 f1000 movement_acceleration_default
374                 f1000 movement_acceleration_air
375                 f1000 movement_acceleration_fast
376                 f1000 movement_speed_walk
377                 f1000 movement_speed_crouch
378                 f1000 movement_speed_fast
379                 f1000 movement_speed_climb
380                 f1000 movement_speed_jump
381                 f1000 movement_liquid_fluidity
382                 f1000 movement_liquid_fluidity_smooth
383                 f1000 movement_liquid_sink
384                 f1000 movement_gravity
385         */
386 };
387
388 enum ToServerCommand
389 {
390         TOSERVER_INIT=0x10,
391         /*
392                 Sent first after connected.
393
394                 [0] u16 TOSERVER_INIT
395                 [2] u8 SER_FMT_VER_HIGHEST
396                 [3] u8[20] player_name
397                 [23] u8[28] password (new in some version)
398                 [51] u16 minimum supported network protocol version (added sometime)
399                 [53] u16 maximum supported network protocol version (added later than the previous one)
400         */
401
402         TOSERVER_INIT2 = 0x11,
403         /*
404                 Sent as an ACK for TOCLIENT_INIT.
405                 After this, the server can send data.
406
407                 [0] u16 TOSERVER_INIT2
408         */
409
410         TOSERVER_GETBLOCK=0x20, // Obsolete
411         TOSERVER_ADDNODE = 0x21, // Obsolete
412         TOSERVER_REMOVENODE = 0x22, // Obsolete
413
414         TOSERVER_PLAYERPOS = 0x23,
415         /*
416                 [0] u16 command
417                 [2] v3s32 position*100
418                 [2+12] v3s32 speed*100
419                 [2+12+12] s32 pitch*100
420                 [2+12+12+4] s32 yaw*100
421                 [2+12+12+4+4] u32 keyPressed
422         */
423
424         TOSERVER_GOTBLOCKS = 0x24,
425         /*
426                 [0] u16 command
427                 [2] u8 count
428                 [3] v3s16 pos_0
429                 [3+6] v3s16 pos_1
430                 ...
431         */
432
433         TOSERVER_DELETEDBLOCKS = 0x25,
434         /*
435                 [0] u16 command
436                 [2] u8 count
437                 [3] v3s16 pos_0
438                 [3+6] v3s16 pos_1
439                 ...
440         */
441
442         TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
443         /*
444                 [0] u16 command
445                 [2] v3s16 pos
446                 [8] u16 i
447         */
448
449         TOSERVER_CLICK_OBJECT = 0x27, // Obsolete
450         /*
451                 length: 13
452                 [0] u16 command
453                 [2] u8 button (0=left, 1=right)
454                 [3] v3s16 blockpos
455                 [9] s16 id
456                 [11] u16 item
457         */
458
459         TOSERVER_GROUND_ACTION = 0x28, // Obsolete
460         /*
461                 length: 17
462                 [0] u16 command
463                 [2] u8 action
464                 [3] v3s16 nodepos_undersurface
465                 [9] v3s16 nodepos_abovesurface
466                 [15] u16 item
467                 actions:
468                 0: start digging (from undersurface)
469                 1: place block (to abovesurface)
470                 2: stop digging (all parameters ignored)
471                 3: digging completed
472         */
473         
474         TOSERVER_RELEASE = 0x29, // Obsolete
475
476         // (oops, there is some gap here)
477
478         TOSERVER_SIGNTEXT = 0x30, // Old signs, obsolete
479         /*
480                 u16 command
481                 v3s16 blockpos
482                 s16 id
483                 u16 textlen
484                 textdata
485         */
486
487         TOSERVER_INVENTORY_ACTION = 0x31,
488         /*
489                 See InventoryAction in inventory.h
490         */
491
492         TOSERVER_CHAT_MESSAGE = 0x32,
493         /*
494                 u16 command
495                 u16 length
496                 wstring message
497         */
498
499         TOSERVER_SIGNNODETEXT = 0x33, // obsolete
500         /*
501                 u16 command
502                 v3s16 p
503                 u16 textlen
504                 textdata
505         */
506
507         TOSERVER_CLICK_ACTIVEOBJECT = 0x34, // Obsolete
508         /*
509                 length: 7
510                 [0] u16 command
511                 [2] u8 button (0=left, 1=right)
512                 [3] u16 id
513                 [5] u16 item
514         */
515         
516         TOSERVER_DAMAGE = 0x35,
517         /*
518                 u16 command
519                 u8 amount
520         */
521
522         TOSERVER_PASSWORD=0x36,
523         /*
524                 Sent to change password.
525
526                 [0] u16 TOSERVER_PASSWORD
527                 [2] u8[28] old password
528                 [30] u8[28] new password
529         */
530
531         TOSERVER_PLAYERITEM=0x37,
532         /*
533                 Sent to change selected item.
534
535                 [0] u16 TOSERVER_PLAYERITEM
536                 [2] u16 item
537         */
538         
539         TOSERVER_RESPAWN=0x38,
540         /*
541                 u16 TOSERVER_RESPAWN
542         */
543
544         TOSERVER_INTERACT = 0x39,
545         /*
546                 [0] u16 command
547                 [2] u8 action
548                 [3] u16 item
549                 [5] u32 length of the next item
550                 [9] serialized PointedThing
551                 actions:
552                 0: start digging (from undersurface) or use
553                 1: stop digging (all parameters ignored)
554                 2: digging completed
555                 3: place block or item (to abovesurface)
556                 4: use item
557
558                 (Obsoletes TOSERVER_GROUND_ACTION and TOSERVER_CLICK_ACTIVEOBJECT.)
559         */
560         
561         TOSERVER_REMOVED_SOUNDS = 0x3a,
562         /*
563                 u16 command
564                 u16 len
565                 s32[len] sound_id
566         */
567
568         TOSERVER_NODEMETA_FIELDS = 0x3b,
569         /*
570                 u16 command
571                 v3s16 p
572                 u16 len
573                 u8[len] form name (reserved for future use)
574                 u16 number of fields
575                 for each field:
576                         u16 len
577                         u8[len] field name
578                         u32 len
579                         u8[len] field value
580         */
581
582         TOSERVER_INVENTORY_FIELDS = 0x3c,
583         /*
584                 u16 command
585                 u16 len
586                 u8[len] form name (reserved for future use)
587                 u16 number of fields
588                 for each field:
589                         u16 len
590                         u8[len] field name
591                         u32 len
592                         u8[len] field value
593         */
594
595         TOSERVER_REQUEST_MEDIA = 0x40,
596         /*
597                 u16 command
598                 u16 number of files requested
599                 for each file {
600                         u16 length of name
601                         string name
602                 }
603          */
604
605         TOSERVER_RECEIVED_MEDIA = 0x41,
606         /*
607                 u16 command
608         */
609 };
610
611 #endif
612