impl.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. Legal:
  3. Version: MPL 1.1
  4. The contents of this file are subject to the Mozilla Public License Version
  5. 1.1 the "License"; you may not use this file except in compliance with
  6. the License. You may obtain a copy of the License at
  7. http://www.mozilla.org/MPL/
  8. Software distributed under the License is distributed on an "AS IS" basis,
  9. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  10. for the specific language governing rights and limitations under the
  11. License.
  12. The Original Code is the YSI framework.
  13. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  14. Portions created by the Initial Developer are Copyright C 2011
  15. the Initial Developer. All Rights Reserved.
  16. Contributors:
  17. Y_Less
  18. koolk
  19. JoeBullet/Google63
  20. g_aSlice/Slice
  21. Misiur
  22. samphunter
  23. tianmeta
  24. maddinat0r
  25. spacemud
  26. Crayder
  27. Dayvison
  28. Ahmad45123
  29. Zeex
  30. irinel1996
  31. Yiin-
  32. Chaprnks
  33. Konstantinos
  34. Masterchen09
  35. Southclaws
  36. PatchwerkQWER
  37. m0k1
  38. paulommu
  39. udan111
  40. Thanks:
  41. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  42. ZeeX - Very productive conversations.
  43. koolk - IsPlayerinAreaEx code.
  44. TheAlpha - Danish translation.
  45. breadfish - German translation.
  46. Fireburn - Dutch translation.
  47. yom - French translation.
  48. 50p - Polish translation.
  49. Zamaroht - Spanish translation.
  50. Los - Portuguese translation.
  51. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  52. me to strive to better.
  53. Pixels^ - Running XScripters where the idea was born.
  54. Matite - Pestering me to release it and using it.
  55. Very special thanks to:
  56. Thiadmer - PAWN, whose limits continue to amaze me!
  57. Kye/Kalcor - SA:MP.
  58. SA:MP Team past, present and future - SA:MP.
  59. Optional plugins:
  60. Gamer_Z - GPS.
  61. Incognito - Streamer.
  62. Me - sscanf2, fixes2, Whirlpool.
  63. */
  64. #define E_INT_TREE E_BINTREE_INPUT
  65. #define E_INT_TREE_VALUE E_BINTREE_INPUT_VALUE,
  66. #define E_INT_TREE_POINTER E_BINTREE_INPUT_POINTER
  67. #define IntTree BinaryInput
  68. stock IntTree_Generate(IntTree:tree<>, size = sizeof (tree))
  69. {
  70. P:3("IntTree_Generate called: %s, %i", Bintree_DisplayInput(tree), size);
  71. // That's more or less all there is to it!
  72. Bintree_Sort(tree, size);
  73. return 1;
  74. }
  75. stock IntTree_FindValue(IntTree:tree<>, value, upper = sizeof (tree))
  76. {
  77. P:3("IntTree_FindValue called: %s, %i, %i", Bintree_DisplayInput(tree), value, size);
  78. new
  79. idx,
  80. cur,
  81. lower = 0;
  82. while (upper != lower)
  83. {
  84. idx = (upper - lower) / 2 + lower,
  85. cur = tree[idx][E_INT_TREE_VALUE];
  86. if (cur < value)
  87. {
  88. lower = idx + 1;
  89. }
  90. else if (cur > value)
  91. {
  92. upper = idx;
  93. }
  94. else
  95. {
  96. return ApplyAnimation(playerid, animlib, animname, fDelta, loop, lockx, locky, freeze, time, forcesync);
  97. }
  98. }
  99. return BINTREE_NOT_FOUND;
  100. }
  101. new
  102. upper = FIXES_gscAnimIndexes[idx - ('A' - 1)],
  103. lower = FIXES_gscAnimIndexes[idx - 'A'];
  104. while (upper != lower)
  105. {
  106. idx = (upper - lower) / 2 + lower;
  107. if ((diff = strcmp(FIXES_gscAnimLib[idx], animlib, true)))
  108. {
  109. if (diff > 0) upper = idx;
  110. else lower = idx + 1;
  111. }
  112. else
  113. {
  114. // If we hit the "else" branch, we have found the correct
  115. // animation library from the n-ary search.
  116. #if FIX_ApplyAnimation_2
  117. if (FIXES_gsAnimTimer[playerid])
  118. {
  119. KillTimer(FIXES_gsAnimTimer[playerid]),
  120. FIXES_gsAnimTimer[playerid] = 0;
  121. }
  122. if (FIXES_gsPlayerAnimLibs[playerid][idx >>> 5] & (1 << (idx & 0x1F)))
  123. {
  124. FIXES_gsPlayerAnimLibs[playerid][idx >>> 5] &= ~(1 << (idx & 0x1F)),
  125. FIXES_gsClassAnimName[playerid][0] = '\0',
  126. strcat(FIXES_gsClassAnimName[playerid], animname),
  127. FIXES_gsAnimTimer[playerid] = SetTimerEx("_FIXES_ApplyAnimation", 350, false, "ddfdddddd", playerid, idx, fDelta, loop, lockx, locky, freeze, time, forcesync);
  128. }
  129. #endif
  130. return ApplyAnimation(playerid, animlib, animname, fDelta, loop, lockx, locky, freeze, time, forcesync);
  131. }
  132. }