Browse Source

Handler created for TargetObjectMsg

combat-2
MagicBot 8 months ago
parent
commit
ac92d69914
  1. 18
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 45
      src/engine/net/client/handlers/TargetObjectMsgHandler.java
  4. 6
      src/engine/net/client/msg/TargetObjectMsg.java
  5. 2
      src/engine/server/login/LoginServerMsgHandler.java

18
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); 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 { private static void social(SocialMsg msg, ClientConnection origin) throws MsgSendException {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if (pc == null) if (pc == null)
@ -832,10 +818,6 @@ public class ClientMessagePump implements NetMsgHandler {
protocolMsg = msg.getProtocolMsg(); protocolMsg = msg.getProtocolMsg();
switch (protocolMsg) { switch (protocolMsg) {
case SETSELECTEDOBECT:
ClientMessagePump.targetObject((TargetObjectMsg) msg, origin);
break;
/* /*
* Chat * Chat
*/ */

2
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 SETMOTD(0xFD21FC7C, MOTDCommitMsg.class, MOTDCommitHandler.class), //Commit Guild/Nation/IC MOTD Message
SETOBJVAL(0x08A50FD1, null, null), SETOBJVAL(0x08A50FD1, null, null),
SETRUNE(0x888E7C64, ApplyRuneMsg.class, null), //Apply Promotion, Stat Rune (maybe disc also) 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 SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, null), // Request/Response /show
SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, null), // Socials SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, null), // Socials

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

6
src/engine/net/client/msg/TargetObjectMsg.java

@ -24,7 +24,7 @@ public class TargetObjectMsg extends ClientNetMsg {
* This is the general purpose constructor. * This is the general purpose constructor.
*/ */
public TargetObjectMsg(int targetType, int targetID) { public TargetObjectMsg(int targetType, int targetID) {
super(Protocol.SETSELECTEDOBECT); super(Protocol.TARGETOBJECT);
this.targetType = targetType; this.targetType = targetType;
this.targetID = targetID; this.targetID = targetID;
} }
@ -33,7 +33,7 @@ public class TargetObjectMsg extends ClientNetMsg {
* This is the general purpose constructor. * This is the general purpose constructor.
*/ */
public TargetObjectMsg() { public TargetObjectMsg() {
super(Protocol.SETSELECTEDOBECT); super(Protocol.TARGETOBJECT);
} }
/** /**
@ -43,7 +43,7 @@ public class TargetObjectMsg extends ClientNetMsg {
* caller. * caller.
*/ */
public TargetObjectMsg(AbstractConnection origin, ByteBufferReader reader) { public TargetObjectMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.SETSELECTEDOBECT, origin, reader); super(Protocol.TARGETOBJECT, origin, reader);
} }
/** /**

2
src/engine/server/login/LoginServerMsgHandler.java

@ -108,7 +108,7 @@ public class LoginServerMsgHandler implements NetMsgHandler {
this.RequestGameServer((GameServerIPRequestMsg) clientNetMsg, origin); this.RequestGameServer((GameServerIPRequestMsg) clientNetMsg, origin);
break; break;
case SETSELECTEDOBECT: case TARGETOBJECT:
// Why is this being sent to login server? // Why is this being sent to login server?
break; break;

Loading…
Cancel
Save