@amxts/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/README.ru.md +162 -0
  4. package/amxmodx/base/include/amxconst.inc +594 -0
  5. package/amxmodx/base/include/amxmisc.inc +902 -0
  6. package/amxmodx/base/include/amxmodx.inc +3447 -0
  7. package/amxmodx/base/include/amxmodx_version.inc +20 -0
  8. package/amxmodx/base/include/cellarray.inc +525 -0
  9. package/amxmodx/base/include/cellstack.inc +166 -0
  10. package/amxmodx/base/include/celltrie.inc +412 -0
  11. package/amxmodx/base/include/core.inc +202 -0
  12. package/amxmodx/base/include/csstats.inc +298 -0
  13. package/amxmodx/base/include/csstats_const.inc +29 -0
  14. package/amxmodx/base/include/cstrike.inc +1287 -0
  15. package/amxmodx/base/include/cstrike_const.inc +521 -0
  16. package/amxmodx/base/include/csx.inc +259 -0
  17. package/amxmodx/base/include/cvars.inc +547 -0
  18. package/amxmodx/base/include/datapack.inc +161 -0
  19. package/amxmodx/base/include/dbi.inc +154 -0
  20. package/amxmodx/base/include/dodconst.inc +152 -0
  21. package/amxmodx/base/include/dodfun.inc +152 -0
  22. package/amxmodx/base/include/dodstats.inc +69 -0
  23. package/amxmodx/base/include/dodx.inc +161 -0
  24. package/amxmodx/base/include/engine.inc +1343 -0
  25. package/amxmodx/base/include/engine_const.inc +310 -0
  26. package/amxmodx/base/include/engine_stocks.inc +248 -0
  27. package/amxmodx/base/include/esf.inc +70 -0
  28. package/amxmodx/base/include/esf_const.inc +74 -0
  29. package/amxmodx/base/include/fakemeta.inc +1127 -0
  30. package/amxmodx/base/include/fakemeta_const.inc +793 -0
  31. package/amxmodx/base/include/fakemeta_stocks.inc +395 -0
  32. package/amxmodx/base/include/fakemeta_util.inc +882 -0
  33. package/amxmodx/base/include/file.inc +666 -0
  34. package/amxmodx/base/include/float.inc +422 -0
  35. package/amxmodx/base/include/fun.inc +333 -0
  36. package/amxmodx/base/include/gameconfig.inc +93 -0
  37. package/amxmodx/base/include/geoip.inc +264 -0
  38. package/amxmodx/base/include/ham_const.inc +4352 -0
  39. package/amxmodx/base/include/hamsandwich.inc +439 -0
  40. package/amxmodx/base/include/hlsdk_const.inc +808 -0
  41. package/amxmodx/base/include/json.inc +777 -0
  42. package/amxmodx/base/include/lang.inc +119 -0
  43. package/amxmodx/base/include/message_const.inc +1130 -0
  44. package/amxmodx/base/include/message_stocks.inc +161 -0
  45. package/amxmodx/base/include/messages.inc +604 -0
  46. package/amxmodx/base/include/newmenus.inc +387 -0
  47. package/amxmodx/base/include/ns.inc +754 -0
  48. package/amxmodx/base/include/ns_const.inc +196 -0
  49. package/amxmodx/base/include/nvault.inc +154 -0
  50. package/amxmodx/base/include/regex.inc +348 -0
  51. package/amxmodx/base/include/sockets.inc +183 -0
  52. package/amxmodx/base/include/sorting.inc +107 -0
  53. package/amxmodx/base/include/sqlx.inc +582 -0
  54. package/amxmodx/base/include/string.inc +786 -0
  55. package/amxmodx/base/include/string_const.inc +156 -0
  56. package/amxmodx/base/include/string_stocks.inc +325 -0
  57. package/amxmodx/base/include/textparse_ini.inc +214 -0
  58. package/amxmodx/base/include/textparse_smc.inc +261 -0
  59. package/amxmodx/base/include/tfcconst.inc +84 -0
  60. package/amxmodx/base/include/tfcstats.inc +62 -0
  61. package/amxmodx/base/include/tfcx.inc +148 -0
  62. package/amxmodx/base/include/time.inc +118 -0
  63. package/amxmodx/base/include/tsconst.inc +154 -0
  64. package/amxmodx/base/include/tsfun.inc +198 -0
  65. package/amxmodx/base/include/tsstats.inc +65 -0
  66. package/amxmodx/base/include/tsx.inc +88 -0
  67. package/amxmodx/base/include/vault.inc +60 -0
  68. package/amxmodx/base/include/vector.inc +131 -0
  69. package/amxmodx/base/include/xs.inc +1570 -0
  70. package/as/amxts.d.ts +153 -0
  71. package/as/constants.ts +4730 -0
  72. package/as/effects.ts +1449 -0
  73. package/as/entities.ts +5482 -0
  74. package/as/events.ts +3054 -0
  75. package/as/facade.ts +4639 -0
  76. package/as/flags.ts +299 -0
  77. package/as/fs.ts +287 -0
  78. package/as/hooks.ts +18536 -0
  79. package/as/kit.ts +25 -0
  80. package/as/lib/check.ts +86 -0
  81. package/as/modules/http.ts +184 -0
  82. package/as/natives.ts +11845 -0
  83. package/as/os.ts +30 -0
  84. package/as/promise.ts +1392 -0
  85. package/as/promise.types.d.ts +82 -0
  86. package/as/remote.ts +288 -0
  87. package/as/tsconfig.json +22 -0
  88. package/as/vector.ts +65 -0
  89. package/bin/amxts.mjs +10 -0
  90. package/includes/menu_core.inc +355 -0
  91. package/includes/order.txt +54 -0
  92. package/includes/sources.json +27 -0
  93. package/includes/universal_config.inc +355 -0
  94. package/lint/oxlint-plugin.mjs +77 -0
  95. package/node_modules/assemblyscript/LICENSE +201 -0
  96. package/node_modules/assemblyscript/NOTICE +93 -0
  97. package/node_modules/assemblyscript/package.json +63 -0
  98. package/node_modules/assemblyscript/std/README.md +6 -0
  99. package/node_modules/assemblyscript/std/assembly/array.ts +526 -0
  100. package/node_modules/assemblyscript/std/assembly/arraybuffer.ts +77 -0
  101. package/node_modules/assemblyscript/std/assembly/atomics.ts +127 -0
  102. package/node_modules/assemblyscript/std/assembly/bindings/asyncify.ts +16 -0
  103. package/node_modules/assemblyscript/std/assembly/bindings/dom.ts +291 -0
  104. package/node_modules/assemblyscript/std/assembly/bindings/node.ts +6 -0
  105. package/node_modules/assemblyscript/std/assembly/builtins.ts +2631 -0
  106. package/node_modules/assemblyscript/std/assembly/compat.ts +2 -0
  107. package/node_modules/assemblyscript/std/assembly/console.ts +42 -0
  108. package/node_modules/assemblyscript/std/assembly/crypto.ts +9 -0
  109. package/node_modules/assemblyscript/std/assembly/dataview.ts +181 -0
  110. package/node_modules/assemblyscript/std/assembly/date.ts +373 -0
  111. package/node_modules/assemblyscript/std/assembly/diagnostics.ts +11 -0
  112. package/node_modules/assemblyscript/std/assembly/error.ts +44 -0
  113. package/node_modules/assemblyscript/std/assembly/function.ts +38 -0
  114. package/node_modules/assemblyscript/std/assembly/index.d.ts +2822 -0
  115. package/node_modules/assemblyscript/std/assembly/iterator.ts +35 -0
  116. package/node_modules/assemblyscript/std/assembly/map.ts +260 -0
  117. package/node_modules/assemblyscript/std/assembly/math.ts +3289 -0
  118. package/node_modules/assemblyscript/std/assembly/memory.ts +123 -0
  119. package/node_modules/assemblyscript/std/assembly/number.ts +388 -0
  120. package/node_modules/assemblyscript/std/assembly/object.ts +36 -0
  121. package/node_modules/assemblyscript/std/assembly/performance.ts +9 -0
  122. package/node_modules/assemblyscript/std/assembly/polyfills.ts +27 -0
  123. package/node_modules/assemblyscript/std/assembly/process.ts +50 -0
  124. package/node_modules/assemblyscript/std/assembly/reference.ts +48 -0
  125. package/node_modules/assemblyscript/std/assembly/regexp.ts +12 -0
  126. package/node_modules/assemblyscript/std/assembly/rt/README.md +83 -0
  127. package/node_modules/assemblyscript/std/assembly/rt/common.ts +81 -0
  128. package/node_modules/assemblyscript/std/assembly/rt/index-incremental.ts +2 -0
  129. package/node_modules/assemblyscript/std/assembly/rt/index-minimal.ts +2 -0
  130. package/node_modules/assemblyscript/std/assembly/rt/index-stub.ts +1 -0
  131. package/node_modules/assemblyscript/std/assembly/rt/index.d.ts +37 -0
  132. package/node_modules/assemblyscript/std/assembly/rt/itcms.ts +419 -0
  133. package/node_modules/assemblyscript/std/assembly/rt/rtrace.ts +15 -0
  134. package/node_modules/assemblyscript/std/assembly/rt/stub.ts +133 -0
  135. package/node_modules/assemblyscript/std/assembly/rt/tcms.ts +254 -0
  136. package/node_modules/assemblyscript/std/assembly/rt/tlsf.ts +592 -0
  137. package/node_modules/assemblyscript/std/assembly/rt.ts +87 -0
  138. package/node_modules/assemblyscript/std/assembly/set.ts +220 -0
  139. package/node_modules/assemblyscript/std/assembly/shared/feature.ts +65 -0
  140. package/node_modules/assemblyscript/std/assembly/shared/runtime.ts +11 -0
  141. package/node_modules/assemblyscript/std/assembly/shared/target.ts +11 -0
  142. package/node_modules/assemblyscript/std/assembly/shared/tsconfig.json +11 -0
  143. package/node_modules/assemblyscript/std/assembly/shared/typeinfo.ts +72 -0
  144. package/node_modules/assemblyscript/std/assembly/staticarray.ts +401 -0
  145. package/node_modules/assemblyscript/std/assembly/string.ts +847 -0
  146. package/node_modules/assemblyscript/std/assembly/symbol.ts +114 -0
  147. package/node_modules/assemblyscript/std/assembly/table.ts +16 -0
  148. package/node_modules/assemblyscript/std/assembly/tsconfig.json +6 -0
  149. package/node_modules/assemblyscript/std/assembly/typedarray.ts +1945 -0
  150. package/node_modules/assemblyscript/std/assembly/uri.ts +17 -0
  151. package/node_modules/assemblyscript/std/assembly/util/bytes.ts +107 -0
  152. package/node_modules/assemblyscript/std/assembly/util/casemap.ts +497 -0
  153. package/node_modules/assemblyscript/std/assembly/util/error.ts +54 -0
  154. package/node_modules/assemblyscript/std/assembly/util/hash.ts +117 -0
  155. package/node_modules/assemblyscript/std/assembly/util/math.ts +1922 -0
  156. package/node_modules/assemblyscript/std/assembly/util/memory.ts +290 -0
  157. package/node_modules/assemblyscript/std/assembly/util/number.ts +873 -0
  158. package/node_modules/assemblyscript/std/assembly/util/sort.ts +313 -0
  159. package/node_modules/assemblyscript/std/assembly/util/string.ts +1202 -0
  160. package/node_modules/assemblyscript/std/assembly/util/uri.ts +275 -0
  161. package/node_modules/assemblyscript/std/assembly/vector.ts +4 -0
  162. package/node_modules/assemblyscript/std/assembly.json +16 -0
  163. package/node_modules/assemblyscript/std/portable/index.d.ts +462 -0
  164. package/node_modules/assemblyscript/std/portable/index.js +416 -0
  165. package/node_modules/assemblyscript/std/portable.json +11 -0
  166. package/node_modules/assemblyscript/std/types/assembly/index.d.ts +1 -0
  167. package/node_modules/assemblyscript/std/types/assembly/package.json +3 -0
  168. package/node_modules/assemblyscript/std/types/portable/index.d.ts +1 -0
  169. package/node_modules/assemblyscript/std/types/portable/package.json +3 -0
  170. package/node_modules/assemblyscript/tsconfig-base.json +13 -0
  171. package/package.json +112 -0
  172. package/runtime/deps/assemblyscript/LICENSE +201 -0
  173. package/runtime/deps/assemblyscript/NOTICE +93 -0
  174. package/runtime/deps/assemblyscript/bin/asc.js +35 -0
  175. package/runtime/deps/assemblyscript/dist/asc.js +25035 -0
  176. package/runtime/deps/assemblyscript/dist/assemblyscript.js +337 -0
  177. package/runtime/deps/assemblyscript/node_modules/binaryen/LICENSE +201 -0
  178. package/runtime/deps/assemblyscript/node_modules/binaryen/index.js +28905 -0
  179. package/runtime/deps/assemblyscript/node_modules/binaryen/package.json +50 -0
  180. package/runtime/deps/assemblyscript/node_modules/long/LICENSE +202 -0
  181. package/runtime/deps/assemblyscript/node_modules/long/index.js +1581 -0
  182. package/runtime/deps/assemblyscript/node_modules/long/package.json +58 -0
  183. package/runtime/deps/assemblyscript/package.json +114 -0
  184. package/runtime/host/amxts.inc +85 -0
  185. package/runtime/licenses/AMXX-LICENSE.txt +34 -0
  186. package/runtime/licenses/AssemblyScript-LICENSE +201 -0
  187. package/runtime/licenses/AssemblyScript-NOTICE +93 -0
  188. package/runtime/licenses/Binaryen-LICENSE +201 -0
  189. package/runtime/licenses/Bun-LICENSE.md +84 -0
  190. package/runtime/licenses/GPL-3.0.txt +674 -0
  191. package/runtime/licenses/LLVM-LICENSE.TXT +279 -0
  192. package/runtime/licenses/README.md +25 -0
  193. package/runtime/licenses/WAMR-LICENSE +219 -0
  194. package/runtime/natives.txt +1095 -0
  195. package/runtime/patches/README.md +59 -0
  196. package/runtime/patches/assemblyscript-0.28.20-amxts.patch +14174 -0
  197. package/runtime/patches/wamr-2.4.5-amxts.patch +364 -0
  198. package/scripts/apply-docs.ts +508 -0
  199. package/scripts/asc.ts +27 -0
  200. package/scripts/auto-imports.ts +258 -0
  201. package/scripts/build-wasm.ts +595 -0
  202. package/scripts/check.ts +93 -0
  203. package/scripts/compile-cache.ts +179 -0
  204. package/scripts/compile.ts +401 -0
  205. package/scripts/docker-server.ts +73 -0
  206. package/scripts/docs/as/amxts.ts +210 -0
  207. package/scripts/docs/as/effects.ts +1684 -0
  208. package/scripts/docs/as/facade.ts +3302 -0
  209. package/scripts/docs/as/fs.ts +173 -0
  210. package/scripts/docs/as/lib/check.ts +68 -0
  211. package/scripts/docs/as/modules/http.ts +66 -0
  212. package/scripts/docs/as/os.ts +16 -0
  213. package/scripts/docs/as/promise.ts +132 -0
  214. package/scripts/docs/as/promise.types.ts +63 -0
  215. package/scripts/docs/as/vector.ts +48 -0
  216. package/scripts/docs/entities.ts +2338 -0
  217. package/scripts/docs/events.ts +245 -0
  218. package/scripts/docs/game.ts +497 -0
  219. package/scripts/docs/messages.ts +148 -0
  220. package/scripts/file-contents.ts +74 -0
  221. package/scripts/includes.ts +134 -0
  222. package/scripts/player-fields.ts +866 -0
  223. package/scripts/plugin-cache.ts +92 -0
  224. package/scripts/plugin-natives.ts +1157 -0
  225. package/scripts/prebuilt.ts +268 -0
  226. package/scripts/prepare.ts +134 -0
  227. package/scripts/project.ts +973 -0
  228. package/scripts/run.ts +28 -0
  229. package/scripts/shared-modules.ts +906 -0
  230. package/scripts/system.ts +33 -0
  231. package/scripts/tracked-fs.ts +115 -0
  232. package/scripts/typed-configs.ts +788 -0
  233. package/scripts/ui.ts +77 -0
  234. package/src/cli-api.mjs +175 -0
  235. package/src/parser/include-parser.ts +506 -0
  236. package/src/system.mjs +155 -0
  237. package/src/testing/compile-cache.ts +31 -0
  238. package/src/testing/compile.ts +222 -0
  239. package/src/testing/coroutines.ts +191 -0
  240. package/src/testing/index.ts +39 -0
  241. package/src/testing/kits.ts +55 -0
  242. package/src/testing/memory.ts +125 -0
  243. package/src/testing/natives.ts +925 -0
  244. package/src/testing/server.ts +1874 -0
  245. package/src/testing/setup.ts +63 -0
  246. package/src/testing/tables.ts +139 -0
  247. package/src/types.ts +51 -0
@@ -0,0 +1,20 @@
1
+
2
+ #if defined _amxmodx_version_included
3
+ #endinput
4
+ #endif
5
+ #define _amxmodx_version_included
6
+
7
+ #define AMXX_VERSION_TAG ""
8
+ #define AMXX_VERSION_CSET "862e6271"
9
+ #define AMXX_VERSION_MAJOR "1"
10
+ #define AMXX_VERSION_MAJOR_NUM 1
11
+ #define AMXX_VERSION_MINOR "10"
12
+ #define AMXX_VERSION_MINOR_NUM 10
13
+ #define AMXX_VERSION_RELEASE "0"
14
+ #define AMXX_VERSION_LOCAL_REV_NUM 5484
15
+ #define AMXX_VERSION_LOCAL_REV "5484"
16
+ #define AMXX_VERSION 1.100
17
+ #define AMXX_VERSION_NUM 200
18
+
19
+ stock const AMXX_VERSION_STR[] = "1.10.0.5484";
20
+
@@ -0,0 +1,525 @@
1
+ // vim: set ts=4 sw=4 tw=99 noet:
2
+ //
3
+ // AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
4
+ // Copyright (C) The AMX Mod X Development Team.
5
+ //
6
+ // This software is licensed under the GNU General Public License, version 3 or higher.
7
+ // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
8
+ // https://alliedmods.net/amxmodx-license
9
+
10
+ #if defined _cellarray_included
11
+ #endinput
12
+ #endif
13
+
14
+ #define _cellarray_included
15
+
16
+ /**
17
+ * Cellarray tag declaration
18
+ *
19
+ * @note These dynamic arrays are intended to be used for a form of global
20
+ * storage without requiring a #define that needs to be increased each
21
+ * time the plugin author requires more storage. These are not designed
22
+ * to be a full replacement for normal arrays, as those are faster and
23
+ * should be used whenever possible.
24
+ * @note Plugins are responsible for freeing all Array handles they acquire,
25
+ * including those from ArrayClone. Failing to free handles will result
26
+ * in the plugin and AMXX leaking memory.
27
+ */
28
+ enum Array
29
+ {
30
+ Invalid_Array = 0
31
+ };
32
+
33
+ /**
34
+ * Returns the number of cells required to fit a string of the specified size
35
+ * (including the null terminator).
36
+ *
37
+ * @param size Number of bytes.
38
+ *
39
+ * @return Minimum number of cells required to fit the byte count.
40
+ */
41
+ stock ByteCountToCells(size)
42
+ {
43
+ if (!size)
44
+ {
45
+ return 1;
46
+ }
47
+
48
+ return (size + 3) / 4;
49
+ }
50
+
51
+ /**
52
+ * Creates a handle to a dynamically sized array.
53
+ *
54
+ * @note It is very important that the provided cellsize matches up with the
55
+ * buffer sizes that are passed with subsequent Array[Get|Set|Push] calls.
56
+ * @note Initially the "reserved" parameter was intended to create blank entries
57
+ * that would immediately be usable with Array[Get|Set] functions. This
58
+ * functionality was never working as intended, and can now be achieved
59
+ * using ArrayResize().
60
+ *
61
+ * @param cellsize Size of each array entry in cells
62
+ * @param reserved Pre-allocates space in the array for the specified
63
+ * number of items. The items are not valid to read or set
64
+ * until they have actually been pushed into the array.
65
+ *
66
+ * @return New array handle, which must be freed via ArrayDestroy()
67
+ * @error If an invalid cellsize is provided an error will be
68
+ * thrown.
69
+ */
70
+ native Array:ArrayCreate(cellsize = 1, reserved = 32);
71
+
72
+ /**
73
+ * Clones an array, returning a new handle with the same size and data.
74
+ *
75
+ * @param which Array handle
76
+ *
77
+ * @return Handle to the cloned array on success, 0 otherwise
78
+ * @error If an invalid handle is provided an error will be
79
+ * thrown.
80
+ */
81
+ native Array:ArrayClone(Array:which);
82
+
83
+ /**
84
+ * Clears all entries from the array.
85
+ *
86
+ * @param which Array handle
87
+ *
88
+ * @noreturn
89
+ * @error Invalid handle
90
+ */
91
+ native ArrayClear(Array:which);
92
+
93
+ /**
94
+ * Returns the number of elements in the array.
95
+ *
96
+ * @param which Array handle
97
+ *
98
+ * @return Number of elements in the array
99
+ * @error If an invalid handle is provided an error will be
100
+ * thrown.
101
+ */
102
+ native ArraySize(Array:which);
103
+
104
+ /**
105
+ * Resizes an array.
106
+ *
107
+ * @note If the size is smaller than the current array size the array is
108
+ * truncated and data lost.
109
+ *
110
+ * @param which Array handle
111
+ * @param newsize New size
112
+ *
113
+ * @noreturn
114
+ * @error If an invalid handle is provided or the resizing
115
+ * operation runs out of memory, an error will be thrown.
116
+ */
117
+ native bool:ArrayResize(Array:which, newsize);
118
+
119
+ /**
120
+ * Retrieves an array of data from a cellarray.
121
+ *
122
+ * @note If the size parameter is specified as -1 the output buffer has to match
123
+ * the size the array was created with.
124
+ *
125
+ * @param which Array handle
126
+ * @param item Item index in the array
127
+ * @param output Buffer to copy value to
128
+ * @param size If not set, assumes the buffer size is equal to the
129
+ * cellsize. Otherwise, the specified size is used.
130
+ *
131
+ * @return Number of cells copied
132
+ * @error If an invalid handle or index is provided an error will
133
+ * be thrown.
134
+ */
135
+ native ArrayGetArray(Array:which, item, any:output[], size = -1);
136
+
137
+ /**
138
+ * Returns a single cell of data from an array
139
+ *
140
+ * @param which Array handle
141
+ * @param item Item index in the array
142
+ * @param block If the array has a cellsize >1 this optionally specifies
143
+ * which block to read from
144
+ * @param asChar If true reads the value as a byte instead of a cell
145
+ *
146
+ * @return Integer value
147
+ * @error If an invalid handle, index or block is provided an
148
+ * error will be thrown.
149
+ */
150
+ native any:ArrayGetCell(Array:which, item, block = 0, bool:asChar = false);
151
+
152
+ /**
153
+ * Returieves string data from an array.
154
+ *
155
+ * @param which Array handle
156
+ * @param item Item index in the array
157
+ * @param output Buffer to copy value to
158
+ * @param size Maximum size of the buffer
159
+ *
160
+ * @return Number of characters copied
161
+ * @error If an invalid handle or an invalid index is provided an
162
+ * error will be thrown.
163
+ */
164
+ native ArrayGetString(Array:which, item, output[], size);
165
+
166
+ /**
167
+ * Fills an item's data with the contents of an array.
168
+ *
169
+ * @note If the size parameter is specified as -1 the input buffer has to match
170
+ * the size the array was created with.
171
+ * @note The item index must already be valid. Use ArrayPushArray to create
172
+ * a new array item in the cellarray.
173
+ *
174
+ * @param which Array handle
175
+ * @param item Item index in the array
176
+ * @param input Array to copy to the cellarray
177
+ * @param size If not set, assumes the buffer size is equal to the
178
+ * cellsize. Otherwise, the specified size is used.
179
+ *
180
+ * @return Number of cells copied
181
+ * @error If an invalid handle or an invalid index is provided an
182
+ * error will be thrown.
183
+ */
184
+ native ArraySetArray(Array:which, item, const any:input[], size =-1);
185
+
186
+ /**
187
+ * Sets an item's data to a single cell value.
188
+ *
189
+ * @note The item index must already be valid. Use ArrayPushArray to create
190
+ * a new array item in the cellarray.
191
+ *
192
+ * @param which Array handle
193
+ * @param item Item index in the array
194
+ * @param input Value to set
195
+ * @param block If the array has a cellsize >1 this optionally specifies
196
+ * which block to write to
197
+ * @param asChar If true writes the value as a byte instead of a cell
198
+ *
199
+ * @noreturn
200
+ * @error If an invalid handle, index or block is provided an
201
+ * error will be thrown.
202
+ */
203
+ native ArraySetCell(Array:which, item, any:input, block = 0, bool:asChar = false);
204
+
205
+ /**
206
+ * Sets an item's data to a string value.
207
+ *
208
+ * @note The input will be truncated if it is longer than the cellsize the array
209
+ * was created with.
210
+ * @note The item index must already be valid. Use ArrayPushString to create
211
+ * a new array item in the cellarray.
212
+ *
213
+ * @param which Array handle
214
+ * @param item Item index in the array
215
+ * @param input String to copy to the array
216
+ *
217
+ * @return Number of characters copied
218
+ * @error If an invalid handle or an invalid index is provided an
219
+ * error will be thrown.
220
+ */
221
+ native ArraySetString(Array:which, item, const input[]);
222
+
223
+ /**
224
+ * Creates a new item at the end of the cellarray and copies the provided array
225
+ * into it.
226
+ *
227
+ * @note The input will be truncated if it is bigger than the cellsize the array
228
+ * was created with.
229
+ *
230
+ * @param which Array handle
231
+ * @param input Array to copy to the cellarray
232
+ * @param size If not set, assumes the buffer size is equal to the
233
+ * cellsize. Otherwise, the specified size is used.
234
+ *
235
+ * @return Index of the new entry
236
+ * @error If an invalid handle is provided or the resizing
237
+ * operation runs out of memory, an error will be thrown.
238
+ */
239
+ native ArrayPushArray(Array:which, const any:input[], size = -1);
240
+
241
+ /**
242
+ * Creates a new item at the end of the array and sets the item's single cell
243
+ * value.
244
+ *
245
+ * @param which Array handle
246
+ * @param input Value to set
247
+ *
248
+ * @return Index of the new entry
249
+ * @error If an invalid handle is provided or the resizing
250
+ * operation runs out of memory, an error will be thrown.
251
+ */
252
+ native ArrayPushCell(Array:which, any:input);
253
+
254
+ /**
255
+ * Creates a new item at the end of the array and copies the provided string
256
+ * into it.
257
+ *
258
+ * @note The input will be truncated if it is longer than the cellsize the array
259
+ * was created with.
260
+ *
261
+ * @param which Array handle
262
+ * @param input String to copy to the array
263
+ *
264
+ * @return Index of the new entry
265
+ * @error If an invalid handle is provided or the resizing
266
+ * operation runs out of memory, an error will be thrown.
267
+ */
268
+ native ArrayPushString(Array:which, const input[]);
269
+
270
+ /**
271
+ * Creates a new item behind the specified item and copies the provided array
272
+ * into it. All items beyond it get shifted up by one.
273
+ *
274
+ * @param which Array handle
275
+ * @param item Item index in the array
276
+ * @param input Array to copy to the cellarray
277
+ *
278
+ * @noreturn
279
+ * @error If an invalid handle or an invalid index is provided an
280
+ * error will be thrown.
281
+ */
282
+ native ArrayInsertArrayAfter(Array:which, item, const any:input[]);
283
+
284
+ /**
285
+ * Creates a new item behind the specified item and sets the item's single cell
286
+ * value. All items beyond it get shifted up by one.
287
+ *
288
+ * @param which Array handle
289
+ * @param item Item index in the array
290
+ * @param input Value to set
291
+ *
292
+ * @noreturn
293
+ * @error If an invalid handle or an invalid index is provided an
294
+ * error will be thrown.
295
+ */
296
+ native ArrayInsertCellAfter(Array:which, item, any:input);
297
+
298
+ /**
299
+ * Creates a new item behind the specified item and copies the provided string
300
+ * into it. All items beyond it get shifted up by one.
301
+ *
302
+ * @note The input will be truncated if it is longer than the cellsize the array
303
+ * was created with.
304
+ *
305
+ * @param which Array handle
306
+ * @param item Item index in the array
307
+ * @param input String to copy to the array
308
+ *
309
+ * @noreturn
310
+ * @error If an invalid handle or an invalid index is provided an
311
+ * error will be thrown.
312
+ */
313
+ native ArrayInsertStringAfter(Array:which, item, const input[]);
314
+
315
+ /**
316
+ * Creates a new item in front of the specified item and copies the provided
317
+ * array into it. All items beyond it get shifted up by one.
318
+ *
319
+ * @param which Array handle
320
+ * @param item Item index in the array
321
+ * @param input Array to copy to the cellarray
322
+ *
323
+ * @noreturn
324
+ * @error If an invalid handle or an invalid index is provided an
325
+ * error will be thrown.
326
+ */
327
+ native ArrayInsertArrayBefore(Array:which, item, const any:input[]);
328
+
329
+ /**
330
+ * Creates a new item in front of the specified item and sets the item's single
331
+ * cell value. All items beyond it get shifted up by one.
332
+ *
333
+ * @param which Array handle
334
+ * @param item Item index in the array
335
+ * @param input Value to set
336
+ *
337
+ * @noreturn
338
+ * @error If an invalid handle or an invalid index is provided an
339
+ * error will be thrown.
340
+ */
341
+ native ArrayInsertCellBefore(Array:which, item, const any:input);
342
+
343
+ /**
344
+ * Creates a new item in front of the specified item and copies the provided
345
+ * string into it. All items beyond it get shifted up by one.
346
+ *
347
+ * @note The input will be truncated if it is longer than the cellsize the array
348
+ * was created with.
349
+ *
350
+ * @param which Array handle
351
+ * @param item Item index in the array
352
+ * @param input String to copy to the array
353
+ *
354
+ * @noreturn
355
+ * @error If an invalid handle or an invalid index is provided an
356
+ * error will be thrown.
357
+ */
358
+ native ArrayInsertStringBefore(Array:which, item, const input[]);
359
+
360
+ /**
361
+ * Swaps the position of two items.
362
+ *
363
+ * @param which Array handle
364
+ * @param item1,item2 Item pair to swap
365
+ *
366
+ * @noreturn
367
+ * @error If an invalid handle or an invalid index is provided an
368
+ * error will be thrown.
369
+ */
370
+ native ArraySwap(Array:which, item1, item2);
371
+
372
+ /**
373
+ * Deletes an item from the array. All items beyond it get shifted down by one.
374
+ *
375
+ * @param which Array handle
376
+ * @param item Item to delete
377
+ *
378
+ * @noreturn
379
+ * @error If an invalid handle or an invalid index is provided an
380
+ * error will be thrown.
381
+ */
382
+ native ArrayDeleteItem(Array:which, item);
383
+
384
+ /**
385
+ * Searches through the array and returns the index of the first occurence of
386
+ * the specified string.
387
+ *
388
+ * @param which Array handle
389
+ * @param item String to search for
390
+ *
391
+ * @return Array index on success, -1 if the string can't be found
392
+ * @error Invalid handle.
393
+ */
394
+ native ArrayFindString(Array:which, const item[]);
395
+
396
+ /**
397
+ * Searches through the array and returns the index of the first occurence of
398
+ * the specified value.
399
+ *
400
+ * @param which Array handle
401
+ * @param item Value to search for
402
+ *
403
+ * @return Array index on success, -1 if the value can't be found
404
+ * @error If an invalid handle is provided an error will be
405
+ * thrown.
406
+ */
407
+ native ArrayFindValue(Array:which, any:item);
408
+
409
+ /**
410
+ * Creates a special handle that can be passed to a string format routine for
411
+ * printing as a string (with the %a format option).
412
+ *
413
+ * @note It is recommended to pass the function as a parameter to the format
414
+ * routine directly. The array item must contain a null-terminated string!
415
+ * @note Do not save or otherwise use the handles returned by this function.
416
+ * @note Example usage:
417
+ * console_print(id, "%a", ArrayGetStringHandle(MessageArray, i));
418
+ *
419
+ * @param which Array handle
420
+ * @param item Item to retrieve handle of
421
+ *
422
+ * @return Handle to the item
423
+ * @error If an invalid handle or an invalid index is provided an
424
+ * error will be thrown.
425
+ */
426
+ native DoNotUse:ArrayGetStringHandle(Array:which, item);
427
+
428
+ /**
429
+ * Destroys the array and frees its memory.
430
+ *
431
+ * @note The function automatically sets the variable passed to it to 0 to aid
432
+ * in preventing accidental usage after destroy.
433
+ *
434
+ * @param which Array to destroy
435
+ *
436
+ * @return 1 if the Array was destroyed, 0 if nothing had to be
437
+ * destroyed (invalid handle)
438
+ */
439
+ native ArrayDestroy(&Array:which);
440
+
441
+ /**
442
+ * Similar to sorting.inc's CustomSort, the sorting algorithm then uses the
443
+ * custom comparison function to sort the data.
444
+ *
445
+ * @note The function is called in the following manner:
446
+ *
447
+ * public MySortFunc(Array:array, item1, item2, const data[], data_size)
448
+ *
449
+ * array - Array handle in its current un-sorted state
450
+ * item1, item2 - Current item pair being compared
451
+ * data[] - Extra data array passed to the sort func
452
+ * data_size - Size of extra data
453
+ *
454
+ * @note The comparison function should return:
455
+ * -1 if item1 should go before item2
456
+ * 0 if item1 and item2 are equal
457
+ * 1 if item1 should go after item2
458
+ *
459
+ * @note All parameters after item2 are optional and do not need to be specified
460
+ * and used.
461
+ * @note Unlike the sorting.inc version, the array passed to the callback is not
462
+ * in mid-sorted state.
463
+ *
464
+ * @param array Array handle
465
+ * @param comparefunc Callback function used for comparison
466
+ * @param data Extra data that is passed through to the callback
467
+ * @param data_size Size of extra data
468
+ *
469
+ * @noreturn
470
+ * @error If an invalid handle or an invalid callback is provided
471
+ * an error will be thrown.
472
+ */
473
+ native ArraySort(Array:array, const comparefunc[], data[]="", data_size=0);
474
+
475
+ /**
476
+ * A faster version of ArraySort, the sorting algorithm then uses the custom
477
+ * comparison function to sort the data.
478
+ *
479
+ * @note The advantage of this function is that the data of the elements being
480
+ * compared is directly passed to the function, instead of the item
481
+ * indexes that are passed by ArraySort. This removes the need for calling
482
+ * ArrayGet[Cell|String|Array] every time before being able to compare the
483
+ * elements.
484
+ *
485
+ * @note For Arrays with a cellsize of 1 (used for storing integers and floats),
486
+ * the function is called in the following manner:
487
+ *
488
+ * public MySortFunc(Array:array, elem1, elem2, const data[], data_size)
489
+ *
490
+ * array - Array handle in its current un-sorted state
491
+ * elem1, elem2 - Current element pair being compared
492
+ * data[] - Extra data array passed to the sort func
493
+ * data_size - Size of extra data
494
+ *
495
+ * @note For Arrays with a cellsize larger than 1 (used for storing arrays and
496
+ * strings), the function is called in the following manner:
497
+ *
498
+ * public MySortFunc(Array:array, elem1[], elem2[], const data[], data_size)
499
+ *
500
+ * array - Array handle in its current un-sorted state
501
+ * elem1[], elem2[] - Current element pair being compared
502
+ * data[] - Extra data array passed to the sort func
503
+ * data_size - Size of extra data
504
+ *
505
+ *
506
+ * @note The comparison function should return:
507
+ * -1 if elem1 should go before elem2
508
+ * 0 if elem1 and elem2 are equal
509
+ * 1 if elem1 should go after elem2
510
+ *
511
+ * @note All parameters after item2 are optional and do not need to be specified
512
+ * and used.
513
+ * @note Unlike the sorting.inc version, the array passed to the callback is not
514
+ * in mid-sorted state.
515
+ *
516
+ * @param array Array handle
517
+ * @param comparefunc Callback function used for comparison
518
+ * @param data Extra data that is passed through to the callback
519
+ * @param data_size Size of extra data
520
+ *
521
+ * @noreturn
522
+ * @error If an invalid handle or an invalid callback is provided
523
+ * an error will be thrown.
524
+ */
525
+ native ArraySortEx(Array:array, const comparefunc[], data[]="", data_size=0);
@@ -0,0 +1,166 @@
1
+ // vim: set ts=4 sw=4 tw=99 noet:
2
+ //
3
+ // AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
4
+ // Copyright (C) The AMX Mod X Development Team.
5
+ //
6
+ // This software is licensed under the GNU General Public License, version 3 or higher.
7
+ // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
8
+ // https://alliedmods.net/amxmodx-license
9
+
10
+ #if defined _cellstack_included
11
+ #endinput
12
+ #endif
13
+ #define _cellstack_included
14
+
15
+ /**
16
+ * Stack tag declaration
17
+ *
18
+ * @note Plugins are responsible for freeing all Stack handles they acquire.
19
+ * Failing to free handles will result in the plugin and AMXX leaking
20
+ * memory.
21
+ */
22
+ enum Stack
23
+ {
24
+ Invalid_Stack = 0
25
+ };
26
+
27
+ /**
28
+ * Creates a stack structure. A stack is a LIFO (last in, first out) vector of
29
+ * of items. It has O(1) insertion and O(1) removal.
30
+ *
31
+ * @note Stacks provide only two operations: Push (adding an item to the top)
32
+ * and Pop (remove an item from the top, in reverse-push order).
33
+ * @note The contents of the stack are uniform; i.e. storing a string and then
34
+ * retrieving it as an integer is NOT the same as str_to_num()!
35
+ * @note The "blocksize" determines how many cells each stack slot has, it can
36
+ * not be changed after creation.
37
+ *
38
+ * @param blocksize The number of cells each entry in the stack can hold
39
+ *
40
+ * @return New stack Handle, which must be freed via DestroyStack()
41
+ * @error If an invalid blocksize is provided an error will be
42
+ * thrown.
43
+ */
44
+ native Stack:CreateStack(blocksize = 1);
45
+
46
+ /**
47
+ * Pushes a value onto the end of the stack, adding a new index.
48
+ *
49
+ * @note This may safely be used even if the stack has a blocksize greater than
50
+ * 1.
51
+ *
52
+ * @param handle Stack handle
53
+ * @param value Value to push
54
+ *
55
+ * @noreturn
56
+ * @error If an invalid handle is provided or the resizing
57
+ * operation runs out of memory, an error will be thrown.
58
+ */
59
+ native PushStackCell(Stack:handle, any:value);
60
+
61
+ /**
62
+ * Pushes a string onto the end of a stack, truncating it if it is too long.
63
+ *
64
+ * @param handle Stack handle
65
+ * @param value String to push
66
+ *
67
+ * @noreturn
68
+ * @error If an invalid handle is provided or the resizing
69
+ * operation runs out of memory, an error will be thrown.
70
+ */
71
+ native PushStackString(Stack:handle, const value[]);
72
+
73
+ /**
74
+ * Pushes an array of cells onto the end of a stack. The cells are pushed as a
75
+ * block (i.e. the entire array takes up one stack slot), rather than pushing
76
+ * each cell individually.
77
+ *
78
+ * @param handle Stack handle
79
+ * @param values Block of values to copy
80
+ * @param size If not set, the number of elements copied from the array
81
+ * will be equal to the blocksize, if set higher than the
82
+ * blocksize, the operation will be truncated,
83
+ *
84
+ * @noreturn
85
+ * @error If an invalid handle is provided or the resizing
86
+ * operation runs out of memory, an error will be thrown.
87
+ */
88
+ native PushStackArray(Stack:handle, const any:values[], size= -1);
89
+
90
+ /**
91
+ * Pops a cell value from a stack.
92
+ *
93
+ * @param handle Stack handle
94
+ * @param value Variable to store the value in
95
+ * @param block Optionally specify which block to read from (useful if the
96
+ * blocksize is > 0)
97
+ * @param asChar Optionally read as a byte instead of a cell
98
+ *
99
+ * @return True on success, false if the stack is empty.
100
+ * @error If an invalid handle, invalid block or invalid byte is
101
+ * provided, an error will be thrown.
102
+ */
103
+ native bool:PopStackCell(Stack:handle, &any:value, block = 0, bool:asChar = false);
104
+
105
+ /**
106
+ * Pops a string value from a stack.
107
+ *
108
+ * @param handle Stack handle
109
+ * @param buffer Buffer to copy string to
110
+ * @param maxlength Maximum size of the buffer
111
+ * @param written Variable to store number of characters copied to
112
+ *
113
+ * @return True on success, false if the stack is empty
114
+ * @error If an invalid handle is provided an error will be thrown.
115
+ */
116
+ native bool:PopStackString(Stack:handle, buffer[], maxlength, &written = 0);
117
+
118
+ /**
119
+ * Pops an array of cells from a stack.
120
+ *
121
+ * @param handle Stack handle
122
+ * @param buffer Array to copy value to
123
+ * @param size Size of buffer, if not set (-1) assumes the size is equal to
124
+ * the stack blocksize
125
+ *
126
+ * @return True on success, false if the stack is empty
127
+ * @error If an invalid handle is provided an error will be thrown.
128
+ */
129
+ native bool:PopStackArray(Stack:handle, any:buffer[], size = -1);
130
+
131
+ /**
132
+ * Returns if a stack is empty.
133
+ *
134
+ * @param handle Stack handle
135
+ *
136
+ * @return True if empty, false if not empty
137
+ * @error If an invalid handle is provided an error will be thrown.
138
+ */
139
+ native bool:IsStackEmpty(Stack:handle);
140
+
141
+ /**
142
+ * Pops a value off a stack, ignoring it completely.
143
+ *
144
+ * @param handle Stack handle
145
+ *
146
+ * @return True if a value was popped, false if stack is empty
147
+ * @error If an invalid handle is provided an error will be thrown.
148
+ */
149
+ stock PopStack(Stack:handle)
150
+ {
151
+ new value;
152
+ return PopStackCell(handle, value);
153
+ }
154
+
155
+ /**
156
+ * Destroys a stack and frees its memory.
157
+ *
158
+ * @note The function automatically sets the variable passed to it to 0 to aid
159
+ * in preventing accidental usage after destroy.
160
+ *
161
+ * @param handle Stack to destroy
162
+ *
163
+ * @return 1 if the Stack was destroyed, 0 if nothing had to be
164
+ * destroyed (invalid handle)
165
+ */
166
+ native DestroyStack(&Stack:handle);