@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.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/README.ru.md +162 -0
- package/amxmodx/base/include/amxconst.inc +594 -0
- package/amxmodx/base/include/amxmisc.inc +902 -0
- package/amxmodx/base/include/amxmodx.inc +3447 -0
- package/amxmodx/base/include/amxmodx_version.inc +20 -0
- package/amxmodx/base/include/cellarray.inc +525 -0
- package/amxmodx/base/include/cellstack.inc +166 -0
- package/amxmodx/base/include/celltrie.inc +412 -0
- package/amxmodx/base/include/core.inc +202 -0
- package/amxmodx/base/include/csstats.inc +298 -0
- package/amxmodx/base/include/csstats_const.inc +29 -0
- package/amxmodx/base/include/cstrike.inc +1287 -0
- package/amxmodx/base/include/cstrike_const.inc +521 -0
- package/amxmodx/base/include/csx.inc +259 -0
- package/amxmodx/base/include/cvars.inc +547 -0
- package/amxmodx/base/include/datapack.inc +161 -0
- package/amxmodx/base/include/dbi.inc +154 -0
- package/amxmodx/base/include/dodconst.inc +152 -0
- package/amxmodx/base/include/dodfun.inc +152 -0
- package/amxmodx/base/include/dodstats.inc +69 -0
- package/amxmodx/base/include/dodx.inc +161 -0
- package/amxmodx/base/include/engine.inc +1343 -0
- package/amxmodx/base/include/engine_const.inc +310 -0
- package/amxmodx/base/include/engine_stocks.inc +248 -0
- package/amxmodx/base/include/esf.inc +70 -0
- package/amxmodx/base/include/esf_const.inc +74 -0
- package/amxmodx/base/include/fakemeta.inc +1127 -0
- package/amxmodx/base/include/fakemeta_const.inc +793 -0
- package/amxmodx/base/include/fakemeta_stocks.inc +395 -0
- package/amxmodx/base/include/fakemeta_util.inc +882 -0
- package/amxmodx/base/include/file.inc +666 -0
- package/amxmodx/base/include/float.inc +422 -0
- package/amxmodx/base/include/fun.inc +333 -0
- package/amxmodx/base/include/gameconfig.inc +93 -0
- package/amxmodx/base/include/geoip.inc +264 -0
- package/amxmodx/base/include/ham_const.inc +4352 -0
- package/amxmodx/base/include/hamsandwich.inc +439 -0
- package/amxmodx/base/include/hlsdk_const.inc +808 -0
- package/amxmodx/base/include/json.inc +777 -0
- package/amxmodx/base/include/lang.inc +119 -0
- package/amxmodx/base/include/message_const.inc +1130 -0
- package/amxmodx/base/include/message_stocks.inc +161 -0
- package/amxmodx/base/include/messages.inc +604 -0
- package/amxmodx/base/include/newmenus.inc +387 -0
- package/amxmodx/base/include/ns.inc +754 -0
- package/amxmodx/base/include/ns_const.inc +196 -0
- package/amxmodx/base/include/nvault.inc +154 -0
- package/amxmodx/base/include/regex.inc +348 -0
- package/amxmodx/base/include/sockets.inc +183 -0
- package/amxmodx/base/include/sorting.inc +107 -0
- package/amxmodx/base/include/sqlx.inc +582 -0
- package/amxmodx/base/include/string.inc +786 -0
- package/amxmodx/base/include/string_const.inc +156 -0
- package/amxmodx/base/include/string_stocks.inc +325 -0
- package/amxmodx/base/include/textparse_ini.inc +214 -0
- package/amxmodx/base/include/textparse_smc.inc +261 -0
- package/amxmodx/base/include/tfcconst.inc +84 -0
- package/amxmodx/base/include/tfcstats.inc +62 -0
- package/amxmodx/base/include/tfcx.inc +148 -0
- package/amxmodx/base/include/time.inc +118 -0
- package/amxmodx/base/include/tsconst.inc +154 -0
- package/amxmodx/base/include/tsfun.inc +198 -0
- package/amxmodx/base/include/tsstats.inc +65 -0
- package/amxmodx/base/include/tsx.inc +88 -0
- package/amxmodx/base/include/vault.inc +60 -0
- package/amxmodx/base/include/vector.inc +131 -0
- package/amxmodx/base/include/xs.inc +1570 -0
- package/as/amxts.d.ts +153 -0
- package/as/constants.ts +4730 -0
- package/as/effects.ts +1449 -0
- package/as/entities.ts +5482 -0
- package/as/events.ts +3054 -0
- package/as/facade.ts +4639 -0
- package/as/flags.ts +299 -0
- package/as/fs.ts +287 -0
- package/as/hooks.ts +18536 -0
- package/as/kit.ts +25 -0
- package/as/lib/check.ts +86 -0
- package/as/modules/http.ts +184 -0
- package/as/natives.ts +11845 -0
- package/as/os.ts +30 -0
- package/as/promise.ts +1392 -0
- package/as/promise.types.d.ts +82 -0
- package/as/remote.ts +288 -0
- package/as/tsconfig.json +22 -0
- package/as/vector.ts +65 -0
- package/bin/amxts.mjs +10 -0
- package/includes/menu_core.inc +355 -0
- package/includes/order.txt +54 -0
- package/includes/sources.json +27 -0
- package/includes/universal_config.inc +355 -0
- package/lint/oxlint-plugin.mjs +77 -0
- package/node_modules/assemblyscript/LICENSE +201 -0
- package/node_modules/assemblyscript/NOTICE +93 -0
- package/node_modules/assemblyscript/package.json +63 -0
- package/node_modules/assemblyscript/std/README.md +6 -0
- package/node_modules/assemblyscript/std/assembly/array.ts +526 -0
- package/node_modules/assemblyscript/std/assembly/arraybuffer.ts +77 -0
- package/node_modules/assemblyscript/std/assembly/atomics.ts +127 -0
- package/node_modules/assemblyscript/std/assembly/bindings/asyncify.ts +16 -0
- package/node_modules/assemblyscript/std/assembly/bindings/dom.ts +291 -0
- package/node_modules/assemblyscript/std/assembly/bindings/node.ts +6 -0
- package/node_modules/assemblyscript/std/assembly/builtins.ts +2631 -0
- package/node_modules/assemblyscript/std/assembly/compat.ts +2 -0
- package/node_modules/assemblyscript/std/assembly/console.ts +42 -0
- package/node_modules/assemblyscript/std/assembly/crypto.ts +9 -0
- package/node_modules/assemblyscript/std/assembly/dataview.ts +181 -0
- package/node_modules/assemblyscript/std/assembly/date.ts +373 -0
- package/node_modules/assemblyscript/std/assembly/diagnostics.ts +11 -0
- package/node_modules/assemblyscript/std/assembly/error.ts +44 -0
- package/node_modules/assemblyscript/std/assembly/function.ts +38 -0
- package/node_modules/assemblyscript/std/assembly/index.d.ts +2822 -0
- package/node_modules/assemblyscript/std/assembly/iterator.ts +35 -0
- package/node_modules/assemblyscript/std/assembly/map.ts +260 -0
- package/node_modules/assemblyscript/std/assembly/math.ts +3289 -0
- package/node_modules/assemblyscript/std/assembly/memory.ts +123 -0
- package/node_modules/assemblyscript/std/assembly/number.ts +388 -0
- package/node_modules/assemblyscript/std/assembly/object.ts +36 -0
- package/node_modules/assemblyscript/std/assembly/performance.ts +9 -0
- package/node_modules/assemblyscript/std/assembly/polyfills.ts +27 -0
- package/node_modules/assemblyscript/std/assembly/process.ts +50 -0
- package/node_modules/assemblyscript/std/assembly/reference.ts +48 -0
- package/node_modules/assemblyscript/std/assembly/regexp.ts +12 -0
- package/node_modules/assemblyscript/std/assembly/rt/README.md +83 -0
- package/node_modules/assemblyscript/std/assembly/rt/common.ts +81 -0
- package/node_modules/assemblyscript/std/assembly/rt/index-incremental.ts +2 -0
- package/node_modules/assemblyscript/std/assembly/rt/index-minimal.ts +2 -0
- package/node_modules/assemblyscript/std/assembly/rt/index-stub.ts +1 -0
- package/node_modules/assemblyscript/std/assembly/rt/index.d.ts +37 -0
- package/node_modules/assemblyscript/std/assembly/rt/itcms.ts +419 -0
- package/node_modules/assemblyscript/std/assembly/rt/rtrace.ts +15 -0
- package/node_modules/assemblyscript/std/assembly/rt/stub.ts +133 -0
- package/node_modules/assemblyscript/std/assembly/rt/tcms.ts +254 -0
- package/node_modules/assemblyscript/std/assembly/rt/tlsf.ts +592 -0
- package/node_modules/assemblyscript/std/assembly/rt.ts +87 -0
- package/node_modules/assemblyscript/std/assembly/set.ts +220 -0
- package/node_modules/assemblyscript/std/assembly/shared/feature.ts +65 -0
- package/node_modules/assemblyscript/std/assembly/shared/runtime.ts +11 -0
- package/node_modules/assemblyscript/std/assembly/shared/target.ts +11 -0
- package/node_modules/assemblyscript/std/assembly/shared/tsconfig.json +11 -0
- package/node_modules/assemblyscript/std/assembly/shared/typeinfo.ts +72 -0
- package/node_modules/assemblyscript/std/assembly/staticarray.ts +401 -0
- package/node_modules/assemblyscript/std/assembly/string.ts +847 -0
- package/node_modules/assemblyscript/std/assembly/symbol.ts +114 -0
- package/node_modules/assemblyscript/std/assembly/table.ts +16 -0
- package/node_modules/assemblyscript/std/assembly/tsconfig.json +6 -0
- package/node_modules/assemblyscript/std/assembly/typedarray.ts +1945 -0
- package/node_modules/assemblyscript/std/assembly/uri.ts +17 -0
- package/node_modules/assemblyscript/std/assembly/util/bytes.ts +107 -0
- package/node_modules/assemblyscript/std/assembly/util/casemap.ts +497 -0
- package/node_modules/assemblyscript/std/assembly/util/error.ts +54 -0
- package/node_modules/assemblyscript/std/assembly/util/hash.ts +117 -0
- package/node_modules/assemblyscript/std/assembly/util/math.ts +1922 -0
- package/node_modules/assemblyscript/std/assembly/util/memory.ts +290 -0
- package/node_modules/assemblyscript/std/assembly/util/number.ts +873 -0
- package/node_modules/assemblyscript/std/assembly/util/sort.ts +313 -0
- package/node_modules/assemblyscript/std/assembly/util/string.ts +1202 -0
- package/node_modules/assemblyscript/std/assembly/util/uri.ts +275 -0
- package/node_modules/assemblyscript/std/assembly/vector.ts +4 -0
- package/node_modules/assemblyscript/std/assembly.json +16 -0
- package/node_modules/assemblyscript/std/portable/index.d.ts +462 -0
- package/node_modules/assemblyscript/std/portable/index.js +416 -0
- package/node_modules/assemblyscript/std/portable.json +11 -0
- package/node_modules/assemblyscript/std/types/assembly/index.d.ts +1 -0
- package/node_modules/assemblyscript/std/types/assembly/package.json +3 -0
- package/node_modules/assemblyscript/std/types/portable/index.d.ts +1 -0
- package/node_modules/assemblyscript/std/types/portable/package.json +3 -0
- package/node_modules/assemblyscript/tsconfig-base.json +13 -0
- package/package.json +112 -0
- package/runtime/deps/assemblyscript/LICENSE +201 -0
- package/runtime/deps/assemblyscript/NOTICE +93 -0
- package/runtime/deps/assemblyscript/bin/asc.js +35 -0
- package/runtime/deps/assemblyscript/dist/asc.js +25035 -0
- package/runtime/deps/assemblyscript/dist/assemblyscript.js +337 -0
- package/runtime/deps/assemblyscript/node_modules/binaryen/LICENSE +201 -0
- package/runtime/deps/assemblyscript/node_modules/binaryen/index.js +28905 -0
- package/runtime/deps/assemblyscript/node_modules/binaryen/package.json +50 -0
- package/runtime/deps/assemblyscript/node_modules/long/LICENSE +202 -0
- package/runtime/deps/assemblyscript/node_modules/long/index.js +1581 -0
- package/runtime/deps/assemblyscript/node_modules/long/package.json +58 -0
- package/runtime/deps/assemblyscript/package.json +114 -0
- package/runtime/host/amxts.inc +85 -0
- package/runtime/licenses/AMXX-LICENSE.txt +34 -0
- package/runtime/licenses/AssemblyScript-LICENSE +201 -0
- package/runtime/licenses/AssemblyScript-NOTICE +93 -0
- package/runtime/licenses/Binaryen-LICENSE +201 -0
- package/runtime/licenses/Bun-LICENSE.md +84 -0
- package/runtime/licenses/GPL-3.0.txt +674 -0
- package/runtime/licenses/LLVM-LICENSE.TXT +279 -0
- package/runtime/licenses/README.md +25 -0
- package/runtime/licenses/WAMR-LICENSE +219 -0
- package/runtime/natives.txt +1095 -0
- package/runtime/patches/README.md +59 -0
- package/runtime/patches/assemblyscript-0.28.20-amxts.patch +14174 -0
- package/runtime/patches/wamr-2.4.5-amxts.patch +364 -0
- package/scripts/apply-docs.ts +508 -0
- package/scripts/asc.ts +27 -0
- package/scripts/auto-imports.ts +258 -0
- package/scripts/build-wasm.ts +595 -0
- package/scripts/check.ts +93 -0
- package/scripts/compile-cache.ts +179 -0
- package/scripts/compile.ts +401 -0
- package/scripts/docker-server.ts +73 -0
- package/scripts/docs/as/amxts.ts +210 -0
- package/scripts/docs/as/effects.ts +1684 -0
- package/scripts/docs/as/facade.ts +3302 -0
- package/scripts/docs/as/fs.ts +173 -0
- package/scripts/docs/as/lib/check.ts +68 -0
- package/scripts/docs/as/modules/http.ts +66 -0
- package/scripts/docs/as/os.ts +16 -0
- package/scripts/docs/as/promise.ts +132 -0
- package/scripts/docs/as/promise.types.ts +63 -0
- package/scripts/docs/as/vector.ts +48 -0
- package/scripts/docs/entities.ts +2338 -0
- package/scripts/docs/events.ts +245 -0
- package/scripts/docs/game.ts +497 -0
- package/scripts/docs/messages.ts +148 -0
- package/scripts/file-contents.ts +74 -0
- package/scripts/includes.ts +134 -0
- package/scripts/player-fields.ts +866 -0
- package/scripts/plugin-cache.ts +92 -0
- package/scripts/plugin-natives.ts +1157 -0
- package/scripts/prebuilt.ts +268 -0
- package/scripts/prepare.ts +134 -0
- package/scripts/project.ts +973 -0
- package/scripts/run.ts +28 -0
- package/scripts/shared-modules.ts +906 -0
- package/scripts/system.ts +33 -0
- package/scripts/tracked-fs.ts +115 -0
- package/scripts/typed-configs.ts +788 -0
- package/scripts/ui.ts +77 -0
- package/src/cli-api.mjs +175 -0
- package/src/parser/include-parser.ts +506 -0
- package/src/system.mjs +155 -0
- package/src/testing/compile-cache.ts +31 -0
- package/src/testing/compile.ts +222 -0
- package/src/testing/coroutines.ts +191 -0
- package/src/testing/index.ts +39 -0
- package/src/testing/kits.ts +55 -0
- package/src/testing/memory.ts +125 -0
- package/src/testing/natives.ts +925 -0
- package/src/testing/server.ts +1874 -0
- package/src/testing/setup.ts +63 -0
- package/src/testing/tables.ts +139 -0
- package/src/types.ts +51 -0
|
@@ -0,0 +1,412 @@
|
|
|
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 _celltrie_included
|
|
11
|
+
#endinput
|
|
12
|
+
#endif
|
|
13
|
+
#define _celltrie_included
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Hash map tag declaration
|
|
17
|
+
*
|
|
18
|
+
* @note The word "Trie" in this API is historical. As of AMX Mod X 1.8.3,
|
|
19
|
+
* tries have been internally replaced with hash tables, which have O(1)
|
|
20
|
+
* insertion time instead of O(n).
|
|
21
|
+
* @note Plugins are responsible for freeing all Trie handles they acquire.
|
|
22
|
+
* Failing to free handles will result in the plugin and AMXX leaking
|
|
23
|
+
* memory.
|
|
24
|
+
*/
|
|
25
|
+
enum Trie
|
|
26
|
+
{
|
|
27
|
+
Invalid_Trie = 0
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Hash map iterator tag declaration
|
|
32
|
+
*
|
|
33
|
+
* @note The word "Trie" in this API is historical. As of AMX Mod X 1.8.3,
|
|
34
|
+
* tries have been internally replaced with hash tables, which have O(1)
|
|
35
|
+
* insertion time instead of O(n).
|
|
36
|
+
* @note Plugins are responsible for freeing all TrieIter handles they acquire.
|
|
37
|
+
* Failing to free handles will result in the plugin and AMXX leaking
|
|
38
|
+
* memory.
|
|
39
|
+
*/
|
|
40
|
+
enum TrieIter
|
|
41
|
+
{
|
|
42
|
+
Invalid_TrieIter = 0
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Hash map snapshot tag declaration
|
|
47
|
+
*
|
|
48
|
+
* @note Plugins are responsible for freeing all Snapshot handles they acquire.
|
|
49
|
+
* Failing to free handles will result in the plugin and AMXX leaking
|
|
50
|
+
* memory.
|
|
51
|
+
*/
|
|
52
|
+
enum Snapshot
|
|
53
|
+
{
|
|
54
|
+
Invalid_Snapshot = 0
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Creates a hash map. A hash map is a container that maps strings (called keys)
|
|
59
|
+
* to arbitrary values (cells, arrays or strings).
|
|
60
|
+
*
|
|
61
|
+
* @note Keys in a hash map are unique so there is no more than one entry in the
|
|
62
|
+
* map for any given key.
|
|
63
|
+
* @note Insertion, deletion, and lookup in a hash map are all considered to be
|
|
64
|
+
* fast operations, amortized to O(1), or constant time.
|
|
65
|
+
*
|
|
66
|
+
* @return New Map handle, which must be freed via TrieDestroy()
|
|
67
|
+
*/
|
|
68
|
+
native Trie:TrieCreate();
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Clears all entries from a Map.
|
|
72
|
+
*
|
|
73
|
+
* @param handle Map handle
|
|
74
|
+
*
|
|
75
|
+
* @error If an invalid handle is provided an error will be
|
|
76
|
+
* thrown.
|
|
77
|
+
* @noreturn
|
|
78
|
+
*/
|
|
79
|
+
native TrieClear(Trie:handle);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Sets a cell value in a hash map, either inserting a new entry or replacing
|
|
83
|
+
* an old one.
|
|
84
|
+
*
|
|
85
|
+
* @param handle Map handle
|
|
86
|
+
* @param key Key string
|
|
87
|
+
* @param value Value to store
|
|
88
|
+
* @param replace If false the operation will fail if the key is already set
|
|
89
|
+
*
|
|
90
|
+
* @return 1 on success, 0 otherwise
|
|
91
|
+
* @error If an invalid handle is provided an error will be
|
|
92
|
+
* thrown.
|
|
93
|
+
*/
|
|
94
|
+
native TrieSetCell(Trie:handle, const key[], any:value, bool:replace = true);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Sets a string value in a hash map, either inserting a new entry or replacing
|
|
98
|
+
* an old one.
|
|
99
|
+
*
|
|
100
|
+
* @param handle Map handle
|
|
101
|
+
* @param key Key string
|
|
102
|
+
* @param value String to store
|
|
103
|
+
* @param replace If false the operation will fail if the key is already set
|
|
104
|
+
*
|
|
105
|
+
* @return 1 on success, 0 otherwise
|
|
106
|
+
* @error If an invalid handle is provided an error will be
|
|
107
|
+
* thrown.
|
|
108
|
+
*/
|
|
109
|
+
native TrieSetString(Trie:handle, const key[], const value[], bool:replace = true);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Sets an array value in a hash map, either inserting a new entry or replacing
|
|
113
|
+
* an old one.
|
|
114
|
+
*
|
|
115
|
+
* @param handle Map handle
|
|
116
|
+
* @param key Key string
|
|
117
|
+
* @param buffer Array to store
|
|
118
|
+
* @param size Array size
|
|
119
|
+
* @param replace If false the operation will fail if the key is already set
|
|
120
|
+
*
|
|
121
|
+
* @return 1 on success, 0 otherwise
|
|
122
|
+
* @error If an invalid handle is provided an error will be
|
|
123
|
+
* thrown. or invalid array size
|
|
124
|
+
*/
|
|
125
|
+
native TrieSetArray(Trie:handle, const key[], const any:buffer[], size, bool:replace = true);
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Retrieves a cell value from a hash map.
|
|
129
|
+
*
|
|
130
|
+
* @param handle Map handle
|
|
131
|
+
* @param key Key string
|
|
132
|
+
* @param value Variable to store value to
|
|
133
|
+
*
|
|
134
|
+
* @return True on success, false if either the key is not set or the
|
|
135
|
+
* value type does not match (value is string or array)
|
|
136
|
+
* @error If an invalid handle is provided an error will be
|
|
137
|
+
* thrown.
|
|
138
|
+
*/
|
|
139
|
+
native bool:TrieGetCell(Trie:handle, const key[], &any:value);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Retrieves a string from a hash map.
|
|
143
|
+
*
|
|
144
|
+
* @param handle Map handle
|
|
145
|
+
* @param key Key string
|
|
146
|
+
* @param output Buffer to copy the value to
|
|
147
|
+
* @param outputsize Maximum size of buffer
|
|
148
|
+
* @param size Optional variable to store the number of cells written
|
|
149
|
+
* to the buffer in
|
|
150
|
+
*
|
|
151
|
+
* @return True on success, false if either the key is not set or
|
|
152
|
+
* the value type does not match (value is cell or array)
|
|
153
|
+
* @error If an invalid handle is provided an error will be
|
|
154
|
+
* thrown.
|
|
155
|
+
*/
|
|
156
|
+
native bool:TrieGetString(Trie:handle, const key[], output[], outputsize, &size = 0);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Retrieves a string from a hash map.
|
|
160
|
+
*
|
|
161
|
+
* @param handle Map handle
|
|
162
|
+
* @param key Key string
|
|
163
|
+
* @param output Array to copy the value to
|
|
164
|
+
* @param outputsize Maximum size of array
|
|
165
|
+
* @param size Optional variable to store the number of cells written
|
|
166
|
+
* to the array in
|
|
167
|
+
*
|
|
168
|
+
* @return True on success, false if either the key is not set or
|
|
169
|
+
* the value type does not match (value is cell or string)
|
|
170
|
+
* @error If an invalid handle or array size is provided an error
|
|
171
|
+
* will be thrown.
|
|
172
|
+
*/
|
|
173
|
+
native bool:TrieGetArray(Trie:handle, const key[], any:output[], outputsize, &size = 0);
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Removes an entry from a hash map.
|
|
177
|
+
*
|
|
178
|
+
* @param handle Map handle
|
|
179
|
+
* @param key Key string
|
|
180
|
+
*
|
|
181
|
+
* @return True on success, false if the key was never set
|
|
182
|
+
* @error If an invalid handle is provided an error will be
|
|
183
|
+
* thrown.
|
|
184
|
+
*/
|
|
185
|
+
native bool:TrieDeleteKey(Trie:handle, const key[]);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Checks a hash map for the existence of an entry.
|
|
189
|
+
*
|
|
190
|
+
* @param handle Map handle
|
|
191
|
+
* @param key Key string
|
|
192
|
+
*
|
|
193
|
+
* @return True if the key is set, false otherwise
|
|
194
|
+
* @error If an invalid handle is provided an error will be
|
|
195
|
+
* thrown.
|
|
196
|
+
*/
|
|
197
|
+
native bool:TrieKeyExists(Trie:handle, const key[]);
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Destroys a hash map and frees its memory.
|
|
201
|
+
*
|
|
202
|
+
* @note The function automatically sets the variable passed to it to 0 to aid
|
|
203
|
+
* in preventing accidental usage after destroy.
|
|
204
|
+
*
|
|
205
|
+
* @param handle Map handle
|
|
206
|
+
*
|
|
207
|
+
* @return 1 on success, 0 if an invalid handle was passed in
|
|
208
|
+
*/
|
|
209
|
+
native TrieDestroy(&Trie:handle);
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Returns the number of entries in a hash map.
|
|
213
|
+
*
|
|
214
|
+
* @param handle Map handle
|
|
215
|
+
*
|
|
216
|
+
* @return Number of elements in the hash map
|
|
217
|
+
* @error If an invalid handle is provided an error will be
|
|
218
|
+
* thrown.
|
|
219
|
+
*/
|
|
220
|
+
native TrieGetSize(Trie:handle);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Creates a snapshot of all keys in a hash map. If the map is changed
|
|
224
|
+
* afterwards, the changes are not reflected in the snapshot.
|
|
225
|
+
* Keys are not sorted.
|
|
226
|
+
*
|
|
227
|
+
* @param handle Map handle
|
|
228
|
+
*
|
|
229
|
+
* @return New map snapshot handle, which must be freed via
|
|
230
|
+
* TrieSnapshotDestroy()
|
|
231
|
+
* @error If an invalid handle is provided an error will be
|
|
232
|
+
* thrown.
|
|
233
|
+
*/
|
|
234
|
+
native Snapshot:TrieSnapshotCreate(Trie:handle);
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Returns the number of keys in a map snapshot. Note that this may be
|
|
238
|
+
* different from the size of the map, since the map can change after the
|
|
239
|
+
* snapshot of its keys was taken.
|
|
240
|
+
*
|
|
241
|
+
* @param handle Map snapshot handle
|
|
242
|
+
*
|
|
243
|
+
* @return Number of keys
|
|
244
|
+
* @error If an invalid handle is provided an error will be
|
|
245
|
+
* thrown.
|
|
246
|
+
*/
|
|
247
|
+
native TrieSnapshotLength(Snapshot:handle);
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Returns the buffer size required to store a given key. That is, it returns
|
|
251
|
+
* the length of the key plus one.
|
|
252
|
+
*
|
|
253
|
+
* @param handle Map snapshot handle
|
|
254
|
+
* @param index Key index (starting from 0)
|
|
255
|
+
*
|
|
256
|
+
* @return Buffer size required to store the key string
|
|
257
|
+
* @error If an invalid handle is provided an error will be
|
|
258
|
+
* thrown. or index out of range
|
|
259
|
+
*/
|
|
260
|
+
native TrieSnapshotKeyBufferSize(Snapshot:handle, index);
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Retrieves the key string of a given key in a map snapshot.
|
|
264
|
+
*
|
|
265
|
+
* @param handle Map snapshot handle
|
|
266
|
+
* @param index Key index (starting from 0)
|
|
267
|
+
* @param buffer String buffer
|
|
268
|
+
* @param maxlength Maximum buffer length
|
|
269
|
+
*
|
|
270
|
+
* @return Number of bytes written to the buffer
|
|
271
|
+
* @error If an invalid handle is provided an error will be
|
|
272
|
+
* thrown. or index out of range
|
|
273
|
+
*/
|
|
274
|
+
native TrieSnapshotGetKey(Snapshot:handle, index, buffer[], maxlength);
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Destroys a map snapshot and frees its memory.
|
|
278
|
+
*
|
|
279
|
+
* @note The function automatically sets the variable passed to it to 0 to aid
|
|
280
|
+
* in preventing accidental usage after destroy.
|
|
281
|
+
*
|
|
282
|
+
* @param handle Map snapshot handle
|
|
283
|
+
*
|
|
284
|
+
* @return 1 on success, 0 if an invalid handle was passed in
|
|
285
|
+
*/
|
|
286
|
+
native TrieSnapshotDestroy(&Snapshot:handle);
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Creates an iterator for a map. It provides iterative read-only access to the
|
|
291
|
+
* maps contents.
|
|
292
|
+
*
|
|
293
|
+
* @note Removing or adding keys to the underlying map will invalidate all its
|
|
294
|
+
* iterators. Updating values of existing keys is allowed and the changes
|
|
295
|
+
* will be immediately reflected in the iterator.
|
|
296
|
+
* @note Iterators are designed to be short-lived and not stored, and creating
|
|
297
|
+
* them is very cheap. Reading data from an iterator is just as fast as
|
|
298
|
+
* reading directly from the map.
|
|
299
|
+
* @note Just like in snapshots the keys are not sorted.
|
|
300
|
+
*
|
|
301
|
+
* @return New iterator handle, which must be freed via TrieIterDestroy().
|
|
302
|
+
* @error Invalid Handle
|
|
303
|
+
*/
|
|
304
|
+
native TrieIter:TrieIterCreate(Trie:handle);
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Returns if the iterator has reached its end and no more data can be read.
|
|
308
|
+
*
|
|
309
|
+
* @param handle Iterator handle
|
|
310
|
+
*
|
|
311
|
+
* @return True if iterator has reached the end, false otherwise
|
|
312
|
+
* @error Invalid Handle
|
|
313
|
+
* Iterator has been closed (underlying map destroyed)
|
|
314
|
+
* Iterator is outdated
|
|
315
|
+
*/
|
|
316
|
+
native bool:TrieIterEnded(TrieIter:handle);
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Advances the iterator to the next key/value pair if one is available.
|
|
320
|
+
*
|
|
321
|
+
* @param handle Iterator handle
|
|
322
|
+
*
|
|
323
|
+
* @error Invalid Handle
|
|
324
|
+
* Iterator has been closed (underlying map destroyed)
|
|
325
|
+
* Iterator is outdated
|
|
326
|
+
*/
|
|
327
|
+
native TrieIterNext(TrieIter:handle);
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Retrieves the key the iterator currently points to.
|
|
331
|
+
*
|
|
332
|
+
* @param handle Iterator handle.
|
|
333
|
+
* @param key Buffer to store the current key in.
|
|
334
|
+
* @param outputsize Maximum size of string buffer.
|
|
335
|
+
*
|
|
336
|
+
* @return Nnumber of bytes written to the buffer
|
|
337
|
+
* @error Invalid handle
|
|
338
|
+
* Iterator has been closed (underlying map destroyed)
|
|
339
|
+
* Iterator is outdated
|
|
340
|
+
*/
|
|
341
|
+
native TrieIterGetKey(TrieIter:handle, key[], outputsize);
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Retrieves the number of elements in the underlying map.
|
|
345
|
+
*
|
|
346
|
+
* @note When used on a valid iterator this is exactly the same as calling TrieGetSize on the map directly.
|
|
347
|
+
*
|
|
348
|
+
* @param handle Iterator handle
|
|
349
|
+
*
|
|
350
|
+
* @return Number of elements in the map
|
|
351
|
+
* @error Invalid handle
|
|
352
|
+
* Iterator has been closed (underlying map destroyed)
|
|
353
|
+
* Iterator is outdated
|
|
354
|
+
*/
|
|
355
|
+
native TrieIterGetSize(TrieIter:handle);
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Retrieves a value at the current position of the iterator.
|
|
359
|
+
*
|
|
360
|
+
* @param handle Iterator handle
|
|
361
|
+
* @param value Variable to store value in
|
|
362
|
+
*
|
|
363
|
+
* @return True on success, false if the iterator is empty or the current
|
|
364
|
+
* value is an array or a string.
|
|
365
|
+
* @error Invalid handle
|
|
366
|
+
* Iterator has been closed (underlying map destroyed)
|
|
367
|
+
* Iterator is outdated
|
|
368
|
+
*/
|
|
369
|
+
native bool:TrieIterGetCell(TrieIter:handle, &any:value);
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Retrieves a string at the current position of the iterator.
|
|
373
|
+
*
|
|
374
|
+
* @param handle Iterator handle
|
|
375
|
+
* @param buffer Buffer to store the string in
|
|
376
|
+
* @param outputsize Maximum size of string buffer
|
|
377
|
+
* @param size Optional parameter to store the number of bytes written to the buffer.
|
|
378
|
+
*
|
|
379
|
+
* @return True on success, false if the iterator is empty or the current value
|
|
380
|
+
* is not a string.
|
|
381
|
+
* @error Invalid handle
|
|
382
|
+
* Invalid buffer size
|
|
383
|
+
* Iterator has been closed (underlying map destroyed)
|
|
384
|
+
* Iterator is outdated
|
|
385
|
+
*/
|
|
386
|
+
native bool:TrieIterGetString(TrieIter:handle, buffer[], outputsize, &size = 0);
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Retrieves an array at the current position of the iterator.
|
|
390
|
+
*
|
|
391
|
+
* @param handle Iterator handle
|
|
392
|
+
* @param buffer Buffer to store the array
|
|
393
|
+
* @param outputsize Maximum size of buffer
|
|
394
|
+
* @param size Optional parameter to store the number of bytes written to the buffer
|
|
395
|
+
*
|
|
396
|
+
* @return True on success, false if the iterator is empty or the current
|
|
397
|
+
* value is not an array.
|
|
398
|
+
* @error Invalid handle
|
|
399
|
+
* Invalid buffer size
|
|
400
|
+
* Iterator has been closed (underlying map destroyed)
|
|
401
|
+
* Iterator is outdated
|
|
402
|
+
*/
|
|
403
|
+
native bool:TrieIterGetArray(TrieIter:handle, any:array[], outputsize, &size = 0);
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Destroys an iterator handle.
|
|
407
|
+
*
|
|
408
|
+
* @param handle Iterator handle.
|
|
409
|
+
*
|
|
410
|
+
* @return True on success, false if the value was never set.
|
|
411
|
+
*/
|
|
412
|
+
native TrieIterDestroy(&TrieIter:handle);
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/* Core functions
|
|
2
|
+
*
|
|
3
|
+
* (c) Copyright 1998-2003, ITB CompuPhase
|
|
4
|
+
*
|
|
5
|
+
* This file is provided as is (no warranties).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#if defined _core_included
|
|
9
|
+
#endinput
|
|
10
|
+
#endif
|
|
11
|
+
#define _core_included
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns the free memory space available to the plugin.
|
|
15
|
+
*
|
|
16
|
+
* @note This is a debugging function that is not intended for general plugin
|
|
17
|
+
* use.
|
|
18
|
+
*
|
|
19
|
+
* @return Free memory space in bytes
|
|
20
|
+
*/
|
|
21
|
+
native heapspace();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns the function index of a public function declared in the plugin.
|
|
25
|
+
*
|
|
26
|
+
* @param name Function name
|
|
27
|
+
*
|
|
28
|
+
* @return Function index > 0 on success, -1 if function was not found
|
|
29
|
+
* @error If the function name is too long (longer than 63 characters)
|
|
30
|
+
* an error will be thrown.
|
|
31
|
+
*/
|
|
32
|
+
native funcidx(const name[]);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Returns the number of arguments passed into the currently executed function.
|
|
36
|
+
*
|
|
37
|
+
* @return Number of arguments passed
|
|
38
|
+
*/
|
|
39
|
+
native numargs();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves an argument value passed into the currently executed function.
|
|
43
|
+
*
|
|
44
|
+
* @param arg Argument index
|
|
45
|
+
* @param index Index to retrieve from the argument (for arrays and strings)
|
|
46
|
+
*
|
|
47
|
+
* @return Argument value at given index
|
|
48
|
+
*/
|
|
49
|
+
native getarg(arg, index = 0);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sets the value of an argument passed into the currently executed function.
|
|
53
|
+
*
|
|
54
|
+
* @note This is not equal to assigning a new value to a by-reference argument.
|
|
55
|
+
*
|
|
56
|
+
* @param arg Argument index
|
|
57
|
+
* @param index Index to set in the argument (for arrays and strings)
|
|
58
|
+
*/
|
|
59
|
+
native setarg(arg, index = 0, value);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Converts a character to lowercase.
|
|
63
|
+
*
|
|
64
|
+
* @note This is not UTF8 or locale-safe.
|
|
65
|
+
*
|
|
66
|
+
* @param c Character to convert
|
|
67
|
+
*
|
|
68
|
+
* @return Converted character
|
|
69
|
+
*/
|
|
70
|
+
native tolower(c);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Converts a character to uppercase.
|
|
74
|
+
*
|
|
75
|
+
* @note This is not UTF8 or locale-safe.
|
|
76
|
+
*
|
|
77
|
+
* @param c Character to convert
|
|
78
|
+
*
|
|
79
|
+
* @return Converted character
|
|
80
|
+
*/
|
|
81
|
+
native toupper(c);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Swaps the bytes of a value (the lowest byte becomes the highest byte).
|
|
85
|
+
*
|
|
86
|
+
* @param c Value to swap
|
|
87
|
+
*
|
|
88
|
+
* @return Byte-swapped value
|
|
89
|
+
*/
|
|
90
|
+
native swapchars(c);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns a random number between 0 and a specified upper bound.
|
|
94
|
+
*
|
|
95
|
+
* @param max Exclusive upper bound
|
|
96
|
+
*
|
|
97
|
+
* @return Random value
|
|
98
|
+
*/
|
|
99
|
+
native random(max);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Returns the smaller of two provided values.
|
|
103
|
+
*
|
|
104
|
+
* @param value1 Value one
|
|
105
|
+
* @param value2 Value two
|
|
106
|
+
*
|
|
107
|
+
* @return Smaller of the two values
|
|
108
|
+
*/
|
|
109
|
+
native min(value1, value2);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns the bigger of two provided values.
|
|
113
|
+
*
|
|
114
|
+
* @param value1 Value one
|
|
115
|
+
* @param value2 Value two
|
|
116
|
+
*
|
|
117
|
+
* @return Bigger of the two values
|
|
118
|
+
*/
|
|
119
|
+
native max(value1, value2);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Limits a provided value between two specified bounds.
|
|
123
|
+
*
|
|
124
|
+
* @param value Value to clamp
|
|
125
|
+
* @param min Lower bound
|
|
126
|
+
* @param max Upper bound
|
|
127
|
+
*
|
|
128
|
+
* @return The value if it is between the lower and upper bound, min if
|
|
129
|
+
* value is below, max if it is above the specified bounds.
|
|
130
|
+
*/
|
|
131
|
+
native clamp(value, min = cellmin, max = cellmax);
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Returns a value raised to a specified exponent.
|
|
135
|
+
*
|
|
136
|
+
* @param value Value
|
|
137
|
+
* @param exponent Exponent to raise value to
|
|
138
|
+
*
|
|
139
|
+
* @return Value to the power of exponent
|
|
140
|
+
*/
|
|
141
|
+
native power(value, exponent);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Returns the approximated square root of a value.
|
|
145
|
+
*
|
|
146
|
+
* @note This uses a simple successice approximation algorithm (continuously
|
|
147
|
+
* dividing the value) and only deals with integers, this makes it very
|
|
148
|
+
* imprecise.
|
|
149
|
+
*
|
|
150
|
+
* @param value Value
|
|
151
|
+
*
|
|
152
|
+
* @return Square root of the value
|
|
153
|
+
*/
|
|
154
|
+
native sqroot(value);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves the current time in hours, minutes and seconds.
|
|
158
|
+
*
|
|
159
|
+
* @param hour Variable to store hours in
|
|
160
|
+
* @param minute Variable to store minutes in
|
|
161
|
+
* @param second Variable to store seconds in
|
|
162
|
+
*
|
|
163
|
+
* @return Unix timestamp
|
|
164
|
+
*/
|
|
165
|
+
native time(&hour = 0, &minute = 0, &second = 0);
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Retrieves the current date in year, month and day.
|
|
169
|
+
*
|
|
170
|
+
* @param year Variable to store year in
|
|
171
|
+
* @param month Variable to store month in
|
|
172
|
+
* @param day Variable to store day in
|
|
173
|
+
*
|
|
174
|
+
* @noreturn
|
|
175
|
+
*/
|
|
176
|
+
native date(&year = 0, &month = 0, &day = 0);
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Returns the elapsed CPU seconds.
|
|
180
|
+
*
|
|
181
|
+
* @note This is a debugging function that is not intended for general plugin
|
|
182
|
+
* use.
|
|
183
|
+
* @note This uses the C clock() function internally and comes with all its
|
|
184
|
+
* drawbacks attached.
|
|
185
|
+
*
|
|
186
|
+
* @param granularity Unused
|
|
187
|
+
*
|
|
188
|
+
* @return Number of CPU seconds elapsed
|
|
189
|
+
*/
|
|
190
|
+
native tickcount(&granularity = 0);
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Returns the absolute value of a number.
|
|
194
|
+
*
|
|
195
|
+
* @param x Integral value
|
|
196
|
+
*
|
|
197
|
+
* @return Absolute value of x (x if it is greater than 0, -x otherwise)
|
|
198
|
+
*/
|
|
199
|
+
stock abs(x)
|
|
200
|
+
{
|
|
201
|
+
return x > 0 ? x : -x;
|
|
202
|
+
}
|