serveropcodes.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. Copyright (C) 2015 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. */
  17. #include "serveropcodes.h"
  18. const static ToServerCommandHandler null_command_handler = { "TOSERVER_NULL", TOSERVER_STATE_ALL, &Server::handleCommand_Null };
  19. const ToServerCommandHandler toServerCommandTable[TOSERVER_NUM_MSG_TYPES] =
  20. {
  21. null_command_handler, // 0x00 (never use this)
  22. null_command_handler, // 0x01
  23. { "TOSERVER_INIT", TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_Init }, // 0x02
  24. null_command_handler, // 0x03
  25. null_command_handler, // 0x04
  26. null_command_handler, // 0x05
  27. null_command_handler, // 0x06
  28. null_command_handler, // 0x07
  29. null_command_handler, // 0x08
  30. null_command_handler, // 0x09
  31. null_command_handler, // 0x0a
  32. null_command_handler, // 0x0b
  33. null_command_handler, // 0x0c
  34. null_command_handler, // 0x0d
  35. null_command_handler, // 0x0e
  36. null_command_handler, // 0x0f
  37. null_command_handler, // 0x10
  38. { "TOSERVER_INIT2", TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_Init2 }, // 0x11
  39. null_command_handler, // 0x12
  40. null_command_handler, // 0x13
  41. null_command_handler, // 0x14
  42. null_command_handler, // 0x15
  43. null_command_handler, // 0x16
  44. { "TOSERVER_MODCHANNEL_JOIN", TOSERVER_STATE_INGAME, &Server::handleCommand_ModChannelJoin }, // 0x17
  45. { "TOSERVER_MODCHANNEL_LEAVE", TOSERVER_STATE_INGAME, &Server::handleCommand_ModChannelLeave }, // 0x18
  46. { "TOSERVER_MODCHANNEL_MSG", TOSERVER_STATE_INGAME, &Server::handleCommand_ModChannelMsg }, // 0x19
  47. null_command_handler, // 0x1a
  48. null_command_handler, // 0x1b
  49. null_command_handler, // 0x1c
  50. null_command_handler, // 0x1d
  51. null_command_handler, // 0x1e
  52. null_command_handler, // 0x1f
  53. null_command_handler, // 0x20
  54. null_command_handler, // 0x21
  55. null_command_handler, // 0x22
  56. { "TOSERVER_PLAYERPOS", TOSERVER_STATE_INGAME, &Server::handleCommand_PlayerPos }, // 0x23
  57. { "TOSERVER_GOTBLOCKS", TOSERVER_STATE_STARTUP, &Server::handleCommand_GotBlocks }, // 0x24
  58. { "TOSERVER_DELETEDBLOCKS", TOSERVER_STATE_INGAME, &Server::handleCommand_DeletedBlocks }, // 0x25
  59. null_command_handler, // 0x26
  60. null_command_handler, // 0x27
  61. null_command_handler, // 0x28
  62. null_command_handler, // 0x29
  63. null_command_handler, // 0x2a
  64. null_command_handler, // 0x2b
  65. null_command_handler, // 0x2c
  66. null_command_handler, // 0x2d
  67. null_command_handler, // 0x2e
  68. null_command_handler, // 0x2f
  69. null_command_handler, // 0x30
  70. { "TOSERVER_INVENTORY_ACTION", TOSERVER_STATE_INGAME, &Server::handleCommand_InventoryAction }, // 0x31
  71. { "TOSERVER_CHAT_MESSAGE", TOSERVER_STATE_INGAME, &Server::handleCommand_ChatMessage }, // 0x32
  72. null_command_handler, // 0x33
  73. null_command_handler, // 0x34
  74. { "TOSERVER_DAMAGE", TOSERVER_STATE_INGAME, &Server::handleCommand_Damage }, // 0x35
  75. null_command_handler, // 0x36
  76. { "TOSERVER_PLAYERITEM", TOSERVER_STATE_INGAME, &Server::handleCommand_PlayerItem }, // 0x37
  77. { "TOSERVER_RESPAWN", TOSERVER_STATE_INGAME, &Server::handleCommand_Respawn }, // 0x38
  78. { "TOSERVER_INTERACT", TOSERVER_STATE_INGAME, &Server::handleCommand_Interact }, // 0x39
  79. { "TOSERVER_REMOVED_SOUNDS", TOSERVER_STATE_INGAME, &Server::handleCommand_RemovedSounds }, // 0x3a
  80. { "TOSERVER_NODEMETA_FIELDS", TOSERVER_STATE_INGAME, &Server::handleCommand_NodeMetaFields }, // 0x3b
  81. { "TOSERVER_INVENTORY_FIELDS", TOSERVER_STATE_INGAME, &Server::handleCommand_InventoryFields }, // 0x3c
  82. null_command_handler, // 0x3d
  83. null_command_handler, // 0x3e
  84. null_command_handler, // 0x3f
  85. { "TOSERVER_REQUEST_MEDIA", TOSERVER_STATE_STARTUP, &Server::handleCommand_RequestMedia }, // 0x40
  86. null_command_handler, // 0x41
  87. null_command_handler, // 0x42
  88. { "TOSERVER_CLIENT_READY", TOSERVER_STATE_STARTUP, &Server::handleCommand_ClientReady }, // 0x43
  89. null_command_handler, // 0x44
  90. null_command_handler, // 0x45
  91. null_command_handler, // 0x46
  92. null_command_handler, // 0x47
  93. null_command_handler, // 0x48
  94. null_command_handler, // 0x49
  95. null_command_handler, // 0x4a
  96. null_command_handler, // 0x4b
  97. null_command_handler, // 0x4c
  98. null_command_handler, // 0x4d
  99. null_command_handler, // 0x4e
  100. null_command_handler, // 0x4f
  101. { "TOSERVER_FIRST_SRP", TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_FirstSrp }, // 0x50
  102. { "TOSERVER_SRP_BYTES_A", TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_SrpBytesA }, // 0x51
  103. { "TOSERVER_SRP_BYTES_M", TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_SrpBytesM }, // 0x52
  104. };
  105. const static ClientCommandFactory null_command_factory = { "TOCLIENT_NULL", 0, false };
  106. const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
  107. {
  108. null_command_factory, // 0x00
  109. null_command_factory, // 0x01
  110. { "TOCLIENT_HELLO", 0, true }, // 0x02
  111. { "TOCLIENT_AUTH_ACCEPT", 0, true }, // 0x03
  112. { "TOCLIENT_ACCEPT_SUDO_MODE", 0, true }, // 0x04
  113. { "TOCLIENT_DENY_SUDO_MODE", 0, true }, // 0x05
  114. null_command_factory, // 0x06
  115. null_command_factory, // 0x07
  116. null_command_factory, // 0x08
  117. null_command_factory, // 0x09
  118. { "TOCLIENT_ACCESS_DENIED", 0, true }, // 0x0A
  119. null_command_factory, // 0x0B
  120. null_command_factory, // 0x0C
  121. null_command_factory, // 0x0D
  122. null_command_factory, // 0x0E
  123. null_command_factory, // 0x0F
  124. { "TOCLIENT_INIT", 0, true }, // 0x10
  125. null_command_factory,
  126. null_command_factory,
  127. null_command_factory,
  128. null_command_factory,
  129. null_command_factory,
  130. null_command_factory,
  131. null_command_factory,
  132. null_command_factory,
  133. null_command_factory,
  134. null_command_factory,
  135. null_command_factory,
  136. null_command_factory,
  137. null_command_factory,
  138. null_command_factory,
  139. null_command_factory,
  140. { "TOCLIENT_BLOCKDATA", 2, true }, // 0x20
  141. { "TOCLIENT_ADDNODE", 0, true }, // 0x21
  142. { "TOCLIENT_REMOVENODE", 0, true }, // 0x22
  143. null_command_factory,
  144. null_command_factory,
  145. null_command_factory,
  146. null_command_factory,
  147. { "TOCLIENT_INVENTORY", 0, true }, // 0x27
  148. null_command_factory,
  149. { "TOCLIENT_TIME_OF_DAY", 0, true }, // 0x29
  150. { "TOCLIENT_CSM_FLAVOUR_LIMITS", 0, true }, // 0x2A
  151. null_command_factory,
  152. null_command_factory,
  153. null_command_factory,
  154. null_command_factory,
  155. { "TOCLIENT_CHAT_MESSAGE", 0, true }, // 0x2F
  156. null_command_factory, // 0x30
  157. { "TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD", 0, true }, // 0x31
  158. { "TOCLIENT_ACTIVE_OBJECT_MESSAGES", 0, true }, // 0x32 Special packet, sent by 0 (rel) and 1 (unrel) channel
  159. { "TOCLIENT_HP", 0, true }, // 0x33
  160. { "TOCLIENT_MOVE_PLAYER", 0, true }, // 0x34
  161. { "TOCLIENT_ACCESS_DENIED_LEGACY", 0, true }, // 0x35
  162. null_command_factory, // 0x36
  163. { "TOCLIENT_DEATHSCREEN", 0, true }, // 0x37
  164. { "TOCLIENT_MEDIA", 2, true }, // 0x38
  165. null_command_factory, // 0x39
  166. { "TOCLIENT_NODEDEF", 0, true }, // 0x3a
  167. null_command_factory, // 0x3b
  168. { "TOCLIENT_ANNOUNCE_MEDIA", 0, true }, // 0x3c
  169. { "TOCLIENT_ITEMDEF", 0, true }, // 0x3d
  170. null_command_factory,
  171. { "TOCLIENT_PLAY_SOUND", 0, true }, // 0x3f
  172. { "TOCLIENT_STOP_SOUND", 0, true }, // 0x40
  173. { "TOCLIENT_PRIVILEGES", 0, true }, // 0x41
  174. { "TOCLIENT_INVENTORY_FORMSPEC", 0, true }, // 0x42
  175. { "TOCLIENT_DETACHED_INVENTORY", 0, true }, // 0x43
  176. { "TOCLIENT_SHOW_FORMSPEC", 0, true }, // 0x44
  177. { "TOCLIENT_MOVEMENT", 0, true }, // 0x45
  178. { "TOCLIENT_SPAWN_PARTICLE", 0, true }, // 0x46
  179. { "TOCLIENT_ADD_PARTICLESPAWNER", 0, true }, // 0x47
  180. null_command_factory, // 0x48
  181. { "TOCLIENT_HUDADD", 1, true }, // 0x49
  182. { "TOCLIENT_HUDRM", 1, true }, // 0x4a
  183. { "TOCLIENT_HUDCHANGE", 0, true }, // 0x4b
  184. { "TOCLIENT_HUD_SET_FLAGS", 0, true }, // 0x4c
  185. { "TOCLIENT_HUD_SET_PARAM", 0, true }, // 0x4d
  186. { "TOCLIENT_BREATH", 0, true }, // 0x4e
  187. { "TOCLIENT_SET_SKY", 0, true }, // 0x4f
  188. { "TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO", 0, true }, // 0x50
  189. { "TOCLIENT_LOCAL_PLAYER_ANIMATIONS", 0, true }, // 0x51
  190. { "TOCLIENT_EYE_OFFSET", 0, true }, // 0x52
  191. { "TOCLIENT_DELETE_PARTICLESPAWNER", 0, true }, // 0x53
  192. { "TOCLIENT_CLOUD_PARAMS", 0, true }, // 0x54
  193. { "TOCLIENT_FADE_SOUND", 0, true }, // 0x55
  194. { "TOCLIENT_UPDATE_PLAYER_LIST", 0, true }, // 0x56
  195. { "TOCLIENT_MODCHANNEL_MSG", 0, true}, // 0x57
  196. { "TOCLIENT_MODCHANNEL_SIGNAL", 0, true}, // 0x58
  197. null_command_factory,
  198. null_command_factory,
  199. null_command_factory,
  200. null_command_factory,
  201. null_command_factory,
  202. null_command_factory,
  203. null_command_factory,
  204. { "TOSERVER_SRP_BYTES_S_B", 0, true }, // 0x60
  205. { "TOCLIENT_FORMSPEC_PREPEND", 0, true }, // 0x61
  206. };