Dear Vivian, Ron and other interested parties ;)

Attached you will find the revised radar patch (still against the
original CVS copy)
Release notes:
1) SGPropertyNode::getIntValue(const char*, int) and company only
return the default value for not-existent nodes. For an existing node
of type SGPropertyNode::NONE they will happily return 0. This is why
the check that I used in the previous patch did not always work.
Rather than changing this behaviour (which could break who-knows-what)
I have just rewritten the check in my patch.

2) As to why the KC135 is different from the T38 (or rather the other
way around). Look in aar.nas and you will find that it iterates over
all models and checks the id node to see if it is valid. Unfortunately
this will create the missing id node with type "none", leading to the
problem above. Also note that the various switches under
/instrumentation/radar (especially mode-control) must be set properly
in order to get anything displayed. Funnily enough, this does not
occur with the T38 because the aar code there is broken. There is
supposed to be a common aar.nas somewhere to replace it. But that's
another story.

3) I have changed the AIBase destructor to just delete the id rather
than the node. (I'd rather set the type to "none" but couldn't figure
out how to do that). This way existing bindings will not be lost and
the AIManager will re-use these nodes. As a convenience, I also set
the radar/in-range property to false, so that radar does not have to
do an extra check on the id.

4) As noted above, aar.nas already uses a check on the id as a means
to establish the validity of a model. Presumably it is done this way
in other places as well. So I have given up my plan to add a "valid"
property for this purpose.

5) The xml files are unchanged.

Comments and testing welcome.

Greets,
Csaba
Index: AIBase.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/AIModel/AIBase.cxx,v
retrieving revision 1.72
diff -u -b -w -r1.72 AIBase.cxx
--- AIBase.cxx  13 Jan 2007 09:04:07 -0000      1.72
+++ AIBase.cxx  27 Mar 2007 02:34:46 -0000
@@ -77,11 +77,10 @@
         
globals->get_scenery()->get_scene_graph()->removeChild(aip.getSceneGraph());
     }
     if (props) {
-        SGPropertyNode* parent = props->getParent();
-        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;
Index: AIManager.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/AIModel/AIManager.cxx,v
retrieving revision 1.73
diff -u -b -w -r1.73 AIManager.cxx
--- AIManager.cxx       26 Feb 2007 11:47:05 -0000      1.73
+++ AIManager.cxx       27 Mar 2007 02:34:46 -0000
@@ -149,10 +149,11 @@
   {
     p = root->getNode(typeString, i, false);
     if (!p) break;
-    if (p->getIntValue("id",-1)==model->getID())
+    const SGPropertyNode* id_node = p->getNode("id");
+    if (!id_node || id_node->getType() == SGPropertyNode::NONE) break;
+    if (id_node->getIntValue() == model->getID())
     {
         p->setStringValue("callsign","***invalid node***"); //debug only, 
should never set!
-                                              
     }
   }
   p = root->getNode(typeString, i, 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
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to