diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index a8391b11..2e1b0a84 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -378,12 +378,6 @@ public class ClientMessagePump implements NetMsgHandler { break; case OPENVAULT: break; - case COMBATMODE: - CombatManager.toggleCombat(((ToggleCombatMsg) msg).toggleCombat(), origin); - break; - case ARCCOMBATMODEATTACKING: - CombatManager.toggleCombat(((SetCombatModeMsg) msg).getToggle(), origin); - break; case MODIFYGUILDSTATE: ToggleLfgRecruitingMsg tlrm = (ToggleLfgRecruitingMsg) msg; toggleLfgRecruiting(tlrm, origin); diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index c498933f..05aefd66 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -28,7 +28,7 @@ public enum Protocol { ADDFRIEND(0xCFA1C787, AddFriendMessage.class, null), ALLIANCECHANGE(0x0E7D0B57, AllianceChangeMsg.class, AllianceChangeMsgHandler.class), // Remove From Allies/Enemies List ALLYENEMYLIST(0xAEA443FD, AllyEnemyListMsg.class, AllyEnemyListMsgHandler.class), - ARCCOMBATMODEATTACKING(0xD8B10579, SetCombatModeMsg.class, null), // Attack From Outside Combat Mode + ARCCOMBATMODEATTACKING(0xD8B10579, SetCombatModeMsg.class, SetCombatModeMsgHandler.class), // Attack From Outside Combat Mode ARCHOTZONECHANGE(0xDCFF196F, null, null), //change hotzone ARCIGNORELISTUPDATE(0x4B1B17C2, IgnoreListMsg.class, null), //req/show ignore list ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world @@ -79,7 +79,7 @@ public enum Protocol { CLAIMGUILDTREE(0xFD1C6442, ClaimGuildTreeMsg.class, ClaimGuildTreeMsgHandler.class), CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, ClientAdminCommandMsgHandler.class), //Admin Command CLIENTUPDATEVAULT(0x66EDBECD, UpdateVaultMsg.class, null), - COMBATMODE(0xFE4BF353, ToggleCombatMsg.class, null), //Toggle Combat mode + COMBATMODE(0xFE4BF353, ToggleCombatMsg.class, ToggleCombatMsgHandler.class), //Toggle Combat mode CONFIRMPROMOTE(0x153BB5F9, ConfirmPromoteMsg.class, null), COSTTOOPENBANK(0x135BE5E8, AckBankWindowOpenedMsg.class, null), // ACK Bank Window Opened CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character, diff --git a/src/engine/net/client/handlers/KeepAliveServerClientHandler.java b/src/engine/net/client/handlers/KeepAliveServerClientHandler.java index cf1ebdea..8a9b2b81 100644 --- a/src/engine/net/client/handlers/KeepAliveServerClientHandler.java +++ b/src/engine/net/client/handlers/KeepAliveServerClientHandler.java @@ -26,8 +26,7 @@ public class KeepAliveServerClientHandler extends AbstractClientMsgHandler { @Override protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { - PlayerCharacter pc = origin.getPlayerCharacter(); - + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); // Member variable declaration @@ -37,10 +36,9 @@ public class KeepAliveServerClientHandler extends AbstractClientMsgHandler { msg = (KeepAliveServerClientMsg) baseMsg; - // Send ping to client - Dispatch dispatch = Dispatch.borrow(pc, msg); + Dispatch dispatch = Dispatch.borrow(playerCharacter, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); return true; diff --git a/src/engine/net/client/handlers/SetCombatModeMsgHandler.java b/src/engine/net/client/handlers/SetCombatModeMsgHandler.java new file mode 100644 index 00000000..193156b9 --- /dev/null +++ b/src/engine/net/client/handlers/SetCombatModeMsgHandler.java @@ -0,0 +1,57 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.Enum; +import engine.exception.MsgSendException; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.SetCombatModeMsg; +import engine.net.client.msg.UpdateStateMsg; +import engine.objects.PlayerCharacter; +import engine.server.MBServerStatics; + +public class SetCombatModeMsgHandler extends AbstractClientMsgHandler { + + public SetCombatModeMsgHandler() { + super(SetCombatModeMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); + + // Member variable declaration + + SetCombatModeMsg msg; + boolean toggle; + + // Member variable assignment + + msg = (SetCombatModeMsg) baseMsg; + + if (playerCharacter == null) + return true; + + toggle = msg.getToggle(); + playerCharacter.setCombat(toggle); + + if (!toggle) // toggle is move it to false so clear combat target + playerCharacter.setCombatTarget(null); //clear last combat target + + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(playerCharacter); + DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); + + return true; + } + +} \ No newline at end of file diff --git a/src/engine/net/client/handlers/ToggleCombatMsgHandler.java b/src/engine/net/client/handlers/ToggleCombatMsgHandler.java new file mode 100644 index 00000000..c00c189e --- /dev/null +++ b/src/engine/net/client/handlers/ToggleCombatMsgHandler.java @@ -0,0 +1,57 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.Enum; +import engine.exception.MsgSendException; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.ToggleCombatMsg; +import engine.net.client.msg.UpdateStateMsg; +import engine.objects.PlayerCharacter; +import engine.server.MBServerStatics; + +public class ToggleCombatMsgHandler extends AbstractClientMsgHandler { + + public ToggleCombatMsgHandler() { + super(ToggleCombatMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); + + // Member variable declaration + + ToggleCombatMsg msg; + boolean toggle; + + // Member variable assignment + + msg = (ToggleCombatMsg) baseMsg; + + if (playerCharacter == null) + return true; + + toggle = msg.toggleCombat(); + playerCharacter.setCombat(toggle); + + if (!toggle) // toggle is move it to false so clear combat target + playerCharacter.setCombatTarget(null); //clear last combat target + + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(playerCharacter); + DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); + + return true; + } + +} \ No newline at end of file