Navigation Menu

Skip to content

Commit

Permalink
Fix wrong path waypoint event
Browse files Browse the repository at this point in the history
When a frame hit the target time of a path waypoint exactly we
incorrectly reported the next waypoint index as reached.

Additonally, when loading old saves this could mean that we
send the 'on pathend' script event again for paths that were already
completed: Even though the path time was past the end before saving,
the millisecond resolution in the save file could result in it
being rounded down to match the end exactly after loading.

Fixes: bug #1293
  • Loading branch information
dscharrer committed Apr 10, 2020
1 parent 9e46a68 commit fb564d6
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/ai/Paths.cpp
Expand Up @@ -399,14 +399,7 @@ long ARX_PATHS_Interpolate(ARX_USE_PATH * aup, Vec3f * pos) {
}

// While we have time left, iterate
while(tim > 0) {

// Path Ended
if(targetwaypoint >= ap->pathways.size()) {
*pos = ap->pos + ap->pathways[ap->pathways.size() - 1].rpos;
aup->aupflags |= ARX_USEPATH_FLAG_FINISHED;
return -2;
}
while(targetwaypoint < ap->pathways.size()) {

bool bezier = (ap->pathways[targetwaypoint - 1].flag == PATHWAY_BEZIER
&& targetwaypoint + 1 < ap->pathways.size());
Expand All @@ -417,7 +410,6 @@ long ARX_PATHS_Interpolate(ARX_USE_PATH * aup, Vec3f * pos) {
GameDuration delta = tim - ap->pathways[targetwaypoint]._time;
if(delta >= 0) {
tim = delta;
*pos = ap->pathways[targetwaypoint].rpos;
targetwaypoint++;
continue;
}
Expand All @@ -433,7 +425,7 @@ long ARX_PATHS_Interpolate(ARX_USE_PATH * aup, Vec3f * pos) {
return targetwaypoint - 1;
}

*pos += ap->pos;

return targetwaypoint;
*pos = ap->pos + ap->pathways[ap->pathways.size() - 1].rpos;
aup->aupflags |= ARX_USEPATH_FLAG_FINISHED;
return -2;
}

0 comments on commit fb564d6

Please sign in to comment.