mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-17 17:11:32 +00:00
qc_vlen, and adding numbers to all builtins for clarity
This commit is contained in:
parent
ce956fa0fb
commit
0b01944d54
1 changed files with 21 additions and 6 deletions
27
exec.c
27
exec.c
|
@ -610,6 +610,8 @@ cleanup:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(QCVM_EXECUTOR)
|
#if defined(QCVM_EXECUTOR)
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
const char *type_name[TYPE_COUNT] = {
|
const char *type_name[TYPE_COUNT] = {
|
||||||
"void",
|
"void",
|
||||||
"string",
|
"string",
|
||||||
|
@ -703,14 +705,27 @@ static int qc_kill(qc_program *prog)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int qc_vlen(qc_program *prog)
|
||||||
|
{
|
||||||
|
qcany *vec, len;
|
||||||
|
CheckArgs(1);
|
||||||
|
vec = GetArg(0);
|
||||||
|
len._float = sqrt(vec->vector[0] * vec->vector[0] +
|
||||||
|
vec->vector[1] * vec->vector[1] +
|
||||||
|
vec->vector[2] * vec->vector[2]);
|
||||||
|
Return(len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static prog_builtin qc_builtins[] = {
|
static prog_builtin qc_builtins[] = {
|
||||||
NULL,
|
NULL,
|
||||||
&qc_print,
|
&qc_print, /* 1 */
|
||||||
&qc_ftos,
|
&qc_ftos, /* 2 */
|
||||||
&qc_spawn,
|
&qc_spawn, /* 3 */
|
||||||
&qc_kill,
|
&qc_kill, /* 4 */
|
||||||
&qc_vtos,
|
&qc_vtos, /* 5 */
|
||||||
&qc_error
|
&qc_error, /* 6 */
|
||||||
|
&qc_vlen /* 7 */
|
||||||
};
|
};
|
||||||
static size_t qc_builtins_count = sizeof(qc_builtins) / sizeof(qc_builtins[0]);
|
static size_t qc_builtins_count = sizeof(qc_builtins) / sizeof(qc_builtins[0]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue