1
0
Fork 0

AIFlightPlan: remove ‘erase’ option from Decrement

Thankfully, the erase option to DecrementWaypoint was never used, so
remove it, since it’s … mental.
This commit is contained in:
James Turner 2020-09-05 11:16:36 +01:00
parent 02cfaeabba
commit e46c6f587b
4 changed files with 8 additions and 22 deletions

View file

@ -374,22 +374,8 @@ void FGAIFlightPlan::IncrementWaypoint(bool eraseWaypoints )
wpt_iterator++;
}
void FGAIFlightPlan::DecrementWaypoint(bool eraseWaypoints )
void FGAIFlightPlan::DecrementWaypoint()
{
if (eraseWaypoints)
{
if (wpt_iterator == waypoints.end())
wpt_iterator--;
else
if (!waypoints.empty())
{
delete *(waypoints.end()-1);
waypoints.erase(waypoints.end()-1);
wpt_iterator = waypoints.end();
wpt_iterator--;
}
}
else
wpt_iterator--;
}

View file

@ -161,7 +161,7 @@ public:
FGAIWaypoint* getCurrentWaypoint( void ) const;
FGAIWaypoint* getNextWaypoint( void ) const;
void IncrementWaypoint( bool erase );
void DecrementWaypoint( bool erase );
void DecrementWaypoint();
double getDistanceToGo(double lat, double lon, FGAIWaypoint* wp) const;
int getLeg () const { return leg;};

View file

@ -409,7 +409,7 @@ void FGAIGroundVehicle::AdvanceFP(){
}
prev = curr;
fp->DecrementWaypoint(false);
fp->DecrementWaypoint();
curr = fp->getCurrentWaypoint();
next = fp->getNextWaypoint();

View file

@ -209,16 +209,16 @@ void AIManagerTests::testAIFlightPlan()
CPPUNIT_ASSERT_EQUAL(static_cast<FGAIWaypoint*>(nullptr), aiFP->getNextWaypoint());
// should put us back on the last waypoint
aiFP->DecrementWaypoint(false);
aiFP->DecrementWaypoint();
CPPUNIT_ASSERT_EQUAL(5, aiFP->getNrOfWayPoints());
CPPUNIT_ASSERT_EQUAL(wp4, aiFP->getPreviousWaypoint());
CPPUNIT_ASSERT_EQUAL(wp5, aiFP->getCurrentWaypoint());
CPPUNIT_ASSERT_EQUAL(static_cast<FGAIWaypoint*>(nullptr), aiFP->getNextWaypoint());
CPPUNIT_ASSERT_EQUAL(0, aiFP->getLeg());
aiFP->DecrementWaypoint(false); // back to wp4
aiFP->DecrementWaypoint(false); // back to wp3
aiFP->DecrementWaypoint(false); // back to wp2
aiFP->DecrementWaypoint(); // back to wp4
aiFP->DecrementWaypoint(); // back to wp3
aiFP->DecrementWaypoint(); // back to wp2
CPPUNIT_ASSERT_EQUAL(5, aiFP->getNrOfWayPoints());
CPPUNIT_ASSERT_EQUAL(wp1, aiFP->getPreviousWaypoint());