X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fdefault%2Fwaypoints.qc;h=fa82d926b63e92776cfd293dbebccf15ba20ad04;hp=fed491b682ab6ae1a0ee8209f15be825735fa0ef;hb=13e8382b4bd9c0de8bcfd2a96f56e638ba5d431d;hpb=4299b97f93fc4753665e198066970bd51bb3b06a diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index fed491b682..fa82d926b6 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -179,19 +179,12 @@ void waypoint_setupmodel(entity wp) wp.model = ""; } -// create a new spawnfunc_waypoint and automatically link it to other waypoints, and link -// them back to it as well -// (suitable for spawnfunc_waypoint editor) entity waypoint_spawn(vector m1, vector m2, float f) { - if(!(f & WAYPOINTFLAG_PERSONAL)) + if(!(f & (WAYPOINTFLAG_PERSONAL | WAYPOINTFLAG_GENERATED)) && m1 == m2) { - vector em1 = m1, em2 = m2; - if (!(f & WAYPOINTFLAG_GENERATED) && m1 == m2) - { - em1 = m1 - '8 8 8'; - em2 = m2 + '8 8 8'; - } + vector em1 = m1 - '8 8 8'; + vector em2 = m2 + '8 8 8'; IL_EACH(g_waypoints, boxesoverlap(em1, em2, it.absmin, it.absmax), { return it; @@ -686,22 +679,32 @@ void waypoint_schedulerelinkall() waypoint_load_links_hardwired(); } +#define GET_GAMETYPE_EXTENSION() ((g_race) ? ".race" : "") + // Load waypoint links from file bool waypoint_load_links() { - string filename, s; + string s; float file, tokens, c = 0, found; entity wp_from = NULL, wp_to; vector wp_to_pos, wp_from_pos; - filename = strcat("maps/", mapname); - filename = strcat(filename, ".waypoints.cache"); + + string gt_ext = GET_GAMETYPE_EXTENSION(); + + string filename = sprintf("maps/%s.waypoints.cache", strcat(mapname, gt_ext)); file = fopen(filename, FILE_READ); + if (gt_ext != "" && file < 0) + { + // if race waypoint file doesn't exist load the default one + filename = sprintf("maps/%s.waypoints.cache", mapname); + file = fopen(filename, FILE_READ); + } + if (file < 0) { - LOG_TRACE("waypoint links load from "); - LOG_TRACE(filename); - LOG_TRACE(" failed"); + LOG_TRACE("waypoint links load from ", filename, " failed"); + waypoint_schedulerelinkall(); return false; } @@ -721,7 +724,20 @@ bool waypoint_load_links() else { if(ver < WAYPOINT_VERSION) - return false; + { + LOG_TRACE("waypoint links for this map are outdated."); + if (g_assault) + { + LOG_TRACE("Assault waypoint links need to be manually updated in the editor"); + } + else + { + LOG_TRACE("automatically updating..."); + waypoint_schedulerelinkall(); + fclose(file); + return false; + } + } parse_comments = false; } } @@ -732,6 +748,7 @@ bool waypoint_load_links() { // bad file format fclose(file); + waypoint_schedulerelinkall(); // link all the autogenerated waypoints (teleporters) return false; } @@ -759,7 +776,6 @@ bool waypoint_load_links() LOG_TRACE("waypoint_load_links: couldn't find 'from' waypoint at ", vtos(wp_from_pos)); continue; } - } // Search "to" waypoint @@ -788,7 +804,19 @@ bool waypoint_load_links() fclose(file); - LOG_TRACE("loaded ", ftos(c), " waypoint links from maps/", mapname, ".waypoints.cache"); + LOG_TRACE("loaded ", ftos(c), " waypoint links from ", filename); + + bool scheduled = false; + IL_EACH(g_waypoints, it.wpflags & WAYPOINTFLAG_ITEM, + { + if (!it.wp00) + { + waypoint_schedulerelink(it); + scheduled = true; + } + }); + if (scheduled) + return false; botframe_cachedwaypointlinks = true; return true; @@ -796,14 +824,23 @@ bool waypoint_load_links() void waypoint_load_or_remove_links_hardwired(bool removal_mode) { - string filename, s; + string s; float file, tokens, c = 0, found; entity wp_from = NULL, wp_to; vector wp_to_pos, wp_from_pos; - filename = strcat("maps/", mapname); - filename = strcat(filename, ".waypoints.hardwired"); + + string gt_ext = GET_GAMETYPE_EXTENSION(); + + string filename = sprintf("maps/%s.waypoints.hardwired", strcat(mapname, gt_ext)); file = fopen(filename, FILE_READ); + if (gt_ext != "" && file < 0) + { + // if race waypoint file doesn't exist load the default one + filename = sprintf("maps/%s.waypoints.hardwired", mapname); + file = fopen(filename, FILE_READ); + } + botframe_loadedforcedlinks = true; if (file < 0) @@ -890,8 +927,8 @@ void waypoint_load_or_remove_links_hardwired(bool removal_mode) fclose(file); - if(!removal_mode) - LOG_TRACE("loaded ", ftos(c), " waypoint links from maps/", mapname, ".waypoints.hardwired"); + LOG_TRACE(((removal_mode) ? "unloaded " : "loaded "), + ftos(c), " waypoint links from maps/", mapname, ".waypoints.hardwired"); } entity waypoint_get_link(entity w, float i) @@ -940,7 +977,9 @@ 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); + string gt_ext = GET_GAMETYPE_EXTENSION(); + + string filename = sprintf("maps/%s.waypoints.cache", strcat(mapname, gt_ext)); int file = fopen(filename, FILE_WRITE); if (file < 0) { @@ -965,9 +1004,10 @@ void waypoint_save_links() } }); fclose(file); + botframe_cachedwaypointlinks = true; - LOG_INFOF("saved %d waypoint links to maps/%s.waypoints.cache", c, mapname); + LOG_INFOF("saved %d waypoint links to %s", c, filename); waypoint_load_links_hardwired(); } @@ -975,7 +1015,9 @@ void waypoint_save_links() // save waypoints to gamedir/data/maps/mapname.waypoints void waypoint_saveall() { - string filename = sprintf("maps/%s.waypoints", mapname); + string gt_ext = GET_GAMETYPE_EXTENSION(); + + string filename = sprintf("maps/%s.waypoints", strcat(mapname, gt_ext)); int file = fopen(filename, FILE_WRITE); if (file < 0) { @@ -1011,23 +1053,29 @@ void waypoint_saveall() waypoint_save_links(); botframe_loadedforcedlinks = false; - LOG_INFOF("saved %d waypoints to maps/%s.waypoints", c, mapname); + LOG_INFOF("saved %d waypoints to %s", c, filename); } // load waypoints from file float waypoint_loadall() { - string filename, s; + string s; float file, cwp, cwb, fl; vector m1, m2; cwp = 0; cwb = 0; - filename = strcat("maps/", mapname); - filename = strcat(filename, ".waypoints"); + + string gt_ext = GET_GAMETYPE_EXTENSION(); + + string filename = sprintf("maps/%s.waypoints", strcat(mapname, gt_ext)); file = fopen(filename, FILE_READ); - bool parse_comments = true; - float ver = 0; + if (gt_ext != "" && file < 0) + { + // if race waypoint file doesn't exist load the default one + filename = sprintf("maps/%s.waypoints", mapname); + file = fopen(filename, FILE_READ); + } if (file < 0) { @@ -1035,6 +1083,9 @@ float waypoint_loadall() return 0; } + bool parse_comments = true; + float ver = 0; + while ((s = fgets(file))) { if(parse_comments) @@ -1048,7 +1099,10 @@ float waypoint_loadall() else { if(floor(ver) < floor(WAYPOINT_VERSION)) + { LOG_TRACE("waypoints for this map are outdated"); + LOG_TRACE("please update them in the editor"); + } parse_comments = false; } }