]> git.mxchange.org Git - flightgear.git/commitdiff
Bugfix: set life timer to 0 on instantiation and when ballistic object dies.
authorVivian Meazza <vivian.meazza@lineone.net>
Mon, 6 Jun 2011 08:32:00 +0000 (09:32 +0100)
committerVivian Meazza <vivian.meazza@lineone.net>
Mon, 6 Jun 2011 08:32:00 +0000 (09:32 +0100)
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
src/AIModel/AIBallistic.cxx

index d31e3b46d8c12382b41d73ee3ecbe3813e0793ea..b3e3bceb55090b0cc3578ca9376e272c2d5f3350 100644 (file)
@@ -143,6 +143,8 @@ bool FGAIBallistic::init(bool search_in_AI_path) {
 
     _elapsed_time += (sg_random() * 100);
 
+    _life_timer = 0;
+
     props->setStringValue("material/name", "");
     props->setStringValue("name", _name.c_str());
     props->setStringValue("submodels/path", _path.c_str());
@@ -152,6 +154,9 @@ bool FGAIBallistic::init(bool search_in_AI_path) {
         props->setStringValue("contents/path", _contents_path.c_str());
     }
 
+    //cout << "init: name " << _name.c_str() << " _life_timer " << _life_timer 
+    //    << endl;
+
     //if(_parent != ""){
     //    setParentNode();
     //}
@@ -330,7 +335,7 @@ void FGAIBallistic::setLife(double seconds) {
 
     if (_random){
         life = seconds * _randomness + (seconds * (1 -_randomness) * sg_random());
-        //cout << "life " << life << endl;
+        //cout << " set life " << life << endl;
     } else
         life = seconds;
 }
@@ -670,15 +675,23 @@ void FGAIBallistic::slaveToAC(double dt){
 
 void FGAIBallistic::Run(double dt) {
     _life_timer += dt;
+    
+    //_pass += 1;
+    //cout<<"AIBallistic run: name " << _name.c_str() 
+    //    << " dt " << dt <<  " _life_timer " << _life_timer << " pass " << _pass << endl;
 
     // if life = -1 the object does not die
     if (_life_timer > life && life != -1){
 
         if (_report_expiry && !_expiry_reported && !_impact_reported && !_collision_reported){
-            //cout<<"AIBallistic: expiry"<< endl;
+            //cout<<"AIBallistic run: name " << _name.c_str() << " expiry " << " pass " << _pass <<endl;
             handle_expiry();
-        } else
+        } else{
+            //cout<<"AIBallistic run: name " << _name.c_str() 
+            //    << " die " <<  " _life_timer " << _life_timer << " pass " << _pass << endl;
             setDie(true);
+            setTime(0);
+        }
 
     }
 
@@ -1010,7 +1023,7 @@ void FGAIBallistic::report_impact(double elevation, const FGAIBase *object)
         n->setStringValue("type", "terrain");
 
     SG_LOG(SG_GENERAL, SG_DEBUG, "AIBallistic: object impact " << _name 
-        << " lon " <<_impact_lon << " lat " <<_impact_lat);
+        << " lon " <<_impact_lon << " lat " <<_impact_lat << " sec " << _life_timer);
 
     n->setDoubleValue("longitude-deg", _impact_lon);
     n->setDoubleValue("latitude-deg", _impact_lat);