From: Wolfgang Bumiller Date: Thu, 22 Jun 2017 06:45:18 +0000 (+0200) Subject: qcvm: add stov builtin #16 X-Git-Tag: xonotic-v0.8.5~38 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=eb2d47877069169ff9dcfb1af35de0e4e66eb00e;p=xonotic%2Fgmqcc.git qcvm: add stov builtin #16 --- diff --git a/exec.cpp b/exec.cpp index 17f52f6..9e49ed8 100644 --- a/exec.cpp +++ b/exec.cpp @@ -668,6 +668,19 @@ static int qc_stof(qc_program_t *prog) { return 0; } +static int qc_stov(qc_program_t *prog) { + qcany_t *str; + qcany_t num; + CheckArgs(1); + str = GetArg(0); + (void)util_sscanf(prog_getstring(prog, str->string), " ' %f %f %f ' ", + &num.vector[0], + &num.vector[1], + &num.vector[2]); + Return(num); + return 0; +} + static int qc_vtos(qc_program_t *prog) { char buffer[512]; qcany_t *num; @@ -833,7 +846,8 @@ static prog_builtin_t qc_builtins[] = { &qc_normalize, /* 12 */ &qc_sqrt, /* 13 */ &qc_floor, /* 14 */ - &qc_pow /* 15 */ + &qc_pow, /* 15 */ + &qc_stov /* 16 */ }; static const char *arg0 = nullptr; diff --git a/tests/defs.qh b/tests/defs.qh index f6ea408..cbe8c98 100644 --- a/tests/defs.qh +++ b/tests/defs.qh @@ -18,3 +18,4 @@ vector (vector vec) normalize = #12; float (float val) sqrt = #13; float (float val) floor = #14; float (float val1, float val2) pow = #15; +vector (string str) stov = #16;