y_master.inc 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767
  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. \*----------------------------------------------------------------------------*/
  117. #if !defined _INC_y_master
  118. // Only do these once.
  119. #include "internal\y_version"
  120. #include "y_debug"
  121. // Don't do this at all - if they want to use hooks they need to include it.
  122. //#include "y_hooks"
  123. #include "internal\y_natives"
  124. #define _INC_y_master
  125. #endif
  126. // ALWAYS! The compiler defines this automatically, don't use it as this is
  127. // included multiple times to handle multiple master systems.
  128. #if !defined _inc_y_master
  129. #error Did you do <YSI/y_master> instead of the required <YSI\y_master>?
  130. #endif
  131. #undef _inc_y_master
  132. /*#if defined YSIM_STORED_SETTINGS
  133. #define _YSIM_OVERRIDE
  134. #endif*/
  135. #if defined _YSIM_RESET_USER
  136. #undef _YSIM_RESET_USER
  137. #if !defined _YSIM_MANUAL_SET
  138. #endinput
  139. #endif
  140. //#define MASTER _YSIM_LAST_MANUAL
  141. #define _YSIM_OVERRIDE _YSIM_LAST_MANUAL
  142. #include "internal\y_overridemaster"
  143. #elseif defined MASTER
  144. #if !defined _YSIM_MANUAL_SET
  145. #define _YSIM_MANUAL_SET
  146. #endif
  147. #if defined _YSIM_LAST_MANUAL
  148. #undef _YSIM_LAST_MANUAL
  149. #endif
  150. #if MASTER == 0
  151. #define _YSIM_LAST_MANUAL 0
  152. // This master was already included, the user just didn't realise.
  153. /*#if defined _YSIM_FAKE_MANUAL_SET
  154. #define _YSIM_OVERRIDE 0
  155. #define YSIM_STORED_SETTINGS 0
  156. #undef _YSIM_FAKE_MANUAL_SET
  157. #endif*/
  158. #elseif MASTER == 1
  159. #define _YSIM_LAST_MANUAL 1
  160. #elseif MASTER == 2
  161. #define _YSIM_LAST_MANUAL 2
  162. #elseif MASTER == 3
  163. #define _YSIM_LAST_MANUAL 3
  164. #elseif MASTER == 4
  165. #define _YSIM_LAST_MANUAL 4
  166. #elseif MASTER == 5
  167. #define _YSIM_LAST_MANUAL 5
  168. #elseif MASTER == 6
  169. #define _YSIM_LAST_MANUAL 6
  170. #elseif MASTER == 7
  171. #define _YSIM_LAST_MANUAL 7
  172. #elseif MASTER == 8
  173. #define _YSIM_LAST_MANUAL 8
  174. #elseif MASTER == 9
  175. #define _YSIM_LAST_MANUAL 9
  176. #elseif MASTER == 10
  177. #define _YSIM_LAST_MANUAL 10
  178. #elseif MASTER == 11
  179. #define _YSIM_LAST_MANUAL 11
  180. #elseif MASTER == 12
  181. #define _YSIM_LAST_MANUAL 12
  182. #elseif MASTER == 13
  183. #define _YSIM_LAST_MANUAL 13
  184. #elseif MASTER == 14
  185. #define _YSIM_LAST_MANUAL 14
  186. #elseif MASTER == 15
  187. #define _YSIM_LAST_MANUAL 15
  188. #elseif MASTER == 16
  189. #define _YSIM_LAST_MANUAL 16
  190. #elseif MASTER == 17
  191. #define _YSIM_LAST_MANUAL 17
  192. #elseif MASTER == 18
  193. #define _YSIM_LAST_MANUAL 18
  194. #elseif MASTER == 19
  195. #define _YSIM_LAST_MANUAL 19
  196. #elseif MASTER == 20
  197. #define _YSIM_LAST_MANUAL 20
  198. #elseif MASTER == 21
  199. #define _YSIM_LAST_MANUAL 21
  200. #elseif MASTER == 22
  201. #define _YSIM_LAST_MANUAL 22
  202. #elseif MASTER == 23
  203. #define _YSIM_LAST_MANUAL 23
  204. #elseif MASTER == 24
  205. #define _YSIM_LAST_MANUAL 24
  206. #elseif MASTER == 25
  207. #define _YSIM_LAST_MANUAL 25
  208. #endif
  209. #else
  210. //#define YSIM_STORED_SETTINGS YSIM_RECALL_19
  211. //#define _YSIM_AUTODEF
  212. #if defined _YSIM_OVERRIDE
  213. #include "internal\y_overridemaster"
  214. #if !defined MASTER
  215. #error _YSIM_OVERRIDE used with an invalid master value.
  216. #endif
  217. #else
  218. #tryinclude "internal\y_automasters"
  219. #if !defined MASTER
  220. //#error "You must define a unique MASTER number from 0 to 25."
  221. #if defined LIBRARY_MASTER
  222. #define MASTER LIBRARY_MASTER
  223. #if defined _YSIM_LAST_LIBRARY_MASTER
  224. #if LIBRARY_MASTER == _YSIM_LAST_LIBRARY_MASTER
  225. // Not a stub.
  226. #if defined YSIM_U_ENABLE
  227. #undef YSIM_U_ENABLE
  228. #endif
  229. #if !defined YSIM_U_DISABLE
  230. #define YSIM_U_DISABLE
  231. #endif
  232. #define YSIM_LIBRARY_OVERRIDE
  233. #else//if !defined YSIM_CORE_LIBRARY
  234. // A stub.
  235. #if !defined YSIM_U_ENABLE
  236. #define YSIM_U_ENABLE
  237. #endif
  238. #if defined YSIM_U_DISABLE
  239. #undef YSIM_U_DISABLE
  240. #endif
  241. #endif
  242. #else
  243. // A stub.
  244. #if !defined YSIM_U_ENABLE
  245. #define YSIM_U_ENABLE
  246. #endif
  247. #if defined YSIM_U_DISABLE
  248. #undef YSIM_U_DISABLE
  249. #endif
  250. #endif
  251. #elseif defined _YSIM_LAST_MANUAL
  252. #define _YSIM_OVERRIDE _YSIM_LAST_MANUAL
  253. #include "internal\y_overridemaster"
  254. #else
  255. // Default for user scripts.
  256. #define MASTER 23
  257. #if defined _YSIM_LAST_MANUAL
  258. #undef _YSIM_LAST_MANUAL
  259. #endif
  260. #define _YSIM_LAST_MANUAL 23
  261. #if !defined _YSIM_MANUAL_SET
  262. #define _YSIM_MANUAL_SET
  263. #endif
  264. #endif
  265. // Detect reinclusions.
  266. /*#if defined _YSIM_FAKE_MANUAL_SET
  267. #define _YSIM_OVERRIDE 0
  268. #define YSIM_STORED_SETTINGS 0
  269. #undef _YSIM_FAKE_MANUAL_SET
  270. #endif*/
  271. #endif
  272. #endif
  273. #endif
  274. #if MASTER > 25 || MASTER < 0
  275. // There are some secret ones reserved purely for YSI! <- Wait, what?
  276. //#if !defined _YSIM_USED_AUTO || MASTER > 42
  277. //#if !defined _YSIM_OVERRIDE
  278. #error Invalid MASTER value, must be between 0 and 25 (inclusive).
  279. //#endif
  280. #endif
  281. #if defined YSIM_HAS_MASTER
  282. #undef YSIM_HAS_MASTER
  283. #endif
  284. #if defined _YSIM_IS_CLIENT
  285. #undef _YSIM_IS_CLIENT
  286. #endif
  287. #if defined _YSIM_IS_SERVER
  288. #undef _YSIM_IS_SERVER
  289. #endif
  290. #if defined _YSIM_IS_STUB
  291. #undef _YSIM_IS_STUB
  292. #endif
  293. #if defined _YSIM_IS_CLOUD
  294. #undef _YSIM_IS_CLOUD
  295. #endif
  296. //#if defined YSIM_NOT_CLIENT
  297. // #undef YSIM_NOT_CLIENT
  298. //#endif
  299. #if defined _YSIM_OVERRIDE
  300. // Get stored settings for YSI libraries. This allows the group system to
  301. // use the same master settings as another library without being there at
  302. // the time.
  303. #if YSIM_STORED_SETTINGS == 0
  304. #define YSIM_HAS_MASTER 0
  305. #else
  306. #define YSIM_HAS_MASTER 1
  307. #endif
  308. #if YSIM_STORED_SETTINGS == 1
  309. #define _YSIM_IS_CLIENT 1
  310. #else
  311. #define _YSIM_IS_CLIENT 0
  312. #endif
  313. #if YSIM_STORED_SETTINGS == 2
  314. #define _YSIM_IS_SERVER 1
  315. #else
  316. #define _YSIM_IS_SERVER 0
  317. #endif
  318. #if YSIM_STORED_SETTINGS == 3
  319. #define _YSIM_IS_CLOUD 1
  320. #else
  321. #define _YSIM_IS_CLOUD 0
  322. #endif
  323. #if YSIM_STORED_SETTINGS == 4
  324. #define _YSIM_IS_STUB 1
  325. #else
  326. #define _YSIM_IS_STUB 0
  327. #endif
  328. #else
  329. // This section of code just got a lot more complicated given that you may
  330. // want to define "YSI_IS_STUB" for custom libraries AND "YSI_IS_OTHER" for
  331. // YSI libraries to default to when not stubs.
  332. #include "internal\y_masterresolve"
  333. // Can't have a global stub (it makes no sense as all the YSI code exists).
  334. /*#if defined YSI_IS_STUB
  335. #error Cannot have a global stub, use YSIM_U_ENABLE.
  336. #endif
  337. #if defined YSIM_U_ENABLE && !defined YSIM_U_DISABLE
  338. #define _YSIM_IS_STUB 1
  339. #else
  340. #define _YSIM_IS_STUB 0
  341. #endif*/
  342. #endif
  343. #if defined _inc_y_masteronce
  344. // Been included at least once, clean up from before.
  345. #undef RF
  346. #undef RF@p
  347. #undef RF@c
  348. #undef RF@v
  349. //#undef RF@n
  350. #undef RF@pc
  351. #undef RF@pv
  352. #undef RF@pcv
  353. #undef RF@vc
  354. #undef RF@t
  355. #undef RF@pt
  356. #undef RF@ct
  357. #undef RF@pct
  358. //#undef RF@vn
  359. // Remote string
  360. #undef RS
  361. #undef RS@p
  362. //#undef RS@c
  363. //#undef RS@cp
  364. // Remote calback
  365. //#undef RC
  366. //#undef RC@v
  367. // Remote hook
  368. #undef RH
  369. // Remote timer
  370. #undef RT
  371. // Remote private
  372. //#undef RP@v
  373. // Remote command
  374. #undef RC
  375. // Remote local
  376. //#undef RL
  377. // Remote text load
  378. //#undef RX
  379. // Remote ALS
  380. #undef RA
  381. //#undef RA@p
  382. //#undef RC@v
  383. //#undef RC@n
  384. //#undef RC@vn
  385. #undef Master_Caller
  386. // New hooks
  387. #undef master_hook
  388. #undef group_hook
  389. #undef foreign
  390. #undef global
  391. //#undef Master_Init
  392. #endif
  393. #include "y_utils"
  394. #include "internal\y_masteronce"
  395. // Clear up some artifacts
  396. #if defined YSIM_DEFINED
  397. #undef YSIM_DEFINED
  398. #endif
  399. #if defined _YCM
  400. #undef _YCM
  401. #undef _YCM@
  402. #endif
  403. // Now set the current script data.
  404. // IDIOT! These are mostly mutually exclusive! You don't need a horrible huge
  405. // bit array to store the fact that this is both a client AND a server!
  406. #if MASTER == 0
  407. #if defined _YCM_a@
  408. #define YSIM_DEFINED
  409. #else
  410. #define _YCM_a@
  411. // Save the settings.
  412. #if !YSIM_HAS_MASTER
  413. #define YSIM_RECALL_0 0
  414. #elseif _YSIM_IS_CLIENT
  415. #define YSIM_RECALL_0 1
  416. #elseif _YSIM_IS_SERVER
  417. #define YSIM_RECALL_0 2
  418. #elseif _YSIM_IS_CLOUD
  419. #define YSIM_RECALL_0 3
  420. #elseif _YSIM_IS_STUB
  421. #define YSIM_RECALL_0 4
  422. #else
  423. #error Undefined master type on 0
  424. #endif
  425. #endif
  426. #define _YCM a@
  427. #define _YCM@ _YCM_ga@
  428. #elseif MASTER == 1
  429. #if defined _YCM_b@
  430. #define YSIM_DEFINED
  431. #else
  432. #define _YCM_b@
  433. // Save the settings.
  434. #if !YSIM_HAS_MASTER
  435. #define YSIM_RECALL_1 0
  436. #elseif _YSIM_IS_CLIENT
  437. #define YSIM_RECALL_1 1
  438. #elseif _YSIM_IS_SERVER
  439. #define YSIM_RECALL_1 2
  440. #elseif _YSIM_IS_CLOUD
  441. #define YSIM_RECALL_1 3
  442. #elseif _YSIM_IS_STUB
  443. #define YSIM_RECALL_1 4
  444. #else
  445. #error Undefined master type on 1
  446. #endif
  447. #endif
  448. #define _YCM b@
  449. #define _YCM@ _YCM_gb@
  450. #elseif MASTER == 2
  451. #if defined _YCM_c@
  452. #define YSIM_DEFINED
  453. #else
  454. #define _YCM_c@
  455. // Save the settings.
  456. #if !YSIM_HAS_MASTER
  457. #define YSIM_RECALL_2 0
  458. #elseif _YSIM_IS_CLIENT
  459. #define YSIM_RECALL_2 1
  460. #elseif _YSIM_IS_SERVER
  461. #define YSIM_RECALL_2 2
  462. #elseif _YSIM_IS_CLOUD
  463. #define YSIM_RECALL_2 3
  464. #elseif _YSIM_IS_STUB
  465. #define YSIM_RECALL_2 4
  466. #else
  467. #error Undefined master type on 2
  468. #endif
  469. #endif
  470. #define _YCM c@
  471. #define _YCM@ _YCM_gc@
  472. #elseif MASTER == 3
  473. #if defined _YCM_d@
  474. #define YSIM_DEFINED
  475. #else
  476. #define _YCM_d@
  477. // Save the settings.
  478. #if !YSIM_HAS_MASTER
  479. #define YSIM_RECALL_3 0
  480. #elseif _YSIM_IS_CLIENT
  481. #define YSIM_RECALL_3 1
  482. #elseif _YSIM_IS_SERVER
  483. #define YSIM_RECALL_3 2
  484. #elseif _YSIM_IS_CLOUD
  485. #define YSIM_RECALL_3 3
  486. #elseif _YSIM_IS_STUB
  487. #define YSIM_RECALL_3 4
  488. #else
  489. #error Undefined master type on 3
  490. #endif
  491. #endif
  492. #define _YCM d@
  493. #define _YCM@ _YCM_gd@
  494. #elseif MASTER == 4
  495. #if defined _YCM_e@
  496. #define YSIM_DEFINED
  497. #else
  498. #define _YCM_e@
  499. // Save the settings.
  500. #if !YSIM_HAS_MASTER
  501. #define YSIM_RECALL_4 0
  502. #elseif _YSIM_IS_CLIENT
  503. #define YSIM_RECALL_4 1
  504. #elseif _YSIM_IS_SERVER
  505. #define YSIM_RECALL_4 2
  506. #elseif _YSIM_IS_CLOUD
  507. #define YSIM_RECALL_4 3
  508. #elseif _YSIM_IS_STUB
  509. #define YSIM_RECALL_4 4
  510. #else
  511. #error Undefined master type on 4
  512. #endif
  513. #endif
  514. #define _YCM e@
  515. #define _YCM@ _YCM_ge@
  516. #elseif MASTER == 5
  517. #if defined _YCM_f@
  518. #define YSIM_DEFINED
  519. #else
  520. #define _YCM_f@
  521. // Save the settings.
  522. #if !YSIM_HAS_MASTER
  523. #define YSIM_RECALL_5 0
  524. #elseif _YSIM_IS_CLIENT
  525. #define YSIM_RECALL_5 1
  526. #elseif _YSIM_IS_SERVER
  527. #define YSIM_RECALL_5 2
  528. #elseif _YSIM_IS_CLOUD
  529. #define YSIM_RECALL_5 3
  530. #elseif _YSIM_IS_STUB
  531. #define YSIM_RECALL_5 4
  532. #else
  533. #error Undefined master type on 5
  534. #endif
  535. #endif
  536. #define _YCM f@
  537. #define _YCM@ _YCM_gf@
  538. #elseif MASTER == 6
  539. #if defined _YCM_g@
  540. #define YSIM_DEFINED
  541. #else
  542. #define _YCM_g@
  543. // Save the settings.
  544. #if !YSIM_HAS_MASTER
  545. #define YSIM_RECALL_6 0
  546. #elseif _YSIM_IS_CLIENT
  547. #define YSIM_RECALL_6 1
  548. #elseif _YSIM_IS_SERVER
  549. #define YSIM_RECALL_6 2
  550. #elseif _YSIM_IS_CLOUD
  551. #define YSIM_RECALL_6 3
  552. #elseif _YSIM_IS_STUB
  553. #define YSIM_RECALL_6 4
  554. #else
  555. #error Undefined master type on 6
  556. #endif
  557. #endif
  558. #define _YCM g@
  559. #define _YCM@ _YCM_gg@
  560. #elseif MASTER == 7
  561. #if defined _YCM_h@
  562. #define YSIM_DEFINED
  563. #else
  564. #define _YCM_h@
  565. // Save the settings.
  566. #if !YSIM_HAS_MASTER
  567. #define YSIM_RECALL_7 0
  568. #elseif _YSIM_IS_CLIENT
  569. #define YSIM_RECALL_7 1
  570. #elseif _YSIM_IS_SERVER
  571. #define YSIM_RECALL_7 2
  572. #elseif _YSIM_IS_CLOUD
  573. #define YSIM_RECALL_7 3
  574. #elseif _YSIM_IS_STUB
  575. #define YSIM_RECALL_7 4
  576. #else
  577. #error Undefined master type on 7
  578. #endif
  579. #endif
  580. #define _YCM h@
  581. #define _YCM@ _YCM_gh@
  582. #elseif MASTER == 8
  583. #if defined _YCM_i@
  584. #define YSIM_DEFINED
  585. #else
  586. #define _YCM_i@
  587. // Save the settings.
  588. #if !YSIM_HAS_MASTER
  589. #define YSIM_RECALL_8 0
  590. #elseif _YSIM_IS_CLIENT
  591. #define YSIM_RECALL_8 1
  592. #elseif _YSIM_IS_SERVER
  593. #define YSIM_RECALL_8 2
  594. #elseif _YSIM_IS_CLOUD
  595. #define YSIM_RECALL_8 3
  596. #elseif _YSIM_IS_STUB
  597. #define YSIM_RECALL_8 4
  598. #else
  599. #error Undefined master type on 8
  600. #endif
  601. #endif
  602. #define _YCM i@
  603. #define _YCM@ _YCM_gi@
  604. #elseif MASTER == 9
  605. #if defined _YCM_j@
  606. #define YSIM_DEFINED
  607. #else
  608. #define _YCM_j@
  609. // Save the settings.
  610. #if !YSIM_HAS_MASTER
  611. #define YSIM_RECALL_9 0
  612. #elseif _YSIM_IS_CLIENT
  613. #define YSIM_RECALL_9 1
  614. #elseif _YSIM_IS_SERVER
  615. #define YSIM_RECALL_9 2
  616. #elseif _YSIM_IS_CLOUD
  617. #define YSIM_RECALL_9 3
  618. #elseif _YSIM_IS_STUB
  619. #define YSIM_RECALL_9 4
  620. #else
  621. #error Undefined master type on 9
  622. #endif
  623. #endif
  624. #define _YCM j@
  625. #define _YCM@ _YCM_gj@
  626. #elseif MASTER == 10
  627. #if defined _YCM_k@
  628. #define YSIM_DEFINED
  629. #else
  630. #define _YCM_k@
  631. // Save the settings.
  632. #if !YSIM_HAS_MASTER
  633. #define YSIM_RECALL_10 0
  634. #elseif _YSIM_IS_CLIENT
  635. #define YSIM_RECALL_10 1
  636. #elseif _YSIM_IS_SERVER
  637. #define YSIM_RECALL_10 2
  638. #elseif _YSIM_IS_CLOUD
  639. #define YSIM_RECALL_10 3
  640. #elseif _YSIM_IS_STUB
  641. #define YSIM_RECALL_10 4
  642. #else
  643. #error Undefined master type on 10
  644. #endif
  645. #endif
  646. #define _YCM k@
  647. #define _YCM@ _YCM_gk@
  648. #elseif MASTER == 11
  649. #if defined _YCM_l@
  650. #define YSIM_DEFINED
  651. #else
  652. #define _YCM_l@
  653. // Save the settings.
  654. #if !YSIM_HAS_MASTER
  655. #define YSIM_RECALL_11 0
  656. #elseif _YSIM_IS_CLIENT
  657. #define YSIM_RECALL_11 1
  658. #elseif _YSIM_IS_SERVER
  659. #define YSIM_RECALL_11 2
  660. #elseif _YSIM_IS_CLOUD
  661. #define YSIM_RECALL_11 3
  662. #elseif _YSIM_IS_STUB
  663. #define YSIM_RECALL_11 4
  664. #else
  665. #error Undefined master type on 11
  666. #endif
  667. #endif
  668. #define _YCM l@
  669. #define _YCM@ _YCM_gl@
  670. #elseif MASTER == 12
  671. #if defined _YCM_m@
  672. #define YSIM_DEFINED
  673. #else
  674. #define _YCM_m@
  675. // Save the settings.
  676. #if !YSIM_HAS_MASTER
  677. #define YSIM_RECALL_12 0
  678. #elseif _YSIM_IS_CLIENT
  679. #define YSIM_RECALL_12 1
  680. #elseif _YSIM_IS_SERVER
  681. #define YSIM_RECALL_12 2
  682. #elseif _YSIM_IS_CLOUD
  683. #define YSIM_RECALL_12 3
  684. #elseif _YSIM_IS_STUB
  685. #define YSIM_RECALL_12 4
  686. #else
  687. #error Undefined master type on 12
  688. #endif
  689. #endif
  690. #define _YCM m@
  691. #define _YCM@ _YCM_gm@
  692. #elseif MASTER == 13
  693. #if defined _YCM_n@
  694. #define YSIM_DEFINED
  695. #else
  696. #define _YCM_n@
  697. // Save the settings.
  698. #if !YSIM_HAS_MASTER
  699. #define YSIM_RECALL_13 0
  700. #elseif _YSIM_IS_CLIENT
  701. #define YSIM_RECALL_13 1
  702. #elseif _YSIM_IS_SERVER
  703. #define YSIM_RECALL_13 2
  704. #elseif _YSIM_IS_CLOUD
  705. #define YSIM_RECALL_13 3
  706. #elseif _YSIM_IS_STUB
  707. #define YSIM_RECALL_13 4
  708. #else
  709. #error Undefined master type on 13
  710. #endif
  711. #endif
  712. #define _YCM n@
  713. #define _YCM@ _YCM_gn@
  714. #elseif MASTER == 14
  715. #if defined _YCM_o@
  716. #define YSIM_DEFINED
  717. #else
  718. #define _YCM_o@
  719. // Save the settings.
  720. #if !YSIM_HAS_MASTER
  721. #define YSIM_RECALL_14 0
  722. #elseif _YSIM_IS_CLIENT
  723. #define YSIM_RECALL_14 1
  724. #elseif _YSIM_IS_SERVER
  725. #define YSIM_RECALL_14 2
  726. #elseif _YSIM_IS_CLOUD
  727. #define YSIM_RECALL_14 3
  728. #elseif _YSIM_IS_STUB
  729. #define YSIM_RECALL_14 4
  730. #else
  731. #error Undefined master type on 14
  732. #endif
  733. #endif
  734. #define _YCM o@
  735. #define _YCM@ _YCM_go@
  736. #elseif MASTER == 15
  737. #if defined _YCM_p@
  738. #define YSIM_DEFINED
  739. #else
  740. #define _YCM_p@
  741. // Save the settings.
  742. #if !YSIM_HAS_MASTER
  743. #define YSIM_RECALL_15 0
  744. #elseif _YSIM_IS_CLIENT
  745. #define YSIM_RECALL_15 1
  746. #elseif _YSIM_IS_SERVER
  747. #define YSIM_RECALL_15 2
  748. #elseif _YSIM_IS_CLOUD
  749. #define YSIM_RECALL_15 3
  750. #elseif _YSIM_IS_STUB
  751. #define YSIM_RECALL_15 4
  752. #else
  753. #error Undefined master type on 15
  754. #endif
  755. #endif
  756. #define _YCM p@
  757. #define _YCM@ _YCM_gp@
  758. #elseif MASTER == 16
  759. #if defined _YCM_q@
  760. #define YSIM_DEFINED
  761. #else
  762. #define _YCM_q@
  763. // Save the settings.
  764. #if !YSIM_HAS_MASTER
  765. #define YSIM_RECALL_16 0
  766. #elseif _YSIM_IS_CLIENT
  767. #define YSIM_RECALL_16 1
  768. #elseif _YSIM_IS_SERVER
  769. #define YSIM_RECALL_16 2
  770. #elseif _YSIM_IS_CLOUD
  771. #define YSIM_RECALL_16 3
  772. #elseif _YSIM_IS_STUB
  773. #define YSIM_RECALL_16 4
  774. #else
  775. #error Undefined master type on 16
  776. #endif
  777. #endif
  778. #define _YCM q@
  779. #define _YCM@ _YCM_gq@
  780. #elseif MASTER == 17
  781. #if defined _YCM_r@
  782. #define YSIM_DEFINED
  783. #else
  784. #define _YCM_r@
  785. // Save the settings.
  786. #if !YSIM_HAS_MASTER
  787. #define YSIM_RECALL_17 0
  788. #elseif _YSIM_IS_CLIENT
  789. #define YSIM_RECALL_17 1
  790. #elseif _YSIM_IS_SERVER
  791. #define YSIM_RECALL_17 2
  792. #elseif _YSIM_IS_CLOUD
  793. #define YSIM_RECALL_17 3
  794. #elseif _YSIM_IS_STUB
  795. #define YSIM_RECALL_17 4
  796. #else
  797. #error Undefined master type on 17
  798. #endif
  799. #endif
  800. #define _YCM r@
  801. #define _YCM@ _YCM_gr@
  802. #elseif MASTER == 18
  803. #if defined _YCM_s@
  804. #define YSIM_DEFINED
  805. #else
  806. #define _YCM_s@
  807. // Save the settings.
  808. #if !YSIM_HAS_MASTER
  809. #define YSIM_RECALL_18 0
  810. #elseif _YSIM_IS_CLIENT
  811. #define YSIM_RECALL_18 1
  812. #elseif _YSIM_IS_SERVER
  813. #define YSIM_RECALL_18 2
  814. #elseif _YSIM_IS_CLOUD
  815. #define YSIM_RECALL_18 3
  816. #elseif _YSIM_IS_STUB
  817. #define YSIM_RECALL_18 4
  818. #else
  819. #error Undefined master type on 18
  820. #endif
  821. #endif
  822. #define _YCM s@
  823. #define _YCM@ _YCM_gs@
  824. #elseif MASTER == 19
  825. #if defined _YCM_t@
  826. #define YSIM_DEFINED
  827. #else
  828. #define _YCM_t@
  829. // Save the settings.
  830. #if !YSIM_HAS_MASTER
  831. #define YSIM_RECALL_19 0
  832. #elseif _YSIM_IS_CLIENT
  833. #define YSIM_RECALL_19 1
  834. #elseif _YSIM_IS_SERVER
  835. #define YSIM_RECALL_19 2
  836. #elseif _YSIM_IS_CLOUD
  837. #define YSIM_RECALL_19 3
  838. #elseif _YSIM_IS_STUB
  839. #define YSIM_RECALL_19 4
  840. #else
  841. #error Undefined master type on 19
  842. #endif
  843. #endif
  844. #define _YCM t@
  845. #define _YCM@ _YCM_gt@
  846. #elseif MASTER == 20
  847. #if defined _YCM_u@
  848. #define YSIM_DEFINED
  849. #else
  850. #define _YCM_u@
  851. // Save the settings.
  852. #if !YSIM_HAS_MASTER
  853. #define YSIM_RECALL_20 0
  854. #elseif _YSIM_IS_CLIENT
  855. #define YSIM_RECALL_20 1
  856. #elseif _YSIM_IS_SERVER
  857. #define YSIM_RECALL_20 2
  858. #elseif _YSIM_IS_CLOUD
  859. #define YSIM_RECALL_20 3
  860. #elseif _YSIM_IS_STUB
  861. #define YSIM_RECALL_20 4
  862. #else
  863. #error Undefined master type on 20
  864. #endif
  865. #endif
  866. #define _YCM u@
  867. #define _YCM@ _YCM_gu@
  868. #elseif MASTER == 21
  869. #if defined _YCM_v@
  870. #define YSIM_DEFINED
  871. #else
  872. #define _YCM_v@
  873. // Save the settings.
  874. #if !YSIM_HAS_MASTER
  875. #define YSIM_RECALL_21 0
  876. #elseif _YSIM_IS_CLIENT
  877. #define YSIM_RECALL_21 1
  878. #elseif _YSIM_IS_SERVER
  879. #define YSIM_RECALL_21 2
  880. #elseif _YSIM_IS_CLOUD
  881. #define YSIM_RECALL_21 3
  882. #elseif _YSIM_IS_STUB
  883. #define YSIM_RECALL_21 4
  884. #else
  885. #error Undefined master type on 21
  886. #endif
  887. #endif
  888. #define _YCM v@
  889. #define _YCM@ _YCM_gv@
  890. #elseif MASTER == 22
  891. #if defined _YCM_w@
  892. #define YSIM_DEFINED
  893. #else
  894. #define _YCM_w@
  895. // Save the settings.
  896. #if !YSIM_HAS_MASTER
  897. #define YSIM_RECALL_22 0
  898. #elseif _YSIM_IS_CLIENT
  899. #define YSIM_RECALL_22 1
  900. #elseif _YSIM_IS_SERVER
  901. #define YSIM_RECALL_22 2
  902. #elseif _YSIM_IS_CLOUD
  903. #define YSIM_RECALL_22 3
  904. #elseif _YSIM_IS_STUB
  905. #define YSIM_RECALL_22 4
  906. #else
  907. #error Undefined master type on 22
  908. #endif
  909. #endif
  910. #define _YCM w@
  911. #define _YCM@ _YCM_gw@
  912. #elseif MASTER == 23
  913. #if defined _YCM_x@
  914. #define YSIM_DEFINED
  915. #else
  916. #define _YCM_x@
  917. // Save the settings.
  918. #if !YSIM_HAS_MASTER
  919. #define YSIM_RECALL_23 0
  920. #elseif _YSIM_IS_CLIENT
  921. #define YSIM_RECALL_23 1
  922. #elseif _YSIM_IS_SERVER
  923. #define YSIM_RECALL_23 2
  924. #elseif _YSIM_IS_CLOUD
  925. #define YSIM_RECALL_23 3
  926. #elseif _YSIM_IS_STUB
  927. #define YSIM_RECALL_23 4
  928. #else
  929. #error Undefined master type on 23
  930. #endif
  931. #endif
  932. #define _YCM x@
  933. #define _YCM@ _YCM_gx@
  934. #elseif MASTER == 24
  935. #if defined _YCM_y@
  936. #define YSIM_DEFINED
  937. #else
  938. #define _YCM_y@
  939. // Save the settings.
  940. #if !YSIM_HAS_MASTER
  941. #define YSIM_RECALL_24 0
  942. #elseif _YSIM_IS_CLIENT
  943. #define YSIM_RECALL_24 1
  944. #elseif _YSIM_IS_SERVER
  945. #define YSIM_RECALL_24 2
  946. #elseif _YSIM_IS_CLOUD
  947. #define YSIM_RECALL_24 3
  948. #elseif _YSIM_IS_STUB
  949. #define YSIM_RECALL_24 4
  950. #else
  951. #error Undefined master type on 24
  952. #endif
  953. #endif
  954. #define _YCM y@
  955. #define _YCM@ _YCM_gy@
  956. #elseif MASTER == 25
  957. #if defined _YCM_z@
  958. #define YSIM_DEFINED
  959. #else
  960. #define _YCM_z@
  961. // Save the settings.
  962. #if !YSIM_HAS_MASTER
  963. #define YSIM_RECALL_25 0
  964. #elseif _YSIM_IS_CLIENT
  965. #define YSIM_RECALL_25 1
  966. #elseif _YSIM_IS_SERVER
  967. #define YSIM_RECALL_25 2
  968. #elseif _YSIM_IS_CLOUD
  969. #define YSIM_RECALL_25 3
  970. #elseif _YSIM_IS_STUB
  971. #define YSIM_RECALL_25 4
  972. #else
  973. #error Undefined master type on 25
  974. #endif
  975. #endif
  976. #define _YCM z@
  977. #define _YCM@ _YCM_gz@
  978. #endif
  979. // Check for non-unique masters here.
  980. #if defined YSIM_DEFINED && !defined _YSIM_OVERRIDE && !defined YSIM_LIBRARY_OVERRIDE
  981. #error Non-unique master used.
  982. #endif
  983. #if YSIM_HAS_MASTER && !_YSIM_IS_CLIENT && !_YSIM_IS_STUB && (!defined YSIM_DEFINED || defined YSIM_LIBRARY_OVERRIDE)
  984. // FIRST declare the next callback in the chain.
  985. //#if defined FILTERSCRIPT
  986. // public OnFilterScriptInit()
  987. //#else
  988. // public OnGameModeInit()
  989. //#endif
  990. stock
  991. _E_YCM:_YCM@ = _E_YCM@u;
  992. public OnMasterSystemInit()
  993. {
  994. P:1(#_YCM "_OGM");
  995. // THEN rename the callbacks.
  996. #if defined _YCM_CALLBACK
  997. #undef _YCM_CALLBACK
  998. #endif
  999. #if MASTER == 0
  1000. #define _YCM_CALLBACK a@OnScriptInit
  1001. #elseif MASTER == 1
  1002. #define _YCM_CALLBACK b@OnScriptInit
  1003. #elseif MASTER == 2
  1004. #define _YCM_CALLBACK c@OnScriptInit
  1005. #elseif MASTER == 3
  1006. #define _YCM_CALLBACK d@OnScriptInit
  1007. #elseif MASTER == 4
  1008. #define _YCM_CALLBACK e@OnScriptInit
  1009. #elseif MASTER == 5
  1010. #define _YCM_CALLBACK f@OnScriptInit
  1011. #elseif MASTER == 6
  1012. #define _YCM_CALLBACK g@OnScriptInit
  1013. #elseif MASTER == 7
  1014. #define _YCM_CALLBACK h@OnScriptInit
  1015. #elseif MASTER == 8
  1016. #define _YCM_CALLBACK i@OnScriptInit
  1017. #elseif MASTER == 9
  1018. #define _YCM_CALLBACK j@OnScriptInit
  1019. #elseif MASTER == 10
  1020. #define _YCM_CALLBACK k@OnScriptInit
  1021. #elseif MASTER == 11
  1022. #define _YCM_CALLBACK l@OnScriptInit
  1023. #elseif MASTER == 12
  1024. #define _YCM_CALLBACK m@OnScriptInit
  1025. #elseif MASTER == 13
  1026. #define _YCM_CALLBACK n@OnScriptInit
  1027. #elseif MASTER == 14
  1028. #define _YCM_CALLBACK o@OnScriptInit
  1029. #elseif MASTER == 15
  1030. #define _YCM_CALLBACK p@OnScriptInit
  1031. #elseif MASTER == 16
  1032. #define _YCM_CALLBACK q@OnScriptInit
  1033. #elseif MASTER == 17
  1034. #define _YCM_CALLBACK r@OnScriptInit
  1035. #elseif MASTER == 18
  1036. #define _YCM_CALLBACK s@OnScriptInit
  1037. #elseif MASTER == 19
  1038. #define _YCM_CALLBACK t@OnScriptInit
  1039. #elseif MASTER == 20
  1040. #define _YCM_CALLBACK u@OnScriptInit
  1041. #elseif MASTER == 21
  1042. #define _YCM_CALLBACK v@OnScriptInit
  1043. #elseif MASTER == 22
  1044. #define _YCM_CALLBACK w@OnScriptInit
  1045. #elseif MASTER == 23
  1046. #define _YCM_CALLBACK x@OnScriptInit
  1047. #elseif MASTER == 24
  1048. #define _YCM_CALLBACK y@OnScriptInit
  1049. #elseif MASTER == 25
  1050. #define _YCM_CALLBACK z@OnScriptInit
  1051. #endif
  1052. #if _YSIM_IS_SERVER
  1053. // Steal the master.
  1054. _Master_Get(#_YCM, true);
  1055. _YCM@ = _E_YCM@y;
  1056. // Determine the next unique name.
  1057. CallRemoteFunction(#_YCM, "");
  1058. #elseif _YSIM_IS_CLOUD
  1059. // See if this script should be master.
  1060. if (_Master_Get(#_YCM))
  1061. {
  1062. P:2("Got master " #_YCM);
  1063. state _YCM:y;
  1064. _YCM@ = _E_YCM@y;
  1065. }
  1066. else
  1067. {
  1068. state _YCM:n;
  1069. _YCM@ = _E_YCM@n;
  1070. }
  1071. #endif
  1072. // FINALLY call the new next one.
  1073. //CallLocalFunction(#_YCM_CALLBACK, "");
  1074. return _YCM_CALLBACK();
  1075. }
  1076. // Don't need extra checks here as we KNOW it is already defined.
  1077. #undef OnMasterSystemInit
  1078. #define OnMasterSystemInit(%0) _YCM_CALLBACK(%0) <_ALS_:hooked>
  1079. forward _YCM_CALLBACK();public _YCM_CALLBACK()<_ALS_:unhooked>{return 1;}public _YCM_CALLBACK()<>{return 1;}
  1080. #endif
  1081. // The code below is now deprecated in favour of foreign/global!
  1082. // There are the following remote function definitions:
  1083. //
  1084. // RF - A basic function.
  1085. // RF@p - A function with special parameters which need passing hints.
  1086. // RF@c - A function with lots of paramteres that needs special code.
  1087. // RF@v - A function with no return value.
  1088. // RF@t - A function with a tag result.
  1089. // RC - A callback function.
  1090. // RH - A y_hooks hook.
  1091. // RS - Return a string.
  1092. //
  1093. //
  1094. // Supported combinations:
  1095. //
  1096. // pc, cp
  1097. // pcv, pvc, cpv, cvp, vpc, vcp
  1098. // pv, vp
  1099. // cv, vc
  1100. // cpt ctp pct ptc tcp tpc
  1101. // ct tc
  1102. // pt tp
  1103. //
  1104. // p and c are for special parameter sets, n is for no parameters, so those two
  1105. // groups can never be mixed together. t is for tag result and v is for no
  1106. // return, so they can never be used together.
  1107. //
  1108. // Note that the callback thing won't work with OnPlayerCommandText as it has a
  1109. // different default return to everything else.
  1110. //
  1111. // These parts are redefined every time the master system is included.
  1112. #if YSIM_HAS_MASTER
  1113. #if _YSIM_IS_SERVER
  1114. #define foreign%0(%1) %0(%1);%0@(%1)
  1115. #define @foreign foreign
  1116. //#define global%0(%1) %0@(%1);public%0@(%1)X@(_:@Zk:%0(_YM@CP:%1,,));%0(%1)
  1117. #define global%0(%1) public%0@(%1)(@Zz:X@(@Zk:_YM@CP:%0(%1,,)));%0(%1)
  1118. #define RF:%1[%2](%3) @%1(%3);@%1(%3)U@(8,YSIM_RETURN,%1(%3));%1(%3)
  1119. #define RF@p:%1[%2](%3)<%4> @%1(%3);@%1(%3)U@(8,YSIM_RETURN,%1(%4));%1(%3)
  1120. #define RF@c RF
  1121. #define RF@v:%1[%2](%3) @%1(%3);@%1(%3)%1(%3);%1(%3)
  1122. //#define RF@n:%1[]() forward %1R();public %1R()U@(8,YSIM_RETURN,%1());%1()
  1123. #define RF@pc RF@p
  1124. #define RF@pv:%1[%2](%3)<%4> @%1(%3);@%1(%3)%1(%4);%1(%3)
  1125. #define RF@pcv RF@pv
  1126. #define RF@vc RF@v
  1127. //#define RF@vn:%1[]() forward %1R();public %1R()%1();%1()
  1128. #define RF@t:%0:%1[%2](%3) %0:%1(%3);@%1(%3);@%1(%3)U@(8,YSIM_RETURN,_:%1(%3));%0:%1(%3)
  1129. #define RF@pt:%0:%1[%2](%3)<%4> %0:%1(%3);@%1(%3);@%1(%3)U@(8,YSIM_RETURN,_:%1(%4));%0:%1(%3)
  1130. #define RF@ct RF@t
  1131. //#define RF@nt:%0:%1[]() forward %0:%1();forward %1R();public %1R()U@(8,YSIM_RETURN,_:%1());%0:%1()
  1132. #define RF@pct RF@pt
  1133. #define RS:%1[%2](%3) @%1(%3);@%1(%3)R@(%1(%3));%1(%3)
  1134. #define RS@p:%1[%2](%3)<%4> @%1(%3);@%1(%3)R@(%1(%4));%1(%3)
  1135. //#define RC:%1(%3) public %1(%3)
  1136. //#define RC@v RC
  1137. #define RH:On%2(%3) hook On%2(%3)
  1138. #define master_hook%0On%2(%3) hook On%2(%3)
  1139. #define group_hook%0On%2(%3) _GROUP_MAKE_NAME<hook On%2...>(%3)
  1140. #define RT:%0[%1](%2) @yT_%1_%0();@yT_%1_%0()
  1141. #if MASTER == 23
  1142. // Less strict (implicit user master).
  1143. #define RC:%0(%1) @yC_%0(a,b[],c,i);@yC_%0(a,b[],c,i)i==_@&&U@(8,YSIM_RETURN,@_yC%0(a,b,c));@_yC%0(%1);@_yC%0(%1)
  1144. #else
  1145. #define RC:%0(%1) @yC_%0(a,b[],c);@yC_%0(a,b[],c)U@(8,YSIM_RETURN,@_yC%0(a,b,c));@_yC%0(%1);@_yC%0(%1)
  1146. #endif
  1147. // Remote local - only calls the local version if we're master,
  1148. // doesn't call the remote version.
  1149. //#define RL:%1[%2](%3) %1(%3)
  1150. //#define RP@v:%1[%2](%3) forward @%1(%3);@%1(%3)%1(%3);static %1(%3)
  1151. // Shortcut for y_als hooks.
  1152. #define RA:%0_On%1(%3) public On%1(%3)
  1153. //#define RA@p:%0_%1[%2](%3)<%4> RA:%0_%1[%2](%3)
  1154. //#define RX:%0(%1) %0@yX_(%1);public %0@yX_(%1)
  1155. #define Master_Caller() \
  1156. (V@(8,YSIM_CALLER))
  1157. //#define Master_Get(%1) state (_Master_Get(#%1)) ? (%1:y) : (%1:n)
  1158. //#define Master_Init(%1); _Master_Get(#%1);
  1159. #else
  1160. // This definition has "%0(%1)" defined as "public", "stock" AND ""!!!
  1161. //#define foreign%0(%1); %0(%1);public %0(%1)<_YCM:m>return 0;stock %0(%1)<>{new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}
  1162. // Define "foreign" more generically. If you want "server" or "none"
  1163. // you will need to define this specifically, otherwise you just need to
  1164. // include the master system and then you can use "#tryinclude". This
  1165. // means that if "global" definitions aren't found this system will try
  1166. // default to STUB. This is NOT a complete definition - the "@Zu:"
  1167. // definition means that more processing is done (mainly for the
  1168. // definition of the "_YCM:m" function to not give warnings.
  1169. //#define foreign%0(%1); stock %0(%1)<>{new i=_:@Zu:Y@();W@(#%0@##,_YM@CX:%1,,);return Z@(i);}%0@(%1);%0(%1)<_YCM:m>
  1170. #define @foreign%0(%1) stock%0(%1)<>{new i=Y@();W@(@Zu:#%0@#,_YM@Cj:%1,,);return Z@(i);}%0(%1)<_YCM:m>
  1171. #define foreign%0(%1) stock%0(%1)<>{W@(@Zu:#%0@#,_YM@Cl:%1,,);return V@(8,YSIM_RETURN);}%0(%1)<_YCM:m>
  1172. #if _YSIM_IS_CLIENT
  1173. #define global%0(%1) stock %0_(%1)
  1174. // Defined the functions as remote calling stubs. Then rename the
  1175. // following code with a name unlikely to ever be used and define the
  1176. // functions as stock so the compiler removes all the code quietly.
  1177. #define RF:%1[%2](%3) stock %1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);stock _@%1(%3)
  1178. #define RF@p:%1[%2](%3)<%4> stock %1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);stock _@%1(%3)
  1179. #define RF@c RF
  1180. #define RF@v:%1[%2](%3) stock %1(%3)U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1);stock _@%1(%3)
  1181. //#define RF@n:%1[]() stock %1()return U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);stock _@%1()
  1182. #define RF@pc RF@p
  1183. #define RF@pv:%1[%2](%3)<%4> stock %1(%3)U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1);stock _@%1(%3)
  1184. #define RF@pcv RF@pv
  1185. #define RF@vc RF@v
  1186. //#define RF@vn:%1[]() stock %1()U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1);stock _@%1()
  1187. #define RF@t:%0:%1[%2](%3) stock %0:%1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);stock %0:_@%1(%3)
  1188. #define RF@pt:%0:%1[%2](%3)<%4> stock %0:%1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);stock %0:_@%1(%3)
  1189. #define RF@ct RF@t
  1190. //#define RF@nt:%0:%1[]() stock %0:%1()return U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);stock %0:_@%1()
  1191. #define RF@pct RF@pt
  1192. #define RS:%1[%2](%3) stock %1(%3)return Y@(),W@(#@%1,(x:#%2#),%3),S@(),Q@;stock _@%1(%3)
  1193. #define RS@p:%1[%2](%3)<%4> stock %1(%3)return Y@(),W@(#@%1,#%2,%4),S@(),Q@;stock _@%1(%3)
  1194. //#define RC:%1(%3) stock _@%1(%3)
  1195. //#define RC@v RC
  1196. #define RH:On%2(%3)
  1197. #define master_hook%0On%2(%3) stock UNIQUE_FUNCTION<_yH@%2...>(%3)
  1198. #define group_hook%0On%2(%3) stock _GROUP_MAKE_NAME<On%2...>(%3)
  1199. #define RT:%0[%1](%2) stock _yT@%1_%0()
  1200. #if MASTER == 23
  1201. // Less strict (implicit user master).
  1202. #define RC:%0(%1) @yC_%0(a,b[],c,i);@yC_%0(a,b[],c,i)i==_@&&U@(8,YSIM_RETURN,@_yC%0(a,b,c));@_yC%0(%1);@_yC%0(%1)
  1203. #else
  1204. #define RC:%0(%1) static stock _@yC%0()
  1205. #endif
  1206. //#define RP@v:%1[%2](%3) static stock %1(%3)U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1);static stock _@%1(%3)
  1207. // Remote local - only calls the local version if we're master,
  1208. // doesn't call the remote version.
  1209. //#define RL:%1[%2](%3) stock %1(%3){}static stock _%1(%3)
  1210. //#define RX:%0(%1) stock %0_yX@(%1)
  1211. // Shortcut for y_als hooks.
  1212. #define RA:%0_On%1(%3) public On%1(%3)ALS_CALL<%1> static stock _%0_%1(%3)
  1213. //#define RA:%0_%1[%2](%3) public %1(%3)<>return Bit_GetBit(Bit:gs_ALS,_:ALS_%0)&&P@(#ALS_PREFIX"_"x:#%2#,%3),1;public %1(%3)<_YCM:y>
  1214. //#define RA@p:%0_%1[%2](%3)<%4> public %1(%3)ALS_CALL<%1,#%2,%4>static stock _%0_%1(%3)
  1215. //#define RA@p:%0_%1[%2](%3)<%4> public %1(%3)<>return Bit_GetBit(Bit:gs_ALS,_:ALS_%0)&&P@(#ALS_PREFIX"_"#%2,%4),1;public %1(%3)<_YCM:y>
  1216. #define Master_Caller() (-1)
  1217. #else
  1218. #if _YSIM_IS_STUB
  1219. //#define foreign%0(%1); stock %0(%1){new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}
  1220. #define global%0(%1)
  1221. // This is used to provide abstractions between different
  1222. // coders on the same team. Setting a library as a stub means
  1223. // that people without the main implementation can use the code
  1224. // through remote function calls and then the whole code can be
  1225. // integrated in to itself. Example use:
  1226. //
  1227. // #tryinclude "streamer_implementation"
  1228. // #if defined _inc_streamer_implementation
  1229. // #endinput
  1230. // #endif
  1231. //
  1232. // #define YSIM_U_ENABLE
  1233. // #define MASTER 10
  1234. // #include "y_master"
  1235. //
  1236. // RF@p:CreateObject[ifff](modelid,Float:x,Float:y,Float:z)<modelid,x,y,z>;
  1237. //
  1238. #define RF:%1[%2](%3) stock %1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN)//;stock _@%1()
  1239. #define RF@p:%1[%2](%3)<%4> stock %1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN)//;stock _@%1()
  1240. #define RF@c RF
  1241. #define RF@v:%1[%2](%3) stock %1(%3)U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1)//;stock _@%1()
  1242. //#define RF@n:%1[]() stock %1()return U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);stock _@%1()
  1243. #define RF@pc RF@p
  1244. #define RF@pv:%1[%2](%3)<%4> stock %1(%3)U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1)//;stock _@%1()
  1245. #define RF@pcv RF@pv
  1246. #define RF@vc RF@v
  1247. //#define RF@vn:%1[]() stock %1()U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1);stock _@%1()
  1248. #define RF@t:%0:%1[%2](%3) stock %0:%1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN)//;stock _@%1()
  1249. #define RF@pt:%0:%1[%2](%3)<%4> stock %0:%1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN)//;stock _@%1()
  1250. #define RF@ct RF@t
  1251. //#define RF@nt:%0:%1[]() stock %0:%1()return U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);stock %0:_@%1()
  1252. #define RF@pct RF@pt
  1253. // Doesn't have the end bit as the function isn't included.
  1254. #define RS:%1[%2](%3) stock %1(%3)return Y@(),W@(#@%1,(x:#%2#),%3),S@(),Q@//;stock _@%1()
  1255. #define RS@p:%1[%2](%3)<%4> stock %1(%3)return Y@(),W@(#@%1,#%2,%4),S@(),Q@//;stock _@%1()
  1256. // NOT DEFINED! Should not be used if this is a stub.
  1257. #define RC
  1258. // NOT DEFINED! Should not be used if this is a stub.
  1259. //#define RC@v
  1260. // NOT DEFINED! Should not be used if this is a stub.
  1261. #define RH
  1262. #define master_hook
  1263. #define group_hook
  1264. // NOT DEFINED! Should not be used if this is a stub.
  1265. #define RT
  1266. // Remote local - only calls the local version if we're master,
  1267. // doesn't call the remote version.
  1268. //#define RL:%1[%2](%3)
  1269. //#define RX
  1270. //#define RP@v
  1271. // Shortcut for y_als hooks.
  1272. #define RA //:%0_%1(%3)
  1273. //#define RA@p:%0_%1[%2](%3)<%4>
  1274. // NOT DEFINED! Should not be used if this is a stub.
  1275. #define Master_Caller
  1276. #else
  1277. //#define foreign%0(%1); %0(%1)<>{new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}%0@(%1);%0(%1)<_YCM:x>{}
  1278. //#define global%0(%1) %0@(%1);public%0@(%1)<>{}public%0@(%1)<_YCM:y>X@(_:@Zk:%0(_YM@CP:%1,,));%0(%1)<_YCM:y>
  1279. //#define global%0(%1) public%0@(%1)<>{}public%0@(%1)<_YCM:y>X@(_:@Zk:_YM@CP:%0(%1,,));stock %0(%1)<_YCM:y>
  1280. #define global%0(%1) %0@(%1);public%0@(%1)<>{}public%0@(%1)<_YCM:y>(@Zz:X@(@Zk:_YM@CP:%0(%1,,)));stock%0(%1)<_YCM:y>
  1281. // TODO: I just realised that I have NEVER used the
  1282. // "Master_Caller" feature of the master system EVER, despite
  1283. // all the overhead involved in activating and using it...
  1284. // Maybe I should just remove it! Update: Or make it optional.
  1285. // This is a normal system with the possibility of being the
  1286. // master. This is the very complicated one to write!
  1287. #define RF:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>U@(8,YSIM_RETURN,%1(%3));%1(%3)<>return U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);%1(%3)<_YCM:y>
  1288. #define RF@p:%1[%2](%3)<%4> @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>U@(8,YSIM_RETURN,%1(%4));%1(%3)<>return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);%1(%3)<_YCM:y>
  1289. #define RF@c:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>X@(%1(%3));%1(%3)<>return Y@(),W@(#@%1,(x:#%2#),%3),Z@();%1(%3)<_YCM:y>
  1290. #define RF@v:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>%1(%3);%1(%3)<>U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1);%1(%3)<_YCM:y>
  1291. //#define RF@n:%1[]() forward %1R();public %1R()<>{}public %1R()<_YCM:y>U@(8,YSIM_RETURN,%1());%1()<>return U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);%1()<_YCM:y>
  1292. #define RF@pc:%1[%2](%3)<%4> @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>X@(%1(%4));%1(%3)<>return Y@(),W@(#@%1,#%2,%4),Z@();%1(%3)<_YCM:y>
  1293. #define RF@pv:%1[%2](%3)<%4> @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>%1(%4);%1(%3)<>U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1);%1(%3)<_YCM:y>
  1294. #define RF@pcv:%1[%2](%3)<%4> @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>%1(%4);%1(%3)<>Y@(),W@(#@%1,#%2,%4),T@();%1(%3)<_YCM:y>
  1295. #define RF@vc:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>%1(%3);%1(%3)<>Y@(),W@(#@%1,(x:#%2#),%3),T@();%1(%3)<_YCM:y>
  1296. //#define RF@vn:%1[]() forward %1R();public %1R()<>{}public %1R()<_YCM:y>%1();%1()<>U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1);%1()<_YCM:y>
  1297. #define RF@t:%0:%1[%2](%3) %0:%1(%3);@%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>U@(8,YSIM_RETURN,_:%1(%3));%0:%1(%3)<>return U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);%0:%1(%3)<_YCM:y>
  1298. #define RF@pt:%0:%1[%2](%3)<%4> %0:%1(%3);@%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>U@(8,YSIM_RETURN,_:%1(%4));%0:%1(%3)<>return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2,%4),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);%0:%1(%3)<_YCM:y>
  1299. #define RF@ct:%0:%1[%2](%3) %0:%1(%3);@%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>X@(_:%1(%3));%0:%1(%3)<>return Y@(),W@(#@%1,(x:#%2#),%3),%0:Z@();%0:%1(%3)<_YCM:y>
  1300. //#define RF@nt:%0:%1[]() forward %0:%1();forward %1R();public %1R()<>{}public %1R()<_YCM:y>U@(8,YSIM_RETURN,_:%1());%0:%1()<>return U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);%0:%1()<_YCM:y>
  1301. #define RF@pct:%0:%1[%2](%3)<%4> %0:%1(%3);@%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>X@(_:%1(%4));%0:%1(%3)<>return Y@(),W@(#@%1,#%2,%4),%0:Z@();%0:%1(%3)<_YCM:y>
  1302. //#define RS:%1[%2](%3) forward %1R(%3);public %1R(%3)<>{}public %1R(%3)<_YCM:y>R@(%1(%3));%1(%3)<>return Y@(),W@(#@%1,(x:#%2#),%3),S@();%1(%3)<_YCM:y>
  1303. // Remote STRING (returns a string).
  1304. #define RS:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>R@(%1(%3));%1(%3)<>return Y@(),W@(#@%1,(x:#%2#),%3),S@(),Q@;%1(%3)<_YCM:y>
  1305. #define RS@p:%1[%2](%3)<%4> @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>R@(%1(%4));%1(%3)<>return Y@(),W@(#@%1,#%2,%4),S@(),Q@;%1(%3)<_YCM:y>
  1306. //#define RC:%1(%3) public %1(%3)<>return 1;public %1(%3)<_YCM:y>
  1307. //#define RC@v:%1(%3) public %1(%3)<>{}public %1(%3)<_YCM:y>
  1308. // Requires the y_hooks library.
  1309. #define RH:On%2(%3) hook On%2(%3)<>return ALS_R_%2;rehook On%2(%3)<_YCM:y>
  1310. #define master_hook%0On%2(%3) hook On%2(%3)<>return ALS_R_%2;rehook On%2(%3)<_YCM:y>
  1311. #define group_hook%0On%2(%3) _GROUP_MAKE_NAME<hook On%2...>(%3)<>return ALS_R_%2;_GROUP_MAKE_NAME<rehook On%2...>(%3)<_YCM:y>
  1312. // Requires the y_timers library.
  1313. #define RT:%0[%1](%2) @yT_%1_%0();@yT_%1_%0()<>{}@yT_%1_%0()<_YCM:y>
  1314. /*#if
  1315. #define RC:%0(%1) forward @yC_%0(a,b[],c);@yC_%0(a,b[],c)<>{}@yC_%0(a,b[],c)<_YCM:y>U@(8,YSIM_RETURN,@_yC%0(a,b,c));@_yC%0(%1);@_yC%0(%1)
  1316. #else
  1317. // This code defines two publics so that if the master
  1318. // doesn't have a copy of the command it can still be called
  1319. // in another running script.
  1320. #define RC:%0(%1) forward @yC_%0(a,b[],c);forward @_yC%0(i,a,b,c[]);@yC_%0(a,b[],c)<>{}@yC_%0(a,b[],c)<_YCM:y>U@(8,YSIM_RETURN,@_yC%0(a,b,c));@_yC%0(i,a,b,c[])return i==_@&&U@(8,YSIM_RETURN,@_yC%0(a,b,c));@_yC%0(%1);@_yC%0(%1)
  1321. #endif*/
  1322. //#if defined _YSIM_USED_AUTO
  1323. #if MASTER == 23
  1324. // Less strict (implicit user master).
  1325. #define RC:%0(%1) @yC_%0(a,b[],c,i);@yC_%0(a,b[],c,i)i==_@&&U@(8,YSIM_RETURN,@_yC%0(a,b,c));@_yC%0(%1);@_yC%0(%1)
  1326. #else
  1327. // Strict libraries.
  1328. #define RC:%0(%1) @yC_%0(a,b[],c);@yC_%0(a,b[],c)<>{}@yC_%0(a,b[],c)<_YCM:y>U@(8,YSIM_RETURN,@_yC%0(a,b,c));@_yC%0(%1);@_yC%0(%1)
  1329. #endif
  1330. //#define RP@v:%1[%2](%3) forward @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>%1(%3);static %1(%3)<>U@(8,YSIM_CALLER,_@),W@(#@%1,(x:#%2#),%3),U@(8,YSIM_CALLER,-1);static %1(%3)<_YCM:y>
  1331. #define Master_Caller() \
  1332. (((I@=V@(8,YSIM_CALLER))==-1)?(_@):(I@))
  1333. // Remote local - only calls the local version if we're master,
  1334. // doesn't call the remote version.
  1335. //#define RL:%1[%2](%3) %1(%3)<>return 1;%1(%3)<_YCM:y>
  1336. //#define RX:%0(%1) %0@yX_(%1);public %0@yX_(%1)<>{}public %0@yX_(%1)<_YCM:y>
  1337. //#define RX:%0(%1) UNIQUE_FUNCTION<@yX_...%0>(%1);UNIQUE_FUNCTION<@yX_...%0>(%1)<>{}UNIQUE_FUNCTION(@yX_...%0>(%1)<_YCM:y>
  1338. // Shortcut for y_als hooks.
  1339. //#define RA:%0_%1(%3) public %1(%3)<>ALS_CALL<%1>public %1(%3)<_YCM:y>
  1340. #define RA:%0_On%1(%3) public On%1(%3)<>ALS_CALL<%1> public On%1(%3)<_YCM:y>
  1341. //#define RA:%0_%1[%2](%3) public %1(%3)<>return Bit_GetBit(Bit:gs_ALS,_:ALS_%0)&&P@(#ALS_PREFIX"_"x:#%2#,%3),1;public %1(%3)<_YCM:y>
  1342. //#define RA@p:%0_%1[%2](%3)<%4> public %1(%3)<>ALS_CALL<%1,#%2,%4>public %1(%3)<_YCM:y>
  1343. //#define Master_Get(%1) state (_Master_Get(#%1)) ? (%1:y) : (%1:n)
  1344. //#define Master_Init(%1); if (_Master_Get(#%1)) state %1:y; else state %1:n;
  1345. #endif
  1346. #endif
  1347. #endif
  1348. #else
  1349. #define foreign forward
  1350. #define @foreign forward
  1351. #define global stock
  1352. // Master system isn't used.
  1353. #define RF:%1[%2](%3) stock %1(%3)
  1354. #define RF@p:%1[%2](%3)<%4> RF:%1[%2](%3)
  1355. #define RF@c RF
  1356. #define RF@v RF
  1357. //#define RF@n RF
  1358. #define RF@pc RF@p
  1359. #define RF@pv RF@p
  1360. #define RF@pcv RF@p
  1361. #define RF@vc RF
  1362. //#define RF@vn RF
  1363. #define RF@t:%0:%1[%2](%3) stock %0:%1(%3)
  1364. #define RF@pt:%0:%1[%2](%3)<%4> RF@t:%0:%1[%2](%3)
  1365. #define RF@ct RF@t
  1366. //#define RF@nt RF@t
  1367. #define RF@pct RF@p
  1368. #define RS:%1[%2](%3) stock %1(%3)
  1369. #define RS@p:%1[%2](%3)<%4> stock %1(%3)
  1370. #define RS@c RS
  1371. #define RS@pc RS@p
  1372. //#define RC:%1(%3) public %1(%3)
  1373. //#define RC@v: RC
  1374. #define RT:%0[%1](%2) @yT_%1_%0();@yT_%1_%0()
  1375. //#define RP@v:%0[%1](%2) static stock %0(%2)
  1376. #define RH:On%2(%3) hook On%2(%3)
  1377. #define master_hook%0On%2(%3) hook On%2(%3)
  1378. #define group_hook%0On%2(%3) _GROUP_MAKE_NAME<hook On%2...>(%3)
  1379. #define RC:%0(%1) @yC_%0(%1);@yC_%0(%1)
  1380. //#define RX:%0(%1) %0@yX_(%1);public %0@yX_(%1)
  1381. #define Master_Caller() (_@)
  1382. // Remote local - only calls the local version if we're master,
  1383. // doesn't call the remote version.
  1384. //#define RL:%1[%2](%3) stock %1(%3)
  1385. // Shortcut for y_als hooks.
  1386. #define RA:%0_On%1(%3) public On%1(%3)
  1387. //#define RA@p:%0_%1[%2](%3)<%4> RA:%0_%1[%2](%3)
  1388. //#define Master_Init(%1);
  1389. #endif
  1390. // Undefine this before the next call.
  1391. #undef MASTER
  1392. #if !defined YSIM_DEFINED || defined YSIM_LIBRARY_OVERRIDE
  1393. #if _YSIM_IS_CLOUD || _YSIM_IS_SERVER
  1394. // Define a load of fake functions to cater for the compiler's need to
  1395. // know all the possible states. y means master, n means not master, m
  1396. // means master system missing, p means previous (ending master), u
  1397. // means sort of uninitialised (though technically initialised). This
  1398. // also doubles as a handy call in function for resetting masters when a
  1399. // script ends. Just to clarify - this function is NOT called _YCM,
  1400. // that is a macro which is expanded every time this file is included.
  1401. // m is also now client/stub.
  1402. forward _YCM();
  1403. public _YCM() <_YCM:y>
  1404. {
  1405. P:1("%d: " #_YCM "<y> called", _@);
  1406. if (getproperty(8, #_YCM) != _@)
  1407. {
  1408. // Master, but not. A server has claimed this.
  1409. state _YCM:n;
  1410. _YCM@ = _E_YCM@n;
  1411. }
  1412. else
  1413. {
  1414. P:2("%d: " #_YCM ":y called", _@);
  1415. // Disable the current mastership.
  1416. state _YCM:p;
  1417. _YCM@ = _E_YCM@p;
  1418. setproperty(8, #_YCM, -1);
  1419. // Called locally to begin the hand off process.
  1420. CallRemoteFunction(#_YCM, "");
  1421. }
  1422. }
  1423. public _YCM() <_YCM:n>
  1424. {
  1425. P:1("%d: " #_YCM "<n> called", _@);
  1426. // This has been called remotely from a script which owns the
  1427. // library masterhood (that's the only way this can ever be called).
  1428. if (_Master_Get(#_YCM))
  1429. {
  1430. P:2("%d: " "Got master " #_YCM, _@);
  1431. state _YCM:y;
  1432. _YCM@ = _E_YCM@y;
  1433. }
  1434. }
  1435. public _YCM() <_YCM:m, _YCM:p, _YCM:u>
  1436. {
  1437. P:1("%d: " #_YCM "<m,p,u,x> called", _@);
  1438. // Do nothing at all (just define states).
  1439. }
  1440. public _YCM() <>
  1441. {
  1442. P:1("%d: " #_YCM "<> called", _@);
  1443. if (_Master_Get(#_YCM))
  1444. {
  1445. P:2("%d: " "Got master " #_YCM, _@);
  1446. state _YCM:y;
  1447. _YCM@ = _E_YCM@y;
  1448. }
  1449. else
  1450. {
  1451. state _YCM:n;
  1452. _YCM@ = _E_YCM@n;
  1453. }
  1454. // Do nothing at all (just define states).
  1455. }
  1456. /*#elseif _YSIM_IS_SERVER
  1457. forward _YCM();
  1458. public _YCM() <_YCM:y>
  1459. {
  1460. P:1("%d: " #_YCM "<y> called", _@);
  1461. // Disable the current mastership.
  1462. state _YCM:p;
  1463. setproperty(8, #_YCM, -1);
  1464. // Called locally to begin the hand off process.
  1465. CallRemoteFunction(#_YCM, "");
  1466. }
  1467. public _YCM() <_YCM:n, _YCM:m, _YCM:p, _YCM:u>
  1468. {
  1469. P:1("%d: " #_YCM "<n,m,p,u,x> called", _@);
  1470. // Do nothing at all (just define states).
  1471. }
  1472. public _YCM() <>
  1473. {
  1474. P:1("%d: " #_YCM "<> called", _@);
  1475. //_Master_Get(#_YCM, true);
  1476. P:2("%d: " "Got master " #_YCM, _@);
  1477. state _YCM:y;
  1478. // Do nothing at all (just define states).
  1479. }*/
  1480. /*#else
  1481. #if _YSIM_IS_CLIENT || _YSIM_IS_STUB
  1482. static stock _YCM() <_YCM:m>
  1483. {
  1484. }
  1485. static stock _YCM() <>
  1486. {
  1487. }
  1488. #endif*/
  1489. #elseif YSIM_HAS_MASTER
  1490. stock
  1491. _E_YCM:_YCM@ = _E_YCM@n;
  1492. #else
  1493. stock
  1494. _E_YCM:_YCM@ = _E_YCM@y;
  1495. #endif
  1496. #endif
  1497. #if defined YSIM_T_ENABLE
  1498. #undef YSIM_T_ENABLE
  1499. #endif
  1500. #if defined YSIM_T_DISABLE
  1501. #undef YSIM_T_DISABLE
  1502. #endif
  1503. #if defined YSIM_C_ENABLE
  1504. #undef YSIM_C_ENABLE
  1505. #endif
  1506. #if defined YSIM_C_DISABLE
  1507. #undef YSIM_C_DISABLE
  1508. #endif
  1509. #if defined YSIM_S_ENABLE
  1510. #undef YSIM_S_ENABLE
  1511. #endif
  1512. #if defined YSIM_S_DISABLE
  1513. #undef YSIM_S_DISABLE
  1514. #endif
  1515. #if defined YSIM_U_ENABLE
  1516. #undef YSIM_U_ENABLE
  1517. #endif
  1518. #if defined YSIM_U_DISABLE
  1519. #undef YSIM_U_DISABLE
  1520. #endif
  1521. // Allow YSI scripts to use the extended master system
  1522. /*#if defined _YSIM_USED_AUTO
  1523. #undef _YSIM_USED_AUTO
  1524. #endif*/
  1525. #if defined _YSIM_OVERRIDE
  1526. #undef _YSIM_OVERRIDE
  1527. #endif
  1528. #if defined YSIM_STORED_SETTINGS
  1529. #undef YSIM_STORED_SETTINGS
  1530. #endif
  1531. // Clean up the new library definition code.
  1532. #if defined _YSIM_LAST_LIBRARY_MASTER
  1533. #undef _YSIM_LAST_LIBRARY_MASTER
  1534. #endif
  1535. #if defined LIBRARY_MASTER
  1536. #if LIBRARY_MASTER == 0
  1537. #define _YSIM_LAST_LIBRARY_MASTER 0
  1538. #elseif LIBRARY_MASTER == 1
  1539. #define _YSIM_LAST_LIBRARY_MASTER 1
  1540. #elseif LIBRARY_MASTER == 2
  1541. #define _YSIM_LAST_LIBRARY_MASTER 2
  1542. #elseif LIBRARY_MASTER == 3
  1543. #define _YSIM_LAST_LIBRARY_MASTER 3
  1544. #elseif LIBRARY_MASTER == 4
  1545. #define _YSIM_LAST_LIBRARY_MASTER 4
  1546. #elseif LIBRARY_MASTER == 5
  1547. #define _YSIM_LAST_LIBRARY_MASTER 5
  1548. #elseif LIBRARY_MASTER == 6
  1549. #define _YSIM_LAST_LIBRARY_MASTER 6
  1550. #elseif LIBRARY_MASTER == 7
  1551. #define _YSIM_LAST_LIBRARY_MASTER 7
  1552. #elseif LIBRARY_MASTER == 8
  1553. #define _YSIM_LAST_LIBRARY_MASTER 8
  1554. #elseif LIBRARY_MASTER == 9
  1555. #define _YSIM_LAST_LIBRARY_MASTER 9
  1556. #elseif LIBRARY_MASTER == 10
  1557. #define _YSIM_LAST_LIBRARY_MASTER 10
  1558. #elseif LIBRARY_MASTER == 11
  1559. #define _YSIM_LAST_LIBRARY_MASTER 11
  1560. #elseif LIBRARY_MASTER == 12
  1561. #define _YSIM_LAST_LIBRARY_MASTER 12
  1562. #elseif LIBRARY_MASTER == 13
  1563. #define _YSIM_LAST_LIBRARY_MASTER 13
  1564. #elseif LIBRARY_MASTER == 14
  1565. #define _YSIM_LAST_LIBRARY_MASTER 14
  1566. #elseif LIBRARY_MASTER == 15
  1567. #define _YSIM_LAST_LIBRARY_MASTER 15
  1568. #elseif LIBRARY_MASTER == 16
  1569. #define _YSIM_LAST_LIBRARY_MASTER 16
  1570. #elseif LIBRARY_MASTER == 17
  1571. #define _YSIM_LAST_LIBRARY_MASTER 17
  1572. #elseif LIBRARY_MASTER == 18
  1573. #define _YSIM_LAST_LIBRARY_MASTER 18
  1574. #elseif LIBRARY_MASTER == 19
  1575. #define _YSIM_LAST_LIBRARY_MASTER 19
  1576. #elseif LIBRARY_MASTER == 20
  1577. #define _YSIM_LAST_LIBRARY_MASTER 20
  1578. #elseif LIBRARY_MASTER == 21
  1579. #define _YSIM_LAST_LIBRARY_MASTER 21
  1580. #elseif LIBRARY_MASTER == 22
  1581. #define _YSIM_LAST_LIBRARY_MASTER 22
  1582. #elseif LIBRARY_MASTER == 23
  1583. #define _YSIM_LAST_LIBRARY_MASTER 23
  1584. #elseif LIBRARY_MASTER == 24
  1585. #define _YSIM_LAST_LIBRARY_MASTER 24
  1586. #elseif LIBRARY_MASTER == 25
  1587. #define _YSIM_LAST_LIBRARY_MASTER 25
  1588. #endif
  1589. #undef LIBRARY_MASTER
  1590. #endif
  1591. #if defined YSIM_LIBRARY_OVERRIDE
  1592. #undef YSIM_LIBRARY_OVERRIDE
  1593. #endif