From 01fd6997a8275b347fcc09a5793ff8db1bb16a7e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 29 Mar 2024 06:40:06 -0400 Subject: [PATCH] Handler created for ShowMsg --- src/engine/net/client/ClientMessagePump.java | 41 ----------- src/engine/net/client/Protocol.java | 2 +- .../net/client/handlers/ShowMsgHandler.java | 72 +++++++++++++++++++ 3 files changed, 73 insertions(+), 42 deletions(-) create mode 100644 src/engine/net/client/handlers/ShowMsgHandler.java diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 865fc9b6..9c02f18f 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -9,19 +9,14 @@ package engine.net.client; -import engine.Enum.DispatchChannel; import engine.Enum.GameObjectType; import engine.exception.MsgSendException; import engine.gameManager.*; -import engine.net.Dispatch; -import engine.net.DispatchMessage; import engine.net.NetMsgHandler; import engine.net.client.handlers.AbstractClientMsgHandler; import engine.net.client.msg.*; import engine.net.client.msg.chat.AbstractChatMsg; -import engine.objects.AbstractCharacter; import engine.objects.Mob; -import engine.objects.NPC; import engine.objects.PlayerCharacter; import engine.server.world.WorldServer; import engine.session.Session; @@ -45,39 +40,6 @@ public class ClientMessagePump implements NetMsgHandler { this.server = server; } - // called when player types /show - private static void show(ShowMsg msg, ClientConnection origin) throws MsgSendException { - - PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); - - if (pc == null) - return; - - int targetType = msg.getTargetType(); - AbstractCharacter tar = null; - - if (targetType == GameObjectType.PlayerCharacter.ordinal()) - tar = PlayerCharacter.getFromCache(msg.getTargetID()); - else if (targetType == GameObjectType.NPC.ordinal()) - tar = NPC.getFromCache(msg.getTargetID()); - else if (targetType == GameObjectType.Mob.ordinal()) - tar = Mob.getFromCache(msg.getTargetID()); - - if (tar == null || !tar.isAlive() || !tar.isActive()) - return; - - msg.setUnknown01(pc.getLoc()); - msg.setUnknown02(pc.getLoc()); - msg.setRange01(pc.getRange()); - msg.setUnknown03(tar.getLoc()); - msg.setUnknown04(tar.getLoc()); - msg.setRange01(tar.getRange()); - - Dispatch dispatch = Dispatch.borrow(pc, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - - } - protected static void petAttack(PetAttackMsg msg, ClientConnection conn) throws MsgSendException { PlayerCharacter pc = SessionManager.getPlayerCharacter(conn); @@ -174,9 +136,6 @@ public class ClientMessagePump implements NetMsgHandler { break; case OPENVAULT: break; - case SHOWCOMBATINFO: - show((ShowMsg) msg, origin); - break; case REQUESTTOTRADE: TradeManager.tradeRequest((TradeRequestMsg) msg, origin); break; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index 1043093e..059dfd4c 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -196,7 +196,7 @@ public enum Protocol { SETOBJVAL(0x08A50FD1, null, null), SETRUNE(0x888E7C64, ApplyRuneMsg.class, null), //Apply Promotion, Stat Rune (maybe disc also) TARGETOBJECT(0x64E10938, TargetObjectMsg.class, TargetObjectMsgHandler.class), // Target an object - SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, null), // Request/Response /show + SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, ShowMsgHandler.class), // Request/Response /show SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, SocialMsgHandler.class), // Socials STANDARDALERT(0xFA0A24BB, ErrorPopupMsg.class, null), //Popup messages diff --git a/src/engine/net/client/handlers/ShowMsgHandler.java b/src/engine/net/client/handlers/ShowMsgHandler.java new file mode 100644 index 00000000..97b221bc --- /dev/null +++ b/src/engine/net/client/handlers/ShowMsgHandler.java @@ -0,0 +1,72 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.Enum; +import engine.Enum.DispatchChannel; +import engine.exception.MsgSendException; +import engine.net.Dispatch; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.ShowMsg; +import engine.objects.AbstractCharacter; +import engine.objects.Mob; +import engine.objects.NPC; +import engine.objects.PlayerCharacter; + +public class ShowMsgHandler extends AbstractClientMsgHandler { + + public ShowMsgHandler() { + super(ShowMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); + + // Member variable declaration + + ShowMsg msg; + + // Member variable assignment + + msg = (ShowMsg) baseMsg; + + if (playerCharacter == null) + return true; + + int targetType = msg.getTargetType(); + AbstractCharacter tar = null; + + if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal()) + tar = PlayerCharacter.getFromCache(msg.getTargetID()); + else if (targetType == Enum.GameObjectType.NPC.ordinal()) + tar = NPC.getFromCache(msg.getTargetID()); + else if (targetType == Enum.GameObjectType.Mob.ordinal()) + tar = Mob.getFromCache(msg.getTargetID()); + + if (tar == null || !tar.isAlive() || !tar.isActive()) + return true; + + msg.setUnknown01(playerCharacter.getLoc()); + msg.setUnknown02(playerCharacter.getLoc()); + msg.setRange01(playerCharacter.getRange()); + msg.setUnknown03(tar.getLoc()); + msg.setUnknown04(tar.getLoc()); + msg.setRange01(tar.getRange()); + + Dispatch dispatch = Dispatch.borrow(playerCharacter, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + + return true; + } + +} \ No newline at end of file