networkprotocol.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  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. AO_CMD_SET_ANIMATION
  67. AO_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. AO_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 AO_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_RESTRICTION_FLAGS to define which CSM features 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. PROTOCOL VERSION 37:
  185. Redo detached inventory sending
  186. Add TOCLIENT_NODEMETA_CHANGED
  187. New network float format
  188. ContentFeatures version 13
  189. Add full Euler rotations instead of just yaw
  190. Add TOCLIENT_PLAYER_SPEED
  191. PROTOCOL VERSION 38:
  192. Incremental inventory sending mode
  193. Unknown inventory serialization fields no longer throw an error
  194. Mod-specific formspec version
  195. Player FOV override API
  196. "ephemeral" added to TOCLIENT_PLAY_SOUND
  197. PROTOCOL VERSION 39:
  198. Updated set_sky packet
  199. Adds new sun, moon and stars packets
  200. Minimap modes
  201. PROTOCOL VERSION 40:
  202. TOCLIENT_MEDIA_PUSH changed, TOSERVER_HAVE_MEDIA added
  203. Added new particlespawner parameters
  204. [scheduled bump for 5.6.0]
  205. */
  206. #define LATEST_PROTOCOL_VERSION 41
  207. #define LATEST_PROTOCOL_VERSION_STRING TOSTRING(LATEST_PROTOCOL_VERSION)
  208. // Server's supported network protocol range
  209. #define SERVER_PROTOCOL_VERSION_MIN 37
  210. #define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
  211. // Client's supported network protocol range
  212. // The minimal version depends on whether
  213. // send_pre_v25_init is enabled or not
  214. #define CLIENT_PROTOCOL_VERSION_MIN 37
  215. #define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
  216. // Constant that differentiates the protocol from random data and other protocols
  217. #define PROTOCOL_ID 0x4f457403
  218. #define PASSWORD_SIZE 28 // Maximum password length. Allows for
  219. // base64-encoded SHA-1 (27+\0).
  220. // See also formspec [Version History] in doc/lua_api.txt
  221. #define FORMSPEC_API_VERSION 6
  222. #define TEXTURENAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-"
  223. typedef u16 session_t;
  224. enum ToClientCommand
  225. {
  226. TOCLIENT_HELLO = 0x02,
  227. /*
  228. Sent after TOSERVER_INIT.
  229. u8 deployed serialization version
  230. u16 deployed network compression mode
  231. u16 deployed protocol version
  232. u32 supported auth methods
  233. std::string username that should be used for legacy hash (for proper casing)
  234. */
  235. TOCLIENT_AUTH_ACCEPT = 0x03,
  236. /*
  237. Message from server to accept auth.
  238. v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
  239. u64 map seed
  240. f1000 recommended send interval
  241. u32 : supported auth methods for sudo mode
  242. (where the user can change their password)
  243. */
  244. TOCLIENT_ACCEPT_SUDO_MODE = 0x04,
  245. /*
  246. Sent to client to show it is in sudo mode now.
  247. */
  248. TOCLIENT_DENY_SUDO_MODE = 0x05,
  249. /*
  250. Signals client that sudo mode auth failed.
  251. */
  252. TOCLIENT_ACCESS_DENIED = 0x0A,
  253. /*
  254. u8 reason
  255. std::string custom reason (if needed, otherwise "")
  256. u8 (bool) reconnect
  257. */
  258. TOCLIENT_INIT_LEGACY = 0x10, // Obsolete
  259. TOCLIENT_BLOCKDATA = 0x20, //TODO: Multiple blocks
  260. TOCLIENT_ADDNODE = 0x21,
  261. /*
  262. v3s16 position
  263. serialized mapnode
  264. u8 keep_metadata // Added in protocol version 22
  265. */
  266. TOCLIENT_REMOVENODE = 0x22,
  267. TOCLIENT_PLAYERPOS = 0x23, // Obsolete
  268. TOCLIENT_PLAYERINFO = 0x24, // Obsolete
  269. TOCLIENT_OPT_BLOCK_NOT_FOUND = 0x25, // Obsolete
  270. TOCLIENT_SECTORMETA = 0x26, // Obsolete
  271. TOCLIENT_INVENTORY = 0x27,
  272. /*
  273. [0] u16 command
  274. [2] serialized inventory
  275. */
  276. TOCLIENT_OBJECTDATA = 0x28, // Obsolete
  277. TOCLIENT_TIME_OF_DAY = 0x29,
  278. /*
  279. u16 time (0-23999)
  280. Added in a later version:
  281. f1000 time_speed
  282. */
  283. TOCLIENT_CSM_RESTRICTION_FLAGS = 0x2A,
  284. /*
  285. u32 CSMRestrictionFlags byteflag
  286. */
  287. TOCLIENT_PLAYER_SPEED = 0x2B,
  288. /*
  289. v3f added_vel
  290. */
  291. TOCLIENT_MEDIA_PUSH = 0x2C,
  292. /*
  293. std::string raw_hash
  294. std::string filename
  295. u32 callback_token
  296. bool should_be_cached
  297. */
  298. // (oops, there is some gap here)
  299. TOCLIENT_CHAT_MESSAGE = 0x2F,
  300. /*
  301. u8 version
  302. u8 message_type
  303. u16 sendername length
  304. wstring sendername
  305. u16 length
  306. wstring message
  307. */
  308. TOCLIENT_CHAT_MESSAGE_OLD = 0x30, // Obsolete
  309. TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD = 0x31,
  310. /*
  311. u16 count of removed objects
  312. for all removed objects {
  313. u16 id
  314. }
  315. u16 count of added objects
  316. for all added objects {
  317. u16 id
  318. u8 type
  319. u32 initialization data length
  320. string initialization data
  321. }
  322. */
  323. TOCLIENT_ACTIVE_OBJECT_MESSAGES = 0x32,
  324. /*
  325. for all objects
  326. {
  327. u16 id
  328. u16 message length
  329. string message
  330. }
  331. */
  332. TOCLIENT_HP = 0x33,
  333. /*
  334. u8 hp
  335. */
  336. TOCLIENT_MOVE_PLAYER = 0x34,
  337. /*
  338. v3f1000 player position
  339. f1000 player pitch
  340. f1000 player yaw
  341. */
  342. TOCLIENT_ACCESS_DENIED_LEGACY = 0x35,
  343. /*
  344. u16 reason_length
  345. wstring reason
  346. */
  347. TOCLIENT_FOV = 0x36,
  348. /*
  349. Sends an FOV override/multiplier to client.
  350. f32 fov
  351. bool is_multiplier
  352. f32 transition_time
  353. */
  354. TOCLIENT_DEATHSCREEN = 0x37,
  355. /*
  356. u8 bool set camera point target
  357. v3f1000 camera point target (to point the death cause or whatever)
  358. */
  359. TOCLIENT_MEDIA = 0x38,
  360. /*
  361. u16 total number of texture bunches
  362. u16 index of this bunch
  363. u32 number of files in this bunch
  364. for each file {
  365. u16 length of name
  366. string name
  367. u32 length of data
  368. data
  369. }
  370. u16 length of remote media server url (if applicable)
  371. string url
  372. */
  373. TOCLIENT_TOOLDEF = 0x39,
  374. /*
  375. u32 length of the next item
  376. serialized ToolDefManager
  377. */
  378. TOCLIENT_NODEDEF = 0x3a,
  379. /*
  380. u32 length of the next item
  381. serialized NodeDefManager
  382. */
  383. TOCLIENT_CRAFTITEMDEF = 0x3b,
  384. /*
  385. u32 length of the next item
  386. serialized CraftiItemDefManager
  387. */
  388. TOCLIENT_ANNOUNCE_MEDIA = 0x3c,
  389. /*
  390. u32 number of files
  391. for each texture {
  392. u16 length of name
  393. string name
  394. u16 length of sha1_digest
  395. string sha1_digest
  396. }
  397. */
  398. TOCLIENT_ITEMDEF = 0x3d,
  399. /*
  400. u32 length of next item
  401. serialized ItemDefManager
  402. */
  403. TOCLIENT_PLAY_SOUND = 0x3f,
  404. /*
  405. s32 sound_id
  406. u16 len
  407. u8[len] sound name
  408. s32 gain*1000
  409. u8 type (0=local, 1=positional, 2=object)
  410. s32[3] pos_nodes*10000
  411. u16 object_id
  412. u8 loop (bool)
  413. u8 ephemeral (bool)
  414. */
  415. TOCLIENT_STOP_SOUND = 0x40,
  416. /*
  417. s32 sound_id
  418. */
  419. TOCLIENT_PRIVILEGES = 0x41,
  420. /*
  421. u16 number of privileges
  422. for each privilege
  423. u16 len
  424. u8[len] privilege
  425. */
  426. TOCLIENT_INVENTORY_FORMSPEC = 0x42,
  427. /*
  428. u32 len
  429. u8[len] formspec
  430. */
  431. TOCLIENT_DETACHED_INVENTORY = 0x43,
  432. /*
  433. [0] u16 command
  434. u16 len
  435. u8[len] name
  436. [2] serialized inventory
  437. */
  438. TOCLIENT_SHOW_FORMSPEC = 0x44,
  439. /*
  440. [0] u16 command
  441. u32 len
  442. u8[len] formspec
  443. u16 len
  444. u8[len] formname
  445. */
  446. TOCLIENT_MOVEMENT = 0x45,
  447. /*
  448. f1000 movement_acceleration_default
  449. f1000 movement_acceleration_air
  450. f1000 movement_acceleration_fast
  451. f1000 movement_speed_walk
  452. f1000 movement_speed_crouch
  453. f1000 movement_speed_fast
  454. f1000 movement_speed_climb
  455. f1000 movement_speed_jump
  456. f1000 movement_liquid_fluidity
  457. f1000 movement_liquid_fluidity_smooth
  458. f1000 movement_liquid_sink
  459. f1000 movement_gravity
  460. */
  461. TOCLIENT_SPAWN_PARTICLE = 0x46,
  462. /*
  463. -- struct range<T> { T min, T max, f32 bias };
  464. v3f pos
  465. v3f velocity
  466. v3f acceleration
  467. f32 expirationtime
  468. f32 size
  469. u8 bool collisiondetection
  470. u32 len
  471. u8[len] texture
  472. u8 bool vertical
  473. u8 collision_removal
  474. TileAnimation animation
  475. u8 glow
  476. u8 object_collision
  477. v3f drag
  478. range<v3f> bounce
  479. */
  480. TOCLIENT_ADD_PARTICLESPAWNER = 0x47,
  481. /*
  482. -- struct range<T> { T min, T max, f32 bias };
  483. -- struct tween<T> { T start, T end };
  484. u16 amount
  485. f32 spawntime
  486. v3f minpos
  487. v3f maxpos
  488. v3f minvel
  489. v3f maxvel
  490. v3f minacc
  491. v3f maxacc
  492. f32 minexptime
  493. f32 maxexptime
  494. f32 minsize
  495. f32 maxsize
  496. u8 bool collisiondetection
  497. u32 len
  498. u8[len] texture
  499. u8 bool vertical
  500. u8 collision_removal
  501. u32 id
  502. TileAnimation animation
  503. u8 glow
  504. u8 object_collision
  505. f32 pos_start_bias
  506. f32 vel_start_bias
  507. f32 acc_start_bias
  508. f32 exptime_start_bias
  509. f32 size_start_bias
  510. range<v3f> pos_end
  511. -- i.e v3f pos_end_min
  512. -- v3f pos_end_max
  513. -- f32 pos_end_bias
  514. range<v3f> vel_end
  515. range<v3f> acc_end
  516. tween<range<v3f>> drag
  517. -- i.e. v3f drag_start_min
  518. -- v3f drag_start_max
  519. -- f32 drag_start_bias
  520. -- v3f drag_end_min
  521. -- v3f drag_end_max
  522. -- f32 drag_end_bias
  523. tween<range<v3f>> jitter
  524. tween<range<f32>> bounce
  525. u8 attraction_kind
  526. none = 0
  527. point = 1
  528. line = 2
  529. plane = 3
  530. if attraction_kind > none {
  531. tween<range<f32>> attract_strength
  532. tween<v3f> attractor_origin
  533. u16 attractor_origin_attachment_object_id
  534. u8 spawner_flags
  535. bit 1: attractor_kill (particles dies on contact)
  536. if attraction_mode > point {
  537. tween<v3f> attractor_angle
  538. u16 attractor_origin_attachment_object_id
  539. }
  540. }
  541. tween<range<v3f>> radius
  542. tween<range<v3f>> drag
  543. u16 texpool_sz
  544. texpool_sz.times {
  545. u8 flags
  546. -- bit 0: animated
  547. -- other bits free & ignored as of proto v40
  548. tween<f32> alpha
  549. tween<v2f> scale
  550. if flags.animated {
  551. TileAnimation animation
  552. }
  553. }
  554. */
  555. TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY = 0x48, // Obsolete
  556. TOCLIENT_HUDADD = 0x49,
  557. /*
  558. u32 id
  559. u8 type
  560. v2f1000 pos
  561. u16 len
  562. u8[len] name
  563. v2f1000 scale
  564. u16 len2
  565. u8[len2] text
  566. u32 number
  567. u32 item
  568. u32 dir
  569. v2f1000 align
  570. v2f1000 offset
  571. v3f1000 world_pos
  572. v2s32 size
  573. s16 z_index
  574. u16 len3
  575. u8[len3] text2
  576. */
  577. TOCLIENT_HUDRM = 0x4a,
  578. /*
  579. u32 id
  580. */
  581. TOCLIENT_HUDCHANGE = 0x4b,
  582. /*
  583. u32 id
  584. u8 stat
  585. [v2f1000 data |
  586. u32 len
  587. u8[len] data |
  588. u32 data]
  589. */
  590. TOCLIENT_HUD_SET_FLAGS = 0x4c,
  591. /*
  592. u32 flags
  593. u32 mask
  594. */
  595. TOCLIENT_HUD_SET_PARAM = 0x4d,
  596. /*
  597. u16 param
  598. u16 len
  599. u8[len] value
  600. */
  601. TOCLIENT_BREATH = 0x4e,
  602. /*
  603. u16 breath
  604. */
  605. TOCLIENT_SET_SKY = 0x4f,
  606. /*
  607. Protocol 38:
  608. u8[4] base_color (ARGB)
  609. u8 len
  610. u8[len] type
  611. u16 count
  612. foreach count:
  613. u8 len
  614. u8[len] param
  615. u8 clouds (boolean)
  616. Protocol 39:
  617. u8[4] bgcolor (ARGB)
  618. std::string type
  619. int texture_count
  620. std::string[6] param
  621. bool clouds
  622. bool bgcolor_fog
  623. u8[4] day_sky (ARGB)
  624. u8[4] day_horizon (ARGB)
  625. u8[4] dawn_sky (ARGB)
  626. u8[4] dawn_horizon (ARGB)
  627. u8[4] night_sky (ARGB)
  628. u8[4] night_horizon (ARGB)
  629. u8[4] indoors (ARGB)
  630. u8[4] fog_sun_tint (ARGB)
  631. u8[4] fog_moon_tint (ARGB)
  632. std::string fog_tint_type
  633. */
  634. TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO = 0x50,
  635. /*
  636. u8 do_override (boolean)
  637. u16 day-night ratio 0...65535
  638. */
  639. TOCLIENT_LOCAL_PLAYER_ANIMATIONS = 0x51,
  640. /*
  641. v2s32 stand/idle
  642. v2s32 walk
  643. v2s32 dig
  644. v2s32 walk+dig
  645. f1000 frame_speed
  646. */
  647. TOCLIENT_EYE_OFFSET = 0x52,
  648. /*
  649. v3f1000 first
  650. v3f1000 third
  651. */
  652. TOCLIENT_DELETE_PARTICLESPAWNER = 0x53,
  653. /*
  654. u32 id
  655. */
  656. TOCLIENT_CLOUD_PARAMS = 0x54,
  657. /*
  658. f1000 density
  659. u8[4] color_diffuse (ARGB)
  660. u8[4] color_ambient (ARGB)
  661. f1000 height
  662. f1000 thickness
  663. v2f1000 speed
  664. */
  665. TOCLIENT_FADE_SOUND = 0x55,
  666. /*
  667. s32 sound_id
  668. float step
  669. float gain
  670. */
  671. TOCLIENT_UPDATE_PLAYER_LIST = 0x56,
  672. /*
  673. u8 type
  674. u16 number of players
  675. for each player
  676. u16 len
  677. u8[len] player name
  678. */
  679. TOCLIENT_MODCHANNEL_MSG = 0x57,
  680. /*
  681. u16 channel name length
  682. std::string channel name
  683. u16 channel name sender
  684. std::string channel name
  685. u16 message length
  686. std::string message
  687. */
  688. TOCLIENT_MODCHANNEL_SIGNAL = 0x58,
  689. /*
  690. u8 signal id
  691. u16 channel name length
  692. std::string channel name
  693. */
  694. TOCLIENT_NODEMETA_CHANGED = 0x59,
  695. /*
  696. serialized and compressed node metadata
  697. */
  698. TOCLIENT_SET_SUN = 0x5a,
  699. /*
  700. bool visible
  701. std::string texture
  702. std::string tonemap
  703. std::string sunrise
  704. f32 scale
  705. */
  706. TOCLIENT_SET_MOON = 0x5b,
  707. /*
  708. bool visible
  709. std::string texture
  710. std::string tonemap
  711. f32 scale
  712. */
  713. TOCLIENT_SET_STARS = 0x5c,
  714. /*
  715. bool visible
  716. u32 count
  717. u8[4] starcolor (ARGB)
  718. f32 scale
  719. f32 day_opacity
  720. */
  721. TOCLIENT_SRP_BYTES_S_B = 0x60,
  722. /*
  723. Belonging to AUTH_MECHANISM_SRP.
  724. std::string bytes_s
  725. std::string bytes_B
  726. */
  727. TOCLIENT_FORMSPEC_PREPEND = 0x61,
  728. /*
  729. u16 len
  730. u8[len] formspec
  731. */
  732. TOCLIENT_MINIMAP_MODES = 0x62,
  733. /*
  734. u16 count // modes
  735. u16 mode // wanted current mode index after change
  736. for each mode
  737. u16 type
  738. std::string label
  739. u16 size
  740. std::string extra
  741. */
  742. TOCLIENT_SET_LIGHTING = 0x63,
  743. /*
  744. f32 shadow_intensity
  745. f32 saturation
  746. exposure parameters
  747. f32 luminance_min
  748. f32 luminance_max
  749. f32 exposure_correction
  750. f32 speed_dark_bright
  751. f32 speed_bright_dark
  752. f32 center_weight_power
  753. */
  754. TOCLIENT_NUM_MSG_TYPES = 0x64,
  755. };
  756. enum ToServerCommand
  757. {
  758. TOSERVER_INIT = 0x02,
  759. /*
  760. Sent first after connected.
  761. u8 serialization version (=SER_FMT_VER_HIGHEST_READ)
  762. u16 supported network compression modes
  763. u16 minimum supported network protocol version
  764. u16 maximum supported network protocol version
  765. std::string player name
  766. */
  767. TOSERVER_INIT_LEGACY = 0x10, // Obsolete
  768. TOSERVER_INIT2 = 0x11,
  769. /*
  770. Sent as an ACK for TOCLIENT_INIT.
  771. After this, the server can send data.
  772. [0] u16 TOSERVER_INIT2
  773. */
  774. TOSERVER_MODCHANNEL_JOIN = 0x17,
  775. /*
  776. u16 channel name length
  777. std::string channel name
  778. */
  779. TOSERVER_MODCHANNEL_LEAVE = 0x18,
  780. /*
  781. u16 channel name length
  782. std::string channel name
  783. */
  784. TOSERVER_MODCHANNEL_MSG = 0x19,
  785. /*
  786. u16 channel name length
  787. std::string channel name
  788. u16 message length
  789. std::string message
  790. */
  791. TOSERVER_GETBLOCK = 0x20, // Obsolete
  792. TOSERVER_ADDNODE = 0x21, // Obsolete
  793. TOSERVER_REMOVENODE = 0x22, // Obsolete
  794. TOSERVER_PLAYERPOS = 0x23,
  795. /*
  796. [0] u16 command
  797. [2] v3s32 position*100
  798. [2+12] v3s32 speed*100
  799. [2+12+12] s32 pitch*100
  800. [2+12+12+4] s32 yaw*100
  801. [2+12+12+4+4] u32 keyPressed
  802. [2+12+12+4+4+1] u8 fov*80
  803. [2+12+12+4+4+4+1] u8 ceil(wanted_range / MAP_BLOCKSIZE)
  804. */
  805. TOSERVER_GOTBLOCKS = 0x24,
  806. /*
  807. [0] u16 command
  808. [2] u8 count
  809. [3] v3s16 pos_0
  810. [3+6] v3s16 pos_1
  811. ...
  812. */
  813. TOSERVER_DELETEDBLOCKS = 0x25,
  814. /*
  815. [0] u16 command
  816. [2] u8 count
  817. [3] v3s16 pos_0
  818. [3+6] v3s16 pos_1
  819. ...
  820. */
  821. TOSERVER_ADDNODE_FROM_INVENTORY = 0x26, // Obsolete
  822. TOSERVER_CLICK_OBJECT = 0x27, // Obsolete
  823. TOSERVER_GROUND_ACTION = 0x28, // Obsolete
  824. TOSERVER_RELEASE = 0x29, // Obsolete
  825. TOSERVER_SIGNTEXT = 0x30, // Obsolete
  826. TOSERVER_INVENTORY_ACTION = 0x31,
  827. /*
  828. See InventoryAction in inventorymanager.h
  829. */
  830. TOSERVER_CHAT_MESSAGE = 0x32,
  831. /*
  832. u16 length
  833. wstring message
  834. */
  835. TOSERVER_SIGNNODETEXT = 0x33, // Obsolete
  836. TOSERVER_CLICK_ACTIVEOBJECT = 0x34, // Obsolete
  837. TOSERVER_DAMAGE = 0x35,
  838. /*
  839. u8 amount
  840. */
  841. TOSERVER_PASSWORD_LEGACY = 0x36, // Obsolete
  842. TOSERVER_PLAYERITEM = 0x37,
  843. /*
  844. Sent to change selected item.
  845. [0] u16 TOSERVER_PLAYERITEM
  846. [2] u16 item
  847. */
  848. TOSERVER_RESPAWN = 0x38,
  849. /*
  850. u16 TOSERVER_RESPAWN
  851. */
  852. TOSERVER_INTERACT = 0x39,
  853. /*
  854. [0] u16 command
  855. [2] u8 action
  856. [3] u16 item
  857. [5] u32 length of the next item
  858. [9] serialized PointedThing
  859. actions:
  860. 0: start digging (from undersurface) or use
  861. 1: stop digging (all parameters ignored)
  862. 2: digging completed
  863. 3: place block or item (to abovesurface)
  864. 4: use item
  865. */
  866. TOSERVER_REMOVED_SOUNDS = 0x3a,
  867. /*
  868. u16 len
  869. s32[len] sound_id
  870. */
  871. TOSERVER_NODEMETA_FIELDS = 0x3b,
  872. /*
  873. v3s16 p
  874. u16 len
  875. u8[len] form name (reserved for future use)
  876. u16 number of fields
  877. for each field:
  878. u16 len
  879. u8[len] field name
  880. u32 len
  881. u8[len] field value
  882. */
  883. TOSERVER_INVENTORY_FIELDS = 0x3c,
  884. /*
  885. u16 len
  886. u8[len] form name (reserved for future use)
  887. u16 number of fields
  888. for each field:
  889. u16 len
  890. u8[len] field name
  891. u32 len
  892. u8[len] field value
  893. */
  894. TOSERVER_REQUEST_MEDIA = 0x40,
  895. /*
  896. u16 number of files requested
  897. for each file {
  898. u16 length of name
  899. string name
  900. }
  901. */
  902. TOSERVER_HAVE_MEDIA = 0x41,
  903. /*
  904. u8 number of callback tokens
  905. for each:
  906. u32 token
  907. */
  908. TOSERVER_BREATH = 0x42, // Obsolete
  909. TOSERVER_CLIENT_READY = 0x43,
  910. /*
  911. u8 major
  912. u8 minor
  913. u8 patch
  914. u8 reserved
  915. u16 len
  916. u8[len] full_version_string
  917. */
  918. TOSERVER_FIRST_SRP = 0x50,
  919. /*
  920. Belonging to AUTH_MECHANISM_FIRST_SRP.
  921. std::string srp salt
  922. std::string srp verification key
  923. u8 is_empty (=1 if password is empty, 0 otherwise)
  924. */
  925. TOSERVER_SRP_BYTES_A = 0x51,
  926. /*
  927. Belonging to AUTH_MECHANISM_SRP,
  928. depending on current_login_based_on.
  929. std::string bytes_A
  930. u8 current_login_based_on : on which version of the password's
  931. hash this login is based on (0 legacy hash,
  932. or 1 directly the password)
  933. */
  934. TOSERVER_SRP_BYTES_M = 0x52,
  935. /*
  936. Belonging to AUTH_MECHANISM_SRP.
  937. std::string bytes_M
  938. */
  939. TOSERVER_NUM_MSG_TYPES = 0x53,
  940. };
  941. enum AuthMechanism
  942. {
  943. // reserved
  944. AUTH_MECHANISM_NONE = 0,
  945. // SRP based on the legacy hash
  946. AUTH_MECHANISM_LEGACY_PASSWORD = 1 << 0,
  947. // SRP based on the srp verification key
  948. AUTH_MECHANISM_SRP = 1 << 1,
  949. // Establishes a srp verification key, for first login and password changing
  950. AUTH_MECHANISM_FIRST_SRP = 1 << 2,
  951. };
  952. enum AccessDeniedCode : u8 {
  953. SERVER_ACCESSDENIED_WRONG_PASSWORD,
  954. SERVER_ACCESSDENIED_UNEXPECTED_DATA,
  955. SERVER_ACCESSDENIED_SINGLEPLAYER,
  956. SERVER_ACCESSDENIED_WRONG_VERSION,
  957. SERVER_ACCESSDENIED_WRONG_CHARS_IN_NAME,
  958. SERVER_ACCESSDENIED_WRONG_NAME,
  959. SERVER_ACCESSDENIED_TOO_MANY_USERS,
  960. SERVER_ACCESSDENIED_EMPTY_PASSWORD,
  961. SERVER_ACCESSDENIED_ALREADY_CONNECTED,
  962. SERVER_ACCESSDENIED_SERVER_FAIL,
  963. SERVER_ACCESSDENIED_CUSTOM_STRING,
  964. SERVER_ACCESSDENIED_SHUTDOWN,
  965. SERVER_ACCESSDENIED_CRASH,
  966. SERVER_ACCESSDENIED_MAX,
  967. };
  968. enum NetProtoCompressionMode {
  969. NETPROTO_COMPRESSION_NONE = 0,
  970. };
  971. const static std::string accessDeniedStrings[SERVER_ACCESSDENIED_MAX] = {
  972. "Invalid password",
  973. "Your client sent something the server didn't expect. Try reconnecting or updating your client.",
  974. "The server is running in simple singleplayer mode. You cannot connect.",
  975. "Your client's version is not supported.\nPlease contact the server administrator.",
  976. "Player name contains disallowed characters",
  977. "Player name not allowed",
  978. "Too many users",
  979. "Empty passwords are disallowed. Set a password and try again.",
  980. "Another client is connected with this name. If your client closed unexpectedly, try again in a minute.",
  981. "Internal server error",
  982. "",
  983. "Server shutting down",
  984. "The server has experienced an internal error. You will now be disconnected."
  985. };
  986. enum PlayerListModifer : u8
  987. {
  988. PLAYER_LIST_INIT,
  989. PLAYER_LIST_ADD,
  990. PLAYER_LIST_REMOVE,
  991. };
  992. enum CSMRestrictionFlags : u64 {
  993. CSM_RF_NONE = 0x00000000,
  994. // Until server-sent CSM and verifying of builtin are complete,
  995. // 'CSM_RF_LOAD_CLIENT_MODS' also disables loading 'builtin'.
  996. // When those are complete, this should return to only being a restriction on the
  997. // loading of client mods.
  998. CSM_RF_LOAD_CLIENT_MODS = 0x00000001, // Don't load client-provided mods or 'builtin'
  999. CSM_RF_CHAT_MESSAGES = 0x00000002, // Disable chat message sending from CSM
  1000. CSM_RF_READ_ITEMDEFS = 0x00000004, // Disable itemdef lookups
  1001. CSM_RF_READ_NODEDEFS = 0x00000008, // Disable nodedef lookups
  1002. CSM_RF_LOOKUP_NODES = 0x00000010, // Limit node lookups
  1003. CSM_RF_READ_PLAYERINFO = 0x00000020, // Disable player info lookups
  1004. CSM_RF_ALL = 0xFFFFFFFF,
  1005. };
  1006. enum InteractAction : u8
  1007. {
  1008. INTERACT_START_DIGGING, // 0: start digging (from undersurface) or use
  1009. INTERACT_STOP_DIGGING, // 1: stop digging (all parameters ignored)
  1010. INTERACT_DIGGING_COMPLETED, // 2: digging completed
  1011. INTERACT_PLACE, // 3: place block or item (to abovesurface)
  1012. INTERACT_USE, // 4: use item
  1013. INTERACT_ACTIVATE // 5: rightclick air ("activate")
  1014. };