diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 8759b3a66..182c3e114 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -117,18 +117,22 @@ void FGAIBase::bind() { props->tie("id", SGRawValuePointer(&id)); props->tie("velocities/true-airspeed-kt", SGRawValuePointer(&speed)); props->tie("velocities/vertical-speed-fps", - SGRawValueFunctions(FGAIBase::_getVS_fps, - FGAIBase::_setVS_fps, this)); + SGRawValueMethods(*this, + FGAIBase::_getVS_fps, + FGAIBase::_setVS_fps)); props->tie("position/altitude-ft", - SGRawValueFunctions(FGAIBase::_getAltitude, - FGAIBase::_setAltitude, this)); + SGRawValueMethods(*this, + FGAIBase::_getAltitude, + FGAIBase::_setAltitude)); props->tie("position/latitude-deg", - SGRawValueFunctions(FGAIBase::_getLatitude, - FGAIBase::_setLatitude, this)); + SGRawValueMethods(*this, + FGAIBase::_getLatitude, + FGAIBase::_setLatitude)); props->tie("position/longitude-deg", - SGRawValueFunctions(FGAIBase::_getLongitude, - FGAIBase::_setLongitude, this)); + SGRawValueMethods(*this, + FGAIBase::_getLongitude, + FGAIBase::_setLongitude)); props->tie("orientation/pitch-deg", SGRawValuePointer(&pitch)); props->tie("orientation/roll-deg", SGRawValuePointer(&roll)); @@ -144,7 +148,7 @@ void FGAIBase::bind() { props->tie("radar/rotation", SGRawValuePointer(&rotation)); props->tie("controls/lighting/nav-lights", - SGRawValueFunctions(FGAIBase::_isNight)); + SGRawValueMethods(*this, _isNight)); props->setBoolValue("controls/lighting/beacon", true); props->setBoolValue("controls/lighting/strobe", true); } @@ -178,46 +182,37 @@ void FGAIBase::unbind() { /* * getters and Setters */ -void FGAIBase::_setLongitude( double longitude, void *p ) { - FGAIBase *self = (FGAIBase *)p; - self->pos.setlon(longitude); +void FGAIBase::_setLongitude( double longitude ) { + pos.setlon(longitude); } -void FGAIBase::_setLatitude ( double latitude, void *p ) { - FGAIBase *self = (FGAIBase *)p; - self->pos.setlat(latitude); +void FGAIBase::_setLatitude ( double latitude ) { + pos.setlat(latitude); } -double FGAIBase::_getLongitude(void *p) { - FGAIBase *self = (FGAIBase *)p; - return self->pos.lon(); +double FGAIBase::_getLongitude() const { + return pos.lon(); } -double FGAIBase::_getLatitude (void *p) { - FGAIBase *self = (FGAIBase *)p; - return self->pos.lat(); +double FGAIBase::_getLatitude () const { + return pos.lat(); } -double FGAIBase::_getRdot(void *p) { - FGAIBase *self = (FGAIBase *)p; - return self->rdot; +double FGAIBase::_getRdot() const { + return rdot; } -double FGAIBase::_getVS_fps(void *p) { - FGAIBase *self = (FGAIBase *)p; - return self->vs*60.0; +double FGAIBase::_getVS_fps() const { + return vs*60.0; } -void FGAIBase::_setVS_fps( double _vs, void *p ) { - FGAIBase *self = (FGAIBase *)p; - self->vs = _vs/60.0; +void FGAIBase::_setVS_fps( double _vs ) { + vs = _vs/60.0; } -double FGAIBase::_getAltitude(void *p) { - FGAIBase *self = (FGAIBase *)p; - return self->altitude; +double FGAIBase::_getAltitude() const { + return altitude; } -void FGAIBase::_setAltitude( double _alt, void *p ) { - FGAIBase *self = (FGAIBase *)p; - self->setAltitude( _alt ); +void FGAIBase::_setAltitude( double _alt ) { + setAltitude( _alt ); } -bool FGAIBase::_isNight() { +bool FGAIBase::_isNight() const { return (fgGetFloat("/sim/time/sun-angle-rad") > 1.57); } diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index cdca809f5..d418d9237 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -115,32 +115,30 @@ public: object_type getType(); bool isa( object_type otype ); - static double _getVS_fps(void *p); - static void _setVS_fps( double _vs, void *p ); + double _getVS_fps() const; + void _setVS_fps( double _vs ); - static double _getAltitude(void *p); - static void _setAltitude( double _alt, void *p ); + double _getAltitude() const; + void _setAltitude( double _alt ); - static void _setLongitude( double longitude, void *p ); - static void _setLatitude ( double latitude, void *p ); + void _setLongitude( double longitude ); + void _setLatitude ( double latitude ); - static double _getLongitude(void *p); - static double _getLatitude (void *p); + double _getLongitude() const; + double _getLatitude () const; + + double _getBearing() const; + double _getElevation() const; + double _getRdot() const; + double _getH_offset() const; + double _getV_offset() const; + double _getX_shift() const; + double _getY_shift() const; + double _getRotation() const; - static double _getBearing(void *p); - static double _getElevation(void *p); inline double _getRange() { return range; }; - static double _getRdot(void *p); - static double _getH_offset(void *p); - static double _getV_offset(void *p); - static double _getX_shift(void *p); - static double _getY_shift(void *p); - static double _getRotation(void *p); - static bool _isNight(); - -private: - FGAIBase *self; + bool _isNight() const; }; diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index dad75ddac..b53ac439b 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -217,7 +217,6 @@ int FGAIManager::createAircraft( string model_class, string path, double heading, double speed, double pitch, double roll ) { FGAIAircraft* ai_plane = new FGAIAircraft(this); -cout << "ai_plane: " << ai_plane << endl; ai_list.push_back(ai_plane); ai_plane->setID( assignID() ); ++numObjects; @@ -249,7 +248,6 @@ int FGAIManager::createAircraft( string model_class, string path, FGAIFlightPlan* flightplan ) { FGAIAircraft* ai_plane = new FGAIAircraft(this); -cout << "ai_plane1: " << ai_plane << endl; ai_list.push_back(ai_plane); ai_plane->setID( assignID() ); ++numObjects;