]> git.mxchange.org Git - flightgear.git/commitdiff
Remove debugging statement.
authorVivian Meazza <vivian.meazza@lineone.net>
Thu, 9 Sep 2010 20:38:49 +0000 (21:38 +0100)
committerAnders Gidenstam <anders@gidenstam.org>
Fri, 17 Sep 2010 19:44:58 +0000 (21:44 +0200)
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
src/AIModel/AIBallistic.cxx
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIEscort.cxx
src/AIModel/AIEscort.hxx
src/AIModel/AIGroundVehicle.cxx
src/AIModel/AIGroundVehicle.hxx
src/AIModel/AIShip.cxx

index 1ea0e89b51c243f45c29cda0ffa680c16c732bcc..5446a5d35e32c3e30cf2292e38ceabecdc3c4dc5 100644 (file)
@@ -157,6 +157,7 @@ bool FGAIBallistic::init(bool search_in_AI_path) {
     }
 
     setParentNodes(_selected_ac);
+
     //props->setStringValue("vector/path", _vector_path.c_str());
 
     // start with high value so that animations don't trigger yet
index 6f576078cac6cc7087d60ae7a45c71d5847ed784..8681bc1b10ac5d6684701d707d5b104246277d91 100644 (file)
@@ -533,8 +533,13 @@ void FGAIBase::_setSubID( int s ) {
     _subID = s;
 }
 
-void FGAIBase::setParentNode() {
-//    cout << "AIBase: setParentNode " << _parent << endl;
+bool FGAIBase::setParentNode() {
+
+    if (_parent == ""){
+       SG_LOG(SG_GENERAL, SG_ALERT, "AIBase: " << _name
+            << " parent not set ");
+       return false;
+    }
 
     const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
 
@@ -564,15 +569,16 @@ void FGAIBase::setParentNode() {
 
     if (_selected_ac != 0){
         const string name = _selected_ac->getStringValue("name");
-        //setParent();
-
+        return true;
     } else {
-        SG_LOG(SG_GENERAL, SG_ALERT, "AIEscort: " << _name
+        SG_LOG(SG_GENERAL, SG_ALERT, "AIBase: " << _name
             << " parent not found: dying ");
         setDie(true);
+        return false;
     }
 
 }
+
 double FGAIBase::_getLongitude() const {
     return pos.getLongitudeDeg();
 }
index 3d756254a21767244afb99f4f3715aaf929cd836..c1a533bed0ea0667d0f05dd14080e8b93c8603be 100644 (file)
@@ -86,7 +86,7 @@ public:
     void setImpactLon( double lon );
     void setImpactElev( double e );
     void setParentName(const string& p);
-    void setParentNode();
+    bool setParentNode();
 
     int getID() const;
     int _getSubID() const;
index a59a07c9520587d26c447f2a37855cb2f16cac33..255524cc797222022543d6b09de79d996ad677fb 100644 (file)
@@ -140,12 +140,13 @@ bool FGAIEscort::init(bool search_in_AI_path) {
     no_roll = false;
 
     props->setStringValue("controls/parent-name", _parent.c_str());
-    setParentNode();
-    setParent();
 
-    pos = _tgtpos;
-    speed = _parent_speed;
-    hdg = _parent_hdg;
+    if (setParentNode()){
+        setParent();
+        pos = _tgtpos;
+        speed = _parent_speed;
+        hdg = _parent_hdg;
+    }
 
     return true;
 }
index 235b81c395e529b0e7dfde6de8c892ceaf66807a..e492d830e0d4f5706fbd20a4c7d11b8fc508d5cf 100644 (file)
@@ -102,4 +102,3 @@ private:
 };
 
 #endif  // FG_AIGROUNDVEHICLE_HXX
-
index 3facbaf68ffbe82bc8b8d1b34864887d08689775..1303b60e05a00f05358de345fe22ee24adae6047 100644 (file)
@@ -37,7 +37,6 @@ FGAIShip(otGroundVehicle),
 _pitch(0),
 _pitch_deg(0),
 _speed_kt(0),
-_selected_ac(0),
 _range_ft(0),
 _relbrg (0),
 _parent_speed(0),
@@ -50,6 +49,7 @@ _break_count(0)
 
 {
     invisible = false;
+    _parent = "";
 }
 
 FGAIGroundVehicle::~FGAIGroundVehicle() {}
@@ -149,7 +149,19 @@ bool FGAIGroundVehicle::init(bool search_in_AI_path) {
     no_roll = true;
 
     props->setStringValue("controls/parent-name", _parent.c_str());
-    setParentNode();
+
+    if (setParentNode()){
+        _parent_x_offset = _selected_ac->getDoubleValue("hitch/x-offset-ft");
+        _parent_y_offset = _selected_ac->getDoubleValue("hitch/y-offset-ft");
+        _parent_z_offset = _selected_ac->getDoubleValue("hitch/z-offset-ft");
+        _hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft")
+            * SG_FEET_TO_METER;
+        _hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft")
+            * SG_FEET_TO_METER;
+        _hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft")
+            * SG_FEET_TO_METER;
+        setParent();
+    }
 
     return true;
 }
@@ -344,56 +356,56 @@ bool FGAIGroundVehicle::getPitch() {
     return true;
 }
 
-void FGAIGroundVehicle::setParentNode() {
-
-    if(_parent == "")
-        return;
-
-    const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
-
-    for (int i = ai->nChildren() - 1; i >= -1; i--) {
-        SGPropertyNode_ptr model;
-
-        if (i < 0) { // last iteration: selected model
-            model = _selected_ac;
-        } else {
-            model = ai->getChild(i);
-            string path = ai->getPath();
-            const string name = model->getStringValue("name");
-
-            if (!model->nChildren()){
-                continue;
-            }
-            if (name == _parent) {
-                _selected_ac = model;  // save selected model for last iteration
-                break;
-            }
-
-        }
-        if (!model)
-            continue;
-
-    }// end for loop
-
-    if (_selected_ac != 0){
-        const string name = _selected_ac->getStringValue("name");
-        _parent_x_offset = _selected_ac->getDoubleValue("hitch/x-offset-ft");
-        _parent_y_offset = _selected_ac->getDoubleValue("hitch/y-offset-ft");
-        _parent_z_offset = _selected_ac->getDoubleValue("hitch/z-offset-ft");
-        _hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft")
-            * SG_FEET_TO_METER;
-        _hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft")
-            * SG_FEET_TO_METER;
-        _hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft")
-            * SG_FEET_TO_METER;
-        setParent();
-    } else {
-        SG_LOG(SG_GENERAL, SG_ALERT, "AIGroundVeh1cle: " << _name
-                << " parent not found: dying ");
-        setDie(true);
-    }
-
-}
+//void FGAIGroundVehicle::setParentNode() {
+//
+//    if(_parent == "")
+//        return;
+//
+//    const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
+//
+//    for (int i = ai->nChildren() - 1; i >= -1; i--) {
+//        SGPropertyNode_ptr model;
+//
+//        if (i < 0) { // last iteration: selected model
+//            model = _selected_ac;
+//        } else {
+//            model = ai->getChild(i);
+//            string path = ai->getPath();
+//            const string name = model->getStringValue("name");
+//
+//            if (!model->nChildren()){
+//                continue;
+//            }
+//            if (name == _parent) {
+//                _selected_ac = model;  // save selected model for last iteration
+//                break;
+//            }
+//
+//        }
+//        if (!model)
+//            continue;
+//
+//    }// end for loop
+//
+//    if (_selected_ac != 0){
+//        const string name = _selected_ac->getStringValue("name");
+//        //_parent_x_offset = _selected_ac->getDoubleValue("hitch/x-offset-ft");
+//        //_parent_y_offset = _selected_ac->getDoubleValue("hitch/y-offset-ft");
+//        //_parent_z_offset = _selected_ac->getDoubleValue("hitch/z-offset-ft");
+//        //_hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft")
+//        //    * SG_FEET_TO_METER;
+//        //_hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft")
+//        //    * SG_FEET_TO_METER;
+//        //_hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft")
+//        //    * SG_FEET_TO_METER;
+//        //setParent();
+//    } else {
+//        SG_LOG(SG_GENERAL, SG_ALERT, "AIGroundVeh1cle: " << _name
+//                << " parent not found: dying ");
+//        setDie(true);
+//    }
+//
+//}
 
 void FGAIGroundVehicle::setParent(){
 
index 4f0519c188a8764dc001e5c674fe9bbcc695eaa4..05b1d505b7fbf9c1cd35f8ffa9ef3efa2d7606aa 100644 (file)
@@ -62,10 +62,8 @@ private:
     void setElevation(double _elevation, double dt, double _elevation_coeff);
     void setPitch(double _pitch, double dt, double _pitch_coeff);
     void setTowAngle(double _relbrg, double dt, double _towangle_coeff);
-//    void setParentName(const string& p);
     void setTrainSpeed(double s, double dt, double coeff);
     void setParent();
-    void setParentNode();
     void AdvanceFP();
     void setTowSpeed();
     void RunGroundVehicle(double dt);
@@ -98,9 +96,6 @@ private:
     double _dt_count, _next_run, _break_count;
 
     const SGMaterial* _material;
-    SGPropertyNode_ptr _selected_ac;
-
-//    string _parent;
 
 };
 
index b27b21d965dff8fd484489a362e05a9b6926b5b8..a00f9c941a9e5a99346ba639c14cf349cb2f4dfd 100644 (file)
@@ -70,7 +70,8 @@ _range_rate(0),
 _roll_constant(0.001),
 _hdg_constant(0.01),
 _roll_factor(-0.0083335),
-_restart(false)
+_restart(false),
+_name("")
 
 {
         invisible = false;