Handler created for AddGoldToTradeWindowMsg

This commit is contained in:
2024-03-29 08:39:49 -04:00
parent 3f1385dd33
commit 3a2b138deb
5 changed files with 114 additions and 93 deletions
@@ -444,74 +444,6 @@ public class CharacterItemManager {
return true;
}
public synchronized boolean addGoldToTradeWindow(AddGoldToTradeWindowMsg msg) {
PlayerCharacter source = (PlayerCharacter) this.getOwner();
Dispatch dispatch;
if (source == null || !source.isAlive())
return false;
ClientConnection ccOther = this.getTradingWith();
if (ccOther == null)
return false;
PlayerCharacter other = ccOther.getPlayerCharacter();
if (other == null || !other.isAlive())
return false;
CharacterItemManager tradingWith = other.charItemManager;
if (tradingWith == null)
return false;
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(other, source);
UpdateTradeWindowMsg utwmOther = new UpdateTradeWindowMsg(source, other);
if (!canTrade(source, other))
return false;
this.setTradeCommitted((byte) 0);
tradingWith.setTradeCommitted((byte) 0);
int amt = msg.getAmount();
if (amt <= 0) {
Logger.info(source.getFirstName() + " added negative gold to trade window. Dupe attempt FAILED!");
return false;
}
if (amt > MBServerStatics.PLAYER_GOLD_LIMIT)
return false;
if (this.getGoldInventory().getNumOfItems() - amt < 0)
return false;
this.addGoldToTrade(amt);
// BONUS CODE BELOW: Thanks some unknown retard!
// sourceItemMan.updateInventory(sourceItemMan.getInventory(), true);
UpdateGoldMsg ugm = new UpdateGoldMsg(source);
ugm.configure();
modifyCommitToTrade();
dispatch = Dispatch.borrow(source, utwm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
dispatch = Dispatch.borrow(source, ugm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
dispatch = Dispatch.borrow(other, utwmOther);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
return true;
}
public synchronized boolean uncommitToTrade(UncommitToTradeMsg msg) {
PlayerCharacter source = (PlayerCharacter) this.getOwner();