updates for 0.9.4
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / BodyTube.java
index d3368f1f1365e97eed4e8032db0dc57974631589..05ee9eed92ec9e0aa8b77137fd1343f955c2b70c 100644 (file)
@@ -290,11 +290,26 @@ public class BodyTube extends SymmetricComponent implements MotorMount {
        
        @Override
        public Motor getMotor(String id) {
+               if (id == null)
+                       return null;
+               
+               // Check whether the id is valid for the current rocket
+               RocketComponent root = this.getRoot();
+               if (!(root instanceof Rocket))
+                       return null;
+               if (!((Rocket) root).isMotorConfigurationID(id))
+                       return null;
+               
                return motors.get(id);
        }
 
        @Override
        public void setMotor(String id, Motor motor) {
+               if (id == null) {
+                       if (motor != null) {
+                               throw new IllegalArgumentException("Cannot set non-null motor for id null");
+                       }
+               }
                Motor current = motors.get(id);
                if ((motor == null && current == null) ||
                                (motor != null && motor.equals(current)))