_impl2.inc 51 KB

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