Public Repository for the Magicbane Shadowbane Emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.4 KiB

// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.Enum;
import engine.exception.MsgSendException;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.CloseTradeWindowMsg;
import engine.objects.CharacterItemManager;
import engine.objects.PlayerCharacter;
public class CloseTradeWindowMsgHandler extends AbstractClientMsgHandler {
public CloseTradeWindowMsgHandler() {
super(CloseTradeWindowMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter source = origin.getPlayerCharacter();
// Member variable declaration
CloseTradeWindowMsg msg;
// Member variable assignment
msg = (CloseTradeWindowMsg) baseMsg;
Dispatch dispatch;
if (source == null)
return false;
CharacterItemManager sourceItemMan = source.charItemManager;
if (sourceItemMan == null)
return false;
int tradeID = source.charItemManager.tradeID;
CloseTradeWindowMsg closeMsg = new CloseTradeWindowMsg(source, tradeID);
dispatch = Dispatch.borrow(source, closeMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
ClientConnection cc2 = sourceItemMan.getTradingWith();
if (cc2 == null || cc2.getPlayerCharacter() == null) {
sourceItemMan.endTrade();
return true;
}
sourceItemMan.endTrade();
cc2.getPlayerCharacter().charItemManager.closeTradeWindow(msg, false);
return true;
}
}