11 more rpn functions. Enjoy!
authorRudolf Polzer <divverent@xonotic.org>
Tue, 24 Sep 2013 07:50:13 +0000 (09:50 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 24 Sep 2013 07:50:13 +0000 (09:50 +0200)
qcsrc/common/command/rpn.qc

index 5cca2db..ef330b9 100644 (file)
@@ -158,6 +158,31 @@ void GenericCommand_rpn(float request, float argc, string command)
                                                f = rpn_popf();
                                                f2 = rpn_getf();
                                                rpn_setf(f2 - f * floor(f2 / f));
+                                       } else if(rpncmd == "pow" || rpncmd == "**") {
+                                               f = rpn_popf();
+                                               rpn_setf(pow(rpn_getf(), f));
+                                       } else if(rpncmd == "bitand" || rpncmd == "&") {
+                                               f = rpn_popf();
+                                               rpn_setf(rpn_getf() & f);
+                                       } else if(rpncmd == "bitor" || rpncmd == "|") {
+                                               f = rpn_popf();
+                                               rpn_setf(rpn_getf() | f);
+                                       } else if(rpncmd == "bitxor" || rpncmd == "^") {
+                                               f = rpn_popf();
+                                               rpn_setf(rpn_getf() ^ f);
+                                       } else if(rpncmd == "and" || rpncmd == "&&") {
+                                               f = rpn_popf();
+                                               rpn_setf(rpn_getf() && f);
+                                       } else if(rpncmd == "or" || rpncmd == "||") {
+                                               f = rpn_popf();
+                                               rpn_setf(rpn_getf() || f);
+                                       } else if(rpncmd == "xor" || rpncmd == "^^") {
+                                               f = rpn_popf();
+                                               rpn_setf(!rpn_getf() != !f);
+                                       } else if(rpncmd == "bitnot") {
+                                               rpn_setf(~rpn_popf());
+                                       } else if(rpncmd == "not") {
+                                               rpn_setf(!rpn_popf());
                                        } else if(rpncmd == "abs") {
                                                rpn_setf(fabs(rpn_getf()));
                                        } else if(rpncmd == "sgn") {
@@ -174,6 +199,10 @@ void GenericCommand_rpn(float request, float argc, string command)
                                                rpn_setf(floor(rpn_getf()));
                                        } else if(rpncmd == "ceil" || rpncmd == "c") {
                                                rpn_setf(ceil(rpn_getf()));
+                                       } else if(rpncmd == "exp") {
+                                               rpn_setf(exp(rpn_getf()));
+                                       } else if(rpncmd == "log") {
+                                               rpn_setf(exp(rpn_getf()));
                                        } else if(rpncmd == "max") {
                                                f = rpn_popf();
                                                f2 = rpn_getf();
@@ -528,9 +557,12 @@ void GenericCommand_rpn(float request, float argc, string command)
                        print("    x x exch --------------------------> x x : swap the top two\n");
                        print("    /cvarname load --------------------> x   : loads a cvar\n");
                        print("    /cvarname x def ------------------->     : writes to a cvar\n");
-                       print("    f f add|sub|mul|div|mod|max|min ---> f   : adds/... two numbers\n");
-                       print("    f f eq|ne|gt|ge|lt|le -------------> f   : compares two numbers\n");
+                       print("    f f add|sub|mul|div|mod|pow -------> f   : adds/... two numbers\n");
+                       print("    f f and|or|xor|bitand|bitor|bitxor > f   : logical and bitwise operations\n");
+                       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 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");