From e38fb0c4402ef35f8ff59274ca64a3afa1e2d3d1 Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Sun, 26 Dec 2021 20:16:41 -0600 Subject: [PATCH] GroundController: remove always false condition --- src/ATC/GroundController.cxx | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/ATC/GroundController.cxx b/src/ATC/GroundController.cxx index 6b1507cb7..9c2a1f516 100644 --- a/src/ATC/GroundController.cxx +++ b/src/ATC/GroundController.cxx @@ -608,7 +608,8 @@ bool FGGroundController::checkForCircularWaits(int id) } else { return false; } - if (i == activeTraffic.end() || (trafficSize == 0)) { + + if (i == activeTraffic.end()) { SG_LOG(SG_GENERAL, SG_ALERT, "AI error: Trying to access non-existing aircraft in FGGroundNetwork::checkForCircularWaits at " << SG_ORIGIN); } @@ -623,12 +624,10 @@ bool FGGroundController::checkForCircularWaits(int id) return false; } - while ((target > 0) && (target != id) && counter++ < trafficSize) { //printed = true; TrafficVectorIterator i = activeTraffic.begin(); if (trafficSize) { - //while ((i->getId() != id) && i != activeTraffic.end()) while (i != activeTraffic.end()) { if (i->getId() == target) { break; @@ -638,41 +637,24 @@ bool FGGroundController::checkForCircularWaits(int id) } else { return false; } - if (i == activeTraffic.end() || (trafficSize == 0)) { + + if (i == activeTraffic.end()) { SG_LOG(SG_ATC, SG_DEBUG, "[Waiting for traffic at Runway: DONE] "); // The target id is not found on the current network, which means it's at the tower SG_LOG(SG_ATC, SG_ALERT, "AI error: Trying to access non-existing aircraft in FGGroundNetwork::checkForCircularWaits"); return false; } + other = i; target = other->getWaitsForId(); // actually this trap isn't as impossible as it first seemed: // the setWaitsForID(id) is set to current when the aircraft // is waiting for the user controlled aircraft. - //if (current->getId() == other->getId()) { - // SG_LOG(SG_ATC, SG_DEBUG, "Caught the impossible trap"); - // SG_LOG(SG_ATC, SG_DEBUG, "Current = " << current->getId()); - // SG_LOG(SG_ATC, SG_DEBUG, "Other = " << other ->getId()); - // for (TrafficVectorIterator at = activeTraffic.begin(); - // at != activeTraffic.end(); - // at++) { - // SG_LOG(SG_ATC, SG_BULK, "currently active aircraft : " << at->getCallSign() << " with Id " << at->getId() << " waits for " << at->getWaitsForId()); - // } - // exit(1); if (current->getId() == other->getId()) return false; - //} - //SG_LOG(SG_ATC, SG_DEBUG, current->getCallSign() << " (" << current->getId() << ") " << " -> " << other->getCallSign() - // << " (" << other->getId() << "); "); - //current = other; } - - - - - //if (printed) SG_LOG(SG_ATC, SG_DEBUG, "[done] "); if (id == target) {