networkprotocol.h 20 KB

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