y_master.inc 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821
  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. #endif
  402. // Now set the current script data.
  403. // IDIOT! These are mostly mutually exclusive! You don't need a horrible huge
  404. // bit array to store the fact that this is both a client AND a server!
  405. #if MASTER == 0
  406. #if defined _YCM_a@
  407. #define YSIM_DEFINED
  408. #else
  409. #define _YCM_a@
  410. // Save the settings.
  411. #if !YSIM_HAS_MASTER
  412. #define YSIM_RECALL_0 0
  413. #elseif _YSIM_IS_CLIENT
  414. #define YSIM_RECALL_0 1
  415. #elseif _YSIM_IS_SERVER
  416. #define YSIM_RECALL_0 2
  417. #elseif _YSIM_IS_CLOUD
  418. #define YSIM_RECALL_0 3
  419. #elseif _YSIM_IS_STUB
  420. #define YSIM_RECALL_0 4
  421. #else
  422. #error Undefined master type on 0
  423. #endif
  424. #endif
  425. #define _YCM a@
  426. #elseif MASTER == 1
  427. #if defined _YCM_b@
  428. #define YSIM_DEFINED
  429. #else
  430. #define _YCM_b@
  431. // Save the settings.
  432. #if !YSIM_HAS_MASTER
  433. #define YSIM_RECALL_1 0
  434. #elseif _YSIM_IS_CLIENT
  435. #define YSIM_RECALL_1 1
  436. #elseif _YSIM_IS_SERVER
  437. #define YSIM_RECALL_1 2
  438. #elseif _YSIM_IS_CLOUD
  439. #define YSIM_RECALL_1 3
  440. #elseif _YSIM_IS_STUB
  441. #define YSIM_RECALL_1 4
  442. #else
  443. #error Undefined master type on 1
  444. #endif
  445. #endif
  446. #define _YCM b@
  447. #elseif MASTER == 2
  448. #if defined _YCM_c@
  449. #define YSIM_DEFINED
  450. #else
  451. #define _YCM_c@
  452. // Save the settings.
  453. #if !YSIM_HAS_MASTER
  454. #define YSIM_RECALL_2 0
  455. #elseif _YSIM_IS_CLIENT
  456. #define YSIM_RECALL_2 1
  457. #elseif _YSIM_IS_SERVER
  458. #define YSIM_RECALL_2 2
  459. #elseif _YSIM_IS_CLOUD
  460. #define YSIM_RECALL_2 3
  461. #elseif _YSIM_IS_STUB
  462. #define YSIM_RECALL_2 4
  463. #else
  464. #error Undefined master type on 2
  465. #endif
  466. #endif
  467. #define _YCM c@
  468. #elseif MASTER == 3
  469. #if defined _YCM_d@
  470. #define YSIM_DEFINED
  471. #else
  472. #define _YCM_d@
  473. // Save the settings.
  474. #if !YSIM_HAS_MASTER
  475. #define YSIM_RECALL_3 0
  476. #elseif _YSIM_IS_CLIENT
  477. #define YSIM_RECALL_3 1
  478. #elseif _YSIM_IS_SERVER
  479. #define YSIM_RECALL_3 2
  480. #elseif _YSIM_IS_CLOUD
  481. #define YSIM_RECALL_3 3
  482. #elseif _YSIM_IS_STUB
  483. #define YSIM_RECALL_3 4
  484. #else
  485. #error Undefined master type on 3
  486. #endif
  487. #endif
  488. #define _YCM d@
  489. #elseif MASTER == 4
  490. #if defined _YCM_e@
  491. #define YSIM_DEFINED
  492. #else
  493. #define _YCM_e@
  494. // Save the settings.
  495. #if !YSIM_HAS_MASTER
  496. #define YSIM_RECALL_4 0
  497. #elseif _YSIM_IS_CLIENT
  498. #define YSIM_RECALL_4 1
  499. #elseif _YSIM_IS_SERVER
  500. #define YSIM_RECALL_4 2
  501. #elseif _YSIM_IS_CLOUD
  502. #define YSIM_RECALL_4 3
  503. #elseif _YSIM_IS_STUB
  504. #define YSIM_RECALL_4 4
  505. #else
  506. #error Undefined master type on 4
  507. #endif
  508. #endif
  509. #define _YCM e@
  510. #elseif MASTER == 5
  511. #if defined _YCM_f@
  512. #define YSIM_DEFINED
  513. #else
  514. #define _YCM_f@
  515. // Save the settings.
  516. #if !YSIM_HAS_MASTER
  517. #define YSIM_RECALL_5 0
  518. #elseif _YSIM_IS_CLIENT
  519. #define YSIM_RECALL_5 1
  520. #elseif _YSIM_IS_SERVER
  521. #define YSIM_RECALL_5 2
  522. #elseif _YSIM_IS_CLOUD
  523. #define YSIM_RECALL_5 3
  524. #elseif _YSIM_IS_STUB
  525. #define YSIM_RECALL_5 4
  526. #else
  527. #error Undefined master type on 5
  528. #endif
  529. #endif
  530. #define _YCM f@
  531. #elseif MASTER == 6
  532. #if defined _YCM_g@
  533. #define YSIM_DEFINED
  534. #else
  535. #define _YCM_g@
  536. // Save the settings.
  537. #if !YSIM_HAS_MASTER
  538. #define YSIM_RECALL_6 0
  539. #elseif _YSIM_IS_CLIENT
  540. #define YSIM_RECALL_6 1
  541. #elseif _YSIM_IS_SERVER
  542. #define YSIM_RECALL_6 2
  543. #elseif _YSIM_IS_CLOUD
  544. #define YSIM_RECALL_6 3
  545. #elseif _YSIM_IS_STUB
  546. #define YSIM_RECALL_6 4
  547. #else
  548. #error Undefined master type on 6
  549. #endif
  550. #endif
  551. #define _YCM g@
  552. #elseif MASTER == 7
  553. #if defined _YCM_h@
  554. #define YSIM_DEFINED
  555. #else
  556. #define _YCM_h@
  557. // Save the settings.
  558. #if !YSIM_HAS_MASTER
  559. #define YSIM_RECALL_7 0
  560. #elseif _YSIM_IS_CLIENT
  561. #define YSIM_RECALL_7 1
  562. #elseif _YSIM_IS_SERVER
  563. #define YSIM_RECALL_7 2
  564. #elseif _YSIM_IS_CLOUD
  565. #define YSIM_RECALL_7 3
  566. #elseif _YSIM_IS_STUB
  567. #define YSIM_RECALL_7 4
  568. #else
  569. #error Undefined master type on 7
  570. #endif
  571. #endif
  572. #define _YCM h@
  573. #elseif MASTER == 8
  574. #if defined _YCM_i@
  575. #define YSIM_DEFINED
  576. #else
  577. #define _YCM_i@
  578. // Save the settings.
  579. #if !YSIM_HAS_MASTER
  580. #define YSIM_RECALL_8 0
  581. #elseif _YSIM_IS_CLIENT
  582. #define YSIM_RECALL_8 1
  583. #elseif _YSIM_IS_SERVER
  584. #define YSIM_RECALL_8 2
  585. #elseif _YSIM_IS_CLOUD
  586. #define YSIM_RECALL_8 3
  587. #elseif _YSIM_IS_STUB
  588. #define YSIM_RECALL_8 4
  589. #else
  590. #error Undefined master type on 8
  591. #endif
  592. #endif
  593. #define _YCM i@
  594. #elseif MASTER == 9
  595. #if defined _YCM_j@
  596. #define YSIM_DEFINED
  597. #else
  598. #define _YCM_j@
  599. // Save the settings.
  600. #if !YSIM_HAS_MASTER
  601. #define YSIM_RECALL_9 0
  602. #elseif _YSIM_IS_CLIENT
  603. #define YSIM_RECALL_9 1
  604. #elseif _YSIM_IS_SERVER
  605. #define YSIM_RECALL_9 2
  606. #elseif _YSIM_IS_CLOUD
  607. #define YSIM_RECALL_9 3
  608. #elseif _YSIM_IS_STUB
  609. #define YSIM_RECALL_9 4
  610. #else
  611. #error Undefined master type on 9
  612. #endif
  613. #endif
  614. #define _YCM j@
  615. #elseif MASTER == 10
  616. #if defined _YCM_k@
  617. #define YSIM_DEFINED
  618. #else
  619. #define _YCM_k@
  620. // Save the settings.
  621. #if !YSIM_HAS_MASTER
  622. #define YSIM_RECALL_10 0
  623. #elseif _YSIM_IS_CLIENT
  624. #define YSIM_RECALL_10 1
  625. #elseif _YSIM_IS_SERVER
  626. #define YSIM_RECALL_10 2
  627. #elseif _YSIM_IS_CLOUD
  628. #define YSIM_RECALL_10 3
  629. #elseif _YSIM_IS_STUB
  630. #define YSIM_RECALL_10 4
  631. #else
  632. #error Undefined master type on 10
  633. #endif
  634. #endif
  635. #define _YCM k@
  636. #elseif MASTER == 11
  637. #if defined _YCM_l@
  638. #define YSIM_DEFINED
  639. #else
  640. #define _YCM_l@
  641. // Save the settings.
  642. #if !YSIM_HAS_MASTER
  643. #define YSIM_RECALL_11 0
  644. #elseif _YSIM_IS_CLIENT
  645. #define YSIM_RECALL_11 1
  646. #elseif _YSIM_IS_SERVER
  647. #define YSIM_RECALL_11 2
  648. #elseif _YSIM_IS_CLOUD
  649. #define YSIM_RECALL_11 3
  650. #elseif _YSIM_IS_STUB
  651. #define YSIM_RECALL_11 4
  652. #else
  653. #error Undefined master type on 11
  654. #endif
  655. #endif
  656. #define _YCM l@
  657. #elseif MASTER == 12
  658. #if defined _YCM_m@
  659. #define YSIM_DEFINED
  660. #else
  661. #define _YCM_m@
  662. // Save the settings.
  663. #if !YSIM_HAS_MASTER
  664. #define YSIM_RECALL_12 0
  665. #elseif _YSIM_IS_CLIENT
  666. #define YSIM_RECALL_12 1
  667. #elseif _YSIM_IS_SERVER
  668. #define YSIM_RECALL_12 2
  669. #elseif _YSIM_IS_CLOUD
  670. #define YSIM_RECALL_12 3
  671. #elseif _YSIM_IS_STUB
  672. #define YSIM_RECALL_12 4
  673. #else
  674. #error Undefined master type on 12
  675. #endif
  676. #endif
  677. #define _YCM m@
  678. #elseif MASTER == 13
  679. #if defined _YCM_n@
  680. #define YSIM_DEFINED
  681. #else
  682. #define _YCM_n@
  683. // Save the settings.
  684. #if !YSIM_HAS_MASTER
  685. #define YSIM_RECALL_13 0
  686. #elseif _YSIM_IS_CLIENT
  687. #define YSIM_RECALL_13 1
  688. #elseif _YSIM_IS_SERVER
  689. #define YSIM_RECALL_13 2
  690. #elseif _YSIM_IS_CLOUD
  691. #define YSIM_RECALL_13 3
  692. #elseif _YSIM_IS_STUB
  693. #define YSIM_RECALL_13 4
  694. #else
  695. #error Undefined master type on 13
  696. #endif
  697. #endif
  698. #define _YCM n@
  699. #elseif MASTER == 14
  700. #if defined _YCM_o@
  701. #define YSIM_DEFINED
  702. #else
  703. #define _YCM_o@
  704. // Save the settings.
  705. #if !YSIM_HAS_MASTER
  706. #define YSIM_RECALL_14 0
  707. #elseif _YSIM_IS_CLIENT
  708. #define YSIM_RECALL_14 1
  709. #elseif _YSIM_IS_SERVER
  710. #define YSIM_RECALL_14 2
  711. #elseif _YSIM_IS_CLOUD
  712. #define YSIM_RECALL_14 3
  713. #elseif _YSIM_IS_STUB
  714. #define YSIM_RECALL_14 4
  715. #else
  716. #error Undefined master type on 14
  717. #endif
  718. #endif
  719. #define _YCM o@
  720. #elseif MASTER == 15
  721. #if defined _YCM_p@
  722. #define YSIM_DEFINED
  723. #else
  724. #define _YCM_p@
  725. // Save the settings.
  726. #if !YSIM_HAS_MASTER
  727. #define YSIM_RECALL_15 0
  728. #elseif _YSIM_IS_CLIENT
  729. #define YSIM_RECALL_15 1
  730. #elseif _YSIM_IS_SERVER
  731. #define YSIM_RECALL_15 2
  732. #elseif _YSIM_IS_CLOUD
  733. #define YSIM_RECALL_15 3
  734. #elseif _YSIM_IS_STUB
  735. #define YSIM_RECALL_15 4
  736. #else
  737. #error Undefined master type on 15
  738. #endif
  739. #endif
  740. #define _YCM p@
  741. #elseif MASTER == 16
  742. #if defined _YCM_q@
  743. #define YSIM_DEFINED
  744. #else
  745. #define _YCM_q@
  746. // Save the settings.
  747. #if !YSIM_HAS_MASTER
  748. #define YSIM_RECALL_16 0
  749. #elseif _YSIM_IS_CLIENT
  750. #define YSIM_RECALL_16 1
  751. #elseif _YSIM_IS_SERVER
  752. #define YSIM_RECALL_16 2
  753. #elseif _YSIM_IS_CLOUD
  754. #define YSIM_RECALL_16 3
  755. #elseif _YSIM_IS_STUB
  756. #define YSIM_RECALL_16 4
  757. #else
  758. #error Undefined master type on 16
  759. #endif
  760. #endif
  761. #define _YCM q@
  762. #elseif MASTER == 17
  763. #if defined _YCM_r@
  764. #define YSIM_DEFINED
  765. #else
  766. #define _YCM_r@
  767. // Save the settings.
  768. #if !YSIM_HAS_MASTER
  769. #define YSIM_RECALL_17 0
  770. #elseif _YSIM_IS_CLIENT
  771. #define YSIM_RECALL_17 1
  772. #elseif _YSIM_IS_SERVER
  773. #define YSIM_RECALL_17 2
  774. #elseif _YSIM_IS_CLOUD
  775. #define YSIM_RECALL_17 3
  776. #elseif _YSIM_IS_STUB
  777. #define YSIM_RECALL_17 4
  778. #else
  779. #error Undefined master type on 17
  780. #endif
  781. #endif
  782. #define _YCM r@
  783. #elseif MASTER == 18
  784. #if defined _YCM_s@
  785. #define YSIM_DEFINED
  786. #else
  787. #define _YCM_s@
  788. // Save the settings.
  789. #if !YSIM_HAS_MASTER
  790. #define YSIM_RECALL_18 0
  791. #elseif _YSIM_IS_CLIENT
  792. #define YSIM_RECALL_18 1
  793. #elseif _YSIM_IS_SERVER
  794. #define YSIM_RECALL_18 2
  795. #elseif _YSIM_IS_CLOUD
  796. #define YSIM_RECALL_18 3
  797. #elseif _YSIM_IS_STUB
  798. #define YSIM_RECALL_18 4
  799. #else
  800. #error Undefined master type on 18
  801. #endif
  802. #endif
  803. #define _YCM s@
  804. #elseif MASTER == 19
  805. #if defined _YCM_t@
  806. #define YSIM_DEFINED
  807. #else
  808. #define _YCM_t@
  809. // Save the settings.
  810. #if !YSIM_HAS_MASTER
  811. #define YSIM_RECALL_19 0
  812. #elseif _YSIM_IS_CLIENT
  813. #define YSIM_RECALL_19 1
  814. #elseif _YSIM_IS_SERVER
  815. #define YSIM_RECALL_19 2
  816. #elseif _YSIM_IS_CLOUD
  817. #define YSIM_RECALL_19 3
  818. #elseif _YSIM_IS_STUB
  819. #define YSIM_RECALL_19 4
  820. #else
  821. #error Undefined master type on 19
  822. #endif
  823. #endif
  824. #define _YCM t@
  825. #elseif MASTER == 20
  826. #if defined _YCM_u@
  827. #define YSIM_DEFINED
  828. #else
  829. #define _YCM_u@
  830. // Save the settings.
  831. #if !YSIM_HAS_MASTER
  832. #define YSIM_RECALL_20 0
  833. #elseif _YSIM_IS_CLIENT
  834. #define YSIM_RECALL_20 1
  835. #elseif _YSIM_IS_SERVER
  836. #define YSIM_RECALL_20 2
  837. #elseif _YSIM_IS_CLOUD
  838. #define YSIM_RECALL_20 3
  839. #elseif _YSIM_IS_STUB
  840. #define YSIM_RECALL_20 4
  841. #else
  842. #error Undefined master type on 20
  843. #endif
  844. #endif
  845. #define _YCM u@
  846. #elseif MASTER == 21
  847. #if defined _YCM_v@
  848. #define YSIM_DEFINED
  849. #else
  850. #define _YCM_v@
  851. // Save the settings.
  852. #if !YSIM_HAS_MASTER
  853. #define YSIM_RECALL_21 0
  854. #elseif _YSIM_IS_CLIENT
  855. #define YSIM_RECALL_21 1
  856. #elseif _YSIM_IS_SERVER
  857. #define YSIM_RECALL_21 2
  858. #elseif _YSIM_IS_CLOUD
  859. #define YSIM_RECALL_21 3
  860. #elseif _YSIM_IS_STUB
  861. #define YSIM_RECALL_21 4
  862. #else
  863. #error Undefined master type on 21
  864. #endif
  865. #endif
  866. #define _YCM v@
  867. #elseif MASTER == 22
  868. #if defined _YCM_w@
  869. #define YSIM_DEFINED
  870. #else
  871. #define _YCM_w@
  872. // Save the settings.
  873. #if !YSIM_HAS_MASTER
  874. #define YSIM_RECALL_22 0
  875. #elseif _YSIM_IS_CLIENT
  876. #define YSIM_RECALL_22 1
  877. #elseif _YSIM_IS_SERVER
  878. #define YSIM_RECALL_22 2
  879. #elseif _YSIM_IS_CLOUD
  880. #define YSIM_RECALL_22 3
  881. #elseif _YSIM_IS_STUB
  882. #define YSIM_RECALL_22 4
  883. #else
  884. #error Undefined master type on 22
  885. #endif
  886. #endif
  887. #define _YCM w@
  888. #elseif MASTER == 23
  889. #if defined _YCM_x@
  890. #define YSIM_DEFINED
  891. #else
  892. #define _YCM_x@
  893. // Save the settings.
  894. #if !YSIM_HAS_MASTER
  895. #define YSIM_RECALL_23 0
  896. #elseif _YSIM_IS_CLIENT
  897. #define YSIM_RECALL_23 1
  898. #elseif _YSIM_IS_SERVER
  899. #define YSIM_RECALL_23 2
  900. #elseif _YSIM_IS_CLOUD
  901. #define YSIM_RECALL_23 3
  902. #elseif _YSIM_IS_STUB
  903. #define YSIM_RECALL_23 4
  904. #else
  905. #error Undefined master type on 23
  906. #endif
  907. #endif
  908. #define _YCM x@
  909. #elseif MASTER == 24
  910. #if defined _YCM_y@
  911. #define YSIM_DEFINED
  912. #else
  913. #define _YCM_y@
  914. // Save the settings.
  915. #if !YSIM_HAS_MASTER
  916. #define YSIM_RECALL_24 0
  917. #elseif _YSIM_IS_CLIENT
  918. #define YSIM_RECALL_24 1
  919. #elseif _YSIM_IS_SERVER
  920. #define YSIM_RECALL_24 2
  921. #elseif _YSIM_IS_CLOUD
  922. #define YSIM_RECALL_24 3
  923. #elseif _YSIM_IS_STUB
  924. #define YSIM_RECALL_24 4
  925. #else
  926. #error Undefined master type on 24
  927. #endif
  928. #endif
  929. #define _YCM y@
  930. #elseif MASTER == 25
  931. #if defined _YCM_z@
  932. #define YSIM_DEFINED
  933. #else
  934. #define _YCM_z@
  935. // Save the settings.
  936. #if !YSIM_HAS_MASTER
  937. #define YSIM_RECALL_25 0
  938. #elseif _YSIM_IS_CLIENT
  939. #define YSIM_RECALL_25 1
  940. #elseif _YSIM_IS_SERVER
  941. #define YSIM_RECALL_25 2
  942. #elseif _YSIM_IS_CLOUD
  943. #define YSIM_RECALL_25 3
  944. #elseif _YSIM_IS_STUB
  945. #define YSIM_RECALL_25 4
  946. #else
  947. #error Undefined master type on 25
  948. #endif
  949. #endif
  950. #define _YCM z@
  951. #endif
  952. // Check for non-unique masters here.
  953. #if defined YSIM_DEFINED && !defined _YSIM_OVERRIDE && !defined YSIM_LIBRARY_OVERRIDE
  954. #error Non-unique master used.
  955. #endif
  956. #if YSIM_HAS_MASTER && !_YSIM_IS_CLIENT && !_YSIM_IS_STUB && (!defined YSIM_DEFINED || defined YSIM_LIBRARY_OVERRIDE)
  957. // FIRST declare the next callback in the chain.
  958. //#if defined FILTERSCRIPT
  959. // public OnFilterScriptInit()
  960. //#else
  961. // public OnGameModeInit()
  962. //#endif
  963. public OnMasterSystemInit()
  964. {
  965. P:1(#_YCM "_OGM");
  966. // THEN rename the callbacks.
  967. #if defined _YCM_CALLBACK
  968. #undef _YCM_CALLBACK
  969. #endif
  970. #if MASTER == 0
  971. #define _YCM_CALLBACK a@OnScriptInit
  972. #elseif MASTER == 1
  973. #define _YCM_CALLBACK b@OnScriptInit
  974. #elseif MASTER == 2
  975. #define _YCM_CALLBACK c@OnScriptInit
  976. #elseif MASTER == 3
  977. #define _YCM_CALLBACK d@OnScriptInit
  978. #elseif MASTER == 4
  979. #define _YCM_CALLBACK e@OnScriptInit
  980. #elseif MASTER == 5
  981. #define _YCM_CALLBACK f@OnScriptInit
  982. #elseif MASTER == 6
  983. #define _YCM_CALLBACK g@OnScriptInit
  984. #elseif MASTER == 7
  985. #define _YCM_CALLBACK h@OnScriptInit
  986. #elseif MASTER == 8
  987. #define _YCM_CALLBACK i@OnScriptInit
  988. #elseif MASTER == 9
  989. #define _YCM_CALLBACK j@OnScriptInit
  990. #elseif MASTER == 10
  991. #define _YCM_CALLBACK k@OnScriptInit
  992. #elseif MASTER == 11
  993. #define _YCM_CALLBACK l@OnScriptInit
  994. #elseif MASTER == 12
  995. #define _YCM_CALLBACK m@OnScriptInit
  996. #elseif MASTER == 13
  997. #define _YCM_CALLBACK n@OnScriptInit
  998. #elseif MASTER == 14
  999. #define _YCM_CALLBACK o@OnScriptInit
  1000. #elseif MASTER == 15
  1001. #define _YCM_CALLBACK p@OnScriptInit
  1002. #elseif MASTER == 16
  1003. #define _YCM_CALLBACK q@OnScriptInit
  1004. #elseif MASTER == 17
  1005. #define _YCM_CALLBACK r@OnScriptInit
  1006. #elseif MASTER == 18
  1007. #define _YCM_CALLBACK s@OnScriptInit
  1008. #elseif MASTER == 19
  1009. #define _YCM_CALLBACK t@OnScriptInit
  1010. #elseif MASTER == 20
  1011. #define _YCM_CALLBACK u@OnScriptInit
  1012. #elseif MASTER == 21
  1013. #define _YCM_CALLBACK v@OnScriptInit
  1014. #elseif MASTER == 22
  1015. #define _YCM_CALLBACK w@OnScriptInit
  1016. #elseif MASTER == 23
  1017. #define _YCM_CALLBACK x@OnScriptInit
  1018. #elseif MASTER == 24
  1019. #define _YCM_CALLBACK y@OnScriptInit
  1020. #elseif MASTER == 25
  1021. #define _YCM_CALLBACK z@OnScriptInit
  1022. #endif
  1023. #if _YSIM_IS_SERVER
  1024. // Steal the master.
  1025. _Master_Get(#_YCM, true);
  1026. CallRemoteFunction(#_YCM, "");
  1027. #else
  1028. #if _YSIM_IS_CLOUD
  1029. // Determine the next unique name,
  1030. // See if this script should be master.
  1031. if (_Master_Get(#_YCM))
  1032. {
  1033. P:2("Got master " #_YCM);
  1034. state _YCM:y;
  1035. }
  1036. else
  1037. {
  1038. state _YCM:n;
  1039. }
  1040. #endif
  1041. #endif
  1042. // FINALLY call the new next one.
  1043. CallLocalFunction(#_YCM_CALLBACK, "");
  1044. }
  1045. // Don't need extra checks here as we KNOW it is already defined.
  1046. #undef OnMasterSystemInit
  1047. #define OnMasterSystemInit _YCM_CALLBACK
  1048. forward _YCM_CALLBACK();
  1049. #endif
  1050. // The code below is now deprecated in favour of foreign/global!
  1051. // There are the following remote function definitions:
  1052. //
  1053. // RF - A basic function.
  1054. // RF@p - A function with special parameters which need passing hints.
  1055. // RF@c - A function with lots of paramteres that needs special code.
  1056. // RF@v - A function with no return value.
  1057. // RF@t - A function with a tag result.
  1058. // RC - A callback function.
  1059. // RH - A y_hooks hook.
  1060. // RS - Return a string.
  1061. //
  1062. //
  1063. // Supported combinations:
  1064. //
  1065. // pc, cp
  1066. // pcv, pvc, cpv, cvp, vpc, vcp
  1067. // pv, vp
  1068. // cv, vc
  1069. // cpt ctp pct ptc tcp tpc
  1070. // ct tc
  1071. // pt tp
  1072. //
  1073. // p and c are for special parameter sets, n is for no parameters, so those two
  1074. // groups can never be mixed together. t is for tag result and v is for no
  1075. // return, so they can never be used together.
  1076. //
  1077. // Note that the callback thing won't work with OnPlayerCommandText as it has a
  1078. // different default return to everything else.
  1079. //
  1080. // These parts are redefined every time the master system is included.
  1081. #if YSIM_HAS_MASTER
  1082. #if _YSIM_IS_SERVER
  1083. #define foreign%0(%1); %0(%1);%0@(%1);
  1084. //#define global%0(%1) %0@(%1);public%0@(%1)X@(_:@Zk:%0(_YM@CP:%1,,));%0(%1)
  1085. #define global%0(%1) public%0@(%1)X@(_:@Zk:_YM@CP:%0(%1,,));%0(%1)
  1086. #define RF:%1[%2](%3) @%1(%3);@%1(%3)U@(8,YSIM_RETURN,%1(%3));%1(%3)
  1087. #define RF@p:%1[%2](%3)<%4> @%1(%3);@%1(%3)U@(8,YSIM_RETURN,%1(%4));%1(%3)
  1088. #define RF@c RF
  1089. #define RF@v:%1[%2](%3) @%1(%3);@%1(%3)%1(%3);%1(%3)
  1090. //#define RF@n:%1[]() forward %1R();public %1R()U@(8,YSIM_RETURN,%1());%1()
  1091. #define RF@pc RF@p
  1092. #define RF@pv:%1[%2](%3)<%4> @%1(%3);@%1(%3)%1(%4);%1(%3)
  1093. #define RF@pcv RF@pv
  1094. #define RF@vc RF@v
  1095. //#define RF@vn:%1[]() forward %1R();public %1R()%1();%1()
  1096. #define RF@t:%0:%1[%2](%3) %0:%1(%3);@%1(%3);@%1(%3)U@(8,YSIM_RETURN,_:%1(%3));%0:%1(%3)
  1097. #define RF@pt:%0:%1[%2](%3)<%4> %0:%1(%3);@%1(%3);@%1(%3)U@(8,YSIM_RETURN,_:%1(%4));%0:%1(%3)
  1098. #define RF@ct RF@t
  1099. //#define RF@nt:%0:%1[]() forward %0:%1();forward %1R();public %1R()U@(8,YSIM_RETURN,_:%1());%0:%1()
  1100. #define RF@pct RF@pt
  1101. #define RS:%1[%2](%3) @%1(%3);@%1(%3)R@(%1(%3));%1(%3)
  1102. #define RS@p:%1[%2](%3)<%4> @%1(%3);@%1(%3)R@(%1(%4));%1(%3)
  1103. //#define RC:%1(%3) public %1(%3)
  1104. //#define RC@v RC
  1105. #define RH:On%2(%3) hook On%2(%3)
  1106. #define master_hook%0On%2(%3) hook On%2(%3)
  1107. #define group_hook%0On%2(%3) _GROUP_MAKE_NAME<hook On%2...>(%3)
  1108. #define RT:%0[%1](%2) @yT_%1_%0();@yT_%1_%0()
  1109. #if MASTER == 23
  1110. // Less strict (implicit user master).
  1111. #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)
  1112. #else
  1113. #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)
  1114. #endif
  1115. // Remote local - only calls the local version if we're master,
  1116. // doesn't call the remote version.
  1117. //#define RL:%1[%2](%3) %1(%3)
  1118. //#define RP@v:%1[%2](%3) forward @%1(%3);@%1(%3)%1(%3);static %1(%3)
  1119. // Shortcut for y_als hooks.
  1120. #define RA:%0_On%1(%3) public On%1(%3)
  1121. //#define RA@p:%0_%1[%2](%3)<%4> RA:%0_%1[%2](%3)
  1122. //#define RX:%0(%1) %0@yX_(%1);public %0@yX_(%1)
  1123. #define Master_Caller() \
  1124. (V@(8,YSIM_CALLER))
  1125. //#define Master_Get(%1) state (_Master_Get(#%1)) ? (%1:y) : (%1:n)
  1126. //#define Master_Init(%1); _Master_Get(#%1);
  1127. #else
  1128. // This definition has "%0(%1)" defined as "public", "stock" AND ""!!!
  1129. //#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);}
  1130. // Define "foreign" more generically. If you want "server" or "none"
  1131. // you will need to define this specifically, otherwise you just need to
  1132. // include the master system and then you can use "#tryinclude". This
  1133. // means that if "global" definitions aren't found this system will try
  1134. // default to STUB. This is NOT a complete definition - the "@Zu:"
  1135. // definition means that more processing is done (mainly for the
  1136. // definition of the "_YCM:m" function to not give warnings.
  1137. #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>
  1138. //#define foreign%0(%1); %0(%1)<>{new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}%0@(%1);
  1139. //#define foreign%0(%1); %0(%1)<>{new i=Y@();W@(#%0@##,_YM@CX:%1,,);return Z@(i);}%0@(%1);%0(%1)<_YCM:x>{}
  1140. #if _YSIM_IS_CLIENT
  1141. //#define foreign%0(%1); stock %0(%1){new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}
  1142. #define global%0(%1) stock %0_(%1)
  1143. // Defined the functions as remote calling stubs. Then rename the
  1144. // following code with a name unlikely to ever be used and define the
  1145. // functions as stock so the compiler removes all the code quietly.
  1146. #define RF:%1[%2](%3) stock %1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2#x,%3),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);stock _@%1(%3)
  1147. #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)
  1148. #define RF@c RF
  1149. #define RF@v:%1[%2](%3) stock %1(%3)U@(8,YSIM_CALLER,_@),W@(#@%1,#%2#x,%3),U@(8,YSIM_CALLER,-1);stock _@%1(%3)
  1150. //#define RF@n:%1[]() stock %1()return U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);stock _@%1()
  1151. #define RF@pc RF@p
  1152. #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)
  1153. #define RF@pcv RF@pv
  1154. #define RF@vc RF@v
  1155. //#define RF@vn:%1[]() stock %1()U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1);stock _@%1()
  1156. #define RF@t:%0:%1[%2](%3) stock %0:%1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2#x,%3),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);stock %0:_@%1(%3)
  1157. #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)
  1158. #define RF@ct RF@t
  1159. //#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()
  1160. #define RF@pct RF@pt
  1161. #define RS:%1[%2](%3) stock %1(%3)return Y@(),W@(#@%1,#%2#x,%3),S@(),Q@;stock _@%1(%3)
  1162. #define RS@p:%1[%2](%3)<%4> stock %1(%3)return Y@(),W@(#@%1,#%2,%4),S@(),Q@;stock _@%1(%3)
  1163. //#define RC:%1(%3) stock _@%1(%3)
  1164. //#define RC@v RC
  1165. #define RH:On%2(%3)
  1166. #define master_hook%0On%2(%3) stock UNIQUE_FUNCTION<_yH@%2...>(%3)
  1167. #define group_hook%0On%2(%3) stock _GROUP_MAKE_NAME<On%2...>(%3)
  1168. #define RT:%0[%1](%2) stock _yT@%1_%0()
  1169. #if MASTER == 23
  1170. // Less strict (implicit user master).
  1171. #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)
  1172. #else
  1173. #define RC:%0(%1) static stock _@yC%0()
  1174. #endif
  1175. //#define RP@v:%1[%2](%3) static stock %1(%3)U@(8,YSIM_CALLER,_@),W@(#@%1,#%2#x,%3),U@(8,YSIM_CALLER,-1);static stock _@%1(%3)
  1176. // Remote local - only calls the local version if we're master,
  1177. // doesn't call the remote version.
  1178. //#define RL:%1[%2](%3) stock %1(%3){}static stock _%1(%3)
  1179. //#define RX:%0(%1) stock %0_yX@(%1)
  1180. // Shortcut for y_als hooks.
  1181. #define RA:%0_On%1(%3) public On%1(%3)ALS_CALL<%1> static stock _%0_%1(%3)
  1182. //#define RA:%0_%1[%2](%3) public %1(%3)<>return Bit_GetBit(Bit:gs_ALS,_:ALS_%0)&&P@(#ALS_PREFIX"_"#%2#x,%3),1;public %1(%3)<_YCM:y>
  1183. //#define RA@p:%0_%1[%2](%3)<%4> public %1(%3)ALS_CALL<%1,#%2,%4>static stock _%0_%1(%3)
  1184. //#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>
  1185. #define Master_Caller() (-1)
  1186. #else
  1187. #if _YSIM_IS_STUB
  1188. //#define foreign%0(%1); stock %0(%1){new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}
  1189. #define global%0(%1)
  1190. // This is used to provide abstractions between different
  1191. // coders on the same team. Setting a library as a stub means
  1192. // that people without the main implementation can use the code
  1193. // through remote function calls and then the whole code can be
  1194. // integrated in to itself. Example use:
  1195. //
  1196. // #tryinclude "streamer_implementation"
  1197. // #if defined _inc_streamer_implementation
  1198. // #endinput
  1199. // #endif
  1200. //
  1201. // #define YSIM_U_ENABLE
  1202. // #define MASTER 10
  1203. // #include "y_master"
  1204. //
  1205. // RF@p:CreateObject[ifff](modelid,Float:x,Float:y,Float:z)<modelid,x,y,z>;
  1206. //
  1207. #define RF:%1[%2](%3) stock %1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2#x,%3),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN)//;stock _@%1()
  1208. #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()
  1209. #define RF@c RF
  1210. #define RF@v:%1[%2](%3) stock %1(%3)U@(8,YSIM_CALLER,_@),W@(#@%1,#%2#x,%3),U@(8,YSIM_CALLER,-1)//;stock _@%1()
  1211. //#define RF@n:%1[]() stock %1()return U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);stock _@%1()
  1212. #define RF@pc RF@p
  1213. #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()
  1214. #define RF@pcv RF@pv
  1215. #define RF@vc RF@v
  1216. //#define RF@vn:%1[]() stock %1()U@(8,YSIM_CALLER,_@),W@(#@%1,""),U@(8,YSIM_CALLER,-1);stock _@%1()
  1217. #define RF@t:%0:%1[%2](%3) stock %0:%1(%3)return U@(8,YSIM_CALLER,_@),W@(#@%1,#%2#x,%3),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN)//;stock _@%1()
  1218. #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()
  1219. #define RF@ct RF@t
  1220. //#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()
  1221. #define RF@pct RF@pt
  1222. // Doesn't have the end bit as the function isn't included.
  1223. #define RS:%1[%2](%3) stock %1(%3)return Y@(),W@(#@%1,#%2#x,%3),S@(),Q@//;stock _@%1()
  1224. #define RS@p:%1[%2](%3)<%4> stock %1(%3)return Y@(),W@(#@%1,#%2,%4),S@(),Q@//;stock _@%1()
  1225. // NOT DEFINED! Should not be used if this is a stub.
  1226. #define RC
  1227. // NOT DEFINED! Should not be used if this is a stub.
  1228. //#define RC@v
  1229. // NOT DEFINED! Should not be used if this is a stub.
  1230. #define RH
  1231. #define master_hook
  1232. #define group_hook
  1233. // NOT DEFINED! Should not be used if this is a stub.
  1234. #define RT
  1235. // Remote local - only calls the local version if we're master,
  1236. // doesn't call the remote version.
  1237. //#define RL:%1[%2](%3)
  1238. //#define RX
  1239. //#define RP@v
  1240. // Shortcut for y_als hooks.
  1241. #define RA //:%0_%1(%3)
  1242. //#define RA@p:%0_%1[%2](%3)<%4>
  1243. // NOT DEFINED! Should not be used if this is a stub.
  1244. #define Master_Caller
  1245. #else
  1246. //#define foreign%0(%1); %0(%1)<>{new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}%0@(%1);%0(%1)<_YCM:x>{}
  1247. //#define global%0(%1) %0@(%1);public%0@(%1)<>{}public%0@(%1)<_YCM:y>X@(_:@Zk:%0(_YM@CP:%1,,));%0(%1)<_YCM:y>
  1248. #define global%0(%1) public%0@(%1)<>{}public%0@(%1)<_YCM:y>X@(_:@Zk:_YM@CP:%0(%1,,));stock %0(%1)<_YCM:y>
  1249. // This is a normal system with the possibility of being the
  1250. // master. This is the very complicated one to write!
  1251. #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,#%2#x,%3),U@(8,YSIM_CALLER,-1),V@(8,YSIM_RETURN);%1(%3)<_YCM:y>
  1252. #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>
  1253. #define RF@c:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>X@(%1(%3));%1(%3)<>return Y@(),W@(#@%1,#%2#x,%3),Z@();%1(%3)<_YCM:y>
  1254. #define RF@v:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>%1(%3);%1(%3)<>U@(8,YSIM_CALLER,_@),W@(#@%1,#%2#x,%3),U@(8,YSIM_CALLER,-1);%1(%3)<_YCM:y>
  1255. //#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>
  1256. #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>
  1257. #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>
  1258. #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>
  1259. #define RF@vc:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>%1(%3);%1(%3)<>Y@(),W@(#@%1,#%2#x,%3),T@();%1(%3)<_YCM:y>
  1260. //#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>
  1261. #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,#%2#x,%3),U@(8,YSIM_CALLER,-1),%0:V@(8,YSIM_RETURN);%0:%1(%3)<_YCM:y>
  1262. #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>
  1263. #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,#%2#x,%3),%0:Z@();%0:%1(%3)<_YCM:y>
  1264. //#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>
  1265. #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>
  1266. //#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,#%2#x,%3),S@();%1(%3)<_YCM:y>
  1267. // Remote STRING (returns a string).
  1268. #define RS:%1[%2](%3) @%1(%3);@%1(%3)<>{}@%1(%3)<_YCM:y>R@(%1(%3));%1(%3)<>return Y@(),W@(#@%1,#%2#x,%3),S@(),Q@;%1(%3)<_YCM:y>
  1269. #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>
  1270. //#define RC:%1(%3) public %1(%3)<>return 1;public %1(%3)<_YCM:y>
  1271. //#define RC@v:%1(%3) public %1(%3)<>{}public %1(%3)<_YCM:y>
  1272. // Requires the y_hooks library.
  1273. #define RH:On%2(%3) hook On%2(%3)<>return ALS_R_%2;rehook On%2(%3)<_YCM:y>
  1274. #define master_hook%0On%2(%3) hook On%2(%3)<>return ALS_R_%2;rehook On%2(%3)<_YCM:y>
  1275. #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>
  1276. // Requires the y_timers library.
  1277. #define RT:%0[%1](%2) @yT_%1_%0();@yT_%1_%0()<>{}@yT_%1_%0()<_YCM:y>
  1278. /*#if
  1279. #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)
  1280. #else
  1281. // This code defines two publics so that if the master
  1282. // doesn't have a copy of the command it can still be called
  1283. // in another running script.
  1284. #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)
  1285. #endif*/
  1286. //#if defined _YSIM_USED_AUTO
  1287. #if MASTER == 23
  1288. // Less strict (implicit user master).
  1289. #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)
  1290. #else
  1291. // Strict libraries.
  1292. #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)
  1293. #endif
  1294. //#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,#%2#x,%3),U@(8,YSIM_CALLER,-1);static %1(%3)<_YCM:y>
  1295. #define Master_Caller() \
  1296. ((V@(8,YSIM_CALLER)==-1)?(_@):(V@(8,YSIM_CALLER)))
  1297. // Remote local - only calls the local version if we're master,
  1298. // doesn't call the remote version.
  1299. //#define RL:%1[%2](%3) %1(%3)<>return 1;%1(%3)<_YCM:y>
  1300. //#define RX:%0(%1) %0@yX_(%1);public %0@yX_(%1)<>{}public %0@yX_(%1)<_YCM:y>
  1301. //#define RX:%0(%1) UNIQUE_FUNCTION<@yX_...%0>(%1);UNIQUE_FUNCTION<@yX_...%0>(%1)<>{}UNIQUE_FUNCTION(@yX_...%0>(%1)<_YCM:y>
  1302. // Shortcut for y_als hooks.
  1303. //#define RA:%0_%1(%3) public %1(%3)<>ALS_CALL<%1>public %1(%3)<_YCM:y>
  1304. #define RA:%0_On%1(%3) public On%1(%3)<>ALS_CALL<%1> public On%1(%3)<_YCM:y>
  1305. //#define RA:%0_%1[%2](%3) public %1(%3)<>return Bit_GetBit(Bit:gs_ALS,_:ALS_%0)&&P@(#ALS_PREFIX"_"#%2#x,%3),1;public %1(%3)<_YCM:y>
  1306. //#define RA@p:%0_%1[%2](%3)<%4> public %1(%3)<>ALS_CALL<%1,#%2,%4>public %1(%3)<_YCM:y>
  1307. //#define Master_Get(%1) state (_Master_Get(#%1)) ? (%1:y) : (%1:n)
  1308. //#define Master_Init(%1); if (_Master_Get(#%1)) state %1:y; else state %1:n;
  1309. #endif
  1310. #endif
  1311. #endif
  1312. #else
  1313. #define foreign%0(%1);
  1314. #define global%0(%1) stock %0(%1)
  1315. // Master system isn't used.
  1316. #define RF:%1[%2](%3) stock %1(%3)
  1317. #define RF@p:%1[%2](%3)<%4> RF:%1[%2](%3)
  1318. #define RF@c RF
  1319. #define RF@v RF
  1320. //#define RF@n RF
  1321. #define RF@pc RF@p
  1322. #define RF@pv RF@p
  1323. #define RF@pcv RF@p
  1324. #define RF@vc RF
  1325. //#define RF@vn RF
  1326. #define RF@t:%0:%1[%2](%3) stock %0:%1(%3)
  1327. #define RF@pt:%0:%1[%2](%3)<%4> RF@t:%0:%1[%2](%3)
  1328. #define RF@ct RF@t
  1329. //#define RF@nt RF@t
  1330. #define RF@pct RF@p
  1331. #define RS:%1[%2](%3) stock %1(%3)
  1332. #define RS@p:%1[%2](%3)<%4> stock %1(%3)
  1333. #define RS@c RS
  1334. #define RS@pc RS@p
  1335. //#define RC:%1(%3) public %1(%3)
  1336. //#define RC@v: RC
  1337. #define RT:%0[%1](%2) @yT_%1_%0();@yT_%1_%0()
  1338. //#define RP@v:%0[%1](%2) static stock %0(%2)
  1339. #define RH:On%2(%3) hook On%2(%3)
  1340. #define master_hook%0On%2(%3) hook On%2(%3)
  1341. #define group_hook%0On%2(%3) _GROUP_MAKE_NAME<hook On%2...>(%3)
  1342. #define RC:%0(%1) @yC_%0(%1);@yC_%0(%1)
  1343. //#define RX:%0(%1) %0@yX_(%1);public %0@yX_(%1)
  1344. #define Master_Caller() (_@)
  1345. // Remote local - only calls the local version if we're master,
  1346. // doesn't call the remote version.
  1347. //#define RL:%1[%2](%3) stock %1(%3)
  1348. // Shortcut for y_als hooks.
  1349. #define RA:%0_On%1(%3) public On%1(%3)
  1350. //#define RA@p:%0_%1[%2](%3)<%4> RA:%0_%1[%2](%3)
  1351. //#define Master_Init(%1);
  1352. #endif
  1353. // Undefine this before the next call.
  1354. #undef MASTER
  1355. #if !defined YSIM_DEFINED || defined YSIM_LIBRARY_OVERRIDE
  1356. #if _YSIM_IS_CLOUD || _YSIM_IS_SERVER
  1357. // Define a load of fake functions to cater for the compiler's need to
  1358. // know all the possible states. y means master, n means not master, m
  1359. // means master system missing, p means previous (ending master), u
  1360. // means sort of uninitialised (though technically initialised). This
  1361. // also doubles as a handy call in function for resetting masters when a
  1362. // script ends. Just to clarify - this function is NOT called _YCM,
  1363. // that is a macro which is expanded every time this file is included.
  1364. // m is also now client/stub.
  1365. forward _YCM();
  1366. public _YCM() <_YCM:y>
  1367. {
  1368. P:1("%d: " #_YCM "<y> called", _@);
  1369. if (getproperty(8, #_YCM) != _@)
  1370. {
  1371. // Master, but not. A server has claimed this.
  1372. state _YCM:n;
  1373. }
  1374. else
  1375. {
  1376. P:2("%d: " #_YCM ":y called", _@);
  1377. // Disable the current mastership.
  1378. state _YCM:p;
  1379. setproperty(8, #_YCM, -1);
  1380. // Called locally to begin the hand off process.
  1381. CallRemoteFunction(#_YCM, "");
  1382. }
  1383. }
  1384. public _YCM() <_YCM:n>
  1385. {
  1386. P:1("%d: " #_YCM "<n> called", _@);
  1387. // This has been called remotely from a script which owns the
  1388. // library masterhood (that's the only way this can ever be called).
  1389. if (_Master_Get(#_YCM))
  1390. {
  1391. P:2("%d: " "Got master " #_YCM, _@);
  1392. state _YCM:y;
  1393. }
  1394. }
  1395. public _YCM() <_YCM:m, _YCM:p, _YCM:u>
  1396. {
  1397. P:1("%d: " #_YCM "<m,p,u,x> called", _@);
  1398. // Do nothing at all (just define states).
  1399. }
  1400. public _YCM() <>
  1401. {
  1402. P:1("%d: " #_YCM "<> called", _@);
  1403. if (_Master_Get(#_YCM))
  1404. {
  1405. P:2("%d: " "Got master " #_YCM, _@);
  1406. state _YCM:y;
  1407. }
  1408. else
  1409. {
  1410. state _YCM:n;
  1411. }
  1412. // Do nothing at all (just define states).
  1413. }
  1414. /*#elseif _YSIM_IS_SERVER
  1415. forward _YCM();
  1416. public _YCM() <_YCM:y>
  1417. {
  1418. P:1("%d: " #_YCM "<y> called", _@);
  1419. // Disable the current mastership.
  1420. state _YCM:p;
  1421. setproperty(8, #_YCM, -1);
  1422. // Called locally to begin the hand off process.
  1423. CallRemoteFunction(#_YCM, "");
  1424. }
  1425. public _YCM() <_YCM:n, _YCM:m, _YCM:p, _YCM:u>
  1426. {
  1427. P:1("%d: " #_YCM "<n,m,p,u,x> called", _@);
  1428. // Do nothing at all (just define states).
  1429. }
  1430. public _YCM() <>
  1431. {
  1432. P:1("%d: " #_YCM "<> called", _@);
  1433. //_Master_Get(#_YCM, true);
  1434. P:2("%d: " "Got master " #_YCM, _@);
  1435. state _YCM:y;
  1436. // Do nothing at all (just define states).
  1437. }*/
  1438. /*#else
  1439. #if _YSIM_IS_CLIENT || _YSIM_IS_STUB
  1440. static stock _YCM() <_YCM:m>
  1441. {
  1442. }
  1443. static stock _YCM() <>
  1444. {
  1445. }
  1446. #endif*/
  1447. #endif
  1448. #endif
  1449. #if defined YSIM_T_ENABLE
  1450. #undef YSIM_T_ENABLE
  1451. #endif
  1452. #if defined YSIM_T_DISABLE
  1453. #undef YSIM_T_DISABLE
  1454. #endif
  1455. #if defined YSIM_C_ENABLE
  1456. #undef YSIM_C_ENABLE
  1457. #endif
  1458. #if defined YSIM_C_DISABLE
  1459. #undef YSIM_C_DISABLE
  1460. #endif
  1461. #if defined YSIM_S_ENABLE
  1462. #undef YSIM_S_ENABLE
  1463. #endif
  1464. #if defined YSIM_S_DISABLE
  1465. #undef YSIM_S_DISABLE
  1466. #endif
  1467. #if defined YSIM_U_ENABLE
  1468. #undef YSIM_U_ENABLE
  1469. #endif
  1470. #if defined YSIM_U_DISABLE
  1471. #undef YSIM_U_DISABLE
  1472. #endif
  1473. // Allow YSI scripts to use the extended master system
  1474. /*#if defined _YSIM_USED_AUTO
  1475. #undef _YSIM_USED_AUTO
  1476. #endif*/
  1477. #if defined _YSIM_OVERRIDE
  1478. #undef _YSIM_OVERRIDE
  1479. #endif
  1480. #if defined YSIM_STORED_SETTINGS
  1481. #undef YSIM_STORED_SETTINGS
  1482. #endif
  1483. /*
  1484. // @Zs:@Za:@Zd:#d#i @Zr:|||a|||@Ze: string:b[], array:d[], f);
  1485. //@Zs:@Za:@Zs:@Za:@Zd:#d#i @Zr:|||a|||@Ze:string:b[],array:d[], f);
  1486. //#define @Zs:@Za:@Zd:#%0#i%1||||string:%2[%3],%4); @Zs:@Za:@Zd:#%0s#i%1|||%2||||%4);
  1487. //#define @Za:@Zd:#%0#i%1||||array:%2[%3],%4); @Zs:@Za:@Zd:#%0a#i%1|||%2||||%4);
  1488. //#define @Zd:#%0#i%1||||%2,%4); @Zs:@Za:@Zd:#%0d#i%1|||%2||||%4);
  1489. //#define @Zr:%0|||%1hze: ,%0
  1490. //#define @Zs:@Zd:#%1|||%0string:%2[%3]|||%4,%5); @Zs:@Zd:#%1,s:%2|||%4|||%5);
  1491. //#define @Zd:#%1|||%2|||%3,%4); @Zs:@Zd:#%1,d:%2|||%3|||%4);
  1492. #define @Zs:@Za:@Zd:#%0#%1|||%2string:%3[%4]|||%5,%6) @Zs:@Za:@Zd:#%0s#%1,@Ze:%3|||%5|||%6)
  1493. #define @Za:@Zd:#%0#%1|||%3[%4]|||%5,%6) @Zs:@Za:@Zd:#%0a#%1,@Ze:%3|||%5|||%6)
  1494. #define @Zd:#%0#%1|||%3|||%5,%6) @Zs:@Za:@Zd:#%0i#%1,@Ze:%3|||%5|||%6)
  1495. //#define @Zd:#%1|||%2|||%3,%4); @Zs:@Zd:#%1,d:%2|||%3|||%4);
  1496. #define @Ze:%0|||||| @Ze:%0
  1497. #define z,@Ze:||||||) )
  1498. //#define @Zc:
  1499. #define _YM@CM:%0,%1) @Zf:@Zs:@Za:@Zd:##z|||%0|||%1)
  1500. // DO NOT USE THIS HERE AGAIN! _YM@CR USED IN Y_REMOTE!
  1501. //#define _YM@CR:%0(%1); W@(#%0@##,_YM@CM:%1,,);
  1502. #define W@(#%0:%1##,%2);%3Z@(i) W@(#%1,%2);return %0:Z@(%0:i)
  1503. #define Z@(%0string:i) S@(i),Q@
  1504. #define string:
  1505. #define foreign%0(%1); %0(%1)<>{new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}%0@(%1);
  1506. //#define @Zt:@Zb:@Zg:@Zh:%1|||%2:%3[%4]|||%5,%6) //@Zt:@Zb:@Zg:@Zh:%1%2:@Zi:%3,|||%5|||%6)
  1507. //#define @Zb:@Zg:@Zh:%1|||%3[%4]|||%5,%6) @Zt:@Zb:@Zg:@Zh:%1hzi:%3,|||%5|||%6)
  1508. //#define @Zg:@Zh:%1|||%2:%3|||%5,%6) @Zt:@Zb:@Zg:@Zh:%1%2:@Zi:%3,|||%5|||%6)
  1509. //#define @Zh:%1|||%3|||%5,%6) @Zt:@Zb:@Zg:@Zh:%1hzi:%3,|||%5|||%6)
  1510. #define @Zt:@Zb:@Zh:%1|||%2:%3|||%5) %1%2:@Zb:@Zh:|||%3|||%5)
  1511. #define @Zb:@Zh:%1|||%3[%4]|||%5,%6) @Zt:@Zb:@Zh:%1hzi:%3,|||%5|||%6)
  1512. //#define @Zg:@Zh:%1|||%2:%3|||%5,%6) @Zt:@Zb:@Zg:@Zh:%1%2:@Zi:%3,|||%5|||%6)
  1513. #define @Zh:%1|||%3|||%5,%6) @Zt:@Zb:@Zh:%1hzi:%3,|||%5|||%6)
  1514. //#define @Zd:#%1|||%2|||%3,%4); @Zs:@Zd:#%1,d:%2|||%3|||%4);
  1515. #define @Zi:%0,|||||| @Zi:%0
  1516. #define @Zj:X@(%0(_YM@CP:,,)) X@(%0())
  1517. //#define @Zt:@Zb:@Zg:@Zh:||||||,) )
  1518. //#define z,@Ze:||||||) )
  1519. //#define @Zc:
  1520. #define _YM@CP:%0,%1) @Zt:@Zb:@Zh:|||%0|||%1)
  1521. #define X@(%0string:%1) R@(%1)
  1522. #define global%0(%1) public%0@(%1)<>{}public%0@(%1)<_YCM:y>X@(_:%0(_YM@CP:%1,,));%0(%1)<_YCM:y>
  1523. */
  1524. /*
  1525. // "foreign" declaration.
  1526. #define @Zs:@Za:@Zd:#%0#%1|||%2string:%3[%4]|||%5,%6) @Zs:@Za:@Zd:#%0s#%1,@Ze:%3|||%5|||%6)
  1527. #define @Za:@Zd:#%0#%1|||%3[%4]|||%5,%6) @Zs:@Za:@Zd:#%0a#%1,@Ze:%3|||%5|||%6)
  1528. #define @Zd:#%0#%1|||%3|||%5,%6) @Zs:@Za:@Zd:#%0i#%1,@Ze:%3|||%5|||%6)
  1529. #define @Ze:%0|||||| @Ze:%0
  1530. #define z,@Ze:||||||) )
  1531. #define _YM@CM:%0,%1) @Zf:@Zs:@Za:@Zd:##z|||%0|||%1)
  1532. #define W@(#%0:%1##,%2);%3Z@(i) W@(#%1,%2);return %0:Z@(%0:i)
  1533. #define Z@(%0string:i) S@(i),Q@
  1534. #define string:
  1535. #define foreign%0(%1); %0(%1)<>{new i=Y@();W@(#%0@##,_YM@CM:%1,,);return Z@(i);}%0@(%1);
  1536. // "global" declaration
  1537. #define @Zt:@Zb:@Zh:%1|||%2:%3|||%5) %1%2:@Zb:@Zh:|||%3|||%5)
  1538. #define @Zb:@Zh:%1|||%3[%4]|||%5,%6) @Zt:@Zb:@Zh:%1hzi:%3,|||%5|||%6)
  1539. #define @Zh:%1|||%3|||%5,%6) @Zt:@Zb:@Zh:%1hzi:%3,|||%5|||%6)
  1540. #define @Zi:%0,|||||| @Zi:%0
  1541. #define @Zj:X@(%0(_YM@CP:,,)) X@(%0())
  1542. #define _YM@CP:%0,%1) @Zt:@Zb:@Zh:|||%0|||%1)
  1543. #define X@(%0string:%1) R@(%1)
  1544. #define global%0(%1) public%0@(%1)<>{}public%0@(%1)<_YCM:y>X@(_:%0(_YM@CP:%1,,));%0(%1)<_YCM:y>
  1545. */
  1546. // Clean up the new library definition code.
  1547. #if defined _YSIM_LAST_LIBRARY_MASTER
  1548. #undef _YSIM_LAST_LIBRARY_MASTER
  1549. #endif
  1550. #if defined LIBRARY_MASTER
  1551. #if LIBRARY_MASTER == 0
  1552. #define _YSIM_LAST_LIBRARY_MASTER 0
  1553. #elseif LIBRARY_MASTER == 1
  1554. #define _YSIM_LAST_LIBRARY_MASTER 1
  1555. #elseif LIBRARY_MASTER == 2
  1556. #define _YSIM_LAST_LIBRARY_MASTER 2
  1557. #elseif LIBRARY_MASTER == 3
  1558. #define _YSIM_LAST_LIBRARY_MASTER 3
  1559. #elseif LIBRARY_MASTER == 4
  1560. #define _YSIM_LAST_LIBRARY_MASTER 4
  1561. #elseif LIBRARY_MASTER == 5
  1562. #define _YSIM_LAST_LIBRARY_MASTER 5
  1563. #elseif LIBRARY_MASTER == 6
  1564. #define _YSIM_LAST_LIBRARY_MASTER 6
  1565. #elseif LIBRARY_MASTER == 7
  1566. #define _YSIM_LAST_LIBRARY_MASTER 7
  1567. #elseif LIBRARY_MASTER == 8
  1568. #define _YSIM_LAST_LIBRARY_MASTER 8
  1569. #elseif LIBRARY_MASTER == 9
  1570. #define _YSIM_LAST_LIBRARY_MASTER 9
  1571. #elseif LIBRARY_MASTER == 10
  1572. #define _YSIM_LAST_LIBRARY_MASTER 10
  1573. #elseif LIBRARY_MASTER == 11
  1574. #define _YSIM_LAST_LIBRARY_MASTER 11
  1575. #elseif LIBRARY_MASTER == 12
  1576. #define _YSIM_LAST_LIBRARY_MASTER 12
  1577. #elseif LIBRARY_MASTER == 13
  1578. #define _YSIM_LAST_LIBRARY_MASTER 13
  1579. #elseif LIBRARY_MASTER == 14
  1580. #define _YSIM_LAST_LIBRARY_MASTER 14
  1581. #elseif LIBRARY_MASTER == 15
  1582. #define _YSIM_LAST_LIBRARY_MASTER 15
  1583. #elseif LIBRARY_MASTER == 16
  1584. #define _YSIM_LAST_LIBRARY_MASTER 16
  1585. #elseif LIBRARY_MASTER == 17
  1586. #define _YSIM_LAST_LIBRARY_MASTER 17
  1587. #elseif LIBRARY_MASTER == 18
  1588. #define _YSIM_LAST_LIBRARY_MASTER 18
  1589. #elseif LIBRARY_MASTER == 19
  1590. #define _YSIM_LAST_LIBRARY_MASTER 19
  1591. #elseif LIBRARY_MASTER == 20
  1592. #define _YSIM_LAST_LIBRARY_MASTER 20
  1593. #elseif LIBRARY_MASTER == 21
  1594. #define _YSIM_LAST_LIBRARY_MASTER 21
  1595. #elseif LIBRARY_MASTER == 22
  1596. #define _YSIM_LAST_LIBRARY_MASTER 22
  1597. #elseif LIBRARY_MASTER == 23
  1598. #define _YSIM_LAST_LIBRARY_MASTER 23
  1599. #elseif LIBRARY_MASTER == 24
  1600. #define _YSIM_LAST_LIBRARY_MASTER 24
  1601. #elseif LIBRARY_MASTER == 25
  1602. #define _YSIM_LAST_LIBRARY_MASTER 25
  1603. #endif
  1604. #undef LIBRARY_MASTER
  1605. #endif
  1606. #if defined YSIM_LIBRARY_OVERRIDE
  1607. #undef YSIM_LIBRARY_OVERRIDE
  1608. #endif