Browse Source

Handler created for ToggleSitStandMsg

combat-2
MagicBot 8 months ago
parent
commit
7b9d9d64bb
  1. 29
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 65
      src/engine/net/client/handlers/ToggleSitStandMsgHandler.java

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

@ -48,31 +48,6 @@ public class ClientMessagePump implements NetMsgHandler {
this.server = server; 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) { private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) {
// According to the Wiki, the client should not send this message. // According to the Wiki, the client should not send this message.
// Log the instance to investigate, and modify Wiki accordingly. // Log the instance to investigate, and modify Wiki accordingly.
@ -362,10 +337,6 @@ public class ClientMessagePump implements NetMsgHandler {
break; break;
case OPENVAULT: case OPENVAULT:
break; break;
case TOGGLESITSTAND:
ToggleSitStandMsg tssm = (ToggleSitStandMsg) msg;
toggleSitStand(tssm, origin);
break;
case IGNORE: case IGNORE:
((IgnoreMsg) msg).handleRequest(origin); ((IgnoreMsg) msg).handleRequest(origin);
break; break;

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

@ -210,7 +210,7 @@ public enum Protocol {
TAXRESOURCES(0x4AD458AF, TaxResourcesMsg.class, TaxResourcesMsgHandler.class), TAXRESOURCES(0x4AD458AF, TaxResourcesMsg.class, TaxResourcesMsgHandler.class),
TELEPORT(0x23E726EA, TeleportToPointMsg.class, null), // Teleport to point TELEPORT(0x23E726EA, TeleportToPointMsg.class, null), // Teleport to point
TERRITORYCHANGE(0x6B388C8C, TerritoryChangeMessage.class, null), //Hey rich, look what I found? :) 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 TRADEADDGOLD(0x654ACB45, AddGoldToTradeWindowMsg.class, null), // Add Gold to Trade Window
TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, null), // Add an Item to the Trade Window TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, null), // Add an Item to the Trade Window
TRADECLOSE(0x5008D7FC, CloseTradeWindowMsg.class, null), // Cancel trade/ACK trade complete TRADECLOSE(0x5008D7FC, CloseTradeWindowMsg.class, null), // Cancel trade/ACK trade complete

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