fix eval and when commands. Now this works:
authorRudolf Polzer <divverent@xonotic.org>
Thu, 3 Oct 2013 15:09:00 +0000 (17:09 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Thu, 3 Oct 2013 15:09:00 +0000 (17:09 +0200)
rpn /i 91 def /k 2 def "/\"/pop 1\" \"/\\\"//k k 1 add def dup eval\\\" \\\"/pop 0\\\" i k mod 0 > when eval\" k k mul i > when eval" dup eval

qcsrc/common/command/rpn.qc

index 4fc918c..374d07d 100644 (file)
@@ -222,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);
@@ -537,7 +537,8 @@ void GenericCommand_rpn(float request, float argc, string command)
                                                rpn_set(sprintf(s, rpn_get()));
                                        } else if(rpncmd == "eval") {
                                                s = rpn_pop();
-                                               tokenize_console(strcat(s, substring(command, argv_end_index(rpnpos), -1)));
+                                               command = strcat(s, substring(command, argv_end_index(rpnpos), -1));
+                                               argc = tokenize_console(command);
                                                rpnpos = -1;
                                        } else {
                                                rpn_push(cvar_string(rpncmd));