// (SLOW!)
void waypoint_think(entity this)
{
- vector sv, sv2, ev, ev2, dv;
- float sv2_height, ev2_height;
+ vector sv = '0 0 0', sv2 = '0 0 0', ev = '0 0 0', ev2 = '0 0 0', dv;
+ float sv2_height = 0, ev2_height = 0;
bot_calculate_stepheightvec();
return false;
}
+ bool parse_comments = true;
+ float ver = 0;
+
while ((s = fgets(file)))
{
+ if(parse_comments)
+ {
+ if(substring(s, 0, 2) == "//")
+ {
+ if(substring(s, 2, 8) == "VERSION ")
+ ver = stof(substring(s, 10, -1));
+ continue;
+ }
+ else
+ {
+ if(ver < WAYPOINT_VERSION)
+ return false;
+ parse_comments = false;
+ }
+ }
+
tokens = tokenizebyseparator(s, "*");
if (tokens!=2)
return;
}
+ fputs(file, strcat("//", "VERSION ", ftos_decimals(WAYPOINT_VERSION, 2), "\n"));
+
int c = 0;
IL_EACH(g_waypoints, true,
{
return;
}
+ // add 3 comments to not break compatibility with older Xonotic versions
+ // (they are read as a waypoint with origin '0 0 0' and flag 0 though)
+ fputs(file, strcat("//", "VERSION ", ftos_decimals(WAYPOINT_VERSION, 2), "\n"));
+ fputs(file, strcat("//", "\n"));
+ fputs(file, strcat("//", "\n"));
+
int c = 0;
IL_EACH(g_waypoints, true,
{
filename = strcat(filename, ".waypoints");
file = fopen(filename, FILE_READ);
+ bool parse_comments = true;
+ float ver = 0;
+
if (file < 0)
{
LOG_TRACE("waypoint load from ", filename, " failed");
while ((s = fgets(file)))
{
+ if(parse_comments)
+ {
+ if(substring(s, 0, 2) == "//")
+ {
+ if(substring(s, 2, 8) == "VERSION ")
+ ver = stof(substring(s, 10, -1));
+ continue;
+ }
+ else
+ {
+ if(floor(ver) < floor(WAYPOINT_VERSION))
+ LOG_TRACE("waypoints for this map are outdated");
+ parse_comments = false;
+ }
+ }
m1 = stov(s);
s = fgets(file);
if (!s)
// if wp -> porg, then OK
float maxdist;
- if(navigation_waypoint_will_link(wp.origin, porg, p, wp.origin, 0, walkfromwp, 1050))
+ if(navigation_waypoint_will_link(wp.origin, porg, p, porg, 0, wp.origin, 0, walkfromwp, 1050))
{
// we may find a better one
maxdist = vlen(wp.origin - porg);
{
float d = vlen(wp.origin - it.origin) + vlen(it.origin - porg);
if(d < bestdist)
- if(navigation_waypoint_will_link(wp.origin, it.origin, p, wp.origin, 0, walkfromwp, 1050))
- if(navigation_waypoint_will_link(it.origin, porg, p, it.origin, 0, walkfromwp, 1050))
+ if(navigation_waypoint_will_link(wp.origin, it.origin, p, it.origin, 0, wp.origin, 0, walkfromwp, 1050))
+ if(navigation_waypoint_will_link(it.origin, porg, p, porg, 0, it.origin, 0, walkfromwp, 1050))
{
bestdist = d;
p.(fld) = it;
if(wp)
{
- if(!navigation_waypoint_will_link(wp.origin, o, p, wp.origin, 0, walkfromwp, 1050))
+ if(!navigation_waypoint_will_link(wp.origin, o, p, o, 0, wp.origin, 0, walkfromwp, 1050))
{
// we cannot walk from wp.origin to o
// get closer to tmax
// if we get here, o is valid regarding waypoints
// check if o is connected right to the player
// we break if it succeeds, as that means o is a good waypoint location
- if(navigation_waypoint_will_link(o, porg, p, o, 0, walkfromwp, 1050))
+ if(navigation_waypoint_will_link(o, porg, p, porg, 0, o, 0, walkfromwp, 1050))
break;
// o is no good, we need to get closer to the player