From 7b9d9d64bbda966b581ebdede6fda6c44506e1fe Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 29 Mar 2024 06:02:29 -0400 Subject: [PATCH] Handler created for ToggleSitStandMsg --- src/engine/net/client/ClientMessagePump.java | 29 --------- src/engine/net/client/Protocol.java | 2 +- .../handlers/ToggleSitStandMsgHandler.java | 65 +++++++++++++++++++ 3 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 src/engine/net/client/handlers/ToggleSitStandMsgHandler.java diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 2f672355..fdfc2c18 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -48,31 +48,6 @@ public class ClientMessagePump implements NetMsgHandler { this.server = server; } - private static void toggleSitStand(ToggleSitStandMsg msg, ClientConnection origin) throws MsgSendException { - PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); - if (pc == null) - return; - - pc.update(); - - pc.setSit(msg.toggleSitStand()); - - // cancel effects that break on sit - if (pc.isSit()) { - pc.setCombat(false); - pc.cancelOnSit(); - } - - UpdateStateMsg rwss = new UpdateStateMsg(); - if (pc.isSit()) { - pc.setCombat(false); - rwss.setAware(1); - } - rwss.setPlayer(pc); - - DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - } - private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) { // According to the Wiki, the client should not send this message. // Log the instance to investigate, and modify Wiki accordingly. @@ -362,10 +337,6 @@ public class ClientMessagePump implements NetMsgHandler { break; case OPENVAULT: break; - case TOGGLESITSTAND: - ToggleSitStandMsg tssm = (ToggleSitStandMsg) msg; - toggleSitStand(tssm, origin); - break; case IGNORE: ((IgnoreMsg) msg).handleRequest(origin); break; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index 274ee5aa..6b3f6b94 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -210,7 +210,7 @@ public enum Protocol { TAXRESOURCES(0x4AD458AF, TaxResourcesMsg.class, TaxResourcesMsgHandler.class), TELEPORT(0x23E726EA, TeleportToPointMsg.class, null), // Teleport to point TERRITORYCHANGE(0x6B388C8C, TerritoryChangeMessage.class, null), //Hey rich, look what I found? :) - TOGGLESITSTAND(0x624F3C0F, ToggleSitStandMsg.class, null), //Toggle Sit/Stand + TOGGLESITSTAND(0x624F3C0F, ToggleSitStandMsg.class, ToggleSitStandMsgHandler.class), //Toggle Sit/Stand TRADEADDGOLD(0x654ACB45, AddGoldToTradeWindowMsg.class, null), // Add Gold to Trade Window TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, null), // Add an Item to the Trade Window TRADECLOSE(0x5008D7FC, CloseTradeWindowMsg.class, null), // Cancel trade/ACK trade complete diff --git a/src/engine/net/client/handlers/ToggleSitStandMsgHandler.java b/src/engine/net/client/handlers/ToggleSitStandMsgHandler.java new file mode 100644 index 00000000..2ec21a0a --- /dev/null +++ b/src/engine/net/client/handlers/ToggleSitStandMsgHandler.java @@ -0,0 +1,65 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.Enum.DispatchChannel; +import engine.exception.MsgSendException; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.ToggleSitStandMsg; +import engine.net.client.msg.UpdateStateMsg; +import engine.objects.PlayerCharacter; +import engine.server.MBServerStatics; + +public class ToggleSitStandMsgHandler extends AbstractClientMsgHandler { + + public ToggleSitStandMsgHandler() { + super(ToggleSitStandMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); + + // Member variable declaration + + ToggleSitStandMsg msg; + + // Member variable assignment + + msg = (ToggleSitStandMsg) baseMsg; + + if (playerCharacter == null) + return true; + + playerCharacter.update(); + + playerCharacter.setSit(msg.toggleSitStand()); + + // cancel effects that break on sit + if (playerCharacter.isSit()) { + playerCharacter.setCombat(false); + playerCharacter.cancelOnSit(); + } + + UpdateStateMsg rwss = new UpdateStateMsg(); + + if (playerCharacter.isSit()) { + playerCharacter.setCombat(false); + rwss.setAware(1); + } + rwss.setPlayer(playerCharacter); + + DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); + return true; + } + +} \ No newline at end of file