y_master.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /**--------------------------------------------------------------------------**\
  2. ======================
  3. YSI - Master Include
  4. ======================
  5. Description:
  6. Handles distribution of control of code segments across all running scripts
  7. with YSI to avoid conflicts of checkpoint streamers etc and allow features
  8. like "/commands" displaying all commands on the server.
  9. Now fully autonomous - to use the master system simply define which one you
  10. want and include the script:
  11. #define MASTER 14
  12. #include "Master"
  13. That will make the current script attempt to make itself the main master -
  14. you don't need ANY other code for initialisation anywhere (which took a
  15. while to figure out)...
  16. This is now over 2000 lines of repetitive and complex macros!
  17. Legal:
  18. Version: MPL 1.1
  19. The contents of this file are subject to the Mozilla Public License Version
  20. 1.1 (the "License"); you may not use this file except in compliance with
  21. the License. You may obtain a copy of the License at
  22. http://www.mozilla.org/MPL/
  23. Software distributed under the License is distributed on an "AS IS" basis,
  24. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  25. for the specific language governing rights and limitations under the
  26. License.
  27. The Original Code is the YSI master systems include.
  28. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  29. Portions created by the Initial Developer are Copyright (C) 2011
  30. the Initial Developer. All Rights Reserved.
  31. Contributors:
  32. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  33. Thanks:
  34. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  35. ZeeX - Very productive conversations.
  36. koolk - IsPlayerinAreaEx code.
  37. TheAlpha - Danish translation.
  38. breadfish - German translation.
  39. Fireburn - Dutch translation.
  40. yom - French translation.
  41. 50p - Polish translation.
  42. Zamaroht - Spanish translation.
  43. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  44. for me to strive to better.
  45. Pixels^ - Running XScripters where the idea was born.
  46. Matite - Pestering me to release it and using it.
  47. Very special thanks to:
  48. Thiadmer - PAWN, whose limits continue to amaze me!
  49. Kye/Kalcor - SA:MP.
  50. SA:MP Team past, present and future - SA:MP.
  51. Version:
  52. 0.2
  53. Changelog:
  54. 06/08/10:
  55. Managed the ultimate - got completely transparent inclusion!
  56. 05/08/10:
  57. Completed new master system, now does all syncing and clients.
  58. 06/10/09:
  59. Rewrote using states.
  60. Added remote function macros.
  61. Reduced the number of masters to a single one. It must have them all.
  62. Vastly simplified the master model - ending the master ends everything.
  63. 06/01/08:
  64. Added code to not pass data if no other script exists.
  65. 17/11/07:
  66. Added code for a script to remove itself from the global list.
  67. 11/10/07:
  68. Not first version but added documentation months late.
  69. Functions:
  70. Public:
  71. -
  72. Core:
  73. -
  74. Stock:
  75. -
  76. Static:
  77. -
  78. Inline:
  79. -
  80. API:
  81. -
  82. Hooks:
  83. -
  84. Callbacks:
  85. -
  86. Definitions:
  87. -
  88. Enums:
  89. -
  90. Macros:
  91. RF - Declare a function which may be remote.
  92. RV - Declare a void function which may be remote.
  93. RS - Declare an optional callback.
  94. RFN - Declare an optional callback with no parameters.
  95. RFC - Declare a slower but shorter function.
  96. RFP - Declare a function with tags and give recall hints.
  97. RFPC - Combination of P and C.
  98. RFCP - Combination of P and C.
  99. Tags:
  100. -
  101. Variables:
  102. Global:
  103. _@ - ID of this script.
  104. Static:
  105. -
  106. Commands:
  107. -
  108. Compile options:
  109. YSI_NO_MASTER - Don't use the master system.
  110. YSI_IS_CLIENT - Script is a client only script.
  111. YSI_IS_SERVER - Script is a server only script.
  112. Operators:
  113. -
  114. Natives:
  115. -
  116. </remarks>
  117. \**--------------------------------------------------------------------------**/
  118. // ALWAYS! The compiler defines this automatically, don't use it as this is
  119. // included multiple times to handle multiple master systems.
  120. #if !defined _inc_y_master
  121. #error Did you do <YSI/y_master> instead of the required <YSI\y_master>?
  122. #endif
  123. #undef _inc_y_master
  124. #if !defined _INC_y_master
  125. // Only do these once.
  126. #include "internal\y_version"
  127. #include "y_debug"
  128. // Don't do this at all - if they want to use hooks they need to include it.
  129. //#include "y_hooks"
  130. #include "internal\y_natives"
  131. #define _INC_y_master
  132. // Determine a master ID for the tests.
  133. #if defined YSI_TESTS
  134. // The used defined their own master first time including this file, yet
  135. // we need to define two of our own (y_testing and y_master tests). So
  136. // include y_master once to store the user settings, then include it
  137. // twice more (once via including "y_testing" - possibly, not currently)
  138. // to set up all the internal masters. Finally, reset to the user's
  139. // data and run normally.
  140. #if defined MASTER
  141. // Set the last master data.
  142. #include "y_master\_impl1"
  143. #if defined _Y_MASTER_ONCE
  144. #include "y_master\_cleanup"
  145. #endif
  146. #include "y_utils"
  147. #include "y_master/once"
  148. #include "y_master\_impl2"
  149. #define _Y_MASTER_TESTS_OVERRIDE
  150. #endif
  151. // Include y_testing, with the option to have a master for that.
  152. #include "y_testing"
  153. #define _MASTER_TEST_ID
  154. #include "y_master\_impl1"
  155. #if defined _Y_MASTER_ONCE
  156. // Been included at least once, clean up from before.
  157. #include "y_master\_cleanup"
  158. #endif
  159. // Included only once - generate setup code.
  160. #include "y_utils"
  161. #include "y_master/once"
  162. // Set macros based on current MASTER ID.
  163. #include "y_master\_impl2"
  164. #include "y_master/tests"
  165. #if defined _Y_MASTER_TESTS_OVERRIDE
  166. #define _YSIM_RESET_USER
  167. #undef _Y_MASTER_TESTS_OVERRIDE
  168. #endif
  169. #endif
  170. #endif
  171. //#error
  172. // Determine the current MASTER ID.
  173. #if defined _YSIM_RESET_USER && !defined _YSIM_MANUAL_SET
  174. #endinput
  175. #endif
  176. #include "y_master\_impl1"
  177. #if defined _Y_MASTER_ONCE
  178. // Been included at least once, clean up from before.
  179. #include "y_master\_cleanup"
  180. #endif
  181. // Included only once - generate setup code.
  182. #include "y_utils"
  183. #include "y_master/once"
  184. // Set macros based on current MASTER ID.
  185. #include "y_master\_impl2"