Hi!

Next incarnation :)

This time I have added a "valid" property to make it explicit which
entries are, duh, valid :)
I have moved the destruction administration for AI objects into the
AIManager, I think that's where it belongs (since the construction is
also there, and nobody else should know or influence that). For this
purpose I had to make the property node available, either by storing
in the AIManager, or (and this is what I did) by exposing it in
AIBase.
When an AI object dies the new "valid" property will be set to false.
Also I have added code setting 3 properties to sensible defaults so
that current a/c have a chance of working without modifications.

Additionally, this patch removes a chunk of the previous version that
accidentally made it into CVS.

Greets,
Csaba
Index: AIBase.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/AIModel/AIBase.cxx,v
retrieving revision 1.74
diff -u -r1.74 AIBase.cxx
--- AIBase.cxx  1 Apr 2007 12:39:20 -0000       1.74
+++ AIBase.cxx  4 Apr 2007 01:29:06 -0000
@@ -85,13 +85,7 @@
 
         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 +501,10 @@
     return serviceable;
 }
 
+SGPropertyNode* FGAIBase::_getProps() const {
+    return props;
+}
+
 void FGAIBase::_setAltitude( double _alt ) {
     setAltitude( _alt );
 }
Index: AIBase.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/AIModel/AIBase.hxx,v
retrieving revision 1.62
diff -u -r1.62 AIBase.hxx
--- AIBase.hxx  30 Mar 2007 22:51:52 -0000      1.62
+++ AIBase.hxx  4 Apr 2007 01:29:07 -0000
@@ -184,6 +184,7 @@
     double _get_speed_north_fps() const;
 
     bool   _getServiceable() const;
+    SGPropertyNode* _getProps() const;
 
     const char* _getPath();
     const char* _getCallsign();
Index: AIManager.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/AIModel/AIManager.cxx,v
retrieving revision 1.75
diff -u -r1.75 AIManager.cxx
--- AIManager.cxx       2 Apr 2007 12:47:26 -0000       1.75
+++ AIManager.cxx       4 Apr 2007 01:29:07 -0000
@@ -122,7 +122,17 @@
       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();
+
+      // HACK: try not to break too many things
+      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,7 +160,7 @@
       //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 || !p->getBoolValue("valid", false)) break;
     if (p->getIntValue("id",-1)==model->getID())
     {
         p->setStringValue("callsign","***invalid node***"); //debug only, 
should never set!
@@ -166,6 +176,7 @@
       || model->getType()==FGAIBase::otMultiplayer
       || model->getType()==FGAIBase::otStatic);
   model->bind();
+  p->setBoolValue("valid", true);
 }
 
 
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to