networkprotocol.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  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. Change TileDef serialization format.
  177. Add world-aligned tiles.
  178. Mod channels
  179. Raise ObjectProperties version to 3 for removing 'can_zoom' and adding
  180. 'zoom_fov'.
  181. Nodebox version 5
  182. Add disconnected nodeboxes
  183. Add TOCLIENT_FORMSPEC_PREPEND
  184. */
  185. #define LATEST_PROTOCOL_VERSION 36
  186. // Server's supported network protocol range
  187. #define SERVER_PROTOCOL_VERSION_MIN 36
  188. #define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
  189. // Client's supported network protocol range
  190. // The minimal version depends on whether
  191. // send_pre_v25_init is enabled or not
  192. #define CLIENT_PROTOCOL_VERSION_MIN 36
  193. #define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
  194. // Constant that differentiates the protocol from random data and other protocols
  195. #define PROTOCOL_ID 0x4f457403
  196. #define PASSWORD_SIZE 28 // Maximum password length. Allows for
  197. // base64-encoded SHA-1 (27+\0).
  198. #define FORMSPEC_API_VERSION 1
  199. #define FORMSPEC_VERSION_STRING "formspec_version[" TOSTRING(FORMSPEC_API_VERSION) "]"
  200. #define TEXTURENAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-"
  201. typedef u16 session_t;
  202. enum ToClientCommand
  203. {
  204. TOCLIENT_HELLO = 0x02,
  205. /*
  206. Sent after TOSERVER_INIT.
  207. u8 deployed serialisation version
  208. u16 deployed network compression mode
  209. u16 deployed protocol version
  210. u32 supported auth methods
  211. std::string username that should be used for legacy hash (for proper casing)
  212. */
  213. TOCLIENT_AUTH_ACCEPT = 0x03,
  214. /*
  215. Message from server to accept auth.
  216. v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
  217. u64 map seed
  218. f1000 recommended send interval
  219. u32 : supported auth methods for sudo mode
  220. (where the user can change their password)
  221. */
  222. TOCLIENT_ACCEPT_SUDO_MODE = 0x04,
  223. /*
  224. Sent to client to show it is in sudo mode now.
  225. */
  226. TOCLIENT_DENY_SUDO_MODE = 0x05,
  227. /*
  228. Signals client that sudo mode auth failed.
  229. */
  230. TOCLIENT_ACCESS_DENIED = 0x0A,
  231. /*
  232. u8 reason
  233. std::string custom reason (if needed, otherwise "")
  234. u8 (bool) reconnect
  235. */
  236. TOCLIENT_INIT_LEGACY = 0x10, // Obsolete
  237. TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
  238. TOCLIENT_ADDNODE = 0x21,
  239. /*
  240. v3s16 position
  241. serialized mapnode
  242. u8 keep_metadata // Added in protocol version 22
  243. */
  244. TOCLIENT_REMOVENODE = 0x22,
  245. TOCLIENT_PLAYERPOS = 0x23, // Obsolete
  246. TOCLIENT_PLAYERINFO = 0x24, // Obsolete
  247. TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
  248. TOCLIENT_SECTORMETA = 0x26, // Obsolete
  249. TOCLIENT_INVENTORY = 0x27,
  250. /*
  251. [0] u16 command
  252. [2] serialized inventory
  253. */
  254. TOCLIENT_OBJECTDATA = 0x28, // Obsolete
  255. TOCLIENT_TIME_OF_DAY = 0x29,
  256. /*
  257. u16 time (0-23999)
  258. Added in a later version:
  259. f1000 time_speed
  260. */
  261. TOCLIENT_CSM_FLAVOUR_LIMITS = 0x2A,
  262. /*
  263. u32 CSMFlavourLimits byteflag
  264. */
  265. // (oops, there is some gap here)
  266. TOCLIENT_CHAT_MESSAGE = 0x2F,
  267. /*
  268. u8 version
  269. u8 message_type
  270. u16 sendername length
  271. wstring sendername
  272. u16 length
  273. wstring message
  274. */
  275. TOCLIENT_CHAT_MESSAGE_OLD = 0x30, // Obsolete
  276. TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
  277. /*
  278. u16 count of removed objects
  279. for all removed objects {
  280. u16 id
  281. }
  282. u16 count of added objects
  283. for all added objects {
  284. u16 id
  285. u8 type
  286. u32 initialization data length
  287. string initialization data
  288. }
  289. */
  290. TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
  291. /*
  292. for all objects
  293. {
  294. u16 id
  295. u16 message length
  296. string message
  297. }
  298. */
  299. TOCLIENT_HP = 0x33,
  300. /*
  301. u8 hp
  302. */
  303. TOCLIENT_MOVE_PLAYER = 0x34,
  304. /*
  305. v3f1000 player position
  306. f1000 player pitch
  307. f1000 player yaw
  308. */
  309. TOCLIENT_ACCESS_DENIED_LEGACY = 0x35,
  310. /*
  311. u16 reason_length
  312. wstring reason
  313. */
  314. TOCLIENT_PLAYERITEM = 0x36, // Obsolete
  315. TOCLIENT_DEATHSCREEN = 0x37,
  316. /*
  317. u8 bool set camera point target
  318. v3f1000 camera point target (to point the death cause or whatever)
  319. */
  320. TOCLIENT_MEDIA = 0x38,
  321. /*
  322. u16 total number of texture bunches
  323. u16 index of this bunch
  324. u32 number of files in this bunch
  325. for each file {
  326. u16 length of name
  327. string name
  328. u32 length of data
  329. data
  330. }
  331. u16 length of remote media server url (if applicable)
  332. string url
  333. */
  334. TOCLIENT_TOOLDEF = 0x39,
  335. /*
  336. u32 length of the next item
  337. serialized ToolDefManager
  338. */
  339. TOCLIENT_NODEDEF = 0x3a,
  340. /*
  341. u32 length of the next item
  342. serialized NodeDefManager
  343. */
  344. TOCLIENT_CRAFTITEMDEF = 0x3b,
  345. /*
  346. u32 length of the next item
  347. serialized CraftiItemDefManager
  348. */
  349. TOCLIENT_ANNOUNCE_MEDIA = 0x3c,
  350. /*
  351. u32 number of files
  352. for each texture {
  353. u16 length of name
  354. string name
  355. u16 length of sha1_digest
  356. string sha1_digest
  357. }
  358. */
  359. TOCLIENT_ITEMDEF = 0x3d,
  360. /*
  361. u32 length of next item
  362. serialized ItemDefManager
  363. */
  364. TOCLIENT_PLAY_SOUND = 0x3f,
  365. /*
  366. s32 sound_id
  367. u16 len
  368. u8[len] sound name
  369. s32 gain*1000
  370. u8 type (0=local, 1=positional, 2=object)
  371. s32[3] pos_nodes*10000
  372. u16 object_id
  373. u8 loop (bool)
  374. */
  375. TOCLIENT_STOP_SOUND = 0x40,
  376. /*
  377. s32 sound_id
  378. */
  379. TOCLIENT_PRIVILEGES = 0x41,
  380. /*
  381. u16 number of privileges
  382. for each privilege
  383. u16 len
  384. u8[len] privilege
  385. */
  386. TOCLIENT_INVENTORY_FORMSPEC = 0x42,
  387. /*
  388. u32 len
  389. u8[len] formspec
  390. */
  391. TOCLIENT_DETACHED_INVENTORY = 0x43,
  392. /*
  393. [0] u16 command
  394. u16 len
  395. u8[len] name
  396. [2] serialized inventory
  397. */
  398. TOCLIENT_SHOW_FORMSPEC = 0x44,
  399. /*
  400. [0] u16 command
  401. u32 len
  402. u8[len] formspec
  403. u16 len
  404. u8[len] formname
  405. */
  406. TOCLIENT_MOVEMENT = 0x45,
  407. /*
  408. f1000 movement_acceleration_default
  409. f1000 movement_acceleration_air
  410. f1000 movement_acceleration_fast
  411. f1000 movement_speed_walk
  412. f1000 movement_speed_crouch
  413. f1000 movement_speed_fast
  414. f1000 movement_speed_climb
  415. f1000 movement_speed_jump
  416. f1000 movement_liquid_fluidity
  417. f1000 movement_liquid_fluidity_smooth
  418. f1000 movement_liquid_sink
  419. f1000 movement_gravity
  420. */
  421. TOCLIENT_SPAWN_PARTICLE = 0x46,
  422. /*
  423. v3f1000 pos
  424. v3f1000 velocity
  425. v3f1000 acceleration
  426. f1000 expirationtime
  427. f1000 size
  428. u8 bool collisiondetection
  429. u8 bool vertical
  430. u32 len
  431. u8[len] texture
  432. u8 collision_removal
  433. */
  434. TOCLIENT_ADD_PARTICLESPAWNER = 0x47,
  435. /*
  436. u16 amount
  437. f1000 spawntime
  438. v3f1000 minpos
  439. v3f1000 maxpos
  440. v3f1000 minvel
  441. v3f1000 maxvel
  442. v3f1000 minacc
  443. v3f1000 maxacc
  444. f1000 minexptime
  445. f1000 maxexptime
  446. f1000 minsize
  447. f1000 maxsize
  448. u8 bool collisiondetection
  449. u8 bool vertical
  450. u32 len
  451. u8[len] texture
  452. u32 id
  453. u8 collision_removal
  454. */
  455. TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY = 0x48, // Obsolete
  456. TOCLIENT_HUDADD = 0x49,
  457. /*
  458. u32 id
  459. u8 type
  460. v2f1000 pos
  461. u32 len
  462. u8[len] name
  463. v2f1000 scale
  464. u32 len2
  465. u8[len2] text
  466. u32 number
  467. u32 item
  468. u32 dir
  469. v2f1000 align
  470. v2f1000 offset
  471. v3f1000 world_pos
  472. v2s32 size
  473. */
  474. TOCLIENT_HUDRM = 0x4a,
  475. /*
  476. u32 id
  477. */
  478. TOCLIENT_HUDCHANGE = 0x4b,
  479. /*
  480. u32 id
  481. u8 stat
  482. [v2f1000 data |
  483. u32 len
  484. u8[len] data |
  485. u32 data]
  486. */
  487. TOCLIENT_HUD_SET_FLAGS = 0x4c,
  488. /*
  489. u32 flags
  490. u32 mask
  491. */
  492. TOCLIENT_HUD_SET_PARAM = 0x4d,
  493. /*
  494. u16 param
  495. u16 len
  496. u8[len] value
  497. */
  498. TOCLIENT_BREATH = 0x4e,
  499. /*
  500. u16 breath
  501. */
  502. TOCLIENT_SET_SKY = 0x4f,
  503. /*
  504. u8[4] color (ARGB)
  505. u8 len
  506. u8[len] type
  507. u16 count
  508. foreach count:
  509. u8 len
  510. u8[len] param
  511. u8 clouds (boolean)
  512. */
  513. TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO = 0x50,
  514. /*
  515. u8 do_override (boolean)
  516. u16 day-night ratio 0...65535
  517. */
  518. TOCLIENT_LOCAL_PLAYER_ANIMATIONS = 0x51,
  519. /*
  520. v2s32 stand/idle
  521. v2s32 walk
  522. v2s32 dig
  523. v2s32 walk+dig
  524. f1000 frame_speed
  525. */
  526. TOCLIENT_EYE_OFFSET = 0x52,
  527. /*
  528. v3f1000 first
  529. v3f1000 third
  530. */
  531. TOCLIENT_DELETE_PARTICLESPAWNER = 0x53,
  532. /*
  533. u32 id
  534. */
  535. TOCLIENT_CLOUD_PARAMS = 0x54,
  536. /*
  537. f1000 density
  538. u8[4] color_diffuse (ARGB)
  539. u8[4] color_ambient (ARGB)
  540. f1000 height
  541. f1000 thickness
  542. v2f1000 speed
  543. */
  544. TOCLIENT_FADE_SOUND = 0x55,
  545. /*
  546. s32 sound_id
  547. float step
  548. float gain
  549. */
  550. TOCLIENT_UPDATE_PLAYER_LIST = 0x56,
  551. /*
  552. u8 type
  553. u16 number of players
  554. for each player
  555. u16 len
  556. u8[len] player name
  557. */
  558. TOCLIENT_MODCHANNEL_MSG = 0x57,
  559. /*
  560. u16 channel name length
  561. std::string channel name
  562. u16 channel name sender
  563. std::string channel name
  564. u16 message length
  565. std::string message
  566. */
  567. TOCLIENT_MODCHANNEL_SIGNAL = 0x58,
  568. /*
  569. u8 signal id
  570. u16 channel name length
  571. std::string channel name
  572. */
  573. TOCLIENT_SRP_BYTES_S_B = 0x60,
  574. /*
  575. Belonging to AUTH_MECHANISM_SRP.
  576. std::string bytes_s
  577. std::string bytes_B
  578. */
  579. TOCLIENT_FORMSPEC_PREPEND = 0x61,
  580. /*
  581. u16 len
  582. u8[len] formspec
  583. */
  584. TOCLIENT_NUM_MSG_TYPES = 0x62,
  585. };
  586. enum ToServerCommand
  587. {
  588. TOSERVER_INIT = 0x02,
  589. /*
  590. Sent first after connected.
  591. u8 serialisation version (=SER_FMT_VER_HIGHEST_READ)
  592. u16 supported network compression modes
  593. u16 minimum supported network protocol version
  594. u16 maximum supported network protocol version
  595. std::string player name
  596. */
  597. TOSERVER_INIT_LEGACY = 0x10, // Obsolete
  598. TOSERVER_INIT2 = 0x11,
  599. /*
  600. Sent as an ACK for TOCLIENT_INIT.
  601. After this, the server can send data.
  602. [0] u16 TOSERVER_INIT2
  603. */
  604. TOSERVER_MODCHANNEL_JOIN = 0x17,
  605. /*
  606. u16 channel name length
  607. std::string channel name
  608. */
  609. TOSERVER_MODCHANNEL_LEAVE = 0x18,
  610. /*
  611. u16 channel name length
  612. std::string channel name
  613. */
  614. TOSERVER_MODCHANNEL_MSG = 0x19,
  615. /*
  616. u16 channel name length
  617. std::string channel name
  618. u16 message length
  619. std::string message
  620. */
  621. TOSERVER_GETBLOCK = 0x20, // Obsolete
  622. TOSERVER_ADDNODE = 0x21, // Obsolete
  623. TOSERVER_REMOVENODE = 0x22, // Obsolete
  624. TOSERVER_PLAYERPOS = 0x23,
  625. /*
  626. [0] u16 command
  627. [2] v3s32 position*100
  628. [2+12] v3s32 speed*100
  629. [2+12+12] s32 pitch*100
  630. [2+12+12+4] s32 yaw*100
  631. [2+12+12+4+4] u32 keyPressed
  632. [2+12+12+4+4+1] u8 fov*80
  633. [2+12+12+4+4+4+1] u8 ceil(wanted_range / MAP_BLOCKSIZE)
  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. TOSERVER_DELETEDBLOCKS = 0x25,
  644. /*
  645. [0] u16 command
  646. [2] u8 count
  647. [3] v3s16 pos_0
  648. [3+6] v3s16 pos_1
  649. ...
  650. */
  651. TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
  652. TOSERVER_CLICK_OBJECT = 0x27, // Obsolete
  653. TOSERVER_GROUND_ACTION = 0x28, // Obsolete
  654. TOSERVER_RELEASE = 0x29, // Obsolete
  655. TOSERVER_SIGNTEXT = 0x30, // Obsolete
  656. TOSERVER_INVENTORY_ACTION = 0x31,
  657. /*
  658. See InventoryAction in inventorymanager.h
  659. */
  660. TOSERVER_CHAT_MESSAGE = 0x32,
  661. /*
  662. u16 length
  663. wstring message
  664. */
  665. TOSERVER_SIGNNODETEXT = 0x33, // Obsolete
  666. TOSERVER_CLICK_ACTIVEOBJECT = 0x34, // Obsolete
  667. TOSERVER_DAMAGE = 0x35,
  668. /*
  669. u8 amount
  670. */
  671. TOSERVER_PASSWORD_LEGACY = 0x36, // Obsolete
  672. TOSERVER_PLAYERITEM = 0x37,
  673. /*
  674. Sent to change selected item.
  675. [0] u16 TOSERVER_PLAYERITEM
  676. [2] u16 item
  677. */
  678. TOSERVER_RESPAWN = 0x38,
  679. /*
  680. u16 TOSERVER_RESPAWN
  681. */
  682. TOSERVER_INTERACT = 0x39,
  683. /*
  684. [0] u16 command
  685. [2] u8 action
  686. [3] u16 item
  687. [5] u32 length of the next item
  688. [9] serialized PointedThing
  689. actions:
  690. 0: start digging (from undersurface) or use
  691. 1: stop digging (all parameters ignored)
  692. 2: digging completed
  693. 3: place block or item (to abovesurface)
  694. 4: use item
  695. */
  696. TOSERVER_REMOVED_SOUNDS = 0x3a,
  697. /*
  698. u16 len
  699. s32[len] sound_id
  700. */
  701. TOSERVER_NODEMETA_FIELDS = 0x3b,
  702. /*
  703. v3s16 p
  704. u16 len
  705. u8[len] form name (reserved for future use)
  706. u16 number of fields
  707. for each field:
  708. u16 len
  709. u8[len] field name
  710. u32 len
  711. u8[len] field value
  712. */
  713. TOSERVER_INVENTORY_FIELDS = 0x3c,
  714. /*
  715. u16 len
  716. u8[len] form name (reserved for future use)
  717. u16 number of fields
  718. for each field:
  719. u16 len
  720. u8[len] field name
  721. u32 len
  722. u8[len] field value
  723. */
  724. TOSERVER_REQUEST_MEDIA = 0x40,
  725. /*
  726. u16 number of files requested
  727. for each file {
  728. u16 length of name
  729. string name
  730. }
  731. */
  732. TOSERVER_RECEIVED_MEDIA = 0x41, // Obsolete
  733. TOSERVER_BREATH = 0x42, // Obsolete
  734. TOSERVER_CLIENT_READY = 0x43,
  735. /*
  736. u8 major
  737. u8 minor
  738. u8 patch
  739. u8 reserved
  740. u16 len
  741. u8[len] full_version_string
  742. */
  743. TOSERVER_FIRST_SRP = 0x50,
  744. /*
  745. Belonging to AUTH_MECHANISM_FIRST_SRP.
  746. std::string srp salt
  747. std::string srp verification key
  748. u8 is_empty (=1 if password is empty, 0 otherwise)
  749. */
  750. TOSERVER_SRP_BYTES_A = 0x51,
  751. /*
  752. Belonging to AUTH_MECHANISM_SRP,
  753. depending on current_login_based_on.
  754. std::string bytes_A
  755. u8 current_login_based_on : on which version of the password's
  756. hash this login is based on (0 legacy hash,
  757. or 1 directly the password)
  758. */
  759. TOSERVER_SRP_BYTES_M = 0x52,
  760. /*
  761. Belonging to AUTH_MECHANISM_SRP.
  762. std::string bytes_M
  763. */
  764. TOSERVER_NUM_MSG_TYPES = 0x53,
  765. };
  766. enum AuthMechanism
  767. {
  768. // reserved
  769. AUTH_MECHANISM_NONE = 0,
  770. // SRP based on the legacy hash
  771. AUTH_MECHANISM_LEGACY_PASSWORD = 1 << 0,
  772. // SRP based on the srp verification key
  773. AUTH_MECHANISM_SRP = 1 << 1,
  774. // Establishes a srp verification key, for first login and password changing
  775. AUTH_MECHANISM_FIRST_SRP = 1 << 2,
  776. };
  777. enum AccessDeniedCode {
  778. SERVER_ACCESSDENIED_WRONG_PASSWORD,
  779. SERVER_ACCESSDENIED_UNEXPECTED_DATA,
  780. SERVER_ACCESSDENIED_SINGLEPLAYER,
  781. SERVER_ACCESSDENIED_WRONG_VERSION,
  782. SERVER_ACCESSDENIED_WRONG_CHARS_IN_NAME,
  783. SERVER_ACCESSDENIED_WRONG_NAME,
  784. SERVER_ACCESSDENIED_TOO_MANY_USERS,
  785. SERVER_ACCESSDENIED_EMPTY_PASSWORD,
  786. SERVER_ACCESSDENIED_ALREADY_CONNECTED,
  787. SERVER_ACCESSDENIED_SERVER_FAIL,
  788. SERVER_ACCESSDENIED_CUSTOM_STRING,
  789. SERVER_ACCESSDENIED_SHUTDOWN,
  790. SERVER_ACCESSDENIED_CRASH,
  791. SERVER_ACCESSDENIED_MAX,
  792. };
  793. enum NetProtoCompressionMode {
  794. NETPROTO_COMPRESSION_NONE = 0,
  795. };
  796. const static std::string accessDeniedStrings[SERVER_ACCESSDENIED_MAX] = {
  797. "Invalid password",
  798. "Your client sent something the server didn't expect. Try reconnecting or updating your client",
  799. "The server is running in simple singleplayer mode. You cannot connect.",
  800. "Your client's version is not supported.\nPlease contact server administrator.",
  801. "Player name contains disallowed characters.",
  802. "Player name not allowed.",
  803. "Too many users.",
  804. "Empty passwords are disallowed. Set a password and try again.",
  805. "Another client is connected with this name. If your client closed unexpectedly, try again in a minute.",
  806. "Server authentication failed. This is likely a server error.",
  807. "",
  808. "Server shutting down.",
  809. "This server has experienced an internal error. You will now be disconnected."
  810. };
  811. enum PlayerListModifer: u8
  812. {
  813. PLAYER_LIST_INIT,
  814. PLAYER_LIST_ADD,
  815. PLAYER_LIST_REMOVE,
  816. };
  817. enum CSMFlavourLimit : u64 {
  818. CSM_FL_NONE = 0x00000000,
  819. CSM_FL_LOAD_CLIENT_MODS = 0x00000001, // Disable mods provided by clients
  820. CSM_FL_CHAT_MESSAGES = 0x00000002, // Disable chat message sending from CSM
  821. CSM_FL_READ_ITEMDEFS = 0x00000004, // Disable itemdef lookups
  822. CSM_FL_READ_NODEDEFS = 0x00000008, // Disable nodedef lookups
  823. CSM_FL_LOOKUP_NODES = 0x00000010, // Limit node lookups
  824. CSM_FL_ALL = 0xFFFFFFFF,
  825. };