language selector, bug fixed
[debian/openrocket] / src / net / sf / openrocket / file / motor / RockSimMotorLoader.java
index 2e156f2d79ecf543b698d6abed714d34d1d88542..d2bbcd265e0e83ec29d436a635716b4029f86fc8 100644 (file)
@@ -8,29 +8,32 @@ import java.util.HashMap;
 import java.util.List;
 
 import net.sf.openrocket.aerodynamics.WarningSet;
-import net.sf.openrocket.file.MotorLoader;
 import net.sf.openrocket.file.simplesax.ElementHandler;
 import net.sf.openrocket.file.simplesax.NullElementHandler;
 import net.sf.openrocket.file.simplesax.PlainTextHandler;
 import net.sf.openrocket.file.simplesax.SimpleSAX;
+import net.sf.openrocket.logging.LogHelper;
 import net.sf.openrocket.motor.Manufacturer;
 import net.sf.openrocket.motor.Motor;
 import net.sf.openrocket.motor.MotorDigest;
-import net.sf.openrocket.motor.ThrustCurveMotor;
 import net.sf.openrocket.motor.MotorDigest.DataType;
+import net.sf.openrocket.motor.ThrustCurveMotor;
+import net.sf.openrocket.startup.Application;
 import net.sf.openrocket.util.Coordinate;
 
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
-public class RockSimMotorLoader extends MotorLoader {
+public class RockSimMotorLoader extends AbstractMotorLoader {
+       
+       private static final LogHelper log = Application.getLogger();
        
        public static final String CHARSET_NAME = "UTF-8";
        
        public static final Charset CHARSET = Charset.forName(CHARSET_NAME);
        
 
-       /** Any delay longed than this will be interpreted as a plugged motor. */
+       /** Any delay longer than this will be interpreted as a plugged motor. */
        private static final int DELAY_LIMIT = 90;
        
        
@@ -363,8 +366,20 @@ public class RockSimMotorLoader extends MotorLoader {
                        
 
                        try {
-                               return new ThrustCurveMotor(Manufacturer.getManufacturer(manufacturer),
-                                               designation, description, type,
+                               Manufacturer m = Manufacturer.getManufacturer(manufacturer);
+                               Motor.Type t = type;
+                               if (t == Motor.Type.UNKNOWN) {
+                                       t = m.getMotorType();
+                               } else {
+                                       if (m.getMotorType() != Motor.Type.UNKNOWN && m.getMotorType() != t) {
+                                               log.warn("Loaded motor type inconsistent with manufacturer," +
+                                                               " loaded type=" + t + " manufacturer=" + m +
+                                                               " manufacturer type=" + m.getMotorType() +
+                                                               " designation=" + designation);
+                                       }
+                               }
+                               
+                               return new ThrustCurveMotor(m, designation, description, t,
                                                delays, diameter, length, timeArray, thrustArray, cgArray);
                        } catch (IllegalArgumentException e) {
                                throw new SAXException("Illegal motor data", e);