y_shortfunc.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. \**--------------------------------------------------------------------------**/
  88. #if defined _INC_y_shortfunc
  89. #endinput
  90. #endif
  91. #define _INC_y_shortfunc
  92. // Used to get rid of the "string:" tag once it has been used.
  93. #if !defined string
  94. #define string:
  95. #endif
  96. #if !defined void
  97. #define void:
  98. #endif
  99. #include "..\YSI_Core\y_utils"
  100. #include "y_globaltags"
  101. #include "y_shortvar"
  102. #include "..\YSI_Core\y_debug"
  103. #include "y_renative"
  104. // N@ taken by y_uvar.
  105. // M@ taken by y_svar.
  106. // L@ taken by y_testing.
  107. native _YSI_RE_NATIVE<U@|||id=0, const name[]="", value=cellmin, const string[]=""|||setproperty>
  108. native _YSI_RE_NATIVE<V@|||GLOBAL_TAG_TYPES:id=0, const name[]="", value=cellmin, string[]=""|||getproperty>
  109. #if defined _YSI_MINI_MODE
  110. #undef CallRemoteFunction
  111. #undef CallLocalFunction
  112. #endif
  113. #if defined _ALS_CallRemoteFunction
  114. #if defined BAD_CallRemoteFunction
  115. #undef CallRemoteFunction
  116. #else
  117. #error Unknown redefinition of CallRemoteFunction.
  118. #endif
  119. #endif
  120. // Define this command with basically every strong tag in existence to avoid
  121. // tag mismatch warnings with remote functions with strong tag parameters.
  122. native _YSI_RE_NATIVE<W@|||const function[], const format[], GLOBAL_TAG_TYPES:...|||CallRemoteFunction>
  123. native _YSI_RE_NATIVE<P@|||const function[], const format[], GLOBAL_TAG_TYPES:...|||CallLocalFunction>
  124. #if defined _ALS_CallRemoteFunction
  125. #if defined BAD_CallRemoteFunction
  126. #define CallRemoteFunction FIXES_CallRemoteFunction
  127. #endif
  128. #endif
  129. #if defined _YSI_MINI_MODE
  130. #if defined _ALS_CallRemoteFunction
  131. #undef CallRemoteFunction
  132. #else
  133. #define _ALS_CallRemoteFunction
  134. #endif
  135. #define CallRemoteFunction _MMD(CallRemoteFunction)
  136. #if defined _ALS_CallLocalFunction
  137. #undef CallLocalFunction
  138. #else
  139. #define _ALS_CallLocalFunction
  140. #endif
  141. #define CallLocalFunction _MMD(CallLocalFunction)
  142. #endif
  143. native _YSI_RE_NATIVE<O@|||const function[], time, repeat, const format[], GLOBAL_TAG_TYPES:...|||SetTimerEx>
  144. native _YSI_RE_NATIVE<K@|||const function[], time, repeat|||SetTimer>
  145. stock X@(GLOBAL_TAG_TYPES:n)
  146. {
  147. P:4("X@ called: %i", n);
  148. setproperty(8, YSIM_RETURN, n);
  149. }
  150. stock Y@()
  151. {
  152. P:4("Y@ called");
  153. // Already returns the previous value.
  154. return setproperty(8, YSIM_CALLER, _@);
  155. }
  156. stock Z@(GLOBAL_TAG_TYPES:v = -1)
  157. {
  158. P:4("Z@ called");
  159. return
  160. setproperty(8, YSIM_CALLER, v),
  161. getproperty(8, YSIM_RETURN);
  162. }
  163. new Q@[YSI_MAX_STRING];
  164. stock S@(GLOBAL_TAG_TYPES:v = -1)
  165. {
  166. P:4("S@ called");
  167. return
  168. getproperty(8, "", YSIM_STRING, Q@),
  169. strunpack(Q@, Q@),
  170. setproperty(8, YSIM_CALLER, v);
  171. //return Q@;
  172. }
  173. stock R@(buffer[])
  174. {
  175. P:4("R@ called: \"%s\"", buffer);
  176. return setproperty(8, "", YSIM_STRING, buffer);
  177. }
  178. stock H@(GLOBAL_TAG_TYPES:...)
  179. {
  180. // Just a dead-end for spare parameters.
  181. return 0;
  182. }
  183. #define _UNUSED(%0) H@(_:_H@0:_H@1:%0)
  184. #define _H@0:_H@1:%0&%1) _H@0:_H@1:%0%1)
  185. #define _H@1:%0[%9]%1) _H@1:%0%1)
  186. stock G@(GLOBAL_TAG_TYPES:...)
  187. {
  188. // Just a dead-end for spare parameters which returns a string.
  189. return Q@;
  190. }
  191. stock F@()
  192. {
  193. P:4("F@ called");
  194. return
  195. getproperty(8, "", YSIM_STRING, Q@),
  196. //P:4("2"),
  197. //P:4("3"),
  198. strunpack(Q@, Q@);
  199. //return Q@;
  200. }
  201. // Consume trailing spaces. Despite being a common letter, this is unlkely to
  202. // ever be matched due to the unusual series of operators after it. If anyone
  203. // else tries to define "x" however they may have a slight problem (they can't).
  204. //#define x,), x),
  205. // Changed as x,): was also needed (for ?:).
  206. #define x:##),) #))
  207. //#define x,) )
  208. #define q:##),ALS_RS_none:) #))
  209. // This is for getting excess parameters on non-strings. Now safely recursive.
  210. #define _:%0,) _:%0)
  211. #if defined YSI_LOCK_MODE
  212. #include "..\YSI_Internal\y_unique"
  213. forward UNIQUE_FUNCTION<@yH_OnScriptInit@...>();
  214. public UNIQUE_FUNCTION<@yH_OnScriptInit@...>()
  215. {
  216. new
  217. find = strfind(YSI_gLockData[5], YSI_gLockData[1]) + 6;
  218. find = strfind(YSI_gLockData[5], YSI_gLockData[1], _, find - 5) + 6;
  219. new
  220. found = strfind(YSI_gLockData[5], YSI_gLockData[1], _, find - 5) + 6;
  221. 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)
  222. {
  223. y_lock 1;
  224. }
  225. }
  226. #endif