]> git.mxchange.org Git - flightgear.git/commitdiff
Tie the count into the property tree instead of using snprintf every frame. Add the...
authorehofman <ehofman>
Mon, 30 Aug 2004 11:13:29 +0000 (11:13 +0000)
committerehofman <ehofman>
Mon, 30 Aug 2004 11:13:29 +0000 (11:13 +0000)
src/AIModel/AIBallistic.cxx
src/Systems/submodel.cxx
src/Systems/submodel.hxx

index e06bf9f4b9b858260c0f3368571e279436a98b1a..b6675ff05eb740c5db6c571af00328e36747b13d 100644 (file)
@@ -49,10 +49,12 @@ bool FGAIBallistic::init() {
 
 void FGAIBallistic::bind() {
 //    FGAIBase::bind();
+   props->tie("sim/time/elapsed-sec", SGRawValuePointer<double>(&life_timer));
 }
 
 void FGAIBallistic::unbind() {
 //    FGAIBase::unbind();
+   props->untie("sim/time/elapsed-sec");
 }
 
 void FGAIBallistic::update(double dt) {
index 94e3ad76c79b20da824202a21bf302b0f974890e..e87ef0e2395c318bf6e8e434b4795471936e253d 100644 (file)
@@ -53,6 +53,11 @@ SubmodelSystem::bind ()
 void
 SubmodelSystem::unbind ()
 {
+  submodel_iterator = submodels.begin();
+  while(submodel_iterator != submodels.end()) {
+    (*submodel_iterator)->prop->untie("count");
+    ++submodel_iterator;
+  }
 }
 
 void
@@ -66,10 +71,6 @@ SubmodelSystem::update (double dt)
     if ((*submodel_iterator)->trigger->getBoolValue()) {
         if ((*submodel_iterator)->count != 0) {
           release( (*submodel_iterator), dt);
-         // now update the "count" property for this submodel
-         char name[80];
-         snprintf(name, 80, "/systems/submodels/submodel[%d]/count", i);  
-         fgSetInt(name, (*submodel_iterator)->count);
         } 
     } 
     ++submodel_iterator;
@@ -119,8 +120,8 @@ SubmodelSystem::load ()
    int count = root.nChildren();
    for (i = 0; i < count; i++) { 
      // cout << "Reading submodel " << i << endl;        
+     SGPropertyNode *prop;
      submodel* sm = new submodel;
-     submodels.push_back( sm );
      SGPropertyNode * entry_node = root.getChild(i);
      sm->trigger        = fgGetNode(entry_node->getStringValue("trigger", "none"), true);
      sm->name           = entry_node->getStringValue("name", "none_defined");
@@ -141,9 +142,10 @@ SubmodelSystem::load ()
      sm->trigger->setBoolValue(false);
      sm->timer = sm->delay;
 
-     char name[80];
-     snprintf(name, 80, "/systems/submodels/submodel[%d]/count", i);  
-     fgSetInt(name, sm->count);
+     sm->prop = fgGetNode("/systems/submodels/submodel", i, true);
+     sm->prop->tie("count", SGRawValuePointer<int>(&(sm->count)));
+
+     submodels.push_back( sm );
    }
 
   submodel_iterator = submodels.begin();
index f088173a0b79816904ee85ecfd32ecd19587c3df..5c5b2046a5ccc23afaf711e295fe00bc334c1b44 100644 (file)
@@ -27,6 +27,7 @@ public:
 
  typedef struct {
   SGPropertyNode_ptr trigger;
+  SGPropertyNode_ptr prop;
   string             name;
   string             model;
   double             speed;