From c0c9d51c09ce0dc22524b6795e0fcdfa59d1af2b Mon Sep 17 00:00:00 2001 From: mfranz Date: Sat, 15 Apr 2006 18:48:59 +0000 Subject: [PATCH] aircraft are often in several state lists at the same time, and they can even be more than once in the same list. We need to remove all such instances, or the a pointer to TowerPlaneRec may become invalid and cause crashes. The proper fix would, of course, be to be careful with state changes and to prevent *any* duplication of entries. [OK'ed by David] --- src/ATC/tower.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ATC/tower.cxx b/src/ATC/tower.cxx index adb8aee50..c224c3d19 100644 --- a/src/ATC/tower.cxx +++ b/src/ATC/tower.cxx @@ -204,13 +204,11 @@ FGTower::FGTower() { update_count_max = 15; holdListItr = holdList.begin(); - appList.clear(); appListItr = appList.begin(); depListItr = depList.begin(); rwyListItr = rwyList.begin(); circuitListItr = circuitList.begin(); trafficListItr = trafficList.begin(); - vacatedList.clear(); vacatedListItr = vacatedList.begin(); freqClear = true; @@ -2173,7 +2171,9 @@ void FGTower::RemovePlane(const string& ID) { t = *twrItr; twrItr = appList.erase(twrItr); appListItr = appList.begin(); - break; + // HACK: aircraft are sometimes more than once in a list, so we need to + // remove them all before we can delete the TowerPlaneRec class + //break; } } for(twrItr = depList.begin(); twrItr != depList.end(); twrItr++) { @@ -2181,7 +2181,7 @@ void FGTower::RemovePlane(const string& ID) { t = *twrItr; twrItr = depList.erase(twrItr); depListItr = depList.begin(); - break; + //break; } } for(twrItr = circuitList.begin(); twrItr != circuitList.end(); twrItr++) { @@ -2189,7 +2189,7 @@ void FGTower::RemovePlane(const string& ID) { t = *twrItr; twrItr = circuitList.erase(twrItr); circuitListItr = circuitList.begin(); - break; + //break; } } for(twrItr = holdList.begin(); twrItr != holdList.end(); twrItr++) { @@ -2197,7 +2197,7 @@ void FGTower::RemovePlane(const string& ID) { t = *twrItr; twrItr = holdList.erase(twrItr); holdListItr = holdList.begin(); - break; + //break; } } for(twrItr = rwyList.begin(); twrItr != rwyList.end(); twrItr++) { @@ -2205,7 +2205,7 @@ void FGTower::RemovePlane(const string& ID) { t = *twrItr; twrItr = rwyList.erase(twrItr); rwyListItr = rwyList.begin(); - break; + //break; } } for(twrItr = vacatedList.begin(); twrItr != vacatedList.end(); twrItr++) { @@ -2213,7 +2213,7 @@ void FGTower::RemovePlane(const string& ID) { t = *twrItr; twrItr = vacatedList.erase(twrItr); vacatedListItr = vacatedList.begin(); - break; + //break; } } for(twrItr = trafficList.begin(); twrItr != trafficList.end(); twrItr++) { @@ -2221,7 +2221,7 @@ void FGTower::RemovePlane(const string& ID) { t = *twrItr; twrItr = trafficList.erase(twrItr); trafficListItr = trafficList.begin(); - break; + //break; } } // And finally, delete the record. -- 2.39.5