diff --git a/megamek/src/megamek/client/commands/MoveCommand.java b/megamek/src/megamek/client/commands/MoveCommand.java index df4084ffbef..9f083861b55 100644 --- a/megamek/src/megamek/client/commands/MoveCommand.java +++ b/megamek/src/megamek/client/commands/MoveCommand.java @@ -16,10 +16,7 @@ import megamek.client.Client; import megamek.client.ui.swing.MovementDisplay; -import megamek.common.Coords; -import megamek.common.Entity; -import megamek.common.EntityMovementMode; -import megamek.common.MovePath; +import megamek.common.*; import megamek.common.MovePath.MoveStepType; import megamek.common.options.OptionsConstants; @@ -164,7 +161,7 @@ public String run(String[] args) { private void currentMove(Coords dest) { if (dest != null) { if (gear == GEAR_TURN) { - cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), false); + cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), false, ManeuverType.MAN_NONE); } else if (gear == GEAR_LAND || gear == GEAR_JUMP) { cmd.findPathTo(dest, MoveStepType.FORWARDS); } else if (gear == GEAR_BACKUP) { diff --git a/megamek/src/megamek/client/ui/swing/MovementDisplay.java b/megamek/src/megamek/client/ui/swing/MovementDisplay.java index 1d047c751d0..71ba509c442 100644 --- a/megamek/src/megamek/client/ui/swing/MovementDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MovementDisplay.java @@ -987,14 +987,14 @@ private void addStepToMovePath(MoveStepType moveStep, boolean noCost) { updateMove(); } - private void addStepToMovePath(MoveStepType moveStep, boolean noCost, boolean isManeuver) { - cmd.addStep(moveStep, noCost, isManeuver); + private void addStepToMovePath(MoveStepType moveStep, boolean noCost, boolean isManeuver, int maneuverType) { + cmd.addStep(moveStep, noCost, isManeuver, maneuverType); updateMove(); } - private void addStepsToMovePath(boolean noCost, boolean isManeuver, MoveStepType ... moveSteps) { + private void addStepsToMovePath(boolean noCost, boolean isManeuver, int maneuverType, MoveStepType ... moveSteps) { for (MoveStepType moveStep : moveSteps) { - cmd.addStep(moveStep, noCost, isManeuver); + cmd.addStep(moveStep, noCost, isManeuver, maneuverType); } updateMove(); } @@ -1747,7 +1747,7 @@ private synchronized Entity ce() { */ private void currentMove(Coords dest) { if (shiftheld || (gear == GEAR_TURN)) { - cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), false); + cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), false, ManeuverType.MAN_NONE); } else if ((gear == GEAR_JUMP) && (ce().getJumpType() == Mech.JUMP_BOOSTER)) { // Jumps with mechanical jump boosters are special @@ -1836,19 +1836,19 @@ private void currentMove(Coords dest) { } else if (gear == GEAR_RAM) { cmd.findPathTo(dest, MoveStepType.FORWARDS); } else if (gear == GEAR_IMMEL) { - addStepsToMovePath(true, true, + addStepsToMovePath(true, true, ManeuverType.MAN_IMMELMAN, MoveStepType.UP, MoveStepType.UP, MoveStepType.DEC, MoveStepType.DEC); - cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), true); + cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), true, ManeuverType.MAN_IMMELMAN); gear = GEAR_LAND; } else if (gear == GEAR_SPLIT_S) { - addStepsToMovePath(true, true, + addStepsToMovePath(true, true, ManeuverType.MAN_SPLIT_S, MoveStepType.DOWN, MoveStepType.DOWN, MoveStepType.ACC); - cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), true); + cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), true, ManeuverType.MAN_SPLIT_S); gear = GEAR_LAND; } if (gear == GEAR_LONGEST_WALK || gear == GEAR_LONGEST_RUN) { @@ -4244,13 +4244,13 @@ private boolean addManeuver(int type) { cmd.addManeuver(type); switch (type) { case ManeuverType.MAN_HAMMERHEAD: - addStepToMovePath(MoveStepType.YAW, true, true); + addStepToMovePath(MoveStepType.YAW, true, true, type); return true; case ManeuverType.MAN_HALF_ROLL: - addStepToMovePath(MoveStepType.ROLL, true, true); + addStepToMovePath(MoveStepType.ROLL, true, true, type); return true; case ManeuverType.MAN_BARREL_ROLL: - addStepToMovePath(MoveStepType.DEC, true, true); + addStepToMovePath(MoveStepType.DEC, true, true, type); return true; case ManeuverType.MAN_IMMELMAN: gear = MovementDisplay.GEAR_IMMEL; @@ -4269,7 +4269,7 @@ private boolean addManeuver(int type) { vel = last.getVelocityLeft(); } while (vel > 0) { - addStepToMovePath(MoveStepType.DEC, true, true); + addStepToMovePath(MoveStepType.DEC, true, true, type); vel--; } addStepToMovePath(MoveStepType.UP); @@ -4279,13 +4279,13 @@ private boolean addManeuver(int type) { // See Total Warfare pg 85 if (clientgui.getClient().getGame().getBoard().getType() == Board.T_GROUND) { for (int i = 0; i < 8; i++) { - addStepToMovePath(MoveStepType.LATERAL_LEFT, true, true); + addStepToMovePath(MoveStepType.LATERAL_LEFT, true, true, type); } for (int i = 0; i < 8; i++) { - addStepToMovePath(MoveStepType.FORWARDS, true, true); + addStepToMovePath(MoveStepType.FORWARDS, true, true, type); } } else { - addStepToMovePath(MoveStepType.LATERAL_LEFT, true, true); + addStepToMovePath(MoveStepType.LATERAL_LEFT, true, true, type); } return true; case ManeuverType.MAN_SIDE_SLIP_RIGHT: @@ -4293,17 +4293,17 @@ private boolean addManeuver(int type) { // See Total Warfare pg 85 if (clientgui.getClient().getGame().getBoard().getType() == Board.T_GROUND) { for (int i = 0; i < 8; i++) { - addStepToMovePath(MoveStepType.LATERAL_RIGHT, true, true); + addStepToMovePath(MoveStepType.LATERAL_RIGHT, true, true, type); } for (int i = 0; i < 8; i++) { - addStepToMovePath(MoveStepType.FORWARDS, true, true); + addStepToMovePath(MoveStepType.FORWARDS, true, true, type); } } else { - addStepToMovePath(MoveStepType.LATERAL_RIGHT, true, true); + addStepToMovePath(MoveStepType.LATERAL_RIGHT, true, true, type); } return true; case ManeuverType.MAN_LOOP: - addStepToMovePath(MoveStepType.LOOP, true, true); + addStepToMovePath(MoveStepType.LOOP, true, true, type); return true; default: return false; diff --git a/megamek/src/megamek/common/ManeuverType.java b/megamek/src/megamek/common/ManeuverType.java index edfb19c2e7f..590a2a9101f 100644 --- a/megamek/src/megamek/common/ManeuverType.java +++ b/megamek/src/megamek/common/ManeuverType.java @@ -87,13 +87,13 @@ public static boolean canPerform(int type, int velocity, int altitude, MovePath tmpMp = mp.clone(); for (int i = 0; i < 8; i++) { if (type == MAN_SIDE_SLIP_LEFT) { - tmpMp.addStep(MoveStepType.LATERAL_LEFT, true, true); + tmpMp.addStep(MoveStepType.LATERAL_LEFT, true, true, type); } else { - tmpMp.addStep(MoveStepType.LATERAL_RIGHT, true, true); + tmpMp.addStep(MoveStepType.LATERAL_RIGHT, true, true, type); } } for (int i = 0; i < 8; i++) { - tmpMp.addStep(MoveStepType.FORWARDS, true, true); + tmpMp.addStep(MoveStepType.FORWARDS, true, true, type); } return tmpMp.getLastStep().isLegal(tmpMp); } else { diff --git a/megamek/src/megamek/common/MovePath.java b/megamek/src/megamek/common/MovePath.java index b94c00503e0..b38f935b186 100644 --- a/megamek/src/megamek/common/MovePath.java +++ b/megamek/src/megamek/common/MovePath.java @@ -206,8 +206,8 @@ public MovePath addStep(final MoveStepType type, final boolean noCost) { return addStep(new MoveStep(this, type, noCost)); } - public MovePath addStep(final MoveStepType type, final boolean noCost, final boolean isManeuver) { - return addStep(new MoveStep(this, type, noCost, isManeuver)); + public MovePath addStep(final MoveStepType type, final boolean noCost, final boolean isManeuver, final int maneuverType) { + return addStep(new MoveStep(this, type, noCost, isManeuver, maneuverType)); } public MovePath addStep(final MoveStepType type, final Minefield mf) { @@ -567,10 +567,10 @@ public void compile(final Game g, final Entity en, boolean clip) { step = new MoveStep(this, step.getType(), step.getBraceLocation()); } else if (!step.getLaunched().isEmpty()) { step = new MoveStep(this, step.getType(), step.getLaunched()); + } else if (step.isManeuver()) { + step = new MoveStep(this, step.getType(), step.hasNoCost(), step.isManeuver(), step.getManeuverType()); } else if (step.getManeuverType() != ManeuverType.MAN_NONE) { step = new MoveStep(this, step.getType(), -1, -1, step.getManeuverType()); - } else if (step.isManeuver()) { - step = new MoveStep(this, step.getType(), step.hasNoCost(), step.isManeuver()); } else if (step.hasNoCost()) { step = new MoveStep(this, step.getType(), step.hasNoCost()); } else if (null != step.getMinefield()) { @@ -1440,11 +1440,12 @@ private void lazyPathfinder(final Coords dest, final MoveStepType type) { while (!getFinalCoords().equals(subDest)) { // adjust facing rotatePathfinder((getFinalCoords().direction(subDest) + (step == MoveStepType.BACKWARDS ? 3 : 0)) % 6, - false); + false, ManeuverType.MAN_NONE); // step forwards addStep(step); } - rotatePathfinder((getFinalCoords().direction(dest) + (step == MoveStepType.BACKWARDS ? 3 : 0)) % 6, false); + rotatePathfinder((getFinalCoords().direction(dest) + (step == MoveStepType.BACKWARDS ? 3 : 0)) % 6, + false, ManeuverType.MAN_NONE); if (!dest.equals(getFinalCoords())) { addStep(type); } @@ -1553,10 +1554,10 @@ protected void copyFields(MovePath copy) { /** * Rotate from the current facing to the destination facing. */ - public void rotatePathfinder(final int destFacing, final boolean isManeuver) { + public void rotatePathfinder(final int destFacing, final boolean isManeuver, int maneuverType) { while (getFinalFacing() != destFacing) { final MoveStepType stepType = getDirection(getFinalFacing(), destFacing); - addStep(stepType, isManeuver, isManeuver); + addStep(stepType, isManeuver, isManeuver, maneuverType); } } diff --git a/megamek/src/megamek/common/MoveStep.java b/megamek/src/megamek/common/MoveStep.java index be865b08d71..22efe4bcc16 100644 --- a/megamek/src/megamek/common/MoveStep.java +++ b/megamek/src/megamek/common/MoveStep.java @@ -292,10 +292,11 @@ public MoveStep(MovePath path, MoveStepType type, boolean noCost) { } public MoveStep(MovePath path, MoveStepType type, boolean noCost, - boolean isManeuver) { + boolean isManeuver, int maneuverType) { this(path, type); this.noCost = noCost; maneuver = isManeuver; + this.maneuverType = maneuverType; } public MoveStep(MovePath path, MoveStepType type, int recovery,