From: <bm...@pr...> - 2004-01-27 19:47:14
|
Update of /cvsroot/megamek/megamek/megamek/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5185/megamek/common Modified Files: MoveStep.java MovePath.java Log Message: + Bug 868218: Fixed bug in backwards lateral shifts Index: MoveStep.java =================================================================== RCS file: /cvsroot/megamek/megamek/megamek/common/MoveStep.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MoveStep.java 24 Jan 2004 17:49:43 -0000 1.11 --- MoveStep.java 27 Jan 2004 19:46:10 -0000 1.12 *************** *** 247,251 **** .getAdjustedFacing( getFacing(), ! MovePath.turnForLateralShift(getType(), MovePath.STEP_FORWARDS)) + 3) % 6); --- 247,251 ---- .getAdjustedFacing( getFacing(), ! MovePath.turnForLateralShift(getType())) + 3) % 6); *************** *** 256,260 **** MovePath.getAdjustedFacing( getFacing(), ! MovePath.turnForLateralShift(getType(), MovePath.STEP_FORWARDS))); setThisStepBackwards(false); } --- 256,260 ---- MovePath.getAdjustedFacing( getFacing(), ! MovePath.turnForLateralShift(getType()))); setThisStepBackwards(false); } Index: MovePath.java =================================================================== RCS file: /cvsroot/megamek/megamek/megamek/common/MovePath.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MovePath.java 26 Jan 2004 15:55:58 -0000 1.8 --- MovePath.java 27 Jan 2004 19:46:10 -0000 1.9 *************** *** 298,302 **** if (step1.oppositeTurn(step3) && (step2.getType() == MovePath.STEP_BACKWARDS || step2.getType() == MovePath.STEP_FORWARDS)) { ! int stepType = getStep(index).getType(); // remove all old steps steps.removeElementAt(index); --- 298,303 ---- if (step1.oppositeTurn(step3) && (step2.getType() == MovePath.STEP_BACKWARDS || step2.getType() == MovePath.STEP_FORWARDS)) { ! int stepType = step1.getType(); ! int direction = step2.getType(); // remove all old steps steps.removeElementAt(index); *************** *** 304,308 **** steps.removeElementAt(index); // add new step ! MoveStep shift = new MoveStep(this, lateralShiftForTurn(stepType)); addStep(shift); } --- 305,309 ---- steps.removeElementAt(index); // add new step ! MoveStep shift = new MoveStep(this, lateralShiftForTurn(stepType, direction)); addStep(shift); } *************** *** 312,350 **** * Returns the lateral shift that corresponds to the turn direction */ ! public static int lateralShiftForTurn(int turn) { ! switch (turn) { ! case MovePath.STEP_TURN_LEFT : ! return MovePath.STEP_LATERAL_LEFT; ! case MovePath.STEP_TURN_RIGHT : ! return MovePath.STEP_LATERAL_RIGHT; ! default : ! return turn; ! } ! } ! ! /** ! * Returns the turn direction that corresponds to the lateral shift ! */ ! static int turnForLateralShift(int shift, int direction) { if (direction == MovePath.STEP_FORWARDS) { ! switch (shift) { ! case MovePath.STEP_LATERAL_LEFT : ! return MovePath.STEP_TURN_LEFT; ! case MovePath.STEP_LATERAL_RIGHT : ! return MovePath.STEP_TURN_RIGHT; default : ! return shift; } } else { ! switch (shift) { case MovePath.STEP_TURN_LEFT : - return MovePath.STEP_LATERAL_RIGHT_BACKWARDS; - case MovePath.STEP_TURN_RIGHT : return MovePath.STEP_LATERAL_LEFT_BACKWARDS; default : ! return shift; } } } /** --- 313,355 ---- * Returns the lateral shift that corresponds to the turn direction */ ! public static int lateralShiftForTurn(int turn, int direction) { if (direction == MovePath.STEP_FORWARDS) { ! switch (turn) { ! case MovePath.STEP_TURN_LEFT : ! return MovePath.STEP_LATERAL_LEFT; ! case MovePath.STEP_TURN_RIGHT : ! return MovePath.STEP_LATERAL_RIGHT; default : ! return turn; } } else { ! switch (turn) { case MovePath.STEP_TURN_LEFT : return MovePath.STEP_LATERAL_LEFT_BACKWARDS; + case MovePath.STEP_TURN_RIGHT : + return MovePath.STEP_LATERAL_RIGHT_BACKWARDS; default : ! return turn; } } } + + /** + * Returns the turn direction that corresponds to the lateral shift + */ + static int turnForLateralShift(int shift) { + switch (shift) { + case MovePath.STEP_LATERAL_LEFT : + return MovePath.STEP_TURN_LEFT; + case MovePath.STEP_LATERAL_RIGHT : + return MovePath.STEP_TURN_RIGHT; + case MovePath.STEP_LATERAL_LEFT_BACKWARDS : + return MovePath.STEP_TURN_LEFT; + case MovePath.STEP_LATERAL_RIGHT_BACKWARDS : + return MovePath.STEP_TURN_RIGHT; + default : + return shift; + } + } /** |