isTurning, overallMoveType, prevStepOnPavement );
isTurning, overallMoveType );
    private static void compileIllegal( Game game, int entityId,                                        MovementData md,                                        int overallMoveType,                                        boolean runProhibited,                                        boolean onlyPavement ) {        final Entity entity = game.getEntity(entityId);        Coords curPos = new Coords(entity.getPosition());        boolean legal = true;        boolean danger = false;        boolean pastDanger = false;        boolean firstStep = true;        boolean isInfantry = (entity instanceof Infantry);        boolean isTurning = false;        boolean isUnloaded = false;        boolean prevStepOnPavement = false;        boolean isProne = entity.isProne();                for (final Enumeration i = md.getSteps(); i.hasMoreElements();) {            final MovementData.Step step = (MovementData.Step)i.nextElement();            final int stepType = step.getType();                        Coords lastPos = new Coords(curPos);            curPos = step.getPosition();            // If all movement is on pavement, say so in all steps.            if ( onlyPavement && !step.isOnPavement() ) {                step.setOnPavement( true );            }            // guilty until proven innocent            int moveType = Entity.MOVE_ILLEGAL;                        // check for valid jump mp            if (overallMoveType == Entity.MOVE_JUMP                 && step.getMpUsed() <= entity.getJumpMPWithTerrain()                && !isProne) {                moveType = Entity.MOVE_JUMP;            }                        // check for valid walk/run mp            if ( (overallMoveType == Entity.MOVE_WALK ||                  overallMoveType == Entity.MOVE_RUN)                && (!isProne || md.contains(MovementData.STEP_GET_UP)                    || stepType == MovementData.STEP_TURN_LEFT                     || stepType == MovementData.STEP_TURN_RIGHT)) {                // Vehicles moving along pavement get "road bonus" of 1 MP.                // ASSUMPTION : bonus MP is to walk, which may me 2 MP to run.                if (step.getMpUsed() <= entity.getWalkMP()) {                    moveType = Entity.MOVE_WALK;                } else if ( entity instanceof Tank && onlyPavement &&                            step.getMpUsed() == entity.getWalkMP() + 1 ) {                    moveType = Entity.MOVE_WALK;                } else if ( step.getMpUsed() <= entity.getRunMPwithoutMASC() &&                            !runProhibited ) {                    moveType = Entity.MOVE_RUN;                } else if ( step.getMpUsed() <= entity.getRunMP() &&                            !runProhibited ) {                    step.setUsingMASC(true);                    Mech m = (Mech)entity;                    step.setMASCNumber(m.getMASCTarget());                    moveType = Entity.MOVE_RUN;                } else if ( entity instanceof Tank && onlyPavement &&                            step.getMpUsed() <= entity.getRunMP() +                             (isOdd(entity.getWalkMP()) ? 1 : 2) &&                            !runProhibited ) {                    moveType = Entity.MOVE_RUN;                }            }                        // mechs with 1 MP are allowed to get up            if ( stepType == MovementData.STEP_GET_UP &&                 entity.getRunMP() == 1 ) {                moveType = Entity.MOVE_RUN;            }                        // amnesty for the first step            if ( firstStep && moveType == Entity.MOVE_ILLEGAL &&                 entity.getWalkMP() > 0 && !entity.isProne() &&                 stepType == MovementData.STEP_FORWARDS ) {                moveType = Entity.MOVE_RUN;            }            // Is the entity unloading passeners?            if ( stepType == MovementData.STEP_UNLOAD ) {                // Prone Meks are able to unload, if they have the MP.                if ( step.getMpUsed() <= entity.getRunMP() &&                     entity.isProne() && moveType == Entity.MOVE_ILLEGAL ) {                    moveType = Entity.MOVE_RUN;                    if ( step.getMpUsed() <= entity.getWalkMP() ) {                        moveType = Entity.MOVE_WALK;                    }                }                // Can't unload units into prohibited terrain                // or into stacking violation.                Targetable target = step.getTarget( game );                if ( target instanceof Entity ) {                    Entity other = (Entity) target;                    if ( null != stackingViolation(game, other, curPos, entity)                         || other.isHexProhibited(game.board.getHex(curPos))) {                        moveType = Entity.MOVE_ILLEGAL;                    }                } else {                    System.err.print( "Trying to unload " );                    System.err.print( target.getDisplayName() );                    System.err.print( " from " );                    System.err.print( entity.getDisplayName() );                    System.err.println( "." );                    moveType = Entity.MOVE_ILLEGAL;                }            }            // only standing mechs may go prone            if (stepType == MovementData.STEP_GO_PRONE             && (isProne || !(entity instanceof Mech))) {                moveType = Entity.MOVE_ILLEGAL;            }                        // check if this movement is illegal for reasons other than points            if ( !isMovementPossible(game, entityId, lastPos, curPos,                                     moveType, stepType, firstStep)                 || isUnloaded ) {                moveType = Entity.MOVE_ILLEGAL;            }                        // no legal moves past an illegal one            if (moveType == Entity.MOVE_ILLEGAL) {                legal = false;            }            // check for danger            danger = step.isDanger();            danger |= isPilotingSkillNeeded( game, entityId, lastPos,                                              curPos, moveType,                                             isTurning, overallMoveType,                                             prevStepOnPavement );            // getting up is also danger            if (stepType == MovementData.STEP_GET_UP) {                danger = true;            }                        // set flags            step.setDanger(danger);            step.setPastDanger(pastDanger);            step.setMovementType(legal ? moveType : Entity.MOVE_ILLEGAL);                        // set past danger            pastDanger |= danger;            // Record if we're turning *after* check for danger,            // because the danger lies in moving *after* turn.            switch(stepType) {            case MovementData.STEP_TURN_LEFT :            case MovementData.STEP_TURN_RIGHT :                isTurning = true;                break;            case MovementData.STEP_UNLOAD:                // Unloading must be the last step.                isUnloaded = true;                break;            default:                isTurning = false;                break;            }            firstStep = false;            // Infantry can always move one hex in *any* direction.            if ( isInfantry && step.getMpUsed() == 0 ) {                firstStep = true;            }            // Record if the step just taken was along pavement or a road.            prevStepOnPavement = step.isOnPavement();                        // update prone state            if (stepType == MovementData.STEP_GO_PRONE) {                isProne = true;            } else if (stepType == MovementData.STEP_GET_UP) {                isProne = false;            }        }    }