]> git.mxchange.org Git - flightgear.git/commitdiff
Csaba "Jester" HALASZ: radar fix & extension
authormfranz <mfranz>
Wed, 4 Apr 2007 09:51:41 +0000 (09:51 +0000)
committermfranz <mfranz>
Wed, 4 Apr 2007 09:51:41 +0000 (09:51 +0000)
- fix breakage due to former commit (AIManager.cxx, r1.72)
- make AI properties available in AIBase
- add <valid> property for animations/nasal scripts
- support more MP and AI targets
- add target select and altitude display

src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIManager.cxx

index 862c78f8085d68ab5013ef6cb516f73446126eee..12214e4db6c10db0b516ad3f2ec2cc20da32c956 100644 (file)
@@ -83,15 +83,8 @@ FGAIBase::~FGAIBase() {
     if (props) {
         SGPropertyNode* parent = props->getParent();
 
-        if (parent) {
+        if (parent)
             model_removed->setStringValue(props->getPath());
-            parent->removeChild(props->getName(), props->getIndex(), false);
-        }
-
-        // so that radar does not have to do extra checks
-        props->setBoolValue("radar/in-range", false);
-        props->removeChild("id", 0);
-
     }
     delete fp;
     fp = 0;
@@ -507,6 +500,10 @@ bool FGAIBase::_getServiceable() const {
     return serviceable;
 }
 
+SGPropertyNode* FGAIBase::_getProps() const {
+    return props;
+}
+
 void FGAIBase::_setAltitude( double _alt ) {
     setAltitude( _alt );
 }
index 2d68fa94de339e44ee8dca969ed51d91faaf5c0c..0d99103d120cdc210f3cb70da5f31f6c71582104 100644 (file)
@@ -184,6 +184,7 @@ public:
     double _get_speed_north_fps() const;
 
     bool   _getServiceable() const;
+    SGPropertyNode* _getProps() const;
 
     const char* _getPath();
     const char* _getCallsign();
index 0351e83422a1261df5d7f2b375bc25765206ead2..e1dce1a04d5e1109ab8992f2daac5929d64c98d7 100644 (file)
@@ -122,7 +122,19 @@ void FGAIManager::update(double dt) {
       tmgr->release((*ai_list_itr)->getID());
       --mNumAiModels;
       --(mNumAiTypeModels[(*ai_list_itr)->getType()]);
-      (*ai_list_itr)->unbind();
+      FGAIBase *base = *ai_list_itr;
+      SGPropertyNode *props = base->_getProps();
+
+      props->setBoolValue("valid", false);
+      base->unbind();
+
+      // for backward compatibility reset properties, so that aircraft,
+      // which don't know the <valid> property, keep working
+      // TODO: remove after a while
+      props->setIntValue("id", -1);
+      props->setBoolValue("radar/in-range", false);
+      props->setIntValue("refuel/tanker", false);
+
       ai_list_itr = ai_list.erase(ai_list_itr);
     } else {
       fetchUserState();
@@ -150,11 +162,10 @@ FGAIManager::attach(SGSharedPtr<FGAIBase> model)
       //more than 10000 mp-aircrafts in the property tree we should optimize the mp-server
   {
     p = root->getNode(typeString, i, false);
-    if (!p) break;
-    if (p->getIntValue("id",-1)==model->getID())
-    {
+    if (!p || !p->getBoolValue("valid", false))
+      break;
+    if (p->getIntValue("id",-1)==model->getID()) {
         p->setStringValue("callsign","***invalid node***"); //debug only, should never set!
-                                              
     }
   }
   p = root->getNode(typeString, i, true);
@@ -166,6 +177,7 @@ FGAIManager::attach(SGSharedPtr<FGAIBase> model)
       || model->getType()==FGAIBase::otMultiplayer
       || model->getType()==FGAIBase::otStatic);
   model->bind();
+  p->setBoolValue("valid", true);
 }