_impl1.inc 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. #undef _inc__impl1
  119. #if defined _YSIM_RESET_USER
  120. #undef _YSIM_RESET_USER
  121. //#if !defined _YSIM_MANUAL_SET
  122. // #endinput
  123. //#endif
  124. //#define MASTER _YSIM_LAST_MANUAL
  125. #define _YSIM_OVERRIDE _YSIM_LAST_MANUAL
  126. #include "_override"
  127. #elseif defined MASTER
  128. #if !defined _YSIM_MANUAL_SET
  129. #define _YSIM_MANUAL_SET
  130. #endif
  131. #if defined _YSIM_LAST_MANUAL
  132. #undef _YSIM_LAST_MANUAL
  133. #endif
  134. #if MASTER == 0
  135. #define _YSIM_LAST_MANUAL 0
  136. // This master was already included, the user just didn't realise.
  137. /*#if defined _YSIM_FAKE_MANUAL_SET
  138. #define _YSIM_OVERRIDE 0
  139. #define YSIM_STORED_SETTINGS 0
  140. #undef _YSIM_FAKE_MANUAL_SET
  141. #endif*/
  142. #elseif MASTER == 1
  143. #define _YSIM_LAST_MANUAL 1
  144. #elseif MASTER == 2
  145. #define _YSIM_LAST_MANUAL 2
  146. #elseif MASTER == 3
  147. #define _YSIM_LAST_MANUAL 3
  148. #elseif MASTER == 4
  149. #define _YSIM_LAST_MANUAL 4
  150. #elseif MASTER == 5
  151. #define _YSIM_LAST_MANUAL 5
  152. #elseif MASTER == 6
  153. #define _YSIM_LAST_MANUAL 6
  154. #elseif MASTER == 7
  155. #define _YSIM_LAST_MANUAL 7
  156. #elseif MASTER == 8
  157. #define _YSIM_LAST_MANUAL 8
  158. #elseif MASTER == 9
  159. #define _YSIM_LAST_MANUAL 9
  160. #elseif MASTER == 10
  161. #define _YSIM_LAST_MANUAL 10
  162. #elseif MASTER == 11
  163. #define _YSIM_LAST_MANUAL 11
  164. #elseif MASTER == 12
  165. #define _YSIM_LAST_MANUAL 12
  166. #elseif MASTER == 13
  167. #define _YSIM_LAST_MANUAL 13
  168. #elseif MASTER == 14
  169. #define _YSIM_LAST_MANUAL 14
  170. #elseif MASTER == 15
  171. #define _YSIM_LAST_MANUAL 15
  172. #elseif MASTER == 16
  173. #define _YSIM_LAST_MANUAL 16
  174. #elseif MASTER == 17
  175. #define _YSIM_LAST_MANUAL 17
  176. #elseif MASTER == 18
  177. #define _YSIM_LAST_MANUAL 18
  178. #elseif MASTER == 19
  179. #define _YSIM_LAST_MANUAL 19
  180. #elseif MASTER == 20
  181. #define _YSIM_LAST_MANUAL 20
  182. #elseif MASTER == 21
  183. #define _YSIM_LAST_MANUAL 21
  184. #elseif MASTER == 22
  185. #define _YSIM_LAST_MANUAL 22
  186. #elseif MASTER == 23
  187. #define _YSIM_LAST_MANUAL 23
  188. #elseif MASTER == 24
  189. #define _YSIM_LAST_MANUAL 24
  190. #elseif MASTER == 25
  191. #define _YSIM_LAST_MANUAL 25
  192. #endif
  193. #else
  194. //#define YSIM_STORED_SETTINGS YSIM_RECALL_19
  195. //#define _YSIM_AUTODEF
  196. #if defined _YSIM_OVERRIDE
  197. #include "_override"
  198. #if !defined MASTER
  199. #error _YSIM_OVERRIDE used with an invalid master value.
  200. #endif
  201. #else
  202. #tryinclude "_auto"
  203. #if !defined MASTER
  204. //#error "You must define a unique MASTER number from 0 to 25."
  205. #if defined LIBRARY_MASTER
  206. #define MASTER LIBRARY_MASTER
  207. #if defined _YSIM_LAST_LIBRARY_MASTER
  208. #if LIBRARY_MASTER == _YSIM_LAST_LIBRARY_MASTER
  209. // Not a stub.
  210. #if defined YSIM_U_ENABLE
  211. #undef YSIM_U_ENABLE
  212. #endif
  213. #if !defined YSIM_U_DISABLE
  214. #define YSIM_U_DISABLE
  215. #endif
  216. #define YSIM_LIBRARY_OVERRIDE
  217. #else//if !defined YSIM_CORE_LIBRARY
  218. // A stub.
  219. #if !defined YSIM_U_ENABLE
  220. #define YSIM_U_ENABLE
  221. #endif
  222. #if defined YSIM_U_DISABLE
  223. #undef YSIM_U_DISABLE
  224. #endif
  225. #endif
  226. #else
  227. // A stub.
  228. #if !defined YSIM_U_ENABLE
  229. #define YSIM_U_ENABLE
  230. #endif
  231. #if defined YSIM_U_DISABLE
  232. #undef YSIM_U_DISABLE
  233. #endif
  234. #endif
  235. #elseif defined _YSIM_LAST_MANUAL
  236. #define _YSIM_OVERRIDE _YSIM_LAST_MANUAL
  237. #include "_override"
  238. #else
  239. // Default for user scripts.
  240. #define MASTER 23
  241. #if defined _YSIM_LAST_MANUAL
  242. #undef _YSIM_LAST_MANUAL
  243. #endif
  244. #define _YSIM_LAST_MANUAL 23
  245. #if !defined _YSIM_MANUAL_SET
  246. #define _YSIM_MANUAL_SET
  247. #endif
  248. #endif
  249. // Detect reinclusions.
  250. /*#if defined _YSIM_FAKE_MANUAL_SET
  251. #define _YSIM_OVERRIDE 0
  252. #define YSIM_STORED_SETTINGS 0
  253. #undef _YSIM_FAKE_MANUAL_SET
  254. #endif*/
  255. #endif
  256. #endif
  257. #endif
  258. #if MASTER > 25 || MASTER < 0
  259. // There are some secret ones reserved purely for YSI! <- Wait, what?
  260. //#if !defined _YSIM_USED_AUTO || MASTER > 42
  261. //#if !defined _YSIM_OVERRIDE
  262. #error Invalid MASTER value, must be between 0 and 25 (inclusive).
  263. //#endif
  264. #endif
  265. #if defined YSIM_HAS_MASTER
  266. #undef YSIM_HAS_MASTER
  267. #endif
  268. #if defined _YSIM_IS_CLIENT
  269. #undef _YSIM_IS_CLIENT
  270. #endif
  271. #if defined _YSIM_IS_SERVER
  272. #undef _YSIM_IS_SERVER
  273. #endif
  274. #if defined _YSIM_IS_STUB
  275. #undef _YSIM_IS_STUB
  276. #endif
  277. #if defined _YSIM_IS_CLOUD
  278. #undef _YSIM_IS_CLOUD
  279. #endif
  280. //#if defined YSIM_NOT_CLIENT
  281. // #undef YSIM_NOT_CLIENT
  282. //#endif
  283. #if defined _YSIM_OVERRIDE
  284. // Get stored settings for YSI libraries. This allows the group system to
  285. // use the same master settings as another library without being there at
  286. // the time.
  287. #if YSIM_STORED_SETTINGS == 0
  288. #define YSIM_HAS_MASTER 0
  289. #else
  290. #define YSIM_HAS_MASTER 1
  291. #endif
  292. #if YSIM_STORED_SETTINGS == 1
  293. #define _YSIM_IS_CLIENT 1
  294. #else
  295. #define _YSIM_IS_CLIENT 0
  296. #endif
  297. #if YSIM_STORED_SETTINGS == 2
  298. #define _YSIM_IS_SERVER 1
  299. #else
  300. #define _YSIM_IS_SERVER 0
  301. #endif
  302. #if YSIM_STORED_SETTINGS == 3
  303. #define _YSIM_IS_CLOUD 1
  304. #else
  305. #define _YSIM_IS_CLOUD 0
  306. #endif
  307. #if YSIM_STORED_SETTINGS == 4
  308. #define _YSIM_IS_STUB 1
  309. #else
  310. #define _YSIM_IS_STUB 0
  311. #endif
  312. #else
  313. // This section of code just got a lot more complicated given that you may
  314. // want to define "YSI_IS_STUB" for custom libraries AND "YSI_IS_OTHER" for
  315. // YSI libraries to default to when not stubs.
  316. #include "_resolve"
  317. // Can't have a global stub (it makes no sense as all the YSI code exists).
  318. /*#if defined YSI_IS_STUB
  319. #error Cannot have a global stub, use YSIM_U_ENABLE.
  320. #endif
  321. #if defined YSIM_U_ENABLE && !defined YSIM_U_DISABLE
  322. #define _YSIM_IS_STUB 1
  323. #else
  324. #define _YSIM_IS_STUB 0
  325. #endif*/
  326. #endif