Handlers created for vendor buy/sell windows

This commit is contained in:
2024-03-24 10:34:41 -04:00
parent 083349b75b
commit 53b7aca0ce
6 changed files with 153 additions and 88 deletions
@@ -774,73 +774,6 @@ public class ClientMessagePump implements NetMsgHandler {
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
private static void openSellToNPCWindow(SellToNPCWindowMsg msg, ClientConnection origin) {
PlayerCharacter sourcePlayer = SessionManager.getPlayerCharacter(origin);
Dispatch dispatch;
if (sourcePlayer == null)
return;
NPC npc = NPC.getFromCache(msg.getNPCID());
if (npc == null)
return;
// test within talking range
if (sourcePlayer.getLoc().distanceSquared2D(npc.getLoc()) > MBServerStatics.NPC_TALK_RANGE * MBServerStatics.NPC_TALK_RANGE) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 14);
return;
}
Contract con = npc.getContract();
if (con == null)
return;
float bargain = sourcePlayer.getBargain();
float profit = npc.getBuyPercent(sourcePlayer) + bargain;
if (profit > 1)
profit = 1;
msg.setupOutput();
msg.setUnknown05(profit);
msg.setUnknown06(500000); //TODO set goldItem on npc later
msg.setItemType(con.getBuyItemType());
msg.setSkillTokens(con.getBuySkillToken());
msg.setUnknownArray(con.getBuyUnknownToken());
dispatch = Dispatch.borrow(sourcePlayer, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
private static void openBuyFromNPCWindow(BuyFromNPCWindowMsg msg, ClientConnection origin) {
PlayerCharacter sourcePlayer = SessionManager.getPlayerCharacter(origin);
Dispatch dispatch;
if (sourcePlayer == null)
return;
NPC npc = NPC.getFromCache(msg.getNpcID());
if (npc == null)
return;
// test within talking range
if (sourcePlayer.getLoc().distanceSquared2D(npc.getLoc()) > MBServerStatics.NPC_TALK_RANGE * MBServerStatics.NPC_TALK_RANGE) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 14);
return;
}
dispatch = Dispatch.borrow(sourcePlayer, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
protected static void petAttack(PetAttackMsg msg, ClientConnection conn) throws MsgSendException {
PlayerCharacter pc = SessionManager.getPlayerCharacter(conn);
@@ -1141,12 +1074,6 @@ public class ClientMessagePump implements NetMsgHandler {
case VENDORDIALOG:
VendorDialogMsg.replyDialog((VendorDialogMsg) msg, origin);
break;
case SHOPLIST:
openBuyFromNPCWindow((BuyFromNPCWindowMsg) msg, origin);
break;
case SHOPINFO:
openSellToNPCWindow((SellToNPCWindowMsg) msg, origin);
break;
case TRAINERLIST:
WorldServer.trainerInfo((TrainerInfoMsg) msg, origin);
break;