diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index df5d5ba5..c51b1b7d 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -155,23 +155,8 @@ public class ClientMessagePump implements NetMsgHandler { DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, true); } - private static void transferItemFromVaultToInventory(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin) { - - PlayerCharacter player = origin.getPlayerCharacter(); - Dispatch dispatch; - - if (player == null) - return; - - if (player.getAccount() == null) - return; - player.getAccount().transferItemFromVaultToInventory(msg, origin); - - - } - //call this if the transfer fails server side to kick the item back to inventory from vault - public static void forceTransferFromInventoryToVault(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin, String reason) { + public static void forceTransferFromInventoryToVault(ItemFromVaultMsg msg, ClientConnection origin, String reason) { PlayerCharacter player = origin.getPlayerCharacter(); Dispatch dispatch; @@ -179,29 +164,15 @@ public class ClientMessagePump implements NetMsgHandler { if (player == null) return; - TransferItemFromInventoryToVaultMsg back = new TransferItemFromInventoryToVaultMsg(msg); + ItemToVaultMsg back = new ItemToVaultMsg(msg); dispatch = Dispatch.borrow(player, back); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); ChatManager.chatInfoError(player, "Can't transfer to inventory: " + reason); } - private static void transferItemFromInventoryToVault(TransferItemFromInventoryToVaultMsg msg, ClientConnection origin) { - - PlayerCharacter player = origin.getPlayerCharacter(); - Dispatch dispatch; - - if (player == null) - return; - - if (player.getAccount() == null) - return; - player.getAccount().transferItemFromInventoryToVault(msg, origin); - - } - //call this if the transfer fails server side to kick the item back to vault from inventory - public static void forceTransferFromVaultToInventory(TransferItemFromInventoryToVaultMsg msg, ClientConnection origin, String reason) { + public static void forceTransferFromVaultToInventory(ItemToVaultMsg msg, ClientConnection origin, String reason) { PlayerCharacter player = origin.getPlayerCharacter(); Dispatch dispatch; @@ -209,7 +180,7 @@ public class ClientMessagePump implements NetMsgHandler { if (player == null) return; - TransferItemFromVaultToInventoryMsg back = new TransferItemFromVaultToInventoryMsg(msg); + ItemFromVaultMsg back = new ItemFromVaultMsg(msg); dispatch = Dispatch.borrow(player, back); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); @@ -1173,12 +1144,6 @@ public class ClientMessagePump implements NetMsgHandler { case SHOWCOMBATINFO: show((ShowMsg) msg, origin); break; - case TRANSFERITEMFROMVAULTTOINVENTORY: - transferItemFromVaultToInventory((TransferItemFromVaultToInventoryMsg) msg, origin); - break; - case ITEMTOVAULT: - transferItemFromInventoryToVault((TransferItemFromInventoryToVaultMsg) msg, origin); - break; case TRANSFERGOLDFROMVAULTTOINVENTORY: transferGoldFromVaultToInventory((TransferGoldFromVaultToInventoryMsg) msg, origin); break; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index a88e1092..9a62e9c7 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -116,7 +116,8 @@ public enum Protocol { INVITETOGUILD(0x6819062A, InviteToGuildMsg.class, InviteToGuildHandler.class), // Invite player to guild, refuse guild invite ITEMHEALTHUPDATE(0xB635F55E, ItemHealthUpdateMsg.class, null), //Update Durability of item ITEMPRODUCTION(0x3CCE8E30, ItemProductionMsg.class, ItemProductionMsgHandler.class), - ITEMTOVAULT(0x3ABE4927, TransferItemFromInventoryToVaultMsg.class, null), // Transfer Item to Vault + ITEMTOVAULT(0x3ABE4927, ItemToVaultMsg.class, ItemToVaultMsgHandler.class), // Transfer Item to Vault + ITEMFROMVAULT(0x0119A64D, ItemFromVaultMsg.class, ItemFromVaultMsgHandler.class), // Transfer Item from Vault to Inventory JOINFORPROVINCE(0x1FB369CD, AcceptSubInviteMsg.class, AcceptSubInviteHandler.class), //Response to invite to swear? JOINFORSWORN(0xF6A4170F, null, null), JOINGROUP(0x7EC5E636, GroupInviteResponseMsg.class, GroupInviteResponseHandler.class), // Accept Group Invite @@ -223,7 +224,6 @@ public enum Protocol { TRANSFERGOLDFROMVAULTTOINVENTORY(0x011D0123, TransferGoldFromVaultToInventoryMsg.class, null), // Transfer Gold from Vault to Inventory TRANSFERGOLDTOFROMBUILDING(0x1B1AC8C7, TransferGoldToFromBuildingMsg.class, TransferGoldToFromBuildingMsgHandler.class), // Transfer Gold to/From Building, Transfer Error TRANSFERITEMFROMBANK(0x9D04977B, TransferItemFromBankMsg.class, TransferItemFromBankMsgHandler.class), // Transfer Item from Bank to Inventory - TRANSFERITEMFROMVAULTTOINVENTORY(0x0119A64D, TransferItemFromVaultToInventoryMsg.class, null), // Transfer Item from Vault to Inventory TRANSFERITEMTOBANK(0xD48C46FA, TransferItemToBankMsg.class, TransferItemToBankMsgHandler.class), // Transfer Item from Inventory to Bank UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, TransferItemFromEquipToInventoryHandler.class), // Transfer Item from Equip to Inventory UNKNOWN(0x238C9259, UnknownMsg.class, null), diff --git a/src/engine/net/client/handlers/ItemFromVaultMsgHandler.java b/src/engine/net/client/handlers/ItemFromVaultMsgHandler.java new file mode 100644 index 00000000..9d1a7d0d --- /dev/null +++ b/src/engine/net/client/handlers/ItemFromVaultMsgHandler.java @@ -0,0 +1,43 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.exception.MsgSendException; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.ItemFromVaultMsg; +import engine.objects.PlayerCharacter; + +public class ItemFromVaultMsgHandler extends AbstractClientMsgHandler { + + public ItemFromVaultMsgHandler() { + super(ItemFromVaultMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter player = origin.getPlayerCharacter(); + + ItemFromVaultMsg msg = (ItemFromVaultMsg) baseMsg; + + if (player == null) + return true; + ; + + if (player.getAccount() == null) + return true; + ; + + player.getAccount().transferItemFromVaultToInventory(msg, origin); + + return true; + } + +} \ No newline at end of file diff --git a/src/engine/net/client/handlers/ItemToVaultMsgHandler.java b/src/engine/net/client/handlers/ItemToVaultMsgHandler.java new file mode 100644 index 00000000..6d76e8c8 --- /dev/null +++ b/src/engine/net/client/handlers/ItemToVaultMsgHandler.java @@ -0,0 +1,43 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.exception.MsgSendException; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.ItemToVaultMsg; +import engine.objects.PlayerCharacter; + +public class ItemToVaultMsgHandler extends AbstractClientMsgHandler { + + public ItemToVaultMsgHandler() { + super(ItemToVaultMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + ItemToVaultMsg msg = (ItemToVaultMsg) baseMsg; + + PlayerCharacter player = origin.getPlayerCharacter(); + + if (player == null) + return true; + ; + + if (player.getAccount() == null) + return true; + ; + + player.getAccount().transferItemFromInventoryToVault(msg, origin); + + return true; + } + +} \ No newline at end of file diff --git a/src/engine/net/client/msg/TransferItemFromVaultToInventoryMsg.java b/src/engine/net/client/msg/ItemFromVaultMsg.java similarity index 85% rename from src/engine/net/client/msg/TransferItemFromVaultToInventoryMsg.java rename to src/engine/net/client/msg/ItemFromVaultMsg.java index 053a40d2..c1aee4c9 100644 --- a/src/engine/net/client/msg/TransferItemFromVaultToInventoryMsg.java +++ b/src/engine/net/client/msg/ItemFromVaultMsg.java @@ -22,7 +22,7 @@ import engine.net.client.Protocol; * @author Eighty */ -public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg { +public class ItemFromVaultMsg extends ClientNetMsg { private int unknown01; private int unknown02; @@ -35,9 +35,9 @@ public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg { /** * This is the general purpose constructor */ - public TransferItemFromVaultToInventoryMsg(int unknown01, int unknown02, - long playerCompID, int type, int objectUUID, int unknown03, int unknown04) { - super(Protocol.TRANSFERITEMFROMVAULTTOINVENTORY); + public ItemFromVaultMsg(int unknown01, int unknown02, + long playerCompID, int type, int objectUUID, int unknown03, int unknown04) { + super(Protocol.ITEMFROMVAULT); this.unknown01 = unknown01; this.unknown02 = unknown02; this.playerCompID = playerCompID; @@ -47,8 +47,8 @@ public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg { this.unknown04 = unknown04; } - public TransferItemFromVaultToInventoryMsg(TransferItemFromInventoryToVaultMsg msg) { - super(Protocol.TRANSFERITEMFROMVAULTTOINVENTORY); + public ItemFromVaultMsg(ItemToVaultMsg msg) { + super(Protocol.ITEMFROMVAULT); this.playerCompID = msg.getPlayerCompID(); this.unknown01 = msg.getUnknown01(); this.unknown02 = msg.getUnknown02(); @@ -61,8 +61,8 @@ public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg { /** * This is the general purpose constructor */ - public TransferItemFromVaultToInventoryMsg() { - super(Protocol.TRANSFERITEMFROMVAULTTOINVENTORY); + public ItemFromVaultMsg() { + super(Protocol.ITEMFROMVAULT); } /** @@ -71,9 +71,9 @@ public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg { * past the limit) then this constructor Throws that Exception to the * caller. */ - public TransferItemFromVaultToInventoryMsg(AbstractConnection origin, - ByteBufferReader reader) { - super(Protocol.TRANSFERITEMFROMVAULTTOINVENTORY, origin, reader); + public ItemFromVaultMsg(AbstractConnection origin, + ByteBufferReader reader) { + super(Protocol.ITEMFROMVAULT, origin, reader); } /** diff --git a/src/engine/net/client/msg/TransferItemFromInventoryToVaultMsg.java b/src/engine/net/client/msg/ItemToVaultMsg.java similarity index 88% rename from src/engine/net/client/msg/TransferItemFromInventoryToVaultMsg.java rename to src/engine/net/client/msg/ItemToVaultMsg.java index 9ec0cd7a..b4e3eb11 100644 --- a/src/engine/net/client/msg/TransferItemFromInventoryToVaultMsg.java +++ b/src/engine/net/client/msg/ItemToVaultMsg.java @@ -22,7 +22,7 @@ import engine.net.client.Protocol; * @author Eighty */ -public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg { +public class ItemToVaultMsg extends ClientNetMsg { private int unknown01; private int unknown02; @@ -35,9 +35,9 @@ public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg { /** * This is the general purpose constructor */ - public TransferItemFromInventoryToVaultMsg(long playerCompID, - int unknown01, int unknown02, int type, int objectUUID, int unknown03, - int unknown04) { + public ItemToVaultMsg(long playerCompID, + int unknown01, int unknown02, int type, int objectUUID, int unknown03, + int unknown04) { super(Protocol.ITEMTOVAULT); this.playerCompID = playerCompID; this.unknown01 = unknown01; @@ -48,7 +48,7 @@ public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg { this.unknown04 = unknown04; } - public TransferItemFromInventoryToVaultMsg(TransferItemFromVaultToInventoryMsg msg) { + public ItemToVaultMsg(ItemFromVaultMsg msg) { super(Protocol.ITEMTOVAULT); this.playerCompID = msg.getPlayerCompID(); this.unknown01 = msg.getUnknown01(); @@ -62,7 +62,7 @@ public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg { /** * This is the general purpose constructor */ - public TransferItemFromInventoryToVaultMsg() { + public ItemToVaultMsg() { super(Protocol.ITEMTOVAULT); } @@ -72,8 +72,8 @@ public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg { * past the limit) then this constructor Throws that Exception to the * caller. */ - public TransferItemFromInventoryToVaultMsg(AbstractConnection origin, - ByteBufferReader reader) { + public ItemToVaultMsg(AbstractConnection origin, + ByteBufferReader reader) { super(Protocol.ITEMTOVAULT, origin, reader); } diff --git a/src/engine/objects/Account.java b/src/engine/objects/Account.java index 9b57ad93..32ba9211 100644 --- a/src/engine/objects/Account.java +++ b/src/engine/objects/Account.java @@ -193,7 +193,7 @@ public class Account extends AbstractGameObject { } } - public synchronized void transferItemFromInventoryToVault(TransferItemFromInventoryToVaultMsg msg, ClientConnection origin) { + public synchronized void transferItemFromInventoryToVault(ItemToVaultMsg msg, ClientConnection origin) { PlayerCharacter player = origin.getPlayerCharacter(); Dispatch dispatch; @@ -233,7 +233,7 @@ public class Account extends AbstractGameObject { } } - public synchronized void transferItemFromVaultToInventory(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin) { + public synchronized void transferItemFromVaultToInventory(ItemFromVaultMsg msg, ClientConnection origin) { PlayerCharacter player = origin.getPlayerCharacter(); Dispatch dispatch;