From: david Date: Thu, 25 Apr 2002 15:09:10 +0000 (+0000) Subject: Patches from Erik Hoffman: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=384e56b9b40706eca407584e72616ec04da45c7c;p=simgear.git Patches from Erik Hoffman: Tbis is a first patch in a series to clean up SimGear by removing warning messages. Most of them are straight forwared, but in pops.hxx the compile complaints about "type qualifier is meaningless on return type". I think it's up to you to decide if you want that part applied. --- diff --git a/simgear/ephemeris/celestialBody.cxx b/simgear/ephemeris/celestialBody.cxx index ae6a7929..2a7f5563 100644 --- a/simgear/ephemeris/celestialBody.cxx +++ b/simgear/ephemeris/celestialBody.cxx @@ -158,22 +158,112 @@ double CelestialBody::sgCalcEccAnom(double M, double e) return eccAnom; } +/***************************************************************************** + * inline CelestialBody::CelestialBody + * public constructor for a generic celestialBody object. + * initializes the 6 primary orbital elements. The elements are: + * N: longitude of the ascending node + * i: inclination to the ecliptic + * w: argument of perihelion + * a: semi-major axis, or mean distance from the sun + * e: eccenticity + * M: mean anomaly + * Each orbital element consists of a constant part and a variable part that + * gradually changes over time. + * + * Argumetns: + * the 13 arguments to the constructor constitute the first, constant + * ([NiwaeM]f) and the second variable ([NiwaeM]s) part of the orbital + * elements. The 13th argument is the current time. Note that the inclination + * is written with a capital (If, Is), because 'if' is a reserved word in the + * C/C++ programming language. + ***************************************************************************/ +CelestialBody::CelestialBody(double Nf, double Ns, + double If, double Is, + double wf, double ws, + double af, double as, + double ef, double es, + double Mf, double Ms, double mjd) +{ + NFirst = Nf; NSec = Ns; + iFirst = If; iSec = Is; + wFirst = wf; wSec = ws; + aFirst = af; aSec = as; + eFirst = ef; eSec = es; + MFirst = Mf; MSec = Ms; + updateOrbElements(mjd); +} +CelestialBody::CelestialBody(double Nf, double Ns, + double If, double Is, + double wf, double ws, + double af, double as, + double ef, double es, + double Mf, double Ms) +{ + NFirst = Nf; NSec = Ns; + iFirst = If; iSec = Is; + wFirst = wf; wSec = ws; + aFirst = af; aSec = as; + eFirst = ef; eSec = es; + MFirst = Mf; MSec = Ms; +} +/**************************************************************************** + * inline void CelestialBody::updateOrbElements(double mjd) + * given the current time, this private member calculates the actual + * orbital elements + * + * Arguments: double mjd: the current modified julian date: + * + * return value: none + ***************************************************************************/ +void CelestialBody::updateOrbElements(double mjd) +{ + double actTime = sgCalcActTime(mjd); + M = SGD_DEGREES_TO_RADIANS * (MFirst + (MSec * actTime)); + w = SGD_DEGREES_TO_RADIANS * (wFirst + (wSec * actTime)); + N = SGD_DEGREES_TO_RADIANS * (NFirst + (NSec * actTime)); + i = SGD_DEGREES_TO_RADIANS * (iFirst + (iSec * actTime)); + e = eFirst + (eSec * actTime); + a = aFirst + (aSec * actTime); +} +/***************************************************************************** + * inline double CelestialBody::sgCalcActTime(double mjd) + * this private member function returns the offset in days from the epoch for + * wich the orbital elements are calculated (Jan, 1st, 2000). + * + * Argument: the current time + * + * return value: the (fractional) number of days until Jan 1, 2000. + ****************************************************************************/ +double CelestialBody::sgCalcActTime(double mjd) +{ + return (mjd - 36523.5); +} +/***************************************************************************** + * inline void CelestialBody::getPos(double* ra, double* dec) + * gives public access to Right Ascension and declination + * + ****************************************************************************/ +void CelestialBody::getPos(double* ra, double* dec) +{ + *ra = rightAscension; + *dec = declination; +} - - - - - - - - - - - - +/***************************************************************************** + * inline void CelestialBody::getPos(double* ra, double* dec, double* magnitude + * gives public acces to the current Right ascension, declination, and + * magnitude + ****************************************************************************/ +void CelestialBody::getPos(double* ra, double* dec, double* magn) +{ + *ra = rightAscension; + *dec = declination; + *magn = magnitude; +} diff --git a/simgear/ephemeris/celestialBody.hxx b/simgear/ephemeris/celestialBody.hxx index e477c65c..43b1d480 100644 --- a/simgear/ephemeris/celestialBody.hxx +++ b/simgear/ephemeris/celestialBody.hxx @@ -87,113 +87,6 @@ public: void updatePosition(double mjd, Star *ourSun); }; -/***************************************************************************** - * inline CelestialBody::CelestialBody - * public constructor for a generic celestialBody object. - * initializes the 6 primary orbital elements. The elements are: - * N: longitude of the ascending node - * i: inclination to the ecliptic - * w: argument of perihelion - * a: semi-major axis, or mean distance from the sun - * e: eccenticity - * M: mean anomaly - * Each orbital element consists of a constant part and a variable part that - * gradually changes over time. - * - * Argumetns: - * the 13 arguments to the constructor constitute the first, constant - * ([NiwaeM]f) and the second variable ([NiwaeM]s) part of the orbital - * elements. The 13th argument is the current time. Note that the inclination - * is written with a capital (If, Is), because 'if' is a reserved word in the - * C/C++ programming language. - ***************************************************************************/ -inline CelestialBody::CelestialBody(double Nf, double Ns, - double If, double Is, - double wf, double ws, - double af, double as, - double ef, double es, - double Mf, double Ms, double mjd) -{ - NFirst = Nf; NSec = Ns; - iFirst = If; iSec = Is; - wFirst = wf; wSec = ws; - aFirst = af; aSec = as; - eFirst = ef; eSec = es; - MFirst = Mf; MSec = Ms; - updateOrbElements(mjd); -} - -inline CelestialBody::CelestialBody(double Nf, double Ns, - double If, double Is, - double wf, double ws, - double af, double as, - double ef, double es, - double Mf, double Ms) -{ - NFirst = Nf; NSec = Ns; - iFirst = If; iSec = Is; - wFirst = wf; wSec = ws; - aFirst = af; aSec = as; - eFirst = ef; eSec = es; - MFirst = Mf; MSec = Ms; -} - -/**************************************************************************** - * inline void CelestialBody::updateOrbElements(double mjd) - * given the current time, this private member calculates the actual - * orbital elements - * - * Arguments: double mjd: the current modified julian date: - * - * return value: none - ***************************************************************************/ -inline void CelestialBody::updateOrbElements(double mjd) -{ - double actTime = sgCalcActTime(mjd); - M = SGD_DEGREES_TO_RADIANS * (MFirst + (MSec * actTime)); - w = SGD_DEGREES_TO_RADIANS * (wFirst + (wSec * actTime)); - N = SGD_DEGREES_TO_RADIANS * (NFirst + (NSec * actTime)); - i = SGD_DEGREES_TO_RADIANS * (iFirst + (iSec * actTime)); - e = eFirst + (eSec * actTime); - a = aFirst + (aSec * actTime); -} -/***************************************************************************** - * inline double CelestialBody::sgCalcActTime(double mjd) - * this private member function returns the offset in days from the epoch for - * wich the orbital elements are calculated (Jan, 1st, 2000). - * - * Argument: the current time - * - * return value: the (fractional) number of days until Jan 1, 2000. - ****************************************************************************/ -inline double CelestialBody::sgCalcActTime(double mjd) -{ - return (mjd - 36523.5); -} - -/***************************************************************************** - * inline void CelestialBody::getPos(double* ra, double* dec) - * gives public access to Right Ascension and declination - * - ****************************************************************************/ -inline void CelestialBody::getPos(double* ra, double* dec) -{ - *ra = rightAscension; - *dec = declination; -} - -/***************************************************************************** - * inline void CelestialBody::getPos(double* ra, double* dec, double* magnitude - * gives public acces to the current Right ascension, declination, and - * magnitude - ****************************************************************************/ -inline void CelestialBody::getPos(double* ra, double* dec, double* magn) -{ - *ra = rightAscension; - *dec = declination; - *magn = magnitude; -} - inline double CelestialBody::getRightAscension() { return rightAscension; } inline double CelestialBody::getDeclination() { return declination; } inline double CelestialBody::getMagnitude() { return magnitude; } @@ -210,14 +103,3 @@ inline double CelestialBody::getLat() #endif // _CELESTIALBODY_H_ - - - - - - - - - - - diff --git a/simgear/io/sg_socket.cxx b/simgear/io/sg_socket.cxx index 2d9d4eeb..43735428 100644 --- a/simgear/io/sg_socket.cxx +++ b/simgear/io/sg_socket.cxx @@ -160,7 +160,7 @@ SGSocket::SocketType SGSocket::make_client_socket () { // Wrapper functions -size_t SGSocket::readsocket( int fd, void *buf, size_t count ) { +int SGSocket::readsocket( int fd, void *buf, size_t count ) { #if defined(_MSC_VER) || defined(__MINGW32__) return ::recv( fd, (char *)buf, count, 0 ); #else @@ -168,7 +168,7 @@ size_t SGSocket::readsocket( int fd, void *buf, size_t count ) { #endif } -size_t SGSocket::writesocket( int fd, const void *buf, size_t count ) { +int SGSocket::writesocket( int fd, const void *buf, size_t count ) { #if defined(_MSC_VER) || defined(__MINGW32__) return ::send( fd, (const char*)buf, count, 0 ); #else diff --git a/simgear/io/sg_socket.hxx b/simgear/io/sg_socket.hxx index 9003c086..7c98257d 100644 --- a/simgear/io/sg_socket.hxx +++ b/simgear/io/sg_socket.hxx @@ -81,8 +81,8 @@ private: SocketType make_client_socket(); // wrapper functions - size_t readsocket( int fd, void *buf, size_t count ); - size_t writesocket( int fd, const void *buf, size_t count ); + int readsocket( int fd, void *buf, size_t count ); + int writesocket( int fd, const void *buf, size_t count ); #if !defined(_MSC_VER) && !defined(__MINGW32__) int closesocket(int fd); #endif diff --git a/simgear/misc/props.hxx b/simgear/misc/props.hxx index a5e8528b..6a0032f6 100644 --- a/simgear/misc/props.hxx +++ b/simgear/misc/props.hxx @@ -534,7 +534,7 @@ public: /** * Get the node's integer index. */ - const int getIndex () const { return _index; } + int getIndex () const { return _index; } /** @@ -557,7 +557,7 @@ public: /** * Get the number of child nodes. */ - const int nChildren () const { return _children.size(); } + int nChildren () const { return _children.size(); } /** diff --git a/simgear/sg_inlines.h b/simgear/sg_inlines.h index 89a8b9b8..8e4585d4 100644 --- a/simgear/sg_inlines.h +++ b/simgear/sg_inlines.h @@ -30,31 +30,31 @@ // return the sign of a value template -inline const int SG_SIGN(const T x) { +inline int SG_SIGN(const T x) { return x < T(0) ? -1 : 1; } // return the minimum of two values template -inline const T SG_MIN2(const T a, const T b) { +inline T SG_MIN2(const T a, const T b) { return a < b ? a : b; } // return the minimum of three values template -inline const T SG_MIN3( const T a, const T b, const T c) { +inline T SG_MIN3( const T a, const T b, const T c) { return (a < b ? SG_MIN2 (a, c) : SG_MIN2 (b, c)); } // return the maximum of two values template -inline const T SG_MAX2(const T a, const T b) { +inline T SG_MAX2(const T a, const T b) { return a > b ? a : b; } // return the maximum of three values template -inline const T SG_MAX3 (const T a, const T b, const T c) { +inline T SG_MAX3 (const T a, const T b, const T c) { return (a > b ? SG_MAX2 (a, c) : SG_MAX2 (b, c)); }