1
0

setup.inc 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. Legal:
  3. Version: MPL 1.1
  4. The contents of this file are subject to the Mozilla Public License Version
  5. 1.1 the "License"; you may not use this file except in compliance with
  6. the License. You may obtain a copy of the License at
  7. http://www.mozilla.org/MPL/
  8. Software distributed under the License is distributed on an "AS IS" basis,
  9. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  10. for the specific language governing rights and limitations under the
  11. License.
  12. The Original Code is the YSI framework.
  13. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  14. Portions created by the Initial Developer are Copyright C 2011
  15. the Initial Developer. All Rights Reserved.
  16. Contributors:
  17. Y_Less
  18. koolk
  19. JoeBullet/Google63
  20. g_aSlice/Slice
  21. Misiur
  22. samphunter
  23. tianmeta
  24. maddinat0r
  25. spacemud
  26. Crayder
  27. Dayvison
  28. Ahmad45123
  29. Zeex
  30. irinel1996
  31. Yiin-
  32. Chaprnks
  33. Konstantinos
  34. Masterchen09
  35. Southclaws
  36. PatchwerkQWER
  37. m0k1
  38. paulommu
  39. udan111
  40. Thanks:
  41. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  42. ZeeX - Very productive conversations.
  43. koolk - IsPlayerinAreaEx code.
  44. TheAlpha - Danish translation.
  45. breadfish - German translation.
  46. Fireburn - Dutch translation.
  47. yom - French translation.
  48. 50p - Polish translation.
  49. Zamaroht - Spanish translation.
  50. Los - Portuguese translation.
  51. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  52. me to strive to better.
  53. Pixels^ - Running XScripters where the idea was born.
  54. Matite - Pestering me to release it and using it.
  55. Very special thanks to:
  56. Thiadmer - PAWN, whose limits continue to amaze me!
  57. Kye/Kalcor - SA:MP.
  58. SA:MP Team past, present and future - SA:MP.
  59. Optional plugins:
  60. Gamer_Z - GPS.
  61. Incognito - Streamer.
  62. Me - sscanf2, fixes2, Whirlpool.
  63. */
  64. #define _GROUP_LOCAL_NAME _GROUP_MAKE_TAG:e
  65. // Dummy values.
  66. #define INVALID_GROUP (Group:-1)
  67. // IF THIS VALUE EVER CHANGES, CHANGE y_playerset AS WELL - IT MAY BE INCLUDED
  68. // BEFORE y_groups BUT NEEDS THE MACRO.
  69. //
  70. // TODO: Fix that fact with better y_groups segmenting.
  71. #define GROUP_MASK (Group:0x80000000)
  72. #define GROUP_GLOBAL (Group:_MAX_GROUPS | GROUP_MASK) //-1)
  73. #define GROUP_FIX(%0) ((%0)&=~GROUP_MASK)
  74. #define GROUP_TEMP_FIX(%0) ((%0)&~GROUP_MASK)
  75. #define GROUP_MANGLE(%0) (Group:(%0) | GROUP_MASK)
  76. // This is currently "leaking" code to the final script - code that we don't
  77. // want! No longer.
  78. #if defined _YSI_HAS_y_groups || __COMPILER_1ST_PASS
  79. #define NO_GROUPS(%0) if(_GROUP_INITIALISE(%0))
  80. #else
  81. #define NO_GROUPS(%0)
  82. #endif
  83. #define _GROUP_INITIALISE _GROUP_MAKE_NAME<..._InitialiseFromGroups>
  84. // Chain init functions.
  85. #define GROUP_CHAIN%9<%0>(%1) (J@=_:(_Y_G@C_YES:_Y_G@C_NO:%0%9|||(_:_Y_G@C3:_Y_G@C2:_Y_G@C0:_Y_G@C1:%0(%1))))
  86. #define _Y_G@C3:_Y_G@C2:_Y_G@C0:_Y_G@C1:%0(%1,%2,%3) _Y_G@C_3(%0,_:_Y_G@P:_Y_G@Q:_Y_G@R:%1,_:%2,_:%3|||)
  87. #define _Y_G@C2:_Y_G@C0:_Y_G@C1:%0(%1,%2) _Y_G@C_2(%0,_:_Y_G@P:_Y_G@Q:_Y_G@R:%1,_:%2|||)
  88. #define _Y_G@C0:_Y_G@C1:%0() _Y_G@C_0(%0)
  89. #define _Y_G@C1:%0(%1) _Y_G@C_1(%0,_:_Y_G@P:_Y_G@Q:_Y_G@R:%1|||)
  90. #define _Y_G@C_YES:_Y_G@C_NO:%0?||| (!(%0))?(0):
  91. #define _Y_G@C_NO:%0|||
  92. // Can strip out multiple brackets in one go.
  93. #define _Y_G@P:%0[]%1||| _Y_G@P:%0%1|||
  94. #define _Y_G@Q:%0&%1||| _Y_G@Q:%0%1|||
  95. #define _Y_G@R:%0||| %0
  96. // Set up the uniques to make removing them simpler.
  97. #define _GROUP_UNIQUE_SYMBOL 0
  98. #define _GROUP_UNIQUE_FUNCTION
  99. #if !defined MAX_GROUP_NAME
  100. #define MAX_GROUP_NAME (24)
  101. #endif
  102. #if defined MAX_GROUPS
  103. // Round up to the next nice number (or not, we could with long macros).
  104. #define _MAX_GROUPS (_:MAX_GROUPS)
  105. #else
  106. // 1 less than a nice number (with good reason).
  107. #define _MAX_GROUPS (_:127)
  108. #endif
  109. #define _MAX_GROUPS_G (_:_MAX_GROUPS + 1)
  110. // Note that these macros always do the last element before all the others
  111. // (which may or may not be in order). This is as the last element holds the
  112. // "default" group, which is the most likely to be a good match.
  113. #if _MAX_GROUPS < 32
  114. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[0]&%1[0])
  115. #elseif _MAX_GROUPS < 64
  116. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[1]&%1[1]||%0[0]&%1[0])
  117. #elseif _MAX_GROUPS < 96
  118. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[2]&%1[2]||%0[0]&%1[0]||%0[1]&%1[1])
  119. #elseif _MAX_GROUPS < 128
  120. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[3]&%1[3]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2])
  121. #elseif _MAX_GROUPS < 160
  122. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[4]&%1[4]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3])
  123. #elseif _MAX_GROUPS < 192
  124. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[5]&%1[5]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4])
  125. #elseif _MAX_GROUPS < 224
  126. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[6]&%1[6]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5])
  127. #elseif _MAX_GROUPS < 256
  128. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[7]&%1[7]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6])
  129. #elseif _MAX_GROUPS < 288
  130. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[8]&%1[8]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7])
  131. #elseif _MAX_GROUPS < 320
  132. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[9]&%1[9]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7]||%0[8]&%1[8])
  133. #elseif _MAX_GROUPS < 352
  134. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[10]&%1[10]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7]||%0[8]&%1[8]||%0[9]&%1[9])
  135. #elseif _MAX_GROUPS < 384
  136. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[11]&%1[11]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7]||%0[8]&%1[8]||%0[9]&%1[9]||%0[10]&%1[10])
  137. #elseif _MAX_GROUPS < 416
  138. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[12]&%1[12]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7]||%0[8]&%1[8]||%0[9]&%1[9]||%0[10]&%1[10]||%0[11]&%1[11])
  139. #elseif _MAX_GROUPS < 448
  140. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[13]&%1[13]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7]||%0[8]&%1[8]||%0[9]&%1[9]||%0[10]&%1[10]||%0[11]&%1[11]||%0[12]&%1[12])
  141. #elseif _MAX_GROUPS < 480
  142. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[14]&%1[14]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7]||%0[8]&%1[8]||%0[9]&%1[9]||%0[10]&%1[10]||%0[11]&%1[11]||%0[12]&%1[12]||%0[13]&%1[13])
  143. #elseif _MAX_GROUPS < 512
  144. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[15]&%1[15]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7]||%0[8]&%1[8]||%0[9]&%1[9]||%0[10]&%1[10]||%0[11]&%1[11]||%0[12]&%1[12]||%0[13]&%1[13]||%0[14]&%1[14])
  145. #elseif _MAX_GROUPS < 534
  146. #define _GROUPS_CHECK_ANY(%0,%1) if(%0[16]&%1[16]||%0[0]&%1[0]||%0[1]&%1[1]||%0[2]&%1[2]||%0[3]&%1[3]||%0[4]&%1[4]||%0[5]&%1[5]||%0[6]&%1[6]||%0[7]&%1[7]||%0[8]&%1[8]||%0[9]&%1[9]||%0[10]&%1[10]||%0[11]&%1[11]||%0[12]&%1[12]||%0[13]&%1[13]||%0[14]&%1[14]||%0[15]&%1[15])
  147. #else
  148. // The variable is now based on both input variables to avoid shadow
  149. // warnings when used within another check (as in "Group_FullPlayerUpdate").
  150. #define _GROUPS_CHECK_ANY(%0,%1) \
  151. for (new %1__g%0 = bits<_MAX_GROUPS_G>; %1__g%0--; ) if ((%0[%1__g%0] & %1[%1__g%0]) && !((%1__g%0 = 0)))
  152. #endif
  153. stock
  154. BitArray:YSI_gGroupPlayers[MAX_PLAYERS]<_MAX_GROUPS_G>,
  155. BitArray:YSI_gTempGroups<_MAX_GROUPS_G>;
  156. stock const
  157. BitArray:YSI_g_cEmptyGroups<_MAX_GROUPS_G>;