From 9a207fb4e10eb88c410499eb641e0c27c4ad6f68 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 10 Feb 2000 23:37:56 +0000 Subject: [PATCH] MacOS fixes contributed by Darrell Walisser on 1/26/2000. --- src/Cockpit/panel.hxx | 2 +- src/FDM/JSBSim/FGAircraft.cpp | 10 ++++-- src/FDM/JSBSim/FGEngine.cpp | 4 +++ src/FDM/JSBSim/FGFDMExec.h | 4 +-- src/FDM/JSBSim/FGOutput.cpp | 4 +++ src/FDM/JSBSim/FGfdmSocket.cpp | 7 +++- src/Main/options.cxx | 6 ++-- src/Scenery/tilecache.cxx | 4 +++ src/Scenery/tileentry.cxx | 8 +++++ src/Scenery/tilemgr.cxx | 4 ++- src/Time/lowleveltime.cxx | 5 +++ src/WeatherCM/FGLocalWeatherDatabase.cpp | 8 +++++ src/WeatherCM/FGLocalWeatherDatabase.h | 8 +++++ src/WeatherCM/FGPhysicalProperties.h | 44 ++++++++++++++++++++++++ 14 files changed, 108 insertions(+), 10 deletions(-) diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index 21f82662d..c0906834d 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -132,7 +132,7 @@ class FGTurnCoordinator : public FGInstrument public: FGTurnCoordinator (float inXPos, float inYPos); - virtual FGTurnCoordinator::~FGTurnCoordinator (void); + virtual ~FGTurnCoordinator (void); virtual void Init (void); virtual void Render(void); diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp index 4b67d947b..2042a04b3 100644 --- a/src/FDM/JSBSim/FGAircraft.cpp +++ b/src/FDM/JSBSim/FGAircraft.cpp @@ -101,8 +101,8 @@ Control INCLUDES *******************************************************************************/ -#include #include +#include #ifdef FGFS # ifndef __BORLANDC__ @@ -156,13 +156,17 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f string holding_string; char scratch[128]; ifstream coeffInFile; - streampos gpos; + streampos gpos(0); int axis; string axis_descript; bool readAeroRp=false; axis = -1; +#ifdef MACOS + aircraftDef = aircraft_path + ":" + fname + ":" + fname + ".cfg"; +#else aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg"; +#endif ifstream aircraftfile(aircraftDef.c_str()); cout << "Reading Aircraft Configuration File: " << aircraftDef << endl; // Output->SocketStatusOutput("Reading Aircraft Configuration File: " + aircraftDef); @@ -175,7 +179,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f while (!aircraftfile.fail()) { holding_string.erase(); aircraftfile >> holding_string; -#if defined(__BORLANDC__) || defined(FG_HAVE_NATIVE_SGI_COMPILERS) || defined(_MSC_VER) +#if defined(__BORLANDC__) || defined(FG_HAVE_NATIVE_SGI_COMPILERS) || defined(_MSC_VER) || defined(__MWERKS__) if (holding_string.compare(0, 2, "//") != 0) { #else if (holding_string.compare("//",0,2) != 0) { diff --git a/src/FDM/JSBSim/FGEngine.cpp b/src/FDM/JSBSim/FGEngine.cpp index 2ab29d3b4..eab3cd3fc 100644 --- a/src/FDM/JSBSim/FGEngine.cpp +++ b/src/FDM/JSBSim/FGEngine.cpp @@ -85,7 +85,11 @@ FGEngine::FGEngine(FGFDMExec* fdex, string enginePath, string engineName, int nu Output = FDMExec->GetOutput(); Name = engineName; +#ifdef MACOS + fullpath = enginePath + ":" + engineName + ".dat"; +#else fullpath = enginePath + "/" + engineName + ".dat"; +#endif ifstream enginefile(fullpath.c_str()); if (enginefile) { diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h index e5590e2b7..bfed56142 100644 --- a/src/FDM/JSBSim/FGFDMExec.h +++ b/src/FDM/JSBSim/FGFDMExec.h @@ -64,8 +64,8 @@ class FGInitialCondition; class FGFDMExec { public: - FGFDMExec::FGFDMExec(void); - FGFDMExec::~FGFDMExec(void); + FGFDMExec(void); + ~FGFDMExec(void); FGModel* FirstModel; diff --git a/src/FDM/JSBSim/FGOutput.cpp b/src/FDM/JSBSim/FGOutput.cpp index 9628d5309..c3b145b44 100644 --- a/src/FDM/JSBSim/FGOutput.cpp +++ b/src/FDM/JSBSim/FGOutput.cpp @@ -279,7 +279,11 @@ void FGOutput::SocketOutput(void) { string asciiData; +#ifdef MACOS + if (socket == 0) return; +#else if (socket <= 0) return; +#endif socket->Clear(); if (sFirstPass) { diff --git a/src/FDM/JSBSim/FGfdmSocket.cpp b/src/FDM/JSBSim/FGfdmSocket.cpp index e3b4c053a..f6381b23c 100644 --- a/src/FDM/JSBSim/FGfdmSocket.cpp +++ b/src/FDM/JSBSim/FGfdmSocket.cpp @@ -47,7 +47,7 @@ FGfdmSocket::FGfdmSocket(string address, int port) { size = 0; - #ifdef __BORLANDC__ || _MSC_VER + #if defined( __BORLANDC__ ) || defined( _MSC_VER ) WSADATA wsaData; int PASCAL FAR wsaReturnCode; wsaReturnCode = WSAStartup(MAKEWORD(1,1), &wsaData); @@ -86,6 +86,10 @@ FGfdmSocket::FGfdmSocket(string address, int port) } } +#ifdef MACOS +/* commented out destructor method. shutdown method needs to link when + we don't have networking enabled */ +#else FGfdmSocket::~FGfdmSocket(void) { if (sckt) shutdown(sckt,2); @@ -93,6 +97,7 @@ FGfdmSocket::~FGfdmSocket(void) WSACleanup(); #endif } +#endif void FGfdmSocket::Clear(void) { diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 41bc4c33b..a55b9fd04 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -815,9 +815,11 @@ int fgOPTIONS::parse_config_file( const string& path ) { string line; #ifdef GETLINE_NEEDS_TERMINATOR - getline( in, line, '\n' ); + getline( in, line, '\n' ); +#elif defined (MACOS) + getline( in, line, '\r' ); #else - getline( in, line ); + getline( in, line ); #endif if ( parse_option( line ) == FG_OPTIONS_ERROR ) { diff --git a/src/Scenery/tilecache.cxx b/src/Scenery/tilecache.cxx index bed871391..ed0c6d6b7 100644 --- a/src/Scenery/tilecache.cxx +++ b/src/Scenery/tilecache.cxx @@ -200,7 +200,11 @@ FGTileCache::fill_in( int index, const FGBucket& p ) while ( ! in.eof() ) { in >> token; in >> name; +#ifdef MACOS + in >> ::skipws; +#else in >> skipws; +#endif cout << "token = " << token << " name = " << name << endl; FGPath custom_path = tile_path; diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index 755069288..b46703051 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -98,12 +98,20 @@ void FGTileEntry::free_tile() { << " texture coordinate arrays" ); for ( i = 0; i < (int)vec3_ptrs.size(); ++i ) { +#ifdef MACOS + delete [] vec3_ptrs[i]; +#else delete vec3_ptrs[i]; +#endif } vec3_ptrs.clear(); for ( i = 0; i < (int)vec2_ptrs.size(); ++i ) { +#ifdef MACOS + delete [] vec2_ptrs[i]; +#else delete vec2_ptrs[i]; +#endif } vec2_ptrs.clear(); diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 697ae5a16..2607dd1b8 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -679,7 +679,9 @@ void FGTileMgr::my_ssg_los( string s, ssgBranch *branch, sgdMat4 m, { // cout << "sgLOS hit: " << result[0] << "," // << result[1] << "," << result[2] << endl; - hit_pts[hitcount] = result; + for (int i=0; i < 3; i++) { + hit_pts[hitcount][i] = result[i]; + } hitcount++; } } diff --git a/src/Time/lowleveltime.cxx b/src/Time/lowleveltime.cxx index 27fd7b2a3..2ae157008 100644 --- a/src/Time/lowleveltime.cxx +++ b/src/Time/lowleveltime.cxx @@ -303,11 +303,16 @@ static void fgtzset_internal (int always, const char *tz) /* User specified the empty string; use UTC explicitly. */ tz = "Universal"; +#ifdef MACOS + /* as you well know, mac paths contain leading colon, this code + messes things up.... */ +#else /* A leading colon means "implementation defined syntax". We ignore the colon and always use the same algorithm: try a data file, and if none exists parse the 1003.1 syntax. */ if (tz && *tz == ':') ++tz; +#endif /* Check whether the value changes since the last run. */ if (old_fgtz != NULL && tz != NULL && strcmp (tz, old_fgtz) == 0) diff --git a/src/WeatherCM/FGLocalWeatherDatabase.cpp b/src/WeatherCM/FGLocalWeatherDatabase.cpp index 3e8fadbd1..160466a15 100644 --- a/src/WeatherCM/FGLocalWeatherDatabase.cpp +++ b/src/WeatherCM/FGLocalWeatherDatabase.cpp @@ -199,10 +199,18 @@ FGPhysicalProperty FGLocalWeatherDatabase::get(const sgVec3& p) const return FGPhysicalProperty(database->Evaluate(p), p[3]); } +#ifdef MACOS + /* fix a problem with mw compilers in that they don't know the + difference between the next two methods. Since the first one + doesn't seem to be used anywhere, I commented it out. This is + supposed to be fixed in the forthcoming CodeWarrior Release + 6. */ +#else FGPhysicalProperties FGLocalWeatherDatabase::get(const sgVec2& p) const { return database->Evaluate(p); } +#endif WeatherPrecision FGLocalWeatherDatabase::getAirDensity(const sgVec3& p) const { diff --git a/src/WeatherCM/FGLocalWeatherDatabase.h b/src/WeatherCM/FGLocalWeatherDatabase.h index cf252da21..f45ece1b7 100644 --- a/src/WeatherCM/FGLocalWeatherDatabase.h +++ b/src/WeatherCM/FGLocalWeatherDatabase.h @@ -158,7 +158,15 @@ public: /************************************************************************/ /* Get the physical properties on the specified point p */ /************************************************************************/ +#ifdef MACOS + /* fix a problem with mw compilers in that they don't know the + difference between the next two methods. Since the first one + doesn't seem to be used anywhere, I commented it out. This is + supposed to be fixed in the forthcoming CodeWarrior Release + 6. */ +#else FGPhysicalProperties get(const sgVec2& p) const; +#endif FGPhysicalProperty get(const sgVec3& p) const; WeatherPrecision getAirDensity(const sgVec3& p) const; diff --git a/src/WeatherCM/FGPhysicalProperties.h b/src/WeatherCM/FGPhysicalProperties.h index 35b2fa5f2..a63403605 100644 --- a/src/WeatherCM/FGPhysicalProperties.h +++ b/src/WeatherCM/FGPhysicalProperties.h @@ -229,6 +229,49 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysical return *this; } +// slightly modified version that also makes the Mac happy +inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p) +{ + typedef map::const_iterator wind_iterator; + typedef map::const_iterator turbulence_iterator; + typedef map::const_iterator scalar_iterator; + + // types to replace make_pair + typedef map::value_type wind_type; + typedef map::value_type turb_type; + typedef map::value_type weather_type; + + for (wind_iterator WindIt = p.Wind.begin(); + WindIt != p.Wind.end(); + WindIt++) + if (!Wind.insert( wind_type(WindIt->first, -WindIt->second) ).second) + // when it's not inserted => it's already existing + Wind[WindIt->first] -= WindIt->second; //=> substract the value + + for (turbulence_iterator TurbulenceIt = p.Turbulence.begin(); + TurbulenceIt != p.Turbulence.end(); + TurbulenceIt++) + if (!Turbulence.insert( turb_type(TurbulenceIt->first, -TurbulenceIt->second) ).second) + Turbulence[TurbulenceIt->first] -= TurbulenceIt->second; + + for (scalar_iterator TemperatureIt = p.Temperature.begin(); + TemperatureIt != p.Temperature.end(); + TemperatureIt++) + if (!Temperature.insert( weather_type(TemperatureIt->first, -TemperatureIt->second) ).second) + Temperature[TemperatureIt->first] -= TemperatureIt->second; + + AirPressure -= p.AirPressure.getValue(); + + for (scalar_iterator VaporPressureIt = p.VaporPressure.begin(); + VaporPressureIt != p.VaporPressure.end(); + VaporPressureIt++) + if (!VaporPressure.insert( weather_type(VaporPressureIt->first, -VaporPressureIt->second) ).second) + VaporPressure[VaporPressureIt->first] -= VaporPressureIt->second; + + return *this; +} + +#if 0 // old version inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p) { typedef map::const_iterator wind_iterator; @@ -264,6 +307,7 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysical return *this; } +#endif inline void FGPhysicalProperties::WindAt(sgVec3 ret, const WeatherPrecision a) const { -- 2.39.5