]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIShip.cxx
Fix line endings
[flightgear.git] / src / AIModel / AIShip.cxx
index eecbd0e8f13b11527d0eee50cfa459df2b136b97..a781822ce272e97762c35f473a02cc3a9bc7dd95 100644 (file)
 #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() {
    
@@ -128,7 +140,7 @@ void FGAIShip::Run(double 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) {