@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,183 @@
|
|
|
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
|
+
//
|
|
11
|
+
// Socket Functions
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
#if defined _socket_included
|
|
15
|
+
#endinput
|
|
16
|
+
#endif
|
|
17
|
+
#define _socket_included
|
|
18
|
+
|
|
19
|
+
#pragma reqlib sockets
|
|
20
|
+
#if !defined AMXMODX_NOAUTOLOAD
|
|
21
|
+
#pragma loadlib sockets
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Socket connection type (TCP/UDP)
|
|
26
|
+
*/
|
|
27
|
+
#define SOCKET_TCP 1
|
|
28
|
+
#define SOCKET_UDP 2
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Socket flags
|
|
32
|
+
*/
|
|
33
|
+
#define SOCK_NON_BLOCKING (1 << 0) /* Set the socket a nonblocking */
|
|
34
|
+
#define SOCK_LIBC_ERRORS (1 << 1) /* Enable libc error reporting */
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Error reporting
|
|
38
|
+
*/
|
|
39
|
+
#define SOCK_ERROR_OK 0 /* No error */
|
|
40
|
+
#define SOCK_ERROR_CREATE_SOCKET 1 /* Couldn't create a socket */
|
|
41
|
+
#define SOCK_ERROR_SERVER_UNKNOWN 2 /* Server unknown */
|
|
42
|
+
#define SOCK_ERROR_WHILE_CONNECTING 3 /* Error while connecting */
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Connects to the given node and service via TCP/UDP.
|
|
46
|
+
*
|
|
47
|
+
* @note There's 2 types of error reporting on this function that you can use.
|
|
48
|
+
* @note Default error codes:
|
|
49
|
+
* 0 - No error
|
|
50
|
+
* 1 - Error while creating socket
|
|
51
|
+
* 2 - Couldn't resolve hostname
|
|
52
|
+
* 3 - Couldn't connect
|
|
53
|
+
* @note New, more expressive libc error codes:
|
|
54
|
+
* https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
|
|
55
|
+
* https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/errno.h
|
|
56
|
+
* https://msdn.microsoft.com/en-us/library/ms740668.aspx
|
|
57
|
+
*
|
|
58
|
+
* @note The currently available bit flags are:
|
|
59
|
+
* - SOCK_NON_BLOCKING : if set, the socket will be on nonblocking mode
|
|
60
|
+
* - SOCK_LIBC_ERRORS : if set, the new libc errors will be seen on _error
|
|
61
|
+
*
|
|
62
|
+
* @note If no flags are set, the behaviour of the function will not be modified.
|
|
63
|
+
*
|
|
64
|
+
* @note Multiple flags may be set at the same time using the | operator.
|
|
65
|
+
* For example, SOCK_NON_BLOCKING|SOCK_LIBC_ERRORS will create a nonblocking socket with libc error codes.
|
|
66
|
+
*
|
|
67
|
+
* @note If you're creating a new nonblocking socket, _hostname should be numeric to avoid calling the
|
|
68
|
+
* name resolution server and potentially blocking the call.
|
|
69
|
+
*
|
|
70
|
+
* @note If the socket is a nonblocking one, the returned socket descriptor may be still connecting and
|
|
71
|
+
* further checks should be done with socket_is_writable() before trying to send data.
|
|
72
|
+
*
|
|
73
|
+
* @param _hostname Node to connect to
|
|
74
|
+
* @param _port Service to connect to
|
|
75
|
+
* @param _protocol Connect via SOCKET_TCP or SOCKET_UDP
|
|
76
|
+
* @param _error Set an error code here if anything goes wrong
|
|
77
|
+
* @param _flags Optional bit flags that change the behaviour of the function
|
|
78
|
+
*
|
|
79
|
+
* @return A socket descriptor (a positive integer) on success
|
|
80
|
+
* -1 on failure
|
|
81
|
+
*/
|
|
82
|
+
native socket_open(const _hostname[], _port, _protocol = SOCKET_TCP, &_error, _flags = 0);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Closes a socket.
|
|
86
|
+
*
|
|
87
|
+
* @param _socket Socket descriptor
|
|
88
|
+
*
|
|
89
|
+
* @return 1 on success
|
|
90
|
+
* 0 on failure
|
|
91
|
+
*/
|
|
92
|
+
native socket_close(_socket);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Receives data.
|
|
96
|
+
*
|
|
97
|
+
* @note The amount of bytes than you end up receiving can be less than the one you expected.
|
|
98
|
+
*
|
|
99
|
+
* @note This function will completely block the server until some data arrives
|
|
100
|
+
* to the given socket. Use this only if you are sure there is some data
|
|
101
|
+
* to be retrieved. You can do that by polling with socket_is_readable().
|
|
102
|
+
*
|
|
103
|
+
* @param _socket Socket descriptor
|
|
104
|
+
* @param _data Array to save the data
|
|
105
|
+
* @param _length Length of the array
|
|
106
|
+
*
|
|
107
|
+
* @return Amount of bytes received
|
|
108
|
+
* 0 if the peer closed the connection
|
|
109
|
+
* -1 on failure
|
|
110
|
+
*/
|
|
111
|
+
native socket_recv(_socket, _data[], _length);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Sends data.
|
|
115
|
+
*
|
|
116
|
+
* @note The amount of bytes that end up being sent may be lower than the total length of the array,
|
|
117
|
+
* check the return value and send the rest if needed.
|
|
118
|
+
*
|
|
119
|
+
* @param _socket Socket descriptor
|
|
120
|
+
* @param _data Array with the data to send
|
|
121
|
+
* @param _length Length of the array
|
|
122
|
+
*
|
|
123
|
+
* @return Amount of bytes sent
|
|
124
|
+
* -1 on failure
|
|
125
|
+
*/
|
|
126
|
+
native socket_send(_socket, const _data[], _length);
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Sends data that can contain null bytes.
|
|
130
|
+
*
|
|
131
|
+
* @note The amount of bytes that end up being sent may be lower than the total length of the array,
|
|
132
|
+
* check the return value and send the rest if needed.
|
|
133
|
+
*
|
|
134
|
+
* @note strlen(_data) will return the wrong length if the array contains null bytes.
|
|
135
|
+
*
|
|
136
|
+
* @param _socket Socket descriptor
|
|
137
|
+
* @param _data Array with the data to send
|
|
138
|
+
* @param _length Length of the array
|
|
139
|
+
*
|
|
140
|
+
* @return Amount of bytes sent
|
|
141
|
+
* -1 on failure
|
|
142
|
+
*/
|
|
143
|
+
native socket_send2(_socket, const _data[], _length);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Backwards compatible function.
|
|
147
|
+
*
|
|
148
|
+
* @deprecated Renamed to socket_is_readable()
|
|
149
|
+
*/
|
|
150
|
+
#pragma deprecated Use socket_is_readable() instead
|
|
151
|
+
native socket_change(_socket, _timeout = 100000);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Checks if a socket is marked as readable.
|
|
155
|
+
*
|
|
156
|
+
* @note You can use this function to make sure there's something on the socket and avoid a blocking call.
|
|
157
|
+
* @note Set _timeout to 0 avoid blocking the call.
|
|
158
|
+
* @note A socket will become readable if there's any data or an EOF.
|
|
159
|
+
*
|
|
160
|
+
* @param _socket Socket descriptor
|
|
161
|
+
* @param _timeout Amount of time to block the call waiting for the socket to be marked as readable or
|
|
162
|
+
* for the timeout to expire, in µSeconds (1 sec = 1000000 µsec)
|
|
163
|
+
*
|
|
164
|
+
* @return 1 if the socket is marked as readable
|
|
165
|
+
* 0 otherwise
|
|
166
|
+
*/
|
|
167
|
+
native socket_is_readable(_socket, _timeout = 100000);
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Checks if a socket is marked as writable.
|
|
171
|
+
*
|
|
172
|
+
* @note Use this function to check if a nonblocking socket is ready to be used.
|
|
173
|
+
* @note Set _timeout to 0 avoid blocking the call.
|
|
174
|
+
* @note An UDP socket is always writable.
|
|
175
|
+
*
|
|
176
|
+
* @param _socket Socket descriptor
|
|
177
|
+
* @param _timeout Amount of time to block the call waiting for the socket to be marked as writable or
|
|
178
|
+
* for the timeout to expire, in µSeconds (1 sec = 1000000 µsec)
|
|
179
|
+
*
|
|
180
|
+
* @return 1 if the socket is marked as writable
|
|
181
|
+
* 0 otherwise
|
|
182
|
+
*/
|
|
183
|
+
native socket_is_writable(_socket, _timeout = 100000);
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
//
|
|
11
|
+
// Sorting Functions
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
//
|
|
15
|
+
// All sort functions are based off the qsort() function from the
|
|
16
|
+
// C standard library, which uses the Quick Sort algorithm.
|
|
17
|
+
// For more info, see: http://linux.wku.edu/~lamonml/algor/sort/sort.html
|
|
18
|
+
//
|
|
19
|
+
|
|
20
|
+
#if defined _sorting_included
|
|
21
|
+
#endinput
|
|
22
|
+
#endif
|
|
23
|
+
#define _sorting_included
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Contains sorting orders.
|
|
27
|
+
*/
|
|
28
|
+
enum SortMethod
|
|
29
|
+
{
|
|
30
|
+
Sort_Ascending = 0,
|
|
31
|
+
Sort_Descending,
|
|
32
|
+
Sort_Random,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Data types for ADT Array Sorts
|
|
37
|
+
*/
|
|
38
|
+
enum SortType
|
|
39
|
+
{
|
|
40
|
+
Sort_Integer = 0,
|
|
41
|
+
Sort_Float,
|
|
42
|
+
Sort_String,
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Basic sorting functions below.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
native SortIntegers(array[], array_size, SortMethod:order = Sort_Ascending);
|
|
49
|
+
|
|
50
|
+
native SortFloats(Float:array[], array_size, SortMethod:order = Sort_Ascending);
|
|
51
|
+
|
|
52
|
+
native SortStrings(array[][], num_strings, SortMethod:order = Sort_Ascending);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Custom sorting functions below.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Sorts a custom 1D array. You must pass in a comparison function.
|
|
60
|
+
* The sorting algorithm then uses your comparison function to sort the data.
|
|
61
|
+
* The function is called in the following manner:
|
|
62
|
+
*
|
|
63
|
+
* public MySortFunc(elem1, elem2, const array[], const data[], data_size)
|
|
64
|
+
*
|
|
65
|
+
* elem1, elem2 - Current element pair being compared
|
|
66
|
+
* array[] - Array in its current mid-sorted state.
|
|
67
|
+
* data[] - Extra data array you passed to the sort func.
|
|
68
|
+
* data_size - Size of extra data you passed to the sort func.
|
|
69
|
+
*
|
|
70
|
+
* Your function should return:
|
|
71
|
+
* -1 if elem1 should go before elem2
|
|
72
|
+
* 0 if elem1 and elem2 are equal
|
|
73
|
+
* 1 if elem1 should go after elem2
|
|
74
|
+
* Note that the parameters after elem2 are all optional and you do not need to specify them.
|
|
75
|
+
*/
|
|
76
|
+
native SortCustom1D(array[], array_size, const comparefunc[], data[]="", data_size=0);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Sorts a custom 2D array.
|
|
81
|
+
* The sorting algorithm then uses your comparison function to sort the data.
|
|
82
|
+
* The function is called in the following manner:
|
|
83
|
+
*
|
|
84
|
+
* public MySortFunc(const elem1[], const elem2[], const array[], data[], data_size)
|
|
85
|
+
*
|
|
86
|
+
* elem1[], elem2[] - Current element array pairs being compared
|
|
87
|
+
* array[][] - Array in its currently being sorted state.
|
|
88
|
+
* data[] - Extra data array you passed to the sort func.
|
|
89
|
+
* data_size - Size of extra data you passed to the sort func.
|
|
90
|
+
*
|
|
91
|
+
* Your function should return:
|
|
92
|
+
* -1 if elem1[] should go before elem2[]
|
|
93
|
+
* 0 if elem1[] and elem2 are equal[]
|
|
94
|
+
* 1 if elem1[] should go after elem2[]
|
|
95
|
+
* Note that the parameters after elem2[] are all optional and you do not need to specify them.
|
|
96
|
+
*/
|
|
97
|
+
native SortCustom2D(array[][], array_size, const comparefunc[], data[]="", data_size=0);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Sort an ADT Array. Specify the type as Integer, Float, or String.
|
|
101
|
+
*
|
|
102
|
+
* @param array Array Handle to sort
|
|
103
|
+
* @param order Sort order to use, same as other sorts.
|
|
104
|
+
* @param type Data type stored in the ADT Array
|
|
105
|
+
* @noreturn
|
|
106
|
+
*/
|
|
107
|
+
native SortADTArray(Array:array, SortMethod:order, SortType:type);
|