MSVC5 portability changes contributed by Bruce Finney.
This commit is contained in:
parent
d423fa9337
commit
b074559216
12 changed files with 87 additions and 13 deletions
|
@ -50,6 +50,7 @@
|
||||||
|
|
||||||
#include "simple.hxx"
|
#include "simple.hxx"
|
||||||
|
|
||||||
|
FG_USING_NAMESPACE(std);
|
||||||
|
|
||||||
FGAirports::FGAirports( const string& file ) {
|
FGAirports::FGAirports( const string& file ) {
|
||||||
dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_READER, 0, NULL );
|
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;
|
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,
|
dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_NEWDB | GDBM_FAST,
|
||||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
|
||||||
NULL );
|
NULL );
|
||||||
#else
|
|
||||||
dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_NEWDB | GDBM_FAST,
|
|
||||||
NULL, NULL );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( dbf == NULL ) {
|
if ( dbf == NULL ) {
|
||||||
|
|
|
@ -61,6 +61,7 @@ This source is not checked in this configuration in any way.
|
||||||
#include "ls_types.h"
|
#include "ls_types.h"
|
||||||
#include "ls_generic.h"
|
#include "ls_generic.h"
|
||||||
#include "ls_cockpit.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;
|
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;
|
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;
|
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);
|
Cy = Cyb*Beta + Cyr*(r*b/2.0/V);
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
|
|
||||||
$Header$
|
$Header$
|
||||||
$Log$
|
$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
|
Revision 1.2 2000/04/10 18:09:41 curt
|
||||||
David Megginson made a few (mostly minor) mods to the LaRCsim files, and
|
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
|
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 FACILITY_NAME_STRING "init"
|
||||||
#define CURRENT_VERSION 10
|
#define CURRENT_VERSION 10
|
||||||
|
|
||||||
|
void cherokee_init( void );
|
||||||
|
void c172_init( void );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
symbol_rec Symbol;
|
symbol_rec Symbol;
|
||||||
|
@ -215,7 +221,12 @@ void ls_init_init( void ) {
|
||||||
if (error) Discrete_States[i].Symbol.Addr = NIL_POINTER;
|
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 ) {
|
void ls_init( char * aircraft ) {
|
||||||
/* int i; */
|
/* int i; */
|
||||||
|
|
|
@ -148,7 +148,8 @@ private:
|
||||||
T* object;
|
T* object;
|
||||||
Method0v method0v;
|
Method0v method0v;
|
||||||
|
|
||||||
typedef void * (fgMethodCallback::*DoPtr)( void ** );
|
// typedef void * (fgMethodCallback::*DoPtr)( void ** );
|
||||||
|
typedef void * (fgMethodCallback<T>::*DoPtr)( void ** );
|
||||||
DoPtr doPtr;
|
DoPtr doPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ FG_USING_STD(string);
|
||||||
|
|
||||||
class FGFixList {
|
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::iterator fix_map_iterator;
|
||||||
typedef fix_map_type::const_iterator fix_map_const_iterator;
|
typedef fix_map_type::const_iterator fix_map_const_iterator;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,8 @@ class FGILSList {
|
||||||
typedef ils_list_type::iterator ils_list_iterator;
|
typedef ils_list_type::iterator ils_list_iterator;
|
||||||
typedef ils_list_type::const_iterator ils_list_const_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::iterator ils_map_iterator;
|
||||||
typedef ils_map_type::const_iterator ils_map_const_iterator;
|
typedef ils_map_type::const_iterator ils_map_const_iterator;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,8 @@ class FGNavList {
|
||||||
typedef nav_list_type::iterator nav_list_iterator;
|
typedef nav_list_type::iterator nav_list_iterator;
|
||||||
typedef nav_list_type::const_iterator nav_list_const_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::iterator nav_map_iterator;
|
||||||
typedef nav_map_type::const_iterator nav_map_const_iterator;
|
typedef nav_map_type::const_iterator nav_map_const_iterator;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
|
|
||||||
#include STL_STRING
|
#include STL_STRING
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
#include "fg_file.hxx"
|
#include "fg_file.hxx"
|
||||||
|
@ -43,11 +47,20 @@ FGFile::~FGFile() {
|
||||||
// open the file based on specified direction
|
// open the file based on specified direction
|
||||||
bool FGFile::open( FGProtocol::fgProtocolDir dir ) {
|
bool FGFile::open( FGProtocol::fgProtocolDir dir ) {
|
||||||
if ( dir == FGProtocol::out ) {
|
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,
|
fp = std::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
|
||||||
S_IROTH | S_IWOTH );
|
S_IROTH | S_IWOTH );
|
||||||
|
#endif
|
||||||
} else if ( dir == FGProtocol::in ) {
|
} 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 );
|
fp = std::open( file_name.c_str(), O_RDONLY );
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
FG_LOG( FG_IO, FG_ALERT,
|
FG_LOG( FG_IO, FG_ALERT,
|
||||||
"Error: bidirection mode not available for files." );
|
"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
|
// read a block of data of specified size
|
||||||
int FGFile::read( char *buf, int length ) {
|
int FGFile::read( char *buf, int length ) {
|
||||||
// read a chunk
|
// read a chunk
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
int result = _read( fp, buf, length );
|
||||||
|
#else
|
||||||
int result = std::read( fp, buf, length );
|
int result = std::read( fp, buf, length );
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +95,11 @@ int FGFile::readline( char *buf, int length ) {
|
||||||
int pos = lseek( fp, 0, SEEK_CUR );
|
int pos = lseek( fp, 0, SEEK_CUR );
|
||||||
|
|
||||||
// read a chunk
|
// read a chunk
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
int result = _read( fp, buf, length );
|
||||||
|
#else
|
||||||
int result = std::read( fp, buf, length );
|
int result = std::read( fp, buf, length );
|
||||||
|
#endif
|
||||||
|
|
||||||
// find the end of line and reset position
|
// find the end of line and reset position
|
||||||
int i;
|
int i;
|
||||||
|
@ -99,7 +120,11 @@ int FGFile::readline( char *buf, int length ) {
|
||||||
|
|
||||||
// write data to a file
|
// write data to a file
|
||||||
int FGFile::write( char *buf, int length ) {
|
int FGFile::write( char *buf, int length ) {
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
int result = _write( fp, buf, length );
|
||||||
|
#else
|
||||||
int result = std::write( fp, buf, length );
|
int result = std::write( fp, buf, length );
|
||||||
|
#endif
|
||||||
if ( result != length ) {
|
if ( result != length ) {
|
||||||
FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << file_name );
|
FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << file_name );
|
||||||
}
|
}
|
||||||
|
@ -117,7 +142,11 @@ int FGFile::writestring( char *str ) {
|
||||||
|
|
||||||
// close the port
|
// close the port
|
||||||
bool FGFile::close() {
|
bool FGFile::close() {
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
if ( _close( fp ) == -1 ) {
|
||||||
|
#else
|
||||||
if ( std::close( fp ) == -1 ) {
|
if ( std::close( fp ) == -1 ) {
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,11 @@ int FGSocket::make_client_socket () {
|
||||||
if ( connect(sock, (struct sockaddr *) &name,
|
if ( connect(sock, (struct sockaddr *) &name,
|
||||||
sizeof(struct sockaddr_in)) < 0 )
|
sizeof(struct sockaddr_in)) < 0 )
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
_close(sock);
|
||||||
|
#else
|
||||||
std::close(sock);
|
std::close(sock);
|
||||||
|
#endif
|
||||||
FG_LOG( FG_IO, FG_ALERT,
|
FG_LOG( FG_IO, FG_ALERT,
|
||||||
"Error: connect() failed in make_client_socket()" );
|
"Error: connect() failed in make_client_socket()" );
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -207,7 +211,11 @@ int FGSocket::read( char *buf, int length ) {
|
||||||
select(32, &ready, 0, 0, &tv);
|
select(32, &ready, 0, 0, &tv);
|
||||||
|
|
||||||
if ( FD_ISSET(sock, &ready) ) {
|
if ( FD_ISSET(sock, &ready) ) {
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
result = _read( sock, buf, length );
|
||||||
|
#else
|
||||||
result = std::read( sock, buf, length );
|
result = std::read( sock, buf, length );
|
||||||
|
#endif
|
||||||
if ( result != length ) {
|
if ( result != length ) {
|
||||||
FG_LOG( FG_IO, FG_INFO,
|
FG_LOG( FG_IO, FG_INFO,
|
||||||
"Warning: read() not enough bytes." );
|
"Warning: read() not enough bytes." );
|
||||||
|
@ -239,7 +247,11 @@ int FGSocket::readline( char *buf, int length ) {
|
||||||
// requested amount read
|
// requested amount read
|
||||||
|
|
||||||
char *buf_ptr = save_buf + save_len;
|
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 );
|
result = std::read( sock, buf_ptr, FG_MAX_MSG_SIZE - save_len );
|
||||||
|
#endif
|
||||||
save_len += result;
|
save_len += result;
|
||||||
// cout << "current read = " << buf_ptr << endl;
|
// cout << "current read = " << buf_ptr << endl;
|
||||||
// cout << "current save_buf = " << save_buf << 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 );
|
// std::read( msgsock, junk, FG_MAX_MSG_SIZE );
|
||||||
|
|
||||||
// write the interesting data to the socket
|
// write the interesting data to the socket
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
if ( _write(msgsock, buf, length) < 0 ) {
|
||||||
|
#else
|
||||||
if ( std::write(msgsock, buf, length) < 0 ) {
|
if ( std::write(msgsock, buf, length) < 0 ) {
|
||||||
|
#endif
|
||||||
FG_LOG( FG_IO, FG_ALERT, "Error writing to socket: " << port );
|
FG_LOG( FG_IO, FG_ALERT, "Error writing to socket: " << port );
|
||||||
error_condition = true;
|
error_condition = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -344,10 +360,17 @@ int FGSocket::writestring( char *str ) {
|
||||||
bool FGSocket::close() {
|
bool FGSocket::close() {
|
||||||
for ( int i = 0; i < (int)client_connections.size(); ++i ) {
|
for ( int i = 0; i < (int)client_connections.size(); ++i ) {
|
||||||
int msgsock = client_connections[i];
|
int msgsock = client_connections[i];
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
_close( msgsock );
|
||||||
|
#else
|
||||||
std::close( msgsock );
|
std::close( msgsock );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
_close( sock );
|
||||||
|
#else
|
||||||
std::close( sock );
|
std::close( sock );
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include <plib/ssg.h> // plib include
|
#include <plib/ssg.h> // plib include
|
||||||
|
|
||||||
#include "material.hxx"
|
#include "material.hxx"
|
||||||
|
#include "fragment.hxx"
|
||||||
|
|
||||||
FG_USING_STD(string);
|
FG_USING_STD(string);
|
||||||
FG_USING_STD(map);
|
FG_USING_STD(map);
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "tilecache.hxx"
|
#include "tilecache.hxx"
|
||||||
#include "tileentry.hxx"
|
#include "tileentry.hxx"
|
||||||
|
|
||||||
|
FG_USING_NAMESPACE(std);
|
||||||
|
|
||||||
// a cheesy hack (to be fixed later)
|
// a cheesy hack (to be fixed later)
|
||||||
extern ssgBranch *terrain;
|
extern ssgBranch *terrain;
|
||||||
|
@ -201,7 +202,7 @@ FGTileCache::fill_in( int index, const FGBucket& p )
|
||||||
while ( ! in.eof() ) {
|
while ( ! in.eof() ) {
|
||||||
in >> token;
|
in >> token;
|
||||||
in >> name;
|
in >> name;
|
||||||
#ifdef MACOS
|
#if defined ( MACOS ) || defined ( _MSC_VER )
|
||||||
in >> ::skipws;
|
in >> ::skipws;
|
||||||
#else
|
#else
|
||||||
in >> skipws;
|
in >> skipws;
|
||||||
|
@ -333,6 +334,9 @@ FGTileCache::next_avail( void )
|
||||||
FG_LOG( FG_TERRAIN, FG_ALERT, "WHOOPS!!! Dying in next_avail()" );
|
FG_LOG( FG_TERRAIN, FG_ALERT, "WHOOPS!!! Dying in next_avail()" );
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// avoid a potential compiler warning
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -270,8 +270,8 @@ void fgUpdateWeatherDatabase(void)
|
||||||
#define KPHTOFPS 0.9113 //km/hr to ft/s
|
#define KPHTOFPS 0.9113 //km/hr to ft/s
|
||||||
#define MSTOFPS 3.2808 //m/s 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,
|
current_aircraft.fdm_state->set_Velocities_Local_Airmass(my_value.Wind[1]*KPHTOFPS,
|
||||||
my_value.Wind[0]*KPHTOFPS,
|
my_value.Wind[0]*KPHTOFPS,
|
||||||
my_value.Wind[2]*KPHTOFPS);
|
my_value.Wind[2]*KPHTOFPS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue