Fix FGAIFlightPlan waypoint issues
Iterator must be reset after clearing waypoint list. Deleting "*waypoint.end()" doesn't delete the last waypoint (end()-1 does - it is never actually used though).
This commit is contained in:
parent
4b8e0740c4
commit
a28fe51ccf
1 changed files with 17 additions and 15 deletions
|
@ -286,21 +286,21 @@ FGAIWaypoint* const FGAIFlightPlan::getNextWaypoint( void ) const
|
||||||
|
|
||||||
void FGAIFlightPlan::IncrementWaypoint(bool eraseWaypoints )
|
void FGAIFlightPlan::IncrementWaypoint(bool eraseWaypoints )
|
||||||
{
|
{
|
||||||
if (eraseWaypoints)
|
if (eraseWaypoints)
|
||||||
{
|
{
|
||||||
if (wpt_iterator == waypoints.begin())
|
if (wpt_iterator == waypoints.begin())
|
||||||
wpt_iterator++;
|
wpt_iterator++;
|
||||||
else
|
else
|
||||||
{
|
if (!waypoints.empty())
|
||||||
delete *(waypoints.begin());
|
{
|
||||||
waypoints.erase(waypoints.begin());
|
delete *(waypoints.begin());
|
||||||
wpt_iterator = waypoints.begin();
|
waypoints.erase(waypoints.begin());
|
||||||
wpt_iterator++;
|
wpt_iterator = waypoints.begin();
|
||||||
}
|
wpt_iterator++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wpt_iterator++;
|
wpt_iterator++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAIFlightPlan::DecrementWaypoint(bool eraseWaypoints )
|
void FGAIFlightPlan::DecrementWaypoint(bool eraseWaypoints )
|
||||||
|
@ -310,9 +310,10 @@ void FGAIFlightPlan::DecrementWaypoint(bool eraseWaypoints )
|
||||||
if (wpt_iterator == waypoints.end())
|
if (wpt_iterator == waypoints.end())
|
||||||
wpt_iterator--;
|
wpt_iterator--;
|
||||||
else
|
else
|
||||||
|
if (!waypoints.empty())
|
||||||
{
|
{
|
||||||
delete *(waypoints.end());
|
delete *(waypoints.end()-1);
|
||||||
waypoints.erase(waypoints.end());
|
waypoints.erase(waypoints.end()-1);
|
||||||
wpt_iterator = waypoints.end();
|
wpt_iterator = waypoints.end();
|
||||||
wpt_iterator--;
|
wpt_iterator--;
|
||||||
}
|
}
|
||||||
|
@ -397,6 +398,7 @@ void FGAIFlightPlan::deleteWaypoints()
|
||||||
for (wpt_vector_iterator i = waypoints.begin(); i != waypoints.end();i++)
|
for (wpt_vector_iterator i = waypoints.begin(); i != waypoints.end();i++)
|
||||||
delete (*i);
|
delete (*i);
|
||||||
waypoints.clear();
|
waypoints.clear();
|
||||||
|
wpt_iterator = waypoints.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all waypoints except the last,
|
// Delete all waypoints except the last,
|
||||||
|
|
Loading…
Add table
Reference in a new issue