y_shortfunc.inc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /**--------------------------------------------------------------------------**\
  2. ====================
  3. YSI - Master Funcs
  4. ====================
  5. Description:
  6. Defines new names for native functions.
  7. Legal:
  8. Version: MPL 1.1
  9. The contents of this file are subject to the Mozilla Public License Version
  10. 1.1 (the "License"); you may not use this file except in compliance with
  11. the License. You may obtain a copy of the License at
  12. http://www.mozilla.org/MPL/
  13. Software distributed under the License is distributed on an "AS IS" basis,
  14. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  15. for the specific language governing rights and limitations under the
  16. License.
  17. The Original Code is the YSI master include.
  18. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  19. Portions created by the Initial Developer are Copyright (C) 2011
  20. the Initial Developer. All Rights Reserved.
  21. Contributors:
  22. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  23. Thanks:
  24. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  25. ZeeX - Very productive conversations.
  26. koolk - IsPlayerinAreaEx code.
  27. TheAlpha - Danish translation.
  28. breadfish - German translation.
  29. Fireburn - Dutch translation.
  30. yom - French translation.
  31. 50p - Polish translation.
  32. Zamaroht - Spanish translation.
  33. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  34. for me to strive to better.
  35. Pixels^ - Running XScripters where the idea was born.
  36. Matite - Pestering me to release it and using it.
  37. Very special thanks to:
  38. Thiadmer - PAWN, whose limits continue to amaze me!
  39. Kye/Kalcor - SA:MP.
  40. SA:MP Team past, present and future - SA:MP.
  41. Version:
  42. 0.2
  43. Changelog:
  44. 21/10/10:
  45. Split in to y_shortfunc.
  46. Functions:
  47. Public:
  48. -
  49. Core:
  50. -
  51. Stock:
  52. -
  53. Static:
  54. -
  55. Inline:
  56. -
  57. API:
  58. -
  59. Hooks:
  60. -
  61. Callbacks:
  62. -
  63. Definitions:
  64. -
  65. Enums:
  66. -
  67. Macros:
  68. -
  69. Tags:
  70. -
  71. Variables:
  72. Global:
  73. -
  74. Static:
  75. -
  76. Commands:
  77. -
  78. Compile options:
  79. -
  80. Operators:
  81. -
  82. Natives:
  83. W@ - Renaming of __CallRemoteFunction for size reasons.
  84. V@ - Renaming of getproperty for size reasons.
  85. S@ - Renaming of setproperty for size reasons.
  86. P@ - Renaming of __CallLocalFunction for size reasons.
  87. </remarks>
  88. \**--------------------------------------------------------------------------**/
  89. #if defined _INC_y_shortfunc
  90. #endinput
  91. #endif
  92. #define _INC_y_shortfunc
  93. // Used to get rid of the "string:" tag once it has been used.
  94. #if !defined string
  95. #define string:
  96. #endif
  97. #if !defined void
  98. #define void:
  99. #endif
  100. #include "..\YSI_Core\y_utils"
  101. #include "y_globaltags"
  102. #include "..\YSI_Core\y_debug"
  103. #include "y_renative"
  104. // Public variable.
  105. public stock
  106. _@ = 0;
  107. // J@ is a "nul" target - send things there if they need ignoring or if a
  108. // parameter needs using. I@ is too now.
  109. stock
  110. I@,
  111. J@;
  112. // N@ taken by y_uvar.
  113. // M@ taken by y_svar.
  114. // L@ taken by y_testing.
  115. native _YSI_RE_NATIVE<U@|||id=0, const name[]="", value=cellmin, const string[]=""|||setproperty>
  116. native _YSI_RE_NATIVE<V@|||GLOBAL_TAG_TYPES:id=0, const name[]="", value=cellmin, string[]=""|||getproperty>
  117. #if defined _YSI_MINI_MODE
  118. #undef CallRemoteFunction
  119. #undef CallLocalFunction
  120. #endif
  121. #if defined _ALS_CallRemoteFunction
  122. #if defined BAD_CallRemoteFunction
  123. #undef CallRemoteFunction
  124. #else
  125. #error Unknown redefinition of CallRemoteFunction.
  126. #endif
  127. #endif
  128. // Define this command with basically every strong tag in existence to avoid
  129. // tag mismatch warnings with remote functions with strong tag parameters.
  130. native _YSI_RE_NATIVE<W@|||const function[], const format[], GLOBAL_TAG_TYPES:...|||CallRemoteFunction>
  131. native _YSI_RE_NATIVE<P@|||const function[], const format[], GLOBAL_TAG_TYPES:...|||CallLocalFunction>
  132. #if defined _ALS_CallRemoteFunction
  133. #if defined BAD_CallRemoteFunction
  134. #define CallRemoteFunction FIXES_CallRemoteFunction
  135. #endif
  136. #endif
  137. #if defined _YSI_MINI_MODE
  138. #if defined _ALS_CallRemoteFunction
  139. #undef CallRemoteFunction
  140. #else
  141. #define _ALS_CallRemoteFunction
  142. #endif
  143. #define CallRemoteFunction _MMD(CallRemoteFunction)
  144. #if defined _ALS_CallLocalFunction
  145. #undef CallLocalFunction
  146. #else
  147. #define _ALS_CallLocalFunction
  148. #endif
  149. #define CallLocalFunction _MMD(CallLocalFunction)
  150. #endif
  151. native _YSI_RE_NATIVE<O@|||const function[], time, repeat, const format[], GLOBAL_TAG_TYPES:...|||SetTimerEx>
  152. native _YSI_RE_NATIVE<K@|||const function[], time, repeat|||SetTimer>
  153. stock X@(GLOBAL_TAG_TYPES:n)
  154. {
  155. P:4("X@ called: %i", n);
  156. setproperty(8, YSIM_RETURN, n);
  157. }
  158. // stock Y@()
  159. // {
  160. // P:4("Y@ called");
  161. // static
  162. // ret
  163. // return
  164. // ret = getproperty(8, YSIM_CALLER),
  165. // setproperty(8, YSIM_CALLER, _@),
  166. // ret;
  167. // }
  168. stock Y@()
  169. {
  170. P:4("Y@ called");
  171. // Already returns the previous value.
  172. return setproperty(8, YSIM_CALLER, _@);
  173. }
  174. stock Z@(GLOBAL_TAG_TYPES:v = -1)
  175. {
  176. P:4("Z@ called");
  177. return
  178. setproperty(8, YSIM_CALLER, v),
  179. getproperty(8, YSIM_RETURN);
  180. }
  181. new Q@[YSI_MAX_STRING];
  182. stock S@(GLOBAL_TAG_TYPES:v = -1)
  183. {
  184. P:4("S@ called");
  185. return
  186. getproperty(8, "", YSIM_STRING, Q@),
  187. strunpack(Q@, Q@),
  188. setproperty(8, YSIM_CALLER, v);
  189. //return Q@;
  190. }
  191. stock R@(buffer[])
  192. {
  193. P:4("R@ called: \"%s\"", buffer);
  194. return setproperty(8, "", YSIM_STRING, buffer);
  195. }
  196. stock H@(GLOBAL_TAG_TYPES:...)
  197. {
  198. // Just a dead-end for spare parameters.
  199. return 0;
  200. }
  201. #define _UNUSED(%0) H@(_:_H@0:_H@1:%0)
  202. #define _H@0:_H@1:%0&%1) _H@0:_H@1:%0%1)
  203. #define _H@1:%0[%9]%1) _H@1:%0%1)
  204. stock G@(GLOBAL_TAG_TYPES:...)
  205. {
  206. // Just a dead-end for spare parameters which returns a string.
  207. return Q@;
  208. }
  209. stock F@()
  210. {
  211. P:4("F@ called");
  212. return
  213. getproperty(8, "", YSIM_STRING, Q@),
  214. //P:4("2"),
  215. //P:4("3"),
  216. strunpack(Q@, Q@);
  217. //return Q@;
  218. }
  219. // Consume trailing spaces. Despite being a common letter, this is unlkely to
  220. // ever be matched due to the unusual series of operators after it. If anyone
  221. // else tries to define "x" however they may have a slight problem (they can't).
  222. //#define x,), x),
  223. // Changed as x,): was also needed (for ?:).
  224. #define x:##),) #))
  225. //#define x,) )
  226. #define q:##),ALS_RS_none:) #))
  227. // This is for getting excess parameters on non-strings.
  228. #define _:%0,) %0)
  229. #if defined YSI_LOCK_MODE
  230. #include "..\YSI_Coding\y_hooks"
  231. hook OnScriptInit()
  232. {
  233. new
  234. find = strfind(YSI_gLockData[5], YSI_gLockData[1]) + 6;
  235. find = strfind(YSI_gLockData[5], YSI_gLockData[1], _, find - 5) + 6;
  236. new
  237. found = strfind(YSI_gLockData[5], YSI_gLockData[1], _, find - 5) + 6;
  238. if (strval(YSI_gLockData[found]) ^ 0x12345678 != _LOCK_IP_3 ^ 0x12345678 || strval(YSI_gLockData[find]) - _LOCK_IP_3 != _LOCK_IP_2 - _LOCK_IP_3)
  239. {
  240. y_lock 1;
  241. }
  242. }
  243. #endif