]> git.mxchange.org Git - flightgear.git/commitdiff
MSVC5 portability changes contributed by Bruce Finney.
authorcurt <curt>
Wed, 24 May 2000 06:10:01 +0000 (06:10 +0000)
committercurt <curt>
Wed, 24 May 2000 06:10:01 +0000 (06:10 +0000)
12 files changed:
src/Airports/simple.cxx
src/FDM/LaRCsim/cherokee_aero.c
src/FDM/LaRCsim/ls_init.c
src/Include/fg_callback.hxx
src/Navaids/fixlist.hxx
src/Navaids/ilslist.hxx
src/Navaids/navlist.hxx
src/Network/fg_file.cxx
src/Network/fg_socket.cxx
src/Objects/materialmgr.hxx
src/Scenery/tilecache.cxx
src/WeatherCM/FGLocalWeatherDatabase.cpp

index cad2e4671d7197eea1d0fb9f6ae39f2ce394ede1..2c4314159b11614b0f1f5468fc3345d0d2d2cc04 100644 (file)
@@ -50,6 +50,7 @@
 
 #include "simple.hxx"
 
+FG_USING_NAMESPACE(std);
 
 FGAirports::FGAirports( const string& file ) {
     dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_READER, 0, NULL );
@@ -180,13 +181,13 @@ bool FGAirportsUtil::dump_gdbm( const string& file ) {
 
     GDBM_FILE dbf;
 
-#if !defined( MACOS )
+#if defined( MACOS ) || defined( _MSC_VER )
+    dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_NEWDB | GDBM_FAST,
+                    NULL, NULL );
+#else
     dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_NEWDB | GDBM_FAST, 
                     S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
                     NULL );
-#else
-    dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_NEWDB | GDBM_FAST,
-                    NULL, NULL );
 #endif
 
     if ( dbf == NULL ) {
index 19b9b219b581f0c59f65310462e28c6e693b9d02..8c72ac2bad01b546f485318d83a36417fe7920b2 100644 (file)
@@ -61,6 +61,7 @@ This source is not checked in this configuration in any way.
 #include "ls_types.h"
 #include "ls_generic.h"
 #include "ls_cockpit.h"
+#include "ls_constants.h"
 
 
 
@@ -140,7 +141,7 @@ void cherokee_aero()
                Cz = Cz0 + Cza*Alpha + Czat*(Alpha_dot*c/2.0/V) + Czq*(q*c/2.0/V) + Czde * elevator;
                Cm = Cm0 + Cma*Alpha + Cmat*(Alpha_dot*c/2.0/V) + Cmq*(q*c/2.0/V) + Cmde * elevator; 
 
-               Cx = Cx0 - (Cza*Alpha)*(Cza*Alpha)/(M_PI*5.71*0.6);
+               Cx = Cx0 - (Cza*Alpha)*(Cza*Alpha)/(PI*5.71*0.6);
                Cl = Clb*Beta + Clp*(p*b/2.0/V) + Clr*(r*b/2.0/V) + Clda * aileron;
 
                Cy = Cyb*Beta + Cyr*(r*b/2.0/V); 
index 22472411803247ed630436871167e54780939bc6..b17db217ae889ab6dc750ab485e03e737153248b 100644 (file)
@@ -34,6 +34,9 @@
 
 $Header$
 $Log$
+Revision 1.3  2000/05/24 04:10:01  curt
+MSVC5 portability changes contributed by Bruce Finney.
+
 Revision 1.2  2000/04/10 18:09:41  curt
 David Megginson made a few (mostly minor) mods to the LaRCsim files, and
 it's now possible to choose the LaRCsim model at runtime, as in
@@ -141,6 +144,9 @@ static char rcsid[] = "$Id$";
 #define FACILITY_NAME_STRING "init"
 #define CURRENT_VERSION 10
 
+void cherokee_init( void );
+void c172_init( void );
+
 typedef struct
 {
     symbol_rec Symbol;
@@ -215,7 +221,12 @@ void ls_init_init( void ) {
            if (error) Discrete_States[i].Symbol.Addr = NIL_POINTER;
        }
     */
+
 }
+/* not all system have strcasecmp */
+#ifdef _MSC_VER
+#  define strcasecmp stricmp
+#endif
 
 void ls_init( char * aircraft ) {
     /* int i; */
index e66e62580f824f4c5992841bd64df12a05a7c057..0d44c401bd336fdf4da6ca65c084cded3b1a82a0 100644 (file)
@@ -148,7 +148,8 @@ private:
     T* object;
     Method0v method0v;
 
-    typedef void * (fgMethodCallback::*DoPtr)( void ** );
+    // typedef void * (fgMethodCallback::*DoPtr)( void ** );
+    typedef void * (fgMethodCallback<T>::*DoPtr)( void ** );
     DoPtr doPtr;
 };
 
index cfd61a77d81b05db0d1b13afff66dc4d549fd8b2..968e90faf32de0c489355cdb01414fe269bcb2d9 100644 (file)
@@ -41,7 +41,8 @@ FG_USING_STD(string);
 
 class FGFixList {
 
-    typedef map < string, FGFix, less<string> > fix_map_type;
+    // typedef map < string, FGFix, less<string> > fix_map_type;
+    typedef map < string, FGFix > fix_map_type;
     typedef fix_map_type::iterator fix_map_iterator;
     typedef fix_map_type::const_iterator fix_map_const_iterator;
 
index d5a2e69ffd22996a1168e2c62c3346d3ede2943b..913fc0c28212b9911d91aaeb1ba0b2f2a8badf88 100644 (file)
@@ -44,7 +44,8 @@ class FGILSList {
     typedef ils_list_type::iterator ils_list_iterator;
     typedef ils_list_type::const_iterator ils_list_const_iterator;
 
-    typedef map < int, ils_list_type, less<int> > ils_map_type;
+    // typedef map < int, ils_list_type, less<int> > ils_map_type;
+    typedef map < int, ils_list_type > ils_map_type;
     typedef ils_map_type::iterator ils_map_iterator;
     typedef ils_map_type::const_iterator ils_map_const_iterator;
 
index ef549991fc67d33aa5f69571cd960d458e855bda..44ecb544690cea074bc2d379b9fb5c922dadf71b 100644 (file)
@@ -44,7 +44,8 @@ class FGNavList {
     typedef nav_list_type::iterator nav_list_iterator;
     typedef nav_list_type::const_iterator nav_list_const_iterator;
 
-    typedef map < int, nav_list_type, less<int> > nav_map_type;
+    // typedef map < int, nav_list_type, less<int> > nav_map_type;
+    typedef map < int, nav_list_type > nav_map_type;
     typedef nav_map_type::iterator nav_map_iterator;
     typedef nav_map_type::const_iterator nav_map_const_iterator;
 
index 7575ecb90cf400addac10f31fe4386a90081e210..e73179eb88bcdb6a43a11b2ceda708db0ef2ca77 100644 (file)
 
 #include STL_STRING
 
+#ifdef _MSC_VER
+#  include <io.h>
+#endif
+
 #include <simgear/debug/logstream.hxx>
 
 #include "fg_file.hxx"
@@ -43,11 +47,20 @@ FGFile::~FGFile() {
 // open the file based on specified direction
 bool FGFile::open( FGProtocol::fgProtocolDir dir ) {
     if ( dir == FGProtocol::out ) {
+#ifdef _MSC_VER
+       fp = _open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
+                       00666 );
+#else
        fp = std::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | 
                        S_IROTH | S_IWOTH );
+#endif
     } else if ( dir == FGProtocol::in ) {
+#ifdef _MSC_VER
+       fp = _open( file_name.c_str(), O_RDONLY );
+#else
        fp = std::open( file_name.c_str(), O_RDONLY );
+#endif
     } else {
        FG_LOG( FG_IO, FG_ALERT, 
                "Error:  bidirection mode not available for files." );
@@ -66,7 +79,11 @@ bool FGFile::open( FGProtocol::fgProtocolDir dir ) {
 // read a block of data of specified size
 int FGFile::read( char *buf, int length ) {
     // read a chunk
+#ifdef _MSC_VER
+    int result = _read( fp, buf, length );
+#else
     int result = std::read( fp, buf, length );
+#endif
 
     return result;
 }
@@ -78,7 +95,11 @@ int FGFile::readline( char *buf, int length ) {
     int pos = lseek( fp, 0, SEEK_CUR );
 
     // read a chunk
+#ifdef _MSC_VER
+    int result = _read( fp, buf, length );
+#else
     int result = std::read( fp, buf, length );
+#endif
 
     // find the end of line and reset position
     int i;
@@ -99,7 +120,11 @@ int FGFile::readline( char *buf, int length ) {
 
 // write data to a file
 int FGFile::write( char *buf, int length ) {
+#ifdef _MSC_VER
+    int result = _write( fp, buf, length );
+#else
     int result = std::write( fp, buf, length );
+#endif
     if ( result != length ) {
        FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << file_name );
     }
@@ -117,7 +142,11 @@ int FGFile::writestring( char *str ) {
 
 // close the port
 bool FGFile::close() {
+#ifdef _MSC_VER
+    if ( _close( fp ) == -1 ) {
+#else
     if ( std::close( fp ) == -1 ) {
+#endif
        return false;
     }
 
index 031538751e9c4dfe6d8f31905b002317611704a5..711899131b49cd76047c24cd125206395d8ea178 100644 (file)
@@ -134,7 +134,11 @@ int FGSocket::make_client_socket () {
     if ( connect(sock, (struct sockaddr *) &name, 
                 sizeof(struct sockaddr_in)) < 0 )
     {
+#ifdef _MSC_VER
+       _close(sock);
+#else
        std::close(sock);
+#endif
        FG_LOG( FG_IO, FG_ALERT, 
                "Error: connect() failed in make_client_socket()" );
        return -1;
@@ -207,7 +211,11 @@ int FGSocket::read( char *buf, int length ) {
     select(32, &ready, 0, 0, &tv);
 
     if ( FD_ISSET(sock, &ready) ) {
+#ifdef _MSC_VER
+       result = _read( sock, buf, length );
+#else
        result = std::read( sock, buf, length );
+#endif
        if ( result != length ) {
            FG_LOG( FG_IO, FG_INFO, 
                    "Warning: read() not enough bytes." );
@@ -239,7 +247,11 @@ int FGSocket::readline( char *buf, int length ) {
        // requested amount read
 
        char *buf_ptr = save_buf + save_len;
+#ifdef _MSC_VER
+       result = _read( sock, buf_ptr, FG_MAX_MSG_SIZE - save_len );
+#else
        result = std::read( sock, buf_ptr, FG_MAX_MSG_SIZE - save_len );
+#endif
        save_len += result;
        // cout << "current read = " << buf_ptr << endl;
        // cout << "current save_buf = " << save_buf << endl;
@@ -313,7 +325,11 @@ int FGSocket::write( char *buf, int length ) {
        // std::read( msgsock, junk, FG_MAX_MSG_SIZE );
 
        // write the interesting data to the socket
+#ifdef _MSC_VER
+       if ( _write(msgsock, buf, length) < 0 ) {
+#else
        if ( std::write(msgsock, buf, length) < 0 ) {
+#endif
            FG_LOG( FG_IO, FG_ALERT, "Error writing to socket: " << port );
            error_condition = true;
        } else {
@@ -344,10 +360,17 @@ int FGSocket::writestring( char *str ) {
 bool FGSocket::close() {
     for ( int i = 0; i < (int)client_connections.size(); ++i ) {
        int msgsock = client_connections[i];
+#ifdef _MSC_VER
+       _close( msgsock );
+#else
        std::close( msgsock );
+#endif
     }
 
+#ifdef _MSC_VER
+    _close( sock );
+#else
     std::close( sock );
-
+#endif
     return true;
 }
index cc5d60200bf33d0c40ce33681dba057329214f94..db57805e0ad90996dba4330d8541fe0c93735a0c 100644 (file)
@@ -49,6 +49,7 @@
 #include <plib/ssg.h>          // plib include
 
 #include "material.hxx"
+#include "fragment.hxx"
 
 FG_USING_STD(string);
 FG_USING_STD(map);
index 41dc85b8bb33417e6caddae550fe2ed997712e9a..61cfc0c96637f85dc5e3505844dc572bcf131477 100644 (file)
@@ -49,6 +49,7 @@
 #include "tilecache.hxx"
 #include "tileentry.hxx"
 
+FG_USING_NAMESPACE(std);
 
 // a cheesy hack (to be fixed later)
 extern ssgBranch *terrain;
@@ -201,7 +202,7 @@ FGTileCache::fill_in( int index, const FGBucket& p )
        while ( ! in.eof() ) {
            in >> token;
            in >> name;
-#ifdef MACOS
+#if defined ( MACOS ) || defined ( _MSC_VER )
            in >> ::skipws;
 #else
            in >> skipws;
@@ -333,6 +334,9 @@ FGTileCache::next_avail( void )
        FG_LOG( FG_TERRAIN, FG_ALERT, "WHOOPS!!! Dying in next_avail()" );
        exit( -1 );
     }
+
+    // avoid a potential compiler warning
+    return -1;
 }
 
 
index 5913f7cbff736e2cc5ee69eb7da741c357ecde66..8afe06ef7f7cfb375f4c3e9bf54b3baad83c4202 100644 (file)
@@ -270,8 +270,8 @@ void fgUpdateWeatherDatabase(void)
        #define KPHTOFPS 0.9113 //km/hr to ft/s
        #define MSTOFPS  3.2808 //m/s to ft/s
        current_aircraft.fdm_state->set_Velocities_Local_Airmass(my_value.Wind[1]*KPHTOFPS,
-                                                                                                           my_value.Wind[0]*KPHTOFPS,
-                                                                                                                   my_value.Wind[2]*KPHTOFPS);
+               my_value.Wind[0]*KPHTOFPS,
+               my_value.Wind[2]*KPHTOFPS);
        
 }