]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamecommand.qc
Move fexists from server/miscfunctions.qc to common/util.qc so that it's available...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamecommand.qc
index 60c7199a65c0e4a00a4711190f5d3a1243a73c37..518cf74971a645dde3c412c1a1eaabee9b5ae1b8 100644 (file)
@@ -210,10 +210,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 +312,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 = "";
                
@@ -771,10 +769,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 +779,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()));