Browse Source

Handlers created for gold-vault interactions

combat-2
MagicBot 8 months ago
parent
commit
083349b75b
  1. 39
      src/engine/net/client/ClientMessagePump.java
  2. 4
      src/engine/net/client/Protocol.java
  3. 43
      src/engine/net/client/handlers/GoldFromVaultMsgHandler.java
  4. 43
      src/engine/net/client/handlers/GoldToVaultMsgHandler.java
  5. 10
      src/engine/net/client/msg/GoldFromVaultMsg.java
  6. 8
      src/engine/net/client/msg/GoldToVaultMsg.java
  7. 4
      src/engine/objects/Account.java

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

@ -187,39 +187,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -187,39 +187,6 @@ public class ClientMessagePump implements NetMsgHandler {
ChatManager.chatInfoError(player, "Can't transfer to vault: " + reason);
}
private static void transferGoldFromVaultToInventory(TransferGoldFromVaultToInventoryMsg msg, ClientConnection origin) {
PlayerCharacter player = origin.getPlayerCharacter();
if (player == null)
return;
Account account = player.getAccount();
if (account == null)
return;
account.transferGoldFromVaultToInventory(msg, origin);
}
private static void transferGoldFromInventoryToVault(TransferGoldFromInventoryToVaultMsg msg, ClientConnection origin) {
PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch;
if (player == null)
return;
Account account = player.getAccount();
if (account == null)
return;
account.transferGoldFromInventoryToVault(msg, origin);
}
private static void DeleteItem(DeleteItemMsg msg, ClientConnection origin) {
CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager;
@ -1144,12 +1111,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -1144,12 +1111,6 @@ public class ClientMessagePump implements NetMsgHandler {
case SHOWCOMBATINFO:
show((ShowMsg) msg, origin);
break;
case TRANSFERGOLDFROMVAULTTOINVENTORY:
transferGoldFromVaultToInventory((TransferGoldFromVaultToInventoryMsg) msg, origin);
break;
case GOLDTOVAULT:
transferGoldFromInventoryToVault((TransferGoldFromInventoryToVaultMsg) msg, origin);
break;
case REQUESTTOTRADE:
TradeManager.tradeRequest((TradeRequestMsg) msg, origin);
break;

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

@ -99,7 +99,8 @@ public enum Protocol { @@ -99,7 +99,8 @@ public enum Protocol {
FURNITURE(0xCE7FA503, FurnitureMsg.class, FurnitureHandler.class),
GAMESERVERIPRESPONSE(0x6C95CF87, GameServerIPResponseMsg.class, null), // Game Server IP Response
GLOBALCHANNELMESSAGE(0x2bf03fd2, null, null),
GOLDTOVAULT(0x3ABAEE49, TransferGoldFromInventoryToVaultMsg.class, null), // Transfer Gold from Inventory to Vault
GOLDFROMVAULT(0x011D0123, GoldFromVaultMsg.class, GoldFromVaultMsgHandler.class), // Transfer Gold from Vault to Inventory
GOLDTOVAULT(0x3ABAEE49, GoldToVaultMsg.class, GoldToVaultMsgHandler.class), // Transfer Gold from Inventory to Vault
GROUPDISBAND(0xE2B85AA4, DisbandGroupMsg.class, DisbandGroupHandler.class), //Disband Group
GROUPFOLLOW(0xC61B0476, FormationFollowMsg.class, FormationFollowHandler.class), //Toggle Follow, set Formation
GROUPLEADERAPPOINT(0xEF778DD3, AppointGroupLeaderMsg.class, AppointGroupLeaderHandler.class), //Appoint new group leader
@ -221,7 +222,6 @@ public enum Protocol { @@ -221,7 +222,6 @@ public enum Protocol {
TRAINERLIST(0x41FABA62, TrainerInfoMsg.class, null), //Req/Send Trainer Info/Pricing
TRAINSKILL(0xB0BF68CD, TrainMsg.class, null), //Train skills/powers
TRANSFERASSET(0x3EA1C4C9, TransferAssetMsg.class, TransferAssetMsgHandler.class), // Transfer Building
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
TRANSFERITEMTOBANK(0xD48C46FA, TransferItemToBankMsg.class, TransferItemToBankMsgHandler.class), // Transfer Item from Inventory to Bank

43
src/engine/net/client/handlers/GoldFromVaultMsgHandler.java

@ -0,0 +1,43 @@ @@ -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.GoldFromVaultMsg;
import engine.objects.Account;
import engine.objects.PlayerCharacter;
public class GoldFromVaultMsgHandler extends AbstractClientMsgHandler {
public GoldFromVaultMsgHandler() {
super(GoldFromVaultMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter player = origin.getPlayerCharacter();
GoldFromVaultMsg msg = (GoldFromVaultMsg) baseMsg;
if (player == null)
return true;
Account account = player.getAccount();
if (account == null)
return true;
account.transferGoldFromVaultToInventory(msg, origin);
return true;
}
}

43
src/engine/net/client/handlers/GoldToVaultMsgHandler.java

@ -0,0 +1,43 @@ @@ -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.GoldToVaultMsg;
import engine.objects.Account;
import engine.objects.PlayerCharacter;
public class GoldToVaultMsgHandler extends AbstractClientMsgHandler {
public GoldToVaultMsgHandler() {
super(GoldToVaultMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter player = origin.getPlayerCharacter();
GoldToVaultMsg msg = (GoldToVaultMsg) baseMsg;
if (player == null)
return true;
Account account = player.getAccount();
if (account == null)
return true;
account.transferGoldFromInventoryToVault(msg, origin);
return true;
}
}

10
src/engine/net/client/msg/TransferGoldFromVaultToInventoryMsg.java → src/engine/net/client/msg/GoldFromVaultMsg.java

@ -21,7 +21,7 @@ import engine.net.client.Protocol; @@ -21,7 +21,7 @@ import engine.net.client.Protocol;
*
* @author Eighty
*/
public class TransferGoldFromVaultToInventoryMsg extends ClientNetMsg {
public class GoldFromVaultMsg extends ClientNetMsg {
private long unknown01;
private long playerCompID;
@ -31,8 +31,8 @@ public class TransferGoldFromVaultToInventoryMsg extends ClientNetMsg { @@ -31,8 +31,8 @@ public class TransferGoldFromVaultToInventoryMsg extends ClientNetMsg {
/**
* This is the general purpose constructor
*/
public TransferGoldFromVaultToInventoryMsg(long unknown01, long playerCompID, long accountCompID, int amount) {
super(Protocol.TRANSFERGOLDFROMVAULTTOINVENTORY);
public GoldFromVaultMsg(long unknown01, long playerCompID, long accountCompID, int amount) {
super(Protocol.GOLDFROMVAULT);
this.unknown01 = unknown01;
this.playerCompID = playerCompID;
this.accountCompID = accountCompID;
@ -44,8 +44,8 @@ public class TransferGoldFromVaultToInventoryMsg extends ClientNetMsg { @@ -44,8 +44,8 @@ public class TransferGoldFromVaultToInventoryMsg extends ClientNetMsg {
* past the limit) then this constructor Throws that Exception to the
* caller.
*/
public TransferGoldFromVaultToInventoryMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.TRANSFERGOLDFROMVAULTTOINVENTORY, origin, reader);
public GoldFromVaultMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.GOLDFROMVAULT, origin, reader);
}
/**

8
src/engine/net/client/msg/TransferGoldFromInventoryToVaultMsg.java → src/engine/net/client/msg/GoldToVaultMsg.java

@ -22,7 +22,7 @@ import engine.net.client.Protocol; @@ -22,7 +22,7 @@ import engine.net.client.Protocol;
* @author Eighty
*/
public class TransferGoldFromInventoryToVaultMsg extends ClientNetMsg {
public class GoldToVaultMsg extends ClientNetMsg {
private int playerID;
private int accountID;
@ -33,12 +33,12 @@ public class TransferGoldFromInventoryToVaultMsg extends ClientNetMsg { @@ -33,12 +33,12 @@ public class TransferGoldFromInventoryToVaultMsg extends ClientNetMsg {
/**
* This is the general purpose constructor
*/
public TransferGoldFromInventoryToVaultMsg() {
public GoldToVaultMsg() {
super(Protocol.GOLDTOVAULT);
}
public TransferGoldFromInventoryToVaultMsg(int playerID, int npcID, int accountID, int amount) {
public GoldToVaultMsg(int playerID, int npcID, int accountID, int amount) {
super(Protocol.GOLDTOVAULT);
this.playerID = playerID;
this.npcID = npcID;
@ -52,7 +52,7 @@ public class TransferGoldFromInventoryToVaultMsg extends ClientNetMsg { @@ -52,7 +52,7 @@ public class TransferGoldFromInventoryToVaultMsg extends ClientNetMsg {
* past the limit) then this constructor Throws that Exception to the
* caller.
*/
public TransferGoldFromInventoryToVaultMsg(AbstractConnection origin, ByteBufferReader reader) {
public GoldToVaultMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.GOLDTOVAULT, origin, reader);
}

4
src/engine/objects/Account.java

@ -280,7 +280,7 @@ public class Account extends AbstractGameObject { @@ -280,7 +280,7 @@ public class Account extends AbstractGameObject {
}
}
public synchronized void transferGoldFromVaultToInventory(TransferGoldFromVaultToInventoryMsg msg, ClientConnection origin) {
public synchronized void transferGoldFromVaultToInventory(GoldFromVaultMsg msg, ClientConnection origin) {
PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch;
@ -332,7 +332,7 @@ public class Account extends AbstractGameObject { @@ -332,7 +332,7 @@ public class Account extends AbstractGameObject {
}
public synchronized void transferGoldFromInventoryToVault(TransferGoldFromInventoryToVaultMsg msg, ClientConnection origin) {
public synchronized void transferGoldFromInventoryToVault(GoldToVaultMsg msg, ClientConnection origin) {
PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch;

Loading…
Cancel
Save