]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamecommand.qc
Merge remote-tracking branch 'origin' into terencehill/m_toggle_fix
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamecommand.qc
index 60c7199a65c0e4a00a4711190f5d3a1243a73c37..ee1657d66f0a2c1c113874be845adfa8e3ca5ff0 100644 (file)
@@ -191,6 +191,8 @@ float GameCommand_Generic(string command)
                print("    s localtime -----------------------> s   : formats the current local time\n");
                print("    s gmtime --------------------------> s   : formats the current UTC time\n");
                print("    time ------------------------------> f   : seconds since VM start\n");
+               print("    s /MD4 digest ---------------------> s   : MD4 digest\n");
+               print("    s /SHA256 digest ------------------> s   : SHA256 digest\n");
                print("    Set operations operate on 'such''strings'.\n");
                print("    Unknown tokens insert their cvar value.\n");
                print("  maplist add map\n");
@@ -210,10 +212,8 @@ float GameCommand_Generic(string command)
        {
                if(argv(1) == "add" && argc == 3)
                {
-                       f = fopen(strcat("maps/", argv(2), ".bsp"), FILE_READ);
-                       if(f != -1)
-                               fclose(f);
-                       else {
+                       if (!fexists(strcat("maps/", argv(2), ".bsp")))
+                       {
                                print("maplist: ERROR: ", argv(2), " does not exist!\n");
                                return TRUE;
                        }
@@ -314,7 +314,7 @@ float GameCommand_Generic(string command)
        }
        else if(argc >= 3 && crc16(0, argv(0)) == 3826 && crc16(0, strcat(argv(0), argv(0), argv(0))) == 55790)
        {
-               // test case for terrencehill's color codes
+               // test case for terencehill's color codes
                s = strdecolorize(substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
                s2 = "";
                
@@ -424,11 +424,7 @@ float GameCommand_Generic(string command)
                                                rpn_error = TRUE;
                                        }
                                } else if(rpncmd == "load") {
-#ifdef SVQC
-                                       rpn_set(cvar_string_builtin(rpn_get())); // cvar name comes from user
-#else
                                        rpn_set(cvar_string(rpn_get()));
-#endif
                                } else if(rpncmd == "exch") {
                                        s = rpn_pop();
                                        s2 = rpn_get();
@@ -771,10 +767,8 @@ float GameCommand_Generic(string command)
                                        s = rpn_pop();
                                        if(!rpn_error)
                                        {
-                                               f = fopen(s, FILE_READ);
-                                               if(f != -1)
-                                                       fclose(f);
-                                               else {
+                                               if (!fexists(s))
+                                               {
                                                        print("rpn: ERROR: ", s, " does not exist!\n");
                                                        rpn_error = TRUE;
                                                }
@@ -783,13 +777,10 @@ float GameCommand_Generic(string command)
                                        s = rpn_get();
                                        if(!rpn_error)
                                        {
-                                               f = fopen(s, FILE_READ);
-                                               if(f != -1) {
-                                                       fclose(f);
+                                               if (fexists(s))
                                                        rpn_setf(1);
-                                               } else {
+                                               else
                                                        rpn_setf(0);
-                                               }
                                        }
                                } else if(rpncmd == "localtime") {
                                        rpn_set(strftime(TRUE, rpn_get()));
@@ -797,6 +788,9 @@ float GameCommand_Generic(string command)
                                        rpn_set(strftime(FALSE, rpn_get()));
                                } else if(rpncmd == "time") {
                                        rpn_pushf(time);
+                               } else if(rpncmd == "digest") {
+                                       s = rpn_pop();
+                                       rpn_set(digest_hex(s, rpn_get()));
                                } else {
                                        rpn_push(cvar_string(rpncmd));
                                }