y_unique.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**--------------------------------------------------------------------------**\
  2. ============================
  3. y_unique - Similar symbols
  4. ============================
  5. Description:
  6. Defines a symbol differently every time it is included.
  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 unique symbol 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. 1.0
  43. Changelog:
  44. 19/04/13:
  45. Upped the limit to 343.
  46. Changed to a 7-ary tree.
  47. Reversed check order so smallest numbers come first.
  48. 01/05/11:
  49. First version.
  50. \**--------------------------------------------------------------------------**/
  51. #include "y_compilerpass"
  52. #if AUTO_INCLUDE_GUARD
  53. #undef _inc_y_unique
  54. #endif
  55. #if defined UNIQUE_FUNCTION
  56. #undef UNIQUE_FUNCTION
  57. #endif
  58. // The "static stock const" values are used for debugging, since they will show
  59. // up in preprocessed dumps ("-l") with the value of "UNIQUE_SYMBOL" at that
  60. // moment, instead of its final value.
  61. #if defined UNIQUE_SYMBOL
  62. #if UNIQUE_SYMBOL < 0 || UNIQUE_SYMBOL >= 1000
  63. static stock const UNIQUE_SYMBOL_TOO_LARGE = UNIQUE_SYMBOL;
  64. #error UNIQUE_SYMBOL out of range.
  65. #endif
  66. #if UNIQUE_SYMBOL < 100
  67. static stock const UNIQUE_SYMBOL_LESS_THAN_100 = UNIQUE_SYMBOL;
  68. #include "y_unique\_000_to_099"
  69. #elseif UNIQUE_SYMBOL < 200
  70. static stock const UNIQUE_SYMBOL_LESS_THAN_200 = UNIQUE_SYMBOL;
  71. #include "y_unique\_100_to_199"
  72. #elseif UNIQUE_SYMBOL < 300
  73. static stock const UNIQUE_SYMBOL_LESS_THAN_300 = UNIQUE_SYMBOL;
  74. #include "y_unique\_200_to_299"
  75. #elseif UNIQUE_SYMBOL < 400
  76. static stock const UNIQUE_SYMBOL_LESS_THAN_400 = UNIQUE_SYMBOL;
  77. #include "y_unique\_300_to_399"
  78. #elseif UNIQUE_SYMBOL < 500
  79. static stock const UNIQUE_SYMBOL_LESS_THAN_500 = UNIQUE_SYMBOL;
  80. #include "y_unique\_400_to_499"
  81. #elseif UNIQUE_SYMBOL < 600
  82. static stock const UNIQUE_SYMBOL_LESS_THAN_600 = UNIQUE_SYMBOL;
  83. #include "y_unique\_500_to_599"
  84. #elseif UNIQUE_SYMBOL < 700
  85. static stock const UNIQUE_SYMBOL_LESS_THAN_700 = UNIQUE_SYMBOL;
  86. #include "y_unique\_600_to_699"
  87. #elseif UNIQUE_SYMBOL < 800
  88. static stock const UNIQUE_SYMBOL_LESS_THAN_800 = UNIQUE_SYMBOL;
  89. #include "y_unique\_700_to_799"
  90. #elseif UNIQUE_SYMBOL < 900
  91. static stock const UNIQUE_SYMBOL_LESS_THAN_900 = UNIQUE_SYMBOL;
  92. #include "y_unique\_800_to_899"
  93. #else
  94. static stock const UNIQUE_SYMBOL_OTHER_VALUE;
  95. #include "y_unique\_900_to_999"
  96. #endif
  97. #else
  98. static stock const UNIQUE_SYMBOL_DOESNT_EXIST;
  99. #define UNIQUE_SYMBOL (0)
  100. #define UNIQUE_FUNCTION<%0...%1> %0000%1
  101. #endif
  102. #if !defined Y_UNIQUE_LOCK_CONTRIBUTION
  103. #define Y_UNIQUE_LOCK_CONTRIBUTION 0
  104. #endif
  105. #if defined YSI_LOCK_MODE
  106. #if Y_UNIQUE_LOCK_CONTRIBUTION < 2
  107. forward UNIQUE_FUNCTION<@yH_OnScriptInit@...>();
  108. public UNIQUE_FUNCTION<@yH_OnScriptInit@...>()
  109. {
  110. #if Y_UNIQUE_LOCK_CONTRIBUTION == 0
  111. #undef Y_UNIQUE_LOCK_CONTRIBUTION
  112. #define Y_UNIQUE_LOCK_CONTRIBUTION 1
  113. YSI_gLockData[1] -= 'i' - '.';
  114. #else
  115. #undef Y_UNIQUE_LOCK_CONTRIBUTION
  116. #define Y_UNIQUE_LOCK_CONTRIBUTION 2
  117. YSI_gLockData{11} = 0;
  118. #endif
  119. }
  120. #include "y_unique"
  121. #endif
  122. #endif