if (!lastPos.equals(curPos) && game.board.getHex(lastPos).contains(Terrain.FIRE)) { if (entity instanceof Tank) { doFlamingDeath(entity); } else { entity.heatBuildup+=2; phaseReport.append("\n" + entity.getDisplayName() + " passes through a fire.  It will generate 2 more heat this round.\n"); } }
    private void doEntityMovement(Packet c, int cn) {        final MovementData md = (MovementData)c.getObject(1);        // walk thru data, stopping when the mech is out of movement        final Entity entity = game.getEntity(c.getIntValue(0));	boolean infMoveMulti = game.getOptions().booleanOption("inf_move_multi");	boolean infMoveLast = game.getOptions().booleanOption("inf_move_last");                if (entity == null) {            // what causes this?  --Ben            return;        }                if (!entity.ready) {            // the entity has already moved, apparently            return;        }	// Check for potential cheating:	// If "inf_move_mutli" option is selected, and we're in the middle	// of a block of Infantry moves, entity had better be an Infantry	// platoon owned by the most recent player.	if ( infMoveMulti && turnInfMoved > 0 &&	     ( !(entity instanceof Infantry) ||	       entity.getOwnerId() != turnLastPlayerId ) ) {	    // Do something appropriately awful.	    // TODO: Implement me!!!	}        	// Check for potential cheating:	// If "inf_move_last" option is selected, player can't move	// a Mek or Vehicle after Infantry have started to move.	else if ( infMoveLast && turnInfMoved > 0 &&		  !(entity instanceof Infantry) ) {	    // Do something appropriately awful.	    // TODO: Implement me!!!	}	// check for fleeing        if (md.contains(MovementData.STEP_FLEE)) {            phaseReport.append("\n" + entity.getDisplayName()            + " flees the battlefield.\n");            game.moveToGraveyard(entity.getId());            send(createRemoveEntityPacket(entity.getId()));            return;        }                // check for MASC failure        if (entity instanceof Mech) {            if (((Mech)entity).checkForMASCFailure(phaseReport)) {                // no movement after that                return;            }        }                                // okay, proceed with movement calculations        Coords lastPos = entity.getPosition();        Coords curPos = entity.getPosition();        int curFacing = entity.getFacing();        int distance = 0;        int mpUsed = 0;        int moveType = Entity.MOVE_NONE;        int overallMoveType = Entity.MOVE_NONE;        boolean firstStep;        boolean wasProne;        boolean fellDuringMovement;                Compute.compile(game, entity.getId(), md);                // get last step's movement type        for (final Enumeration i = md.getSteps(); i.hasMoreElements();) {            final MovementData.Step step = (MovementData.Step)i.nextElement();            if (step.getMovementType() == Entity.MOVE_ILLEGAL) {                break;            } else {                overallMoveType = step.getMovementType();            }        }                // iterate through steps        firstStep = true;        fellDuringMovement = false;        for (final Enumeration i = md.getSteps(); i.hasMoreElements();) {            final MovementData.Step step = (MovementData.Step)i.nextElement();            wasProne = entity.isProne();                        // stop for illegal movement            if (step.getMovementType() == Entity.MOVE_ILLEGAL) {                break;            }                        // check piloting skill for getting up            if (step.getType() == MovementData.STEP_GET_UP) {                entity.heatBuildup += 1;                entity.setProne(false);                wasProne = false;                doSkillCheckInPlace(entity, new PilotingRollData(entity.getId(), 0, "getting up"), true);            } else if (firstStep) {                // running with destroyed hip or gyro needs a check                if (overallMoveType == Entity.MOVE_RUN                && (entity.getDestroyedCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO,Mech.LOC_CT) > 0                || entity.hasHipCrit())) {                    doSkillCheckInPlace(entity, new PilotingRollData(entity.getId(), 0, "running with damaged hip actuator or gyro"), false);                }                firstStep = false;            }                        // did the entity just fall?            if (!wasProne && entity.isProne()) {                moveType = step.getMovementType();                curFacing = entity.getFacing();                curPos = entity.getPosition();                mpUsed = step.getMpUsed();                fellDuringMovement = true;                break;            }                        // check for charge            if (step.getType() == MovementData.STEP_CHARGE) {                //FIXME: find the acutal target, not just the likely target                Entity target = game.getFirstEntity(step.getPosition());                                distance = step.getDistance();                                ChargeAttackAction caa = new ChargeAttackAction(entity.getId(), target.getId(), target.getPosition());                entity.setDisplacementAttack(caa);                pendingCharges.addElement(caa);                break;            }                        // check for dfa            if (step.getType() == MovementData.STEP_DFA) {                //FIXME: find the acutal target, not just the likely target                Entity target = game.getFirstEntity(step.getPosition());                                distance = step.getDistance();                                DfaAttackAction daa = new DfaAttackAction(entity.getId(), target.getId(), target.getPosition());                entity.setDisplacementAttack(daa);                pendingCharges.addElement(daa);                break;            }                        // step...            moveType = step.getMovementType();            curPos = step.getPosition();            curFacing = step.getFacing();            distance = step.getDistance();            mpUsed = step.getMpUsed();                        final Hex curHex = game.board.getHex(curPos);                        // check if we've moved into rubble            if (!lastPos.equals(curPos)            && step.getMovementType() != Entity.MOVE_JUMP            && curHex.levelOf(Terrain.RUBBLE) > 0) {                doSkillCheckWhileMoving(entity, lastPos, curPos, new PilotingRollData(entity.getId(), 0, "entering Rubble"));            }                        // check if we've moved into water            if (!lastPos.equals(curPos)            && step.getMovementType() != Entity.MOVE_JUMP            && curHex.levelOf(Terrain.WATER) > 0            && entity.getMovementType() != Entity.MovementType.HOVER) {                if (curHex.levelOf(Terrain.WATER) == 1) {                    doSkillCheckWhileMoving(entity, lastPos, curPos, new PilotingRollData(entity.getId(), -1, "entering Depth 1 Water"));                } else if (curHex.levelOf(Terrain.WATER) == 2) {                    doSkillCheckWhileMoving(entity, lastPos, curPos, new PilotingRollData(entity.getId(), 0, "entering Depth 2 Water"));                } else {                    doSkillCheckWhileMoving(entity, lastPos, curPos, new PilotingRollData(entity.getId(), 1, "entering Depth 3+ Water"));                }            }                        // did the entity just fall?            if (!wasProne && entity.isProne()) {                curFacing = entity.getFacing();                curPos = entity.getPosition();                mpUsed = step.getMpUsed();                fellDuringMovement = true;                break;            }                        // update lastPos            lastPos = new Coords(curPos);        }                // set entity parameters        entity.setPosition(curPos);        entity.setFacing(curFacing);        entity.setSecondaryFacing(curFacing);        entity.delta_distance = distance;        entity.moved = moveType;        entity.mpUsed = mpUsed;                // but the danger isn't over yet!  landing from a jump can be risky!        if (overallMoveType == Entity.MOVE_JUMP && !entity.isMakingDfa()) {            // check for damaged criticals            if (entity.getDestroyedCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO,Mech.LOC_CT) > 0 || entity.hasLegActuatorCrit()) {                doSkillCheckInPlace(entity, new PilotingRollData(entity.getId(), 0, "landing with damaged leg actuator or gyro"), false);            }            // jumped into water?            int waterLevel = game.board.getHex(curPos).levelOf(Terrain.WATER);            if (waterLevel == 1) {                doSkillCheckInPlace(entity, new PilotingRollData(entity.getId(), -1, "entering Depth 1 Water"), false);            } else if (waterLevel == 2) {                doSkillCheckInPlace(entity, new PilotingRollData(entity.getId(), 0, "entering Depth 2 Water"), false);            } else if (waterLevel >= 3) {                doSkillCheckInPlace(entity, new PilotingRollData(entity.getId(), 1, "entering Depth 3+ Water"), false);            }        }                // build up heat from movement        if (moveType == Entity.MOVE_WALK) {            entity.heatBuildup += 1;        } else if (moveType == Entity.MOVE_RUN) {            entity.heatBuildup += 2;        } else if (moveType == Entity.MOVE_JUMP) {            entity.heatBuildup += Math.max(3, distance);        }                // should we give another turn to the entity to keep moving?        if (fellDuringMovement && entity.mpUsed < entity.getRunMP() && entity.isSelectable()) {            entity.applyDamage();            entity.ready = true;            turns.insertElementAt(new GameTurn(entity.getOwner().getId(), entity.getId()), turnIndex);        } else {            entity.ready = false;        }        	// Is the entity Infantry?	if ( entity instanceof Infantry ) {	    // Increment the counter.	    turnInfMoved++;	    // Record the player moving the infantry.	    turnLastPlayerId = entity.getOwnerId();	    // Do infantry move in blocks?	    if ( infMoveMulti ) {		// Are we at the end of a block?		if ( Game.INF_MOVE_MULTI == turnInfMoved ||		     !game.hasInfantry(turnLastPlayerId) ) {		    // Yup.  Reset the counter.		    turnInfMoved = 0;		}		else {		    // Nope.  Decrement the turn index.		    turnIndex--;		}	    } // End inf_move_multi	} // End entity-is-infantry        // send a packet updating everybody on this entity's movement        entityUpdate(entity.getId());                // if using double blind, update the player on new units he might see        if (doBlind()) {            send(entity.getOwner().getId(), createFilteredEntitiesPacket(entity.getOwner()));        }    }