Browse Source

Handlers created for toggle combat messages

combat-2
MagicBot 8 months ago
parent
commit
a103e7c7cd
  1. 6
      src/engine/net/client/ClientMessagePump.java
  2. 4
      src/engine/net/client/Protocol.java
  3. 6
      src/engine/net/client/handlers/KeepAliveServerClientHandler.java
  4. 57
      src/engine/net/client/handlers/SetCombatModeMsgHandler.java
  5. 57
      src/engine/net/client/handlers/ToggleCombatMsgHandler.java

6
src/engine/net/client/ClientMessagePump.java

@ -378,12 +378,6 @@ public class ClientMessagePump implements NetMsgHandler {
break; break;
case OPENVAULT: case OPENVAULT:
break; break;
case COMBATMODE:
CombatManager.toggleCombat(((ToggleCombatMsg) msg).toggleCombat(), origin);
break;
case ARCCOMBATMODEATTACKING:
CombatManager.toggleCombat(((SetCombatModeMsg) msg).getToggle(), origin);
break;
case MODIFYGUILDSTATE: case MODIFYGUILDSTATE:
ToggleLfgRecruitingMsg tlrm = (ToggleLfgRecruitingMsg) msg; ToggleLfgRecruitingMsg tlrm = (ToggleLfgRecruitingMsg) msg;
toggleLfgRecruiting(tlrm, origin); toggleLfgRecruiting(tlrm, origin);

4
src/engine/net/client/Protocol.java

@ -28,7 +28,7 @@ public enum Protocol {
ADDFRIEND(0xCFA1C787, AddFriendMessage.class, null), ADDFRIEND(0xCFA1C787, AddFriendMessage.class, null),
ALLIANCECHANGE(0x0E7D0B57, AllianceChangeMsg.class, AllianceChangeMsgHandler.class), // Remove From Allies/Enemies List ALLIANCECHANGE(0x0E7D0B57, AllianceChangeMsg.class, AllianceChangeMsgHandler.class), // Remove From Allies/Enemies List
ALLYENEMYLIST(0xAEA443FD, AllyEnemyListMsg.class, AllyEnemyListMsgHandler.class), 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 ARCHOTZONECHANGE(0xDCFF196F, null, null), //change hotzone
ARCIGNORELISTUPDATE(0x4B1B17C2, IgnoreListMsg.class, null), //req/show ignore list ARCIGNORELISTUPDATE(0x4B1B17C2, IgnoreListMsg.class, null), //req/show ignore list
ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world
@ -79,7 +79,7 @@ public enum Protocol {
CLAIMGUILDTREE(0xFD1C6442, ClaimGuildTreeMsg.class, ClaimGuildTreeMsgHandler.class), CLAIMGUILDTREE(0xFD1C6442, ClaimGuildTreeMsg.class, ClaimGuildTreeMsgHandler.class),
CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, ClientAdminCommandMsgHandler.class), //Admin Command CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, ClientAdminCommandMsgHandler.class), //Admin Command
CLIENTUPDATEVAULT(0x66EDBECD, UpdateVaultMsg.class, null), 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), CONFIRMPROMOTE(0x153BB5F9, ConfirmPromoteMsg.class, null),
COSTTOOPENBANK(0x135BE5E8, AckBankWindowOpenedMsg.class, null), // ACK Bank Window Opened COSTTOOPENBANK(0x135BE5E8, AckBankWindowOpenedMsg.class, null), // ACK Bank Window Opened
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character, CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,

6
src/engine/net/client/handlers/KeepAliveServerClientHandler.java

@ -26,8 +26,7 @@ public class KeepAliveServerClientHandler extends AbstractClientMsgHandler {
@Override @Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter pc = origin.getPlayerCharacter(); PlayerCharacter playerCharacter = origin.getPlayerCharacter();
// Member variable declaration // Member variable declaration
@ -37,10 +36,9 @@ public class KeepAliveServerClientHandler extends AbstractClientMsgHandler {
msg = (KeepAliveServerClientMsg) baseMsg; msg = (KeepAliveServerClientMsg) baseMsg;
// Send ping to client // Send ping to client
Dispatch dispatch = Dispatch.borrow(pc, msg); Dispatch dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
return true; return true;

57
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;
}
}

57
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;
}
}
Loading…
Cancel
Save