]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
qcvm: add stov builtin #16
authorWolfgang Bumiller <wry.git@bumiller.com>
Thu, 22 Jun 2017 06:45:18 +0000 (08:45 +0200)
committerWolfgang Bumiller <wry.git@bumiller.com>
Thu, 22 Jun 2017 06:45:18 +0000 (08:45 +0200)
exec.cpp
tests/defs.qh

index 17f52f62e5efcb35c673233e93aff702974ff0ff..9e49ed8e9367df2537c8af5493c1d8decd89f342 100644 (file)
--- 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;
index f6ea408ad9ed7f26ff6b812f07a7de719dd82095..cbe8c98300ec04f2d0cb5a9df039e01c0f507a43 100644 (file)
@@ -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;