Browse Source

early exits for attack message handler

feature-workorder
FatBoy-DOTC 1 year ago
parent
commit
47fe764cb0
  1. 29
      src/engine/net/client/handlers/AttackCmdMsgHandler.java

29
src/engine/net/client/handlers/AttackCmdMsgHandler.java

@ -9,6 +9,7 @@ import engine.net.client.msg.AttackCmdMsg; @@ -9,6 +9,7 @@ import engine.net.client.msg.AttackCmdMsg;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.TargetedActionMsg;
import engine.objects.AbstractWorldObject;
import engine.objects.Building;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger;
@ -39,7 +40,6 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler { @@ -39,7 +40,6 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
msg = (AttackCmdMsg) baseMsg;
int targetType;
AbstractWorldObject target;
if (TargetedActionMsg.un2cnt == 60 || TargetedActionMsg.un2cnt == 70)
return true;
@ -54,25 +54,20 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler { @@ -54,25 +54,20 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
return true;
}
targetType = msg.getTargetType();
AbstractWorldObject target = playerCharacter.combatTarget;
if(target == null)
return true; // cannot attack a null target
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal()) {
target = PlayerCharacter.getFromCache(msg.getTargetID());
} else if (targetType == Enum.GameObjectType.Building.ordinal()) {
target = BuildingManager.getBuildingFromCache(msg.getTargetID());
} else if (targetType == Enum.GameObjectType.Mob.ordinal()) {
target = Mob.getFromCache(msg.getTargetID());
} else {
switch(target.getObjectType()){
case NPC:
playerCharacter.setCombatTarget(null);
return true; //cannot attack NPCs
case Building:
Building targetBuilding = (Building) target;
if(!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0)
playerCharacter.setCombatTarget(null);
return true; //not valid type to attack
}
// quit of the combat target is already the current combat target
// or there is no combat target
if (target == null)
return true;
;
}
//set sources target

Loading…
Cancel
Save