Hi all,

User reports on the forum and on the IRC channel indicate that there are still problems with the pilot list and MP chat.

I suspect that work around for the /ai/models/model-added listener problem (i.e. that the listener is called in the middle of the process of adding/removing a MP entry) isn't the right way to solve the problem.

The attached patch instead defer processing of the added/removed MP entries in the multiplayer Nasal module until the next time the Nasal subsystem is executed. This should prevent the problematic execution of the Nasal listener callback in the middle of C++ MP code.


Cheers,

Anders
--
---------------------------------------------------------------------------
Anders Gidenstam
WWW: http://www.gidenstam.org/FlightGear/
Index: multiplayer.nas
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Nasal/multiplayer.nas,v
retrieving revision 1.30
diff -u -p -r1.30 multiplayer.nas
--- multiplayer.nas	5 Sep 2009 20:22:14 -0000	1.30
+++ multiplayer.nas	9 Oct 2009 18:35:41 -0000
@@ -358,8 +358,16 @@ var model = {
         me.L = [];
         me.warned = {};
         me.fg_root = string.normpath(getprop("/sim/fg-root")) ~ '/';
-        append(me.L, setlistener("ai/models/model-added", func(n) me.update(n.getValue())));
-        append(me.L, setlistener("ai/models/model-removed", func(n) me.update(n.getValue())));
+        append(me.L, setlistener("ai/models/model-added", func(n) {
+            # Defer update() to the next convenient time to allow the
+            # new MP entry to become fully initialized.
+            settimer(func me.update(n.getValue()), 0);
+        }));
+        append(me.L, setlistener("ai/models/model-removed", func(n) {
+            # Defer update() to the next convenient time to allow the
+            # old MP entry to become fully deactivated.
+            settimer(func me.update(n.getValue()), 0);
+        }));
         me.update();
     },
     update: func(n = nil) {
@@ -367,18 +375,13 @@ var model = {
         if (n != nil and changedNode.getName() != "multiplayer")
             return;
 
-        var changedNodeIndex = changedNode != nil ? changedNode.getIndex() : -1;
-
         me.data = {};
         me.callsign = {};
         me.available = [];
         me.unavailable = [];
 
         foreach (var n; props.globals.getNode("ai/models", 1).getChildren("multiplayer")) {
-            # Ignore valid property for the newly added multiplayer aircraft.
-            # It is false when model-added is triggered and will become true after this
-            # listener is finished
-            if (n.getIndex() != changedNodeIndex and !n.getNode("valid", 1).getValue())
+            if (!n.getNode("valid").getValue())
                 continue;
 
             if ((var callsign = n.getNode("callsign")) == nil or !(callsign = callsign.getValue()))
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to