void BuySellHandler::handleMessage(Net::MessageIn &msg) { Being *being = actorSpriteManager->findBeing(msg.readInt16()); if (!being || being->getType() != ActorSprite::NPC) { return; } int npcId = being->getId(); switch (msg.getId()) { case GPMSG_NPC_BUY: { BuyDialog* dialog = new BuyDialog(npcId); dialog->reset(); dialog->setMoney(PlayerInfo::getAttribute(MONEY)); while (msg.getUnreadLength()) { int itemId = msg.readInt16(); int amount = msg.readInt16(); int value = msg.readInt16(); dialog->addItem(itemId, amount, value); } break; } case GPMSG_NPC_SELL: { SellDialog* dialog = new SellDialog(npcId); dialog->reset(); dialog->setMoney(PlayerInfo::getAttribute(MONEY)); while (msg.getUnreadLength()) { int itemId = msg.readInt16(); int amount = msg.readInt16(); int value = msg.readInt16(); dialog->addItem(new Item(itemId, amount, false), value); } break; } } }