From 600af765de0bcff081c605965686578eb068f1aa Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 18 Aug 2017 15:20:22 +0200 Subject: [PATCH] Return early if waypoint_loadall can't find any waypoint file --- qcsrc/server/bot/default/waypoints.qc | 45 ++++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-) 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; } -- 2.39.2