]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Return early if waypoint_loadall can't find any waypoint file
authorterencehill <piuntn@gmail.com>
Fri, 18 Aug 2017 13:20:22 +0000 (15:20 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 18 Aug 2017 13:20:22 +0000 (15:20 +0200)
qcsrc/server/bot/default/waypoints.qc

index 50af1d5198c6d38e0d0f5e78d314bdec9ad39476..6e872d2bec418439f7b80bc9ba880eb4a7d78a16 100644 (file)
@@ -994,32 +994,33 @@ float waypoint_loadall()
        filename = strcat("maps/", mapname);
        filename = strcat(filename, ".waypoints");
        file = fopen(filename, FILE_READ);
-       if (file >= 0)
+
+       if (file < 0)
        {
-               while ((s = fgets(file)))
-               {
-                       m1 = stov(s);
-                       s = fgets(file);
-                       if (!s)
-                               break;
-                       m2 = stov(s);
-                       s = fgets(file);
-                       if (!s)
-                               break;
-                       fl = stof(s);
-                       waypoint_spawn(m1, m2, fl);
-                       if (m1 == m2)
-                               cwp = cwp + 1;
-                       else
-                               cwb = cwb + 1;
-               }
-               fclose(file);
-               LOG_TRACE("loaded ", ftos(cwp), " waypoints and ", ftos(cwb), " wayboxes from maps/", mapname, ".waypoints");
+               LOG_TRACE("waypoint load from ", filename, " failed");
+               return 0;
        }
-       else
+
+       while ((s = fgets(file)))
        {
-               LOG_TRACE("waypoint load from ", filename, " failed");
+               m1 = stov(s);
+               s = fgets(file);
+               if (!s)
+                       break;
+               m2 = stov(s);
+               s = fgets(file);
+               if (!s)
+                       break;
+               fl = stof(s);
+               waypoint_spawn(m1, m2, fl);
+               if (m1 == m2)
+                       cwp = cwp + 1;
+               else
+                       cwb = cwb + 1;
        }
+       fclose(file);
+       LOG_TRACE("loaded ", ftos(cwp), " waypoints and ", ftos(cwb), " wayboxes from maps/", mapname, ".waypoints");
+
        return cwp + cwb;
 }