From 32bb2af2af63219a0a29eefa5b6b92f81cd197dd Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 3 Jun 2003 14:34:02 +0000 Subject: [PATCH] Fix a bug where FlightGear would crach when an aiport id was geven in lower case. It turned out that MetaKit is case insensitive, so I adden an extra check to see if we got what we were asking for. --- src/Airports/runways.cxx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx index ff45f4c7e..5729451ca 100644 --- a/src/Airports/runways.cxx +++ b/src/Airports/runways.cxx @@ -145,16 +145,18 @@ bool FGRunways::search( const string& aptid, FGRunway* r ) { c4_StringProp pEnd2 ("End2Flags"); int index = vRunway->Find(pID[aptid.c_str()]); - // cout << "index = " << index << endl; + c4_RowRef row = vRunway->GetAt(index); - if ( index == -1 ) { + // cout << "index = " << index " row = " << row << endl; + + // explicitly check if we got what we were asking for + // because metakit is canse insensitive! + if ( strcmp(aptid.c_str(), pID(row)) ) { return false; } next_index = index + 1; - c4_RowRef row = vRunway->GetAt(index); - r->id = (const char *) pID(row); r->rwy_no = (const char *) pRwy(row); r->lon = (double) pLon(row); @@ -186,10 +188,13 @@ bool FGRunways::search( const string& aptid, const string& rwyno, FGRunway* r ) c4_StringProp pEnd2 ("End2Flags"); int index = vRunway->Find(pID[aptid.c_str()]); - // cout << "index = " << index << endl; + c4_RowRef row = vRunway->GetAt(index); + // cout << "index = " << index " row = " << row << endl; - if ( index == -1 ) { - return false; + // explicitly check if we got what we were asking for + // because metakit is canse insensitive! + if ( strcmp(aptid.c_str(), pID(row)) ) { + return false; } // standardize input number @@ -201,7 +206,6 @@ bool FGRunways::search( const string& aptid, const string& rwyno, FGRunway* r ) << " to " << runwayno ); } - c4_RowRef row = vRunway->GetAt(index); string rowid = (const char *) pID(row); string rowrwyno = (const char *) pRwy(row); while ( rowid == aptid ) { @@ -504,7 +508,9 @@ bool FGRunwaysUtil::dump_mk4( const string& file ) { bool FGRunwaysUtil::search( const string& id, FGRunway* a ) const { +cout << "ID " << id << endl; const_iterator it = runways.find( FGRunway(id) ); +cout << "it = " << it << " end = " << runways.end() << endl; if ( it != runways.end() ) { *a = *it;