y_shortfunc.inc 5.5 KB

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