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:
parent
02cfaeabba
commit
e46c6f587b
4 changed files with 8 additions and 22 deletions
src/AIModel
test_suite/unit_tests/AI
|
@ -374,23 +374,9 @@ 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--;
|
||||
wpt_iterator--;
|
||||
}
|
||||
|
||||
void FGAIFlightPlan::eraseLastWaypoint()
|
||||
|
|
|
@ -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;};
|
||||
|
|
|
@ -409,7 +409,7 @@ void FGAIGroundVehicle::AdvanceFP(){
|
|||
}
|
||||
|
||||
prev = curr;
|
||||
fp->DecrementWaypoint(false);
|
||||
fp->DecrementWaypoint();
|
||||
curr = fp->getCurrentWaypoint();
|
||||
next = fp->getNextWaypoint();
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Add table
Reference in a new issue