1
0

y_master.inc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /* *
  2. * *
  3. * _____ ______ ______ ____ ______ _ ______ __ ______ ____ _____ *
  4. * / ____| ____| ____| | _ \| ____| | / __ \ \ / / | ____/ __ \| __ \ *
  5. * | (___ | |__ | |__ | |_) | |__ | | | | | \ \ /\ / / | |__ | | | | |__) | *
  6. * \___ \| __| | __| | _ <| __| | | | | | |\ \/ \/ / | __|| | | | _ / *
  7. * ____) | |____| |____ | |_) | |____| |___| |__| | \ /\ / | | | |__| | | \ \ *
  8. * |_____/|______|______| |____/|______|______\____/ \/ \/ |_| \____/|_| \_\ *
  9. * *
  10. * _____ ____ _____ _ _ __ __ ______ _ _ _______ _______ _____ ____ _ _ *
  11. * | __ \ / __ \ / ____| | | | \/ | ____| \ | |__ __|/\|__ __|_ _/ __ \| \ | | *
  12. * | | | | | | | | | | | | \ / | |__ | \| | | | / \ | | | || | | | \| | *
  13. * | | | | | | | | | | | | |\/| | __| | . ` | | | / /\ \ | | | || | | | . ` | *
  14. * | |__| | |__| | |____| |__| | | | | |____| |\ | | |/ ____ \| | _| || |__| | |\ | *
  15. * |_____/ \____/ \_____|\____/|_| |_|______|_| \_| |_/_/ \_\_| |_____\____/|_| \_| *
  16. * *
  17. * This is required for technical reasons - to place it after `#endinput` to not generate *
  18. * multiple copies of it in XML when compiling with `-r`. *
  19. * *
  20. *//*
  21. Legal:
  22. Version: MPL 1.1
  23. The contents of this file are subject to the Mozilla Public License Version
  24. 1.1 the "License"; you may not use this file except in compliance with
  25. the License. You may obtain a copy of the License at
  26. http://www.mozilla.org/MPL/
  27. Software distributed under the License is distributed on an "AS IS" basis,
  28. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  29. for the specific language governing rights and limitations under the
  30. License.
  31. The Original Code is the YSI framework.
  32. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  33. Portions created by the Initial Developer are Copyright C 2011
  34. the Initial Developer. All Rights Reserved.
  35. Contributors:
  36. Y_Less
  37. koolk
  38. JoeBullet/Google63
  39. g_aSlice/Slice
  40. Misiur
  41. samphunter
  42. tianmeta
  43. maddinat0r
  44. spacemud
  45. Crayder
  46. Dayvison
  47. Ahmad45123
  48. Zeex
  49. irinel1996
  50. Yiin-
  51. Chaprnks
  52. Konstantinos
  53. Masterchen09
  54. Southclaws
  55. PatchwerkQWER
  56. m0k1
  57. paulommu
  58. udan111
  59. Thanks:
  60. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  61. ZeeX - Very productive conversations.
  62. koolk - IsPlayerinAreaEx code.
  63. TheAlpha - Danish translation.
  64. breadfish - German translation.
  65. Fireburn - Dutch translation.
  66. yom - French translation.
  67. 50p - Polish translation.
  68. Zamaroht - Spanish translation.
  69. Los - Portuguese translation.
  70. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  71. me to strive to better.
  72. Pixels^ - Running XScripters where the idea was born.
  73. Matite - Pestering me to release it and using it.
  74. Very special thanks to:
  75. Thiadmer - PAWN, whose limits continue to amaze me!
  76. Kye/Kalcor - SA:MP.
  77. SA:MP Team past, present and future - SA:MP.
  78. Optional plugins:
  79. Gamer_Z - GPS.
  80. Incognito - Streamer.
  81. Me - sscanf2, fixes2, Whirlpool.
  82. */
  83. #if !defined _INC_y_master
  84. #include "..\YSI_Internal\y_version"
  85. #include "y_debug"
  86. #include "..\YSI_Coding\y_hooks"
  87. #include "..\YSI_Internal\y_shortfunc"
  88. #include "..\YSI_Internal\y_natives"
  89. #include "y_master/once"
  90. #endif
  91. // ALWAYS! The compiler defines this automatically, don't use it as this is
  92. // included multiple times to handle multiple master systems.
  93. #if defined _inc_y_master
  94. #undef _inc_y_master
  95. #endif
  96. #if defined MASTER
  97. #if defined _MASTER
  98. // Store the last master.
  99. #include "y_master\_push_master"
  100. #endif
  101. #else
  102. // Get the previous master (or 0 by default).
  103. #include "y_master\_pop_master"
  104. // Useful debug information (isn't compiled, but shows up with "-l").
  105. P:C(static stock const _POPPED_MASTER = MASTER;);
  106. #endif
  107. #if MASTER < 0 || MASTER >= MAX_MASTERS
  108. #error Invalid MASTER ID.
  109. #endif
  110. #if defined _INC_y_master
  111. // Run at least once - clear previous data.
  112. #include "y_master\_cleanup"
  113. #endif
  114. // Initialise the current master if it hasn't already been done. This is split
  115. // in to 5 parts to reduce compilation times in the common case of not that many
  116. // master systems.
  117. #if MASTER < 16
  118. #include "y_master\_setup_master_A"
  119. #elseif MASTER < 32
  120. #include "y_master\_setup_master_B"
  121. #elseif MASTER < 48
  122. #include "y_master\_setup_master_C"
  123. #else
  124. #include "y_master\_setup_master_D"
  125. #endif
  126. #undef MASTER
  127. // Include all the correct macro versions for the settings we have just found.
  128. #include "y_master\_impl"
  129. #if defined _INC_y_master
  130. #endinput
  131. #endif
  132. #define _INC_y_master
  133. /**
  134. * <library name="y_master">
  135. * <section>
  136. * Description
  137. * </section>
  138. * Handles distribution of control of code segments across all running scripts
  139. * with YSI to avoid conflicts of checkpoint streamers etc and allow features
  140. * like "/commands" displaying all commands on the server.
  141. *
  142. * Now fully autonomous - to use the master system simply define which one you
  143. * want and include the script:
  144. *
  145. * <c>
  146. * #define MASTER 14
  147. * #include "Master"
  148. * </c>
  149. *
  150. * That will make the current script attempt to make itself the main master -
  151. * you don't need ANY other code for initialisation anywhere (which took a
  152. * while to figure out)...
  153. *
  154. * This is now over 2000 lines of repetitive and complex macros!
  155. * <section>
  156. * Version
  157. * </section>
  158. * 0.2
  159. * <section>
  160. * Macros
  161. * </section><ul>
  162. * <symbol name="RF">Declare a function which may be remote.</symbol>
  163. * <symbol name="RV">Declare a void function which may be remote.</symbol>
  164. * <symbol name="RS">Declare an optional callback.</symbol>
  165. * <symbol name="RFN">Declare an optional callback with no parameters.</symbol>
  166. * <symbol name="RFC">Declare a slower but shorter function.</symbol>
  167. * <symbol name="RFP">Declare a function with tags and give recall hints.</symbol>
  168. * <symbol name="RFPC">Combination of P and C.</symbol>
  169. * <symbol name="RFCP">Combination of P and C.</symbol>
  170. * </ul><section>
  171. * Variables
  172. * </section>
  173. * <subsection>
  174. * Global
  175. * </subsection><ul>
  176. * <symbol name="_@">ID of this script.</symbol>
  177. * </ul><section>Compile options</section><ul>
  178. * <symbol name="YSI_NO_MASTER">Don't use the master system.</symbol>
  179. * <symbol name="YSI_IS_CLIENT">Script is a client only script.</symbol>
  180. * <symbol name="YSI_IS_SERVER">Script is a server only script.</symbol>
  181. * </ul>
  182. * </library>
  183. *//** */
  184. // Only include this lot once.
  185. #if defined YSI_TESTS
  186. #include "..\YSI_Core\y_testing"
  187. // Get the new master.
  188. #define MASTER 58
  189. #include "y_master"
  190. // Include the tests.
  191. #include "y_master/tests"
  192. // Pop the master.
  193. #include "y_master"
  194. #endif