diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 57e1e0e1..407d66b4 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -130,20 +130,6 @@ public class ClientMessagePump implements NetMsgHandler { DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); } - private static void targetObject(TargetObjectMsg msg, ClientConnection origin) { - PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); - if (pc == null) - return; - - // TODO improve this later. hacky way to make sure player ingame is - // active. - - if (!pc.isActive()) - pc.setActive(true); - - pc.setLastTarget(GameObjectType.values()[msg.getTargetType()], msg.getTargetID()); - } - private static void social(SocialMsg msg, ClientConnection origin) throws MsgSendException { PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); if (pc == null) @@ -832,10 +818,6 @@ public class ClientMessagePump implements NetMsgHandler { protocolMsg = msg.getProtocolMsg(); switch (protocolMsg) { - case SETSELECTEDOBECT: - ClientMessagePump.targetObject((TargetObjectMsg) msg, origin); - break; - /* * Chat */ diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index 11ffd86a..b4539375 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -195,7 +195,7 @@ public enum Protocol { SETMOTD(0xFD21FC7C, MOTDCommitMsg.class, MOTDCommitHandler.class), //Commit Guild/Nation/IC MOTD Message SETOBJVAL(0x08A50FD1, null, null), SETRUNE(0x888E7C64, ApplyRuneMsg.class, null), //Apply Promotion, Stat Rune (maybe disc also) - SETSELECTEDOBECT(0x64E10938, TargetObjectMsg.class, null), // Target an object + TARGETOBJECT(0x64E10938, TargetObjectMsg.class, TargetObjectMsgHandler.class), // Target an object SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, null), // Request/Response /show SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, null), // Socials diff --git a/src/engine/net/client/handlers/TargetObjectMsgHandler.java b/src/engine/net/client/handlers/TargetObjectMsgHandler.java new file mode 100644 index 00000000..7024ff8c --- /dev/null +++ b/src/engine/net/client/handlers/TargetObjectMsgHandler.java @@ -0,0 +1,45 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.Enum; +import engine.exception.MsgSendException; +import engine.gameManager.SessionManager; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.TargetObjectMsg; +import engine.objects.PlayerCharacter; + +public class TargetObjectMsgHandler extends AbstractClientMsgHandler { + + public TargetObjectMsgHandler() { + super(TargetObjectMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + TargetObjectMsg msg = (TargetObjectMsg) baseMsg; + + PlayerCharacter player = SessionManager.getPlayerCharacter(origin); + + if (player == null) + return true; + + // TODO improve this later. hacky way to make sure player ingame is + // active. + + if (!player.isActive()) + player.setActive(true); + + player.setLastTarget(Enum.GameObjectType.values()[msg.getTargetType()], msg.getTargetID()); + return true; + } + +} \ No newline at end of file diff --git a/src/engine/net/client/msg/TargetObjectMsg.java b/src/engine/net/client/msg/TargetObjectMsg.java index 8c823da7..55d6f28f 100644 --- a/src/engine/net/client/msg/TargetObjectMsg.java +++ b/src/engine/net/client/msg/TargetObjectMsg.java @@ -24,7 +24,7 @@ public class TargetObjectMsg extends ClientNetMsg { * This is the general purpose constructor. */ public TargetObjectMsg(int targetType, int targetID) { - super(Protocol.SETSELECTEDOBECT); + super(Protocol.TARGETOBJECT); this.targetType = targetType; this.targetID = targetID; } @@ -33,7 +33,7 @@ public class TargetObjectMsg extends ClientNetMsg { * This is the general purpose constructor. */ public TargetObjectMsg() { - super(Protocol.SETSELECTEDOBECT); + super(Protocol.TARGETOBJECT); } /** @@ -43,7 +43,7 @@ public class TargetObjectMsg extends ClientNetMsg { * caller. */ public TargetObjectMsg(AbstractConnection origin, ByteBufferReader reader) { - super(Protocol.SETSELECTEDOBECT, origin, reader); + super(Protocol.TARGETOBJECT, origin, reader); } /** diff --git a/src/engine/server/login/LoginServerMsgHandler.java b/src/engine/server/login/LoginServerMsgHandler.java index 98d0deb1..81ee5470 100644 --- a/src/engine/server/login/LoginServerMsgHandler.java +++ b/src/engine/server/login/LoginServerMsgHandler.java @@ -108,7 +108,7 @@ public class LoginServerMsgHandler implements NetMsgHandler { this.RequestGameServer((GameServerIPRequestMsg) clientNetMsg, origin); break; - case SETSELECTEDOBECT: + case TARGETOBJECT: // Why is this being sent to login server? break;