diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index cad2e4671..2c4314159 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -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 ) { diff --git a/src/FDM/LaRCsim/cherokee_aero.c b/src/FDM/LaRCsim/cherokee_aero.c index 19b9b219b..8c72ac2ba 100644 --- a/src/FDM/LaRCsim/cherokee_aero.c +++ b/src/FDM/LaRCsim/cherokee_aero.c @@ -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); diff --git a/src/FDM/LaRCsim/ls_init.c b/src/FDM/LaRCsim/ls_init.c index 224724118..b17db217a 100644 --- a/src/FDM/LaRCsim/ls_init.c +++ b/src/FDM/LaRCsim/ls_init.c @@ -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; */ diff --git a/src/Include/fg_callback.hxx b/src/Include/fg_callback.hxx index e66e62580..0d44c401b 100644 --- a/src/Include/fg_callback.hxx +++ b/src/Include/fg_callback.hxx @@ -148,7 +148,8 @@ private: T* object; Method0v method0v; - typedef void * (fgMethodCallback::*DoPtr)( void ** ); + // typedef void * (fgMethodCallback::*DoPtr)( void ** ); + typedef void * (fgMethodCallback::*DoPtr)( void ** ); DoPtr doPtr; }; diff --git a/src/Navaids/fixlist.hxx b/src/Navaids/fixlist.hxx index cfd61a77d..968e90faf 100644 --- a/src/Navaids/fixlist.hxx +++ b/src/Navaids/fixlist.hxx @@ -41,7 +41,8 @@ FG_USING_STD(string); class FGFixList { - typedef map < string, FGFix, less > fix_map_type; + // typedef map < string, FGFix, less > 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; diff --git a/src/Navaids/ilslist.hxx b/src/Navaids/ilslist.hxx index d5a2e69ff..913fc0c28 100644 --- a/src/Navaids/ilslist.hxx +++ b/src/Navaids/ilslist.hxx @@ -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 > ils_map_type; + // typedef map < int, ils_list_type, less > 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; diff --git a/src/Navaids/navlist.hxx b/src/Navaids/navlist.hxx index ef549991f..44ecb5446 100644 --- a/src/Navaids/navlist.hxx +++ b/src/Navaids/navlist.hxx @@ -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 > nav_map_type; + // typedef map < int, nav_list_type, less > 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; diff --git a/src/Network/fg_file.cxx b/src/Network/fg_file.cxx index 7575ecb90..e73179eb8 100644 --- a/src/Network/fg_file.cxx +++ b/src/Network/fg_file.cxx @@ -25,6 +25,10 @@ #include STL_STRING +#ifdef _MSC_VER +# include +#endif + #include #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; } diff --git a/src/Network/fg_socket.cxx b/src/Network/fg_socket.cxx index 031538751..711899131 100644 --- a/src/Network/fg_socket.cxx +++ b/src/Network/fg_socket.cxx @@ -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; } diff --git a/src/Objects/materialmgr.hxx b/src/Objects/materialmgr.hxx index cc5d60200..db57805e0 100644 --- a/src/Objects/materialmgr.hxx +++ b/src/Objects/materialmgr.hxx @@ -49,6 +49,7 @@ #include // plib include #include "material.hxx" +#include "fragment.hxx" FG_USING_STD(string); FG_USING_STD(map); diff --git a/src/Scenery/tilecache.cxx b/src/Scenery/tilecache.cxx index 41dc85b8b..61cfc0c96 100644 --- a/src/Scenery/tilecache.cxx +++ b/src/Scenery/tilecache.cxx @@ -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; } diff --git a/src/WeatherCM/FGLocalWeatherDatabase.cpp b/src/WeatherCM/FGLocalWeatherDatabase.cpp index 5913f7cbf..8afe06ef7 100644 --- a/src/WeatherCM/FGLocalWeatherDatabase.cpp +++ b/src/WeatherCM/FGLocalWeatherDatabase.cpp @@ -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); }