From f8dde93e05fa985b1bd170f7f170cd7c11872198 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 27 Apr 1999 15:54:39 +0000 Subject: [PATCH] MacOS portability improvements. --- Lib/Bucket/Makefile.am | 6 ++++-- Lib/Bucket/newbucket.cxx | 16 ++++++++-------- Lib/Bucket/newbucket.hxx | 14 ++++++++++++++ Lib/Debug/logstream.hxx | 6 ++++++ Lib/Math/interpolater.cxx | 6 +++++- Lib/Math/mat3.h | 21 ++++++++++----------- Lib/Math/point3d.hxx | 7 ++++--- 7 files changed, 51 insertions(+), 25 deletions(-) diff --git a/Lib/Bucket/Makefile.am b/Lib/Bucket/Makefile.am index 87f83785..dedde377 100644 --- a/Lib/Bucket/Makefile.am +++ b/Lib/Bucket/Makefile.am @@ -6,6 +6,8 @@ bin_PROGRAMS = testbucket testbucket_SOURCES = testbucket.cxx -testbucket_LDADD = $(top_builddir)/Lib/Bucket/libBucket.a +testbucket_LDADD = \ + $(top_builddir)/Lib/Bucket/libBucket.a \ + $(top_builddir)/Lib/Misc/libMisc.a -INCLUDES += -I$(top_builddir) +INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib diff --git a/Lib/Bucket/newbucket.cxx b/Lib/Bucket/newbucket.cxx index af95b4ab..fc41418a 100644 --- a/Lib/Bucket/newbucket.cxx +++ b/Lib/Bucket/newbucket.cxx @@ -28,6 +28,8 @@ #endif +#include + #include "newbucket.hxx" @@ -36,12 +38,8 @@ string FGBucket::gen_base_path() const { // long int index; int top_lon, top_lat, main_lon, main_lat; char hem, pole; - char path[256]; + char raw_path[256]; - // index = gen_index(); - - path[0] = '\0'; - top_lon = lon / 10; main_lon = lon; if ( (lon < 0) && (top_lon * 10 != lon) ) { @@ -74,11 +72,13 @@ string FGBucket::gen_base_path() const { main_lat *= -1; } - sprintf(path, "%c%03d%c%02d/%c%03d%c%02d", - hem, top_lon, pole, top_lat, + sprintf(raw_path, "%c%03d%c%02d/%c%03d%c%02d", + hem, top_lon, pole, top_lat, hem, main_lon, pole, main_lat); - return path; + FGPath path( raw_path ); + + return path.get_path(); } diff --git a/Lib/Bucket/newbucket.hxx b/Lib/Bucket/newbucket.hxx index 101ef7ae..624ccb7d 100644 --- a/Lib/Bucket/newbucket.hxx +++ b/Lib/Bucket/newbucket.hxx @@ -44,6 +44,11 @@ FG_USING_STD(string); FG_USING_STD(ostream); #endif +#ifdef __MWERKS__ +#include +#include +#endif + #include @@ -81,6 +86,7 @@ public: // Set the bucket params for the specified lat and lon void set_bucket( double dlon, double dlat ); + void make_bad ( void ); // Generate the unique scenery tile index for this bucket long int gen_index(); @@ -209,6 +215,7 @@ inline FGBucket::FGBucket(const double dlon, const double dlat) { set_bucket(dlon, dlat); } + // create an impossible bucket if false inline FGBucket::FGBucket(const bool is_good) { set_bucket(0.0, 0.0); @@ -296,6 +303,13 @@ inline double FGBucket::get_height() const { } +// create an impossible bucket +inline void FGBucket::make_bad( void ) { + set_bucket(0.0, 0.0); + lon = -1000; +} + + // offset a bucket struct by the specified tile units in the X & Y // direction FGBucket fgBucketOffset( double dlon, double dlat, int x, int y ); diff --git a/Lib/Debug/logstream.hxx b/Lib/Debug/logstream.hxx index 306193ab..5d3983f5 100644 --- a/Lib/Debug/logstream.hxx +++ b/Lib/Debug/logstream.hxx @@ -47,6 +47,10 @@ FG_USING_STD(cerr); FG_USING_STD(endl); #endif +#ifdef __MWERKS__ +FG_USING_STD(iostream); +#endif + // // TODO: // @@ -204,6 +208,8 @@ fglog() #ifdef FG_NDEBUG # define FG_LOG(C,P,M) +#elif defined( __MWERKS__ ) +# define FG_LOG(C,P,M) ::fglog() << ::loglevel(C,P) << M << std::endl #else # define FG_LOG(C,P,M) fglog() << loglevel(C,P) << M << endl #endif diff --git a/Lib/Math/interpolater.cxx b/Lib/Math/interpolater.cxx index 11b8d10f..f36d579e 100644 --- a/Lib/Math/interpolater.cxx +++ b/Lib/Math/interpolater.cxx @@ -25,6 +25,10 @@ #include +#ifdef __MWERKS__ +#include // for exit() +#endif + #include STL_STRING #include @@ -47,7 +51,7 @@ fgINTERPTABLE::fgINTERPTABLE( const string& file ) { size = 0; in >> skipcomment; - while ( ! in.eof() ){ + while ( in ) { if ( size < MAX_TABLE_SIZE ) { in >> table[size][0] >> table[size][1]; size++; diff --git a/Lib/Math/mat3.h b/Lib/Math/mat3.h index cb8a0d33..f60df04c 100644 --- a/Lib/Math/mat3.h +++ b/Lib/Math/mat3.h @@ -37,16 +37,6 @@ extern "C" { #define USE_XTRA_MAT3_INLINES -/* ------------------------------ Types --------------------------------- */ - -typedef double MAT3mat[4][4]; /* 4x4 matrix */ -typedef double MAT3vec[3]; /* Vector */ -typedef double MAT3hvec[4]; /* Vector with homogeneous coord */ - -/* ------------------------------ Macros -------------------------------- */ - -extern MAT3mat identityMatrix; - #if defined(i386) #define USE_X86_ASM #endif @@ -69,9 +59,18 @@ static __inline int FloatToInt(float f) return r; } #else -#define FloatToInt(F) ((int) (F)) +#define FloatToInt(F) ((int) ((F) < 0.0f ? (F)-0.5f : (F)+0.5f)) #endif +/* ------------------------------ Types --------------------------------- */ + +typedef double MAT3mat[4][4]; /* 4x4 matrix */ +typedef double MAT3vec[3]; /* Vector */ +typedef double MAT3hvec[4]; /* Vector with homogeneous coord */ + +/* ------------------------------ Macros -------------------------------- */ + +extern MAT3mat identityMatrix; /* Tests if a number is within EPSILON of zero */ #define MAT3_IS_ZERO(N) ((N) < MAT3_EPSILON && (N) > -MAT3_EPSILON) diff --git a/Lib/Math/point3d.hxx b/Lib/Math/point3d.hxx index 83f8de04..d677de8d 100644 --- a/Lib/Math/point3d.hxx +++ b/Lib/Math/point3d.hxx @@ -29,7 +29,7 @@ # error This library requires C++ #endif -#include "Include/compiler.h" +#include #ifdef FG_MATH_EXCEPTION_CLASH # define exception c_exception @@ -50,11 +50,12 @@ FG_USING_STD(ostream); FG_USING_STD(istream); #endif -// -rp- assert.h is buggy under MWCWP3, as multiple #include undef assert ! +// -dw- someone seems to have forgotten this... #ifdef __MWERKS__ -# define assert(x) +FG_USING_STD(std); #endif + const double fgPoint3_Epsilon = 0.0000001; enum {PX, PY, PZ}; // axes