Browse Source

null check

feature-workorder
FatBoy-DOTC 1 year ago
parent
commit
c3e206e3b1
  1. 25
      src/engine/net/client/handlers/MoveToPointHandler.java

25
src/engine/net/client/handlers/MoveToPointHandler.java

@ -37,19 +37,20 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
Enum.GameObjectType targetType; Enum.GameObjectType targetType;
targetType = Enum.GameObjectType.values()[msg.getTargetType()]; targetType = Enum.GameObjectType.values()[msg.getTargetType()];
switch(targetType){ if(targetType != null) {
case Building: switch (targetType) {
target = BuildingManager.getBuilding(msg.getTargetID()); case Building:
if(target == null) target = BuildingManager.getBuilding(msg.getTargetID());
return true;// early exit for no building pulled if (target == null)
Building targetBuilding = (Building) target; return true;// early exit for no building pulled
if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0) Building targetBuilding = (Building) target;
return true;// cannot attack destroyed building or protected building if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0)
break; return true;// cannot attack destroyed building or protected building
case NPC: break;
return true;//cannot attack anything other than the 3 above case NPC:
return true;//cannot attack anything other than the 3 above
}
} }
MovementManager.movement(msg, pc); MovementManager.movement(msg, pc);
return true; return true;
} }

Loading…
Cancel
Save