y_shortfunc.inc 6.6 KB

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