From 73969a546640b48d95bd767b27e228de4981b409 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 28 Mar 2017 16:30:51 +0200 Subject: [PATCH] Don't save hardwired links to the .cache file among normal links, otherwise they could stay there for ever even after their removal from the .hardwired file --- qcsrc/server/bot/default/waypoints.qc | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 059a2c8f6..e4c227c8f 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -462,7 +462,7 @@ float waypoint_load_links() return true; } -void waypoint_load_links_hardwired() +void waypoint_load_or_remove_links_hardwired(bool removal_mode) { string filename, s; float file, tokens, c = 0, found; @@ -476,7 +476,8 @@ void waypoint_load_links_hardwired() if (file < 0) { - LOG_TRACE("waypoint links load from ", filename, " failed"); + if(!removal_mode) + LOG_TRACE("waypoint links load from ", filename, " failed"); return; } @@ -514,7 +515,8 @@ void waypoint_load_links_hardwired() if(!found) { - LOG_INFO(strcat("NOTICE: Can not find waypoint at ", vtos(wp_from_pos), ". Path skipped\n")); + if(!removal_mode) + LOG_INFO(strcat("NOTICE: Can not find waypoint at ", vtos(wp_from_pos), ". Path skipped\n")); continue; } } @@ -535,11 +537,18 @@ void waypoint_load_links_hardwired() if(!found) { - LOG_INFO(strcat("NOTICE: Can not find waypoint at ", vtos(wp_to_pos), ". Path skipped\n")); + if(!removal_mode) + LOG_INFO(strcat("NOTICE: Can not find waypoint at ", vtos(wp_to_pos), ". Path skipped\n")); continue; } ++c; + if(removal_mode) + { + waypoint_removelink(wp_from, wp_to); + continue; + } + waypoint_addlink(wp_from, wp_to); wp_from.wphardwired = true; wp_to.wphardwired = true; @@ -547,9 +556,13 @@ void waypoint_load_links_hardwired() fclose(file); - LOG_TRACE("loaded ", ftos(c), " waypoint links from maps/", mapname, ".waypoints.hardwired"); + if(!removal_mode) + LOG_TRACE("loaded ", ftos(c), " waypoint links from maps/", mapname, ".waypoints.hardwired"); } +void waypoint_load_links_hardwired() { waypoint_load_or_remove_links_hardwired(false); } +void waypoint_remove_links_hardwired() { waypoint_load_or_remove_links_hardwired(true); } + entity waypoint_get_link(entity w, float i) { switch(i) @@ -593,6 +606,9 @@ entity waypoint_get_link(entity w, float i) // Save all waypoint links to a file void waypoint_save_links() { + // temporarily remove hardwired links so they don't get saved among normal links + waypoint_remove_links_hardwired(); + string filename = sprintf("maps/%s.waypoints.cache", mapname); int file = fopen(filename, FILE_WRITE); if (file < 0) @@ -619,6 +635,8 @@ void waypoint_save_links() botframe_cachedwaypointlinks = true; LOG_INFOF("saved %d waypoint links to maps/%s.waypoints.cache\n", c, mapname); + + waypoint_load_links_hardwired(); } // save waypoints to gamedir/data/maps/mapname.waypoints -- 2.39.2