]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIShip.cxx
Make the vertical acceleration rate scale with vertical performance. The
[flightgear.git] / src / AIModel / AIShip.cxx
index eecbd0e8f13b11527d0eee50cfa459df2b136b97..2c8e3993f3f85193319532712d036a444045c6f5 100644 (file)
@@ -15,7 +15,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #include <simgear/math/point3d.hxx>
 #include <math.h>
 
+#include "AIFlightPlan.hxx"
 #include "AIShip.hxx"
 
 
-FGAIShip::FGAIShip(FGAIManager* mgr) {
-   manager = mgr;
-   _type_str = "ship";
-   _otype = otShip;
-
+FGAIShip::FGAIShip(object_type ot) : FGAIBase(ot) {
 }
 
 FGAIShip::~FGAIShip() {
 }
 
+void FGAIShip::readFromScenario(SGPropertyNode* scFileNode) {
+  if (!scFileNode)
+    return;
+
+  FGAIBase::readFromScenario(scFileNode);
+
+  setRudder(scFileNode->getFloatValue("rudder", 0.0));
+  setName(scFileNode->getStringValue("name", "Titanic"));
+  
+  std::string flightplan = scFileNode->getStringValue("flightplan");
+  if (!flightplan.empty()){
+    FGAIFlightPlan* fp = new FGAIFlightPlan(flightplan);
+    setFlightPlan(fp);
+  }
+}
 
 bool FGAIShip::init() {
    
@@ -123,12 +135,12 @@ void FGAIShip::Run(double dt) {
                           * speed * 1.686 / ft_per_deg_lon;
 
    // set new position
-   pos.setlat( pos.lat() + speed_north_deg_sec * dt);
-   pos.setlon( pos.lon() + speed_east_deg_sec * dt); 
+   pos.setLatitudeDeg( pos.getLatitudeDeg() + speed_north_deg_sec * dt);
+   pos.setLongitudeDeg( pos.getLongitudeDeg() + speed_east_deg_sec * dt); 
 
    
    // adjust heading based on current rudder angle
-   if (rudder <= -0.25 or rudder >= 0.25)  {
+   if (rudder <= -0.25 || rudder >= 0.25)  {
    /*  turn_radius_ft = 0.088362 * speed * speed
                        / tan( fabs(rudder) / SG_RADIANS_TO_DEGREES );
      turn_circum_ft = SGD_2PI * turn_radius_ft;
@@ -174,8 +186,8 @@ void FGAIShip::Run(double dt) {
     //low pass filter
      roll = (raw_roll * roll_constant) + (roll * (1 - roll_constant));
          
-     cout  << " rudder: " << rudder << " raw roll: "<< raw_roll<<" roll: " << roll ;
-     cout  << " hdg: " << hdg << endl ;
+     /*cout  << " rudder: " << rudder << " raw roll: "<< raw_roll<<" roll: " << roll ;
+     cout  << " hdg: " << hdg << endl ;*/
 
    // adjust target rudder angle if heading lock engaged
    if (hdg_lock) {