1
0

y_commands.inc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. #if defined _INC_y_commands
  2. #endinput
  3. #endif
  4. #define _INC_y_commands
  5. /**
  6. * <library name="y_commands">
  7. * <section>
  8. * Description
  9. * </section>
  10. * Runs commands registered with the system and calls the required functions.
  11. * Also handles alternate names and prefixes. Based very loosely on dcmd.
  12. * <section>
  13. * Version
  14. * </section>
  15. * 0.1.4
  16. * <section>
  17. * Functions
  18. * </section>
  19. * <subsection>
  20. * Public
  21. * </subsection><ul>
  22. * <symbol name="Command_Add">Adds a command to the array for processing.</symbol>
  23. * <symbol name="Command_Remove">Removes a command.</symbol>
  24. * <symbol name="Command_Name">Gets the name of a command in a property.</symbol>
  25. * </ul><subsection>
  26. * Core
  27. * </subsection><ul>
  28. * <symbol name="Command_Process">Called from OnPlayerCommandText to process entered commands.</symbol>
  29. * <symbol name="Command_Parse">Sorts added commands into a binary tree.</symbol>
  30. * <symbol name="Command_Hash">Hashes a word for command hashing.</symbol>
  31. * <symbol name="Command_ProcRem">Processes a help command in the master script.</symbol>
  32. * </ul><subsection>
  33. * Stock
  34. * </subsection><ul>
  35. * <symbol name="Command_SetDisconnectReturn">Sets the return value for unconnected players.</symbol>
  36. * <symbol name="Command_UseShortCuts">Toggles use of per-player command shortcuts.</symbol>
  37. * <symbol name="Command_SetDeniedReturn">Sets the return value for denied use commands.</symbol>
  38. * <symbol name="Command_UseDeniedMessage">Toggles the use of an error message for denied.</symbol>
  39. * <symbol name="Command_SetIllegalReturn">Sets the return value for illegal characters.</symbol>
  40. * <symbol name="Command_UseAltNames">Toggles the use of ini defined alternate names.</symbol>
  41. * <symbol name="Command_UsePrefix">Toggles the use of a global prefix.</symbol>
  42. * <symbol name="Command_UseSpace">Toggles the use of a space between prefix and command.</symbol>
  43. * <symbol name="Command_SetAltName">Sets the alternate name of a function.</symbol>
  44. * <symbol name="Command_SetPrefix">Sets the pfexix to be typed.</symbol>
  45. * <symbol name="Comamnd_SetPlayerUse">Sets wether or not a player can use a command.</symbol>
  46. * <symbol name="Comamnd_SetPlayerUseByID">Sets wether or not a player can use a command.</symbol>
  47. * <symbol name="Command_FindByName">Finds a command in a possibly sorted list.</symbol>
  48. * </ul><section>
  49. * Definitions
  50. * </section><ul>
  51. * <symbol name="MAX_COMMAND_LENGTH">The maximum length of a command string.</symbol>
  52. * <symbol name="COMMAND_NOT_FOUND">Indicates that a searched for string is not a function.</symbol>
  53. * </ul><section>
  54. * Enums
  55. * </section><ul>
  56. * <symbol name="e_COMM_FLAG">Bit mappings for command options.</symbol>
  57. * <symbol name="E_COMMANDS">Structure of the array holding the string data.</symbol>
  58. * </ul><section>
  59. * Macros
  60. * </section><ul>
  61. * <symbol name="Command_(%1)">Forwards and declares a standard command for calling.</symbol>
  62. * <symbol name="ycmd(%1)">Adds a command to the array (wrapper for Command_Add).</symbol>
  63. * </ul><section>
  64. * Tags
  65. * </section><ul>
  66. * <symbol name="e_COMM_FLAG">Flag type.</symbol>
  67. * </ul><section>
  68. * Variables
  69. * </section>
  70. * <subsection>
  71. * Static
  72. * </subsection><ul>
  73. * <symbol name="YSI_g_sCommands">Holds all the textual data of the commands.</symbol>
  74. * <symbol name="YSI_g_sSearchTree">Tree of hashes for function names.</symbol>
  75. * <symbol name="YSI_g_sAltTree">Tree of hashes for alternate names.</symbol>
  76. * <symbol name="YSI_g_sPrefix">The command prefix.</symbol>
  77. * <symbol name="YSI_g_sPrefixLength">Length of the prefix.</symbol>
  78. * <symbol name="YSI_g_sCommandIndex">Pointer to the next free index in the function array.</symbol>
  79. * <symbol name="YSI_g_sAltCount">The number of commands with altnames.</symbol>
  80. * <symbol name="YSI_g_sCommandFlags">Bit array of command options.</symbol>
  81. * </ul><section>
  82. * Commands
  83. * </section><ul>
  84. * <symbol name="commands">Lists all commands available to you.</symbol>
  85. * </ul><section>Compile options</section><ul>
  86. * <symbol name="COMMAND_SENSITIVE">Make commands case sensitive.</symbol>
  87. * <symbol name="COMMAND_ACCURATE">Can use '@' in command names.</symbol>
  88. * <symbol name="MAX_COMMANDS">The maximum number of commands which can be used.</symbol>
  89. * </ul>
  90. * </library>
  91. *//** *//*
  92. Legal:
  93. Version: MPL 1.1
  94. The contents of this file are subject to the Mozilla Public License Version
  95. 1.1 the "License"; you may not use this file except in compliance with
  96. the License. You may obtain a copy of the License at
  97. http://www.mozilla.org/MPL/
  98. Software distributed under the License is distributed on an "AS IS" basis,
  99. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  100. for the specific language governing rights and limitations under the
  101. License.
  102. The Original Code is the YSI framework.
  103. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  104. Portions created by the Initial Developer are Copyright C 2011
  105. the Initial Developer. All Rights Reserved.
  106. Contributors:
  107. Y_Less
  108. koolk
  109. JoeBullet/Google63
  110. g_aSlice/Slice
  111. Misiur
  112. samphunter
  113. tianmeta
  114. maddinat0r
  115. spacemud
  116. Crayder
  117. Dayvison
  118. Ahmad45123
  119. Zeex
  120. irinel1996
  121. Yiin-
  122. Chaprnks
  123. Konstantinos
  124. Masterchen09
  125. Southclaws
  126. PatchwerkQWER
  127. m0k1
  128. paulommu
  129. udan111
  130. Thanks:
  131. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  132. ZeeX - Very productive conversations.
  133. koolk - IsPlayerinAreaEx code.
  134. TheAlpha - Danish translation.
  135. breadfish - German translation.
  136. Fireburn - Dutch translation.
  137. yom - French translation.
  138. 50p - Polish translation.
  139. Zamaroht - Spanish translation.
  140. Los - Portuguese translation.
  141. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  142. me to strive to better.
  143. Pixels^ - Running XScripters where the idea was born.
  144. Matite - Pestering me to release it and using it.
  145. Very special thanks to:
  146. Thiadmer - PAWN, whose limits continue to amaze me!
  147. Kye/Kalcor - SA:MP.
  148. SA:MP Team past, present and future - SA:MP.
  149. Optional plugins:
  150. Gamer_Z - GPS.
  151. Incognito - Streamer.
  152. Me - sscanf2, fixes2, Whirlpool.
  153. */
  154. #include "..\YSI_Internal\y_compilerdata"
  155. #include "..\YSI_Internal\y_version"
  156. #define MAX_COMMAND_LENGTH (32)
  157. #define COMMAND_NOT_FOUND (-1)
  158. #if !defined MAX_COMMANDS
  159. #define MAX_COMMANDS (512)
  160. #endif
  161. // Set commands as master 25.
  162. #define MASTER 63
  163. #define YSIM_U_DISABLE
  164. #include "..\YSI_Core\y_master"
  165. // Misc includes.
  166. #include "..\YSI_Storage\y_amx"
  167. #include "..\YSI_Data\y_hashmap"
  168. #include "..\YSI_Data\y_iterate"
  169. #include "..\YSI_Coding\y_hooks"
  170. #include "..\YSI_Data\y_playerarray"
  171. #include "..\YSI_Server\y_punycode"
  172. #include "..\YSI_Internal\y_distribute"
  173. // Include the group functions (maybe).
  174. #define _GROUP_MAKE_NAME<%0...%1> %0Command%1
  175. #define _GROUP_MAKE_LIMIT MAX_COMMANDS
  176. #include "..\YSI_Players\y_groups\_funcs"
  177. #if defined YSI_TESTS
  178. #if !defined Y_COMMANDS_NO_IPC
  179. #define Y_COMMANDS_NO_IPC
  180. #endif
  181. #endif
  182. // Include the main implementation.
  183. #include "y_commands/impl"
  184. #if defined YSI_TESTS
  185. #include "..\YSI_Core\y_testing"
  186. #include "y_commands/tests"
  187. #endif
  188. // Restore previous settings.
  189. #undef _GROUP_MAKE_LIMIT
  190. #undef _GROUP_MAKE_NAME
  191. #include "..\YSI_Core\y_master"