]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/command/rpn.qc
Remove monster config system to fix compile
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / command / rpn.qc
index ef330b9a642023be619529237a06498c3129fe85..374d07df17ac8e3ec0b28e5177332ccb3763ef66 100644 (file)
@@ -46,8 +46,8 @@ void rpn_set(string s)
 
 float rpn_getf() { return stof(rpn_get()); }
 float rpn_popf() { return stof(rpn_pop()); }
-void rpn_pushf(float f) { return rpn_push(ftos(f)); }
-void rpn_setf(float f) { return rpn_set(ftos(f)); }
+void rpn_pushf(float f) { return rpn_push(sprintf("%.9g", f)); }
+void rpn_setf(float f) { return rpn_set(sprintf("%.9g", f)); }
 
 void GenericCommand_rpn(float request, float argc, string command)
 {
@@ -203,6 +203,10 @@ void GenericCommand_rpn(float request, float argc, string command)
                                                rpn_setf(exp(rpn_getf()));
                                        } else if(rpncmd == "log") {
                                                rpn_setf(exp(rpn_getf()));
+                                       } else if(rpncmd == "sin") {
+                                               rpn_setf(sin(rpn_getf()));
+                                       } else if(rpncmd == "cos") {
+                                               rpn_setf(cos(rpn_getf()));
                                        } else if(rpncmd == "max") {
                                                f = rpn_popf();
                                                f2 = rpn_getf();
@@ -218,12 +222,12 @@ void GenericCommand_rpn(float request, float argc, string command)
                                                rpn_setf(bound(f3, f2, f));
                                        } else if(rpncmd == "when") {
                                                f = rpn_popf();
-                                               f2 = rpn_popf();
-                                               f3 = rpn_getf();
+                                               s = rpn_pop();
+                                               s2 = rpn_get();
                                                if(f)
-                                                       rpn_setf(f3);
+                                                       rpn_set(s2);
                                                else
-                                                       rpn_setf(f2);
+                                                       rpn_set(s);
                                        } else if(rpncmd == ">" || rpncmd == "gt") {
                                                f = rpn_popf();
                                                rpn_setf(rpn_getf() > f);
@@ -531,6 +535,11 @@ void GenericCommand_rpn(float request, float argc, string command)
                                        } else if(rpncmd == "sprintf1s") {
                                                s = rpn_pop();
                                                rpn_set(sprintf(s, rpn_get()));
+                                       } else if(rpncmd == "eval") {
+                                               s = rpn_pop();
+                                               command = strcat(s, substring(command, argv_end_index(rpnpos), -1));
+                                               argc = tokenize_console(command);
+                                               rpnpos = -1;
                                        } else {
                                                rpn_push(cvar_string(rpncmd));
                                        }
@@ -562,7 +571,7 @@ void GenericCommand_rpn(float request, float argc, string command)
                        print("    f f eq|ne|gt|ge|lt|le|max|min -----> f   : compares two numbers\n");
                        print("    f neg|abs|sgn|rand|floor|ceil------> f   : negates/... a number\n");
                        print("    f not|bitnot ----------------------> f   : logical and bitwise negation\n");
-                       print("    f exp|log -------------------------> f   : exponential function & Co.\n");
+                       print("    f exp|log|sin|cos -----------------> f   : exponential function & Co.\n");
                        print("    f f f bound -----------------------> f   : bounds the middle number\n");
                        print("    f1 f2 b when ----------------------> f   : f1 if b, f2 otherwise\n");
                        print("    s s union|intersection|difference -> s   : set operations\n");
@@ -583,6 +592,7 @@ void GenericCommand_rpn(float request, float argc, string command)
                        print("    s /MD4 digest ---------------------> s   : MD4 digest\n");
                        print("    s /SHA256 digest ------------------> s   : SHA256 digest\n");
                        print("    s /formatstring sprintf1s ---------> s   : sprintf with 1 string (pad, cut)\n");
+                       print("    s eval ---------------------------->     : does something eval\n");
                        print("    Set operations operate on 'such''strings'.\n");
                        print("    Unknown tokens insert their cvar value.\n");
                        return;