networkprotocol.h 25 KB

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