From: terencehill Date: Fri, 18 Aug 2017 13:20:22 +0000 (+0200) Subject: Return early if waypoint_loadall can't find any waypoint file X-Git-Tag: xonotic-v0.8.5~2378^2~82 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=600af765de0bcff081c605965686578eb068f1aa;p=xonotic%2Fxonotic-data.pk3dir.git Return early if waypoint_loadall can't find any waypoint file --- diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 50af1d519..6e872d2be 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -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; }