]> git.mxchange.org Git - flightgear.git/commitdiff
MacOS fixes contributed by Darrell Walisser on 1/26/2000.
authorcurt <curt>
Thu, 10 Feb 2000 23:37:56 +0000 (23:37 +0000)
committercurt <curt>
Thu, 10 Feb 2000 23:37:56 +0000 (23:37 +0000)
14 files changed:
src/Cockpit/panel.hxx
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGEngine.cpp
src/FDM/JSBSim/FGFDMExec.h
src/FDM/JSBSim/FGOutput.cpp
src/FDM/JSBSim/FGfdmSocket.cpp
src/Main/options.cxx
src/Scenery/tilecache.cxx
src/Scenery/tileentry.cxx
src/Scenery/tilemgr.cxx
src/Time/lowleveltime.cxx
src/WeatherCM/FGLocalWeatherDatabase.cpp
src/WeatherCM/FGLocalWeatherDatabase.h
src/WeatherCM/FGPhysicalProperties.h

index 21f82662d34be44014ab06d49dc801353a09c58a..c0906834d754c4b117ef44117b80fcb54e40e8d5 100644 (file)
@@ -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);
   
index 4b67d947bd4cad9e62f9eaadfa85621e7b9bd225..2042a04b3b20f306cbb4d0192beafc265a51ddd0 100644 (file)
@@ -101,8 +101,8 @@ Control
 INCLUDES
 *******************************************************************************/
 
-#include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 
 #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) {
index 2ab29d3b4e45e731c8f3c33d830de654bca49560..eab3cd3fcde97e8a2ae6d055cf8fcf7a85fae95b 100644 (file)
@@ -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) {
index e5590e2b7adfffa5e58bbbea26b4b3ae7d3c346b..bfed56142ca2a6e0de43a852a319bd847569b64e 100644 (file)
@@ -64,8 +64,8 @@ class FGInitialCondition;
 class FGFDMExec
 {
 public:
-  FGFDMExec::FGFDMExec(void);
-  FGFDMExec::~FGFDMExec(void);
+  FGFDMExec(void);
+  ~FGFDMExec(void);
 
   FGModel* FirstModel;
 
index 9628d5309d265fde3e654622f1a205f6a5191056..c3b145b4434d53879b3614873fbd0f5139b15969 100644 (file)
@@ -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) {
index e3b4c053a186207f30217c4a59176cee3097a93d..f6381b23cfbd330bc9ca36b10836abcbc5989490 100644 (file)
@@ -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)
 {
index 41bc4c33b1017765a0eadadb84c717248c7ddb80..a55b9fd0422716975c56720908d28a09235e7321 100644 (file)
@@ -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 ) {
index bed8713911da7fe598d88dcb4b447a48d2190dee..ed0c6d6b710c05004133290353dde6c7fad53351 100644 (file)
@@ -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;
index 75506928896b8c255cb0d5e22768a96959dc1383..b46703051989c4408cdb637309055f2709cad1c6 100644 (file)
@@ -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();
 
index 697ae5a16c5cf531a75d6854f61821e8f6f51c25..2607dd1b8e9c85bcb5f743136f5ae8402c4d2810 100644 (file)
@@ -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++;
                    }
                }
index 27fd7b2a385ea9faf4c5626ea2ad3f01309e7cc9..2ae1570087b6433434d6c26d560fc8715a75952b 100644 (file)
@@ -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)
index 3e8fadbd10255a2e6099840249ede25fb373dfbe..160466a15967562948061c95dbe1003e9611932c 100644 (file)
@@ -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
 {
index cf252da21e079e3115bbb1088e22d5914196cfeb..f45ece1b7a1839c281c24cb44baefc558a4a0d6d 100644 (file)
@@ -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;
index 35b2fa5f28f590e9ee7f796a07d7d8c34392ba47..a634036056e1881e3a5d836d574c141f5277a1d0 100644 (file)
@@ -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<FGPhysicalProperties::Altitude, FGWindItem>::const_iterator wind_iterator;
+    typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
+    typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
+    
+    // types to replace make_pair
+    typedef map<FGPhysicalProperties::Altitude, FGWindItem>::value_type wind_type;
+    typedef map<FGPhysicalProperties::Altitude,        FGTurbulenceItem>::value_type turb_type;
+    typedef map<FGPhysicalProperties::Altitude,        WeatherPrecision>::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<FGPhysicalProperties::Altitude, FGWindItem      >::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
 {