Make sure the pointer is not being used after deletion, and tie the elapsed time to the particular class instance.
This commit is contained in:
parent
9e72a38165
commit
c542be5330
3 changed files with 19 additions and 10 deletions
|
@ -51,7 +51,9 @@ bool FGAIBallistic::init() {
|
||||||
|
|
||||||
void FGAIBallistic::bind() {
|
void FGAIBallistic::bind() {
|
||||||
// FGAIBase::bind();
|
// FGAIBase::bind();
|
||||||
props->tie("sim/time/elapsed-sec", SGRawValuePointer<double>(&(this->life_timer)));
|
props->tie("sim/time/elapsed-sec",
|
||||||
|
SGRawValueMethods<FGAIBallistic,double>(*this,
|
||||||
|
&FGAIBallistic::_getTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAIBallistic::unbind() {
|
void FGAIBallistic::unbind() {
|
||||||
|
@ -163,3 +165,8 @@ void FGAIBallistic::Run(double dt) {
|
||||||
if (altitude < -1000.0) setDie(true);
|
if (altitude < -1000.0) setDie(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double FGAIBallistic::_getTime() const {
|
||||||
|
return life_timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ public:
|
||||||
void setWind_from_north( double fps );
|
void setWind_from_north( double fps );
|
||||||
void setWind( bool val );
|
void setWind( bool val );
|
||||||
|
|
||||||
|
double _getTime() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
double azimuth; // degrees true
|
double azimuth; // degrees true
|
||||||
|
|
|
@ -95,9 +95,9 @@ void FGAIManager::update(double dt) {
|
||||||
ai_list_itr = ai_list.begin();
|
ai_list_itr = ai_list.begin();
|
||||||
while(ai_list_itr != ai_list.end()) {
|
while(ai_list_itr != ai_list.end()) {
|
||||||
if ((*ai_list_itr)->getDie()) {
|
if ((*ai_list_itr)->getDie()) {
|
||||||
delete (*ai_list_itr);
|
|
||||||
--numObjects[(*ai_list_itr)->getType()];
|
--numObjects[(*ai_list_itr)->getType()];
|
||||||
--numObjects[0];
|
--numObjects[0];
|
||||||
|
delete (*ai_list_itr);
|
||||||
if ( ai_list_itr == ai_list.begin() ) {
|
if ( ai_list_itr == ai_list.begin() ) {
|
||||||
ai_list.erase(ai_list_itr);
|
ai_list.erase(ai_list_itr);
|
||||||
ai_list_itr = ai_list.begin();
|
ai_list_itr = ai_list.begin();
|
||||||
|
|
Loading…
Add table
Reference in a new issue