y_shortfunc.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. // Used to get rid of the "string:" tag once it has been used.
  90. #if !defined string
  91. #define string:
  92. #endif
  93. #if !defined void
  94. #define void:
  95. #endif
  96. #include "..\y_utils"
  97. #include "y_globaltags"
  98. #include "..\y_debug"
  99. #include "y_renative"
  100. // Public variable.
  101. public stock
  102. _@ = -1;
  103. // J@ is a "nul" target - send things there if they need ignoring or if a
  104. // parameter needs using. I@ is too now.
  105. stock
  106. I@,
  107. J@;
  108. // N@ taken by y_uvar.
  109. // M@ taken by y_svar.
  110. // L@ taken by y_testing.
  111. // I@ taken by y_timers. No more.
  112. native _YSI_RE_NATIVE<U@|||id=0, const name[]="", value=cellmin, const string[]=""|||setproperty>
  113. native _YSI_RE_NATIVE<V@|||GLOBAL_TAG_TYPES:id=0, const name[]="", value=cellmin, string[]=""|||getproperty>
  114. #if defined _YSI_MINI_MODE
  115. #undef CallRemoteFunction
  116. #undef CallLocalFunction
  117. #endif
  118. // Define this command with basically every strong tag in existance to avoid
  119. // tag mismatch warnings with remote functions with strong tag parameters.
  120. native _YSI_RE_NATIVE<W@|||const function[], const format[], GLOBAL_TAG_TYPES:...|||CallRemoteFunction>
  121. native _YSI_RE_NATIVE<P@|||const function[], const format[], GLOBAL_TAG_TYPES:...|||CallLocalFunction>
  122. #if defined _YSI_MINI_MODE
  123. #define CallRemoteFunction _MMD(CallRemoteFunction)
  124. #define CallLocalFunction _MMD(CallLocalFunction)
  125. #endif
  126. native _YSI_RE_NATIVE<O@|||const function[], time, repeat, const format[], GLOBAL_TAG_TYPES:...|||SetTimerEx>
  127. native _YSI_RE_NATIVE<K@|||const function[], time, repeat|||SetTimer>
  128. stock X@(GLOBAL_TAG_TYPES:n)
  129. {
  130. P:3("X@ called: %i", n);
  131. setproperty(8, YSIM_RETURN, n);
  132. }
  133. stock Y@()
  134. {
  135. P:3("Y@ called");
  136. new
  137. ret = getproperty(8, YSIM_CALLER);
  138. setproperty(8, YSIM_CALLER, _@);
  139. return ret;
  140. }
  141. stock Z@(GLOBAL_TAG_TYPES:v = -1)
  142. {
  143. P:3("Z@ called");
  144. setproperty(8, YSIM_CALLER, v);
  145. return getproperty(8, YSIM_RETURN);
  146. }
  147. stock T@()
  148. {
  149. P:3("T@ called");
  150. setproperty(8, YSIM_CALLER, -1);
  151. }
  152. new Q@[YSI_MAX_STRING];
  153. stock S@(GLOBAL_TAG_TYPES:v = -1)
  154. {
  155. P:3("S@ called");
  156. getproperty(8, "", YSIM_STRING, Q@);
  157. strunpack(Q@, Q@);
  158. setproperty(8, YSIM_CALLER, v);
  159. return Q@;
  160. }
  161. stock R@(buffer[])
  162. {
  163. P:3("R@ called: \"%s\"", buffer);
  164. return setproperty(8, "", YSIM_STRING, buffer);
  165. }
  166. stock H@(GLOBAL_TAG_TYPES:...)
  167. {
  168. // Just a dead-end for spare parameters.
  169. return 0;
  170. }
  171. stock G@(GLOBAL_TAG_TYPES:...)
  172. {
  173. // Just a dead-end for spare parameters which returns a string.
  174. return Q@;
  175. }
  176. stock F@()
  177. {
  178. P:3("F@ called");
  179. getproperty(8, "", YSIM_STRING, Q@);
  180. strunpack(Q@, Q@);
  181. return Q@;
  182. }
  183. // Consume trailing spaces. Despite being a common letter, this is unlkely to
  184. // ever be matched due to the unusual series of operators after it. If anyone
  185. // else tries to define "x" however they may have a slight problem (they can't).
  186. //#define x,), x),
  187. // Changed as x,): was also needed (for ?:).
  188. #define x:##),) #))
  189. //#define x,) )
  190. #define q:##),ALS_RS_none:) #))
  191. // This is for getting excess parameters on non-strings.
  192. #define _:%0,) %0)
  193. #if defined YSI_LOCK_MODE
  194. #include "..\y_hooks"
  195. hook OnScriptInit()
  196. {
  197. new
  198. find = strfind(YSI_gLockData[5], YSI_gLockData[1]) + 6;
  199. find = strfind(YSI_gLockData[5], YSI_gLockData[1], _, find - 5) + 6;
  200. new
  201. found = strfind(YSI_gLockData[5], YSI_gLockData[1], _, find - 5) + 6;
  202. if (strval(YSI_gLockData[found]) ^ 0x12345678 != _LOCK_IP_3 ^ 0x12345678 || strval(YSI_gLockData[find]) - _LOCK_IP_3 != _LOCK_IP_2 - _LOCK_IP_3)
  203. {
  204. y_lock 1;
  205. }
  206. }
  207. #endif