Example #1
0
void VendingHandler::processBuyAck(Net::MessageIn &msg)
{
    UNIMPLIMENTEDPACKET;
    msg.readInt16("inv index");
    msg.readInt16("amount");
    msg.readUInt8("flag");
}
Example #2
0
void BuySellHandler::processNpcSell(Net::MessageIn &msg, int offset)
{
    msg.readInt16();  // length
    int n_items = (msg.getLength() - 4) / 10;
    if (n_items > 0)
    {
        SellDialog *dialog = new SellDialog(mNpcId);
        dialog->setMoney(PlayerInfo::getAttribute(MONEY));

        for (int k = 0; k < n_items; k++)
        {
            int index = msg.readInt16() - offset;
            int value = msg.readInt32();
            msg.readInt32();  // OCvalue

            Item *item = PlayerInfo::getInventory()->getItem(index);

            if (item && !(item->isEquipped()))
                dialog->addItem(item, value);
        }
    }
    else
    {
        SERVER_NOTICE(_("Nothing to sell."))
    }
}
Example #3
0
static void handleLooks(Being *being, Net::MessageIn &msg)
{
    // Order of sent slots. Has to be in sync with the server code.
    static int const nb_slots = 4;
    static int const slots[nb_slots] =
        { SPRITE_WEAPON, SPRITE_HAT, SPRITE_TOPCLOTHES,
          SPRITE_BOTTOMCLOTHES };

    int mask = msg.readInt8();

    if (mask & (1 << 7))
    {
        // The equipment has to be cleared first.
        for (int i = 0; i < nb_slots; ++i)
        {
            being->setSprite(slots[i], 0);
        }
    }

    // Fill slots enumerated by the bitmask.
    for (int i = 0; i < nb_slots; ++i)
    {
        if (!(mask & (1 << i))) continue;
        int id = msg.readInt16();
        being->setSprite(slots[i], id,"", (slots[i] == SPRITE_WEAPON));
    }
}
void BuySellRecv::processNpcSell(Net::MessageIn &msg)
{
    msg.readInt16("len");
    const int n_items = (msg.getLength() - 4) / 10;
    if (n_items > 0)
    {
        SellDialog *const dialog = CREATEWIDGETR(NpcSellDialog, mNpcId);
        dialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));

        for (int k = 0; k < n_items; k++)
        {
            const int index = msg.readInt16("index") - INVENTORY_OFFSET;
            const int value = msg.readInt32("value");
            msg.readInt32("value?");

            const Item *const item = PlayerInfo::getInventory()
                ->getItem(index);

            if (item && item->isEquipped() == Equipped_false)
                dialog->addItem(item, value);
        }
    }
    else
    {
        NotifyManager::notify(NotifyTypes::SELL_LIST_EMPTY);
    }
}
Example #5
0
void PlayerHandler::processPlayerRankPoints(Net::MessageIn &msg)
{
    UNIMPLIMENTEDPACKET;
    msg.readInt16("type");
    msg.readInt32("points");
    msg.readInt32("fame");
}
Example #6
0
void PlayerHandler::processPlayerAutoShadowSpellList(Net::MessageIn &msg)
{
    UNIMPLIMENTEDPACKET;
    const int count = (msg.readInt16("len") - 8) / 2;
    for (int f = 0; f < count; f ++)
        msg.readInt16("skill id");
}
Example #7
0
void ItemRecv::processItemDropped2(Net::MessageIn &msg)
{
    const BeingId id = msg.readBeingId("id");
    const int itemId = msg.readInt16("item id");
    const ItemTypeT itemType = static_cast<ItemTypeT>(msg.readUInt8("type"));
    const Identified identified = fromInt(
        msg.readUInt8("identify"), Identified);
    const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
    const uint8_t refine = msg.readUInt8("refine");
    int cards[maxCards];
    for (int f = 0; f < maxCards; f++)
        cards[f] = msg.readInt16("card");
    const int x = msg.readInt16("x");
    const int y = msg.readInt16("y");
    const int amount = msg.readInt16("amount");
    const int subX = CAST_S32(msg.readInt8("subx"));
    const int subY = CAST_S32(msg.readInt8("suby"));

    if (actorManager)
    {
        actorManager->createItem(id,
            itemId,
            x, y,
            itemType,
            amount,
            refine,
            ItemColorManager::getColorFromCards(&cards[0]),
            identified,
            damaged,
            subX, subY,
            &cards[0]);
    }
}
Example #8
0
void SkillRecv::processSkillItemListWindow(Net::MessageIn &msg)
{
    UNIMPLEMENTEDPACKET;

    msg.readInt32("skill level");
    msg.readInt32("unused");
}
Example #9
0
void MercenaryRecv::processMercenaryUpdate(Net::MessageIn &msg)
{
    const int sp = msg.readInt16("type");
    const int val = msg.readInt32("value");
    switch (sp)
    {
        setMercStat(Sp::ATK1, Attributes::MERC_ATK);
        setMercStat(Sp::MATK1, Attributes::MERC_MATK);
        setMercStat(Sp::HIT, Attributes::MERC_HIT);
        setMercStat(Sp::CRITICAL, Attributes::MERC_CRIT);
        setMercStat(Sp::DEF1, Attributes::MERC_DEF);
        setMercStat(Sp::MDEF1, Attributes::MERC_MDEF);
        setMercStat(Sp::MERCFLEE, Attributes::MERC_FLEE);
        setMercStat(Sp::ASPD, Attributes::MERC_ATTACK_DELAY);
        setMercStat(Sp::HP, Attributes::MERC_HP);
        setMercStat(Sp::MAXHP, Attributes::MERC_MAX_HP);
        setMercStat(Sp::SP, Attributes::MERC_MP);
        setMercStat(Sp::MAXSP, Attributes::MERC_MAX_MP);
        setMercStat(Sp::MERCKILLS, Attributes::MERC_KILLS);
        setMercStat(Sp::MERCFAITH, Attributes::MERC_FAITH);
        default:
            reportAlways("Unknown mercenary stat %d",
                sp);
            break;
    }
}
Example #10
0
void CharServerHandler::processCharLogin(Net::MessageIn &msg)
{
    msg.skip(2);  // Length word
    int slots = msg.readInt16();
    if (slots > 0 && slots < 30)
        loginData.characterSlots = static_cast<short unsigned int>(slots);

    bool version = msg.readInt8() == 1 && serverVersion > 0;
    msg.skip(17); // 0 Unused

    delete_all(mCharacters);
    mCharacters.clear();

    // Derive number of characters from message length
    int count = (msg.getLength() - 24);
    if (version)
        count /= 120;
    else
        count /= 106;

    for (int i = 0; i < count; ++i)
    {
        Net::Character *character = new Net::Character;
        readPlayerData(msg, character, version);
        mCharacters.push_back(character);
        if (character && character->dummy)
        {
            logger->log("CharServer: Player: %s (%d)",
                character->dummy->getName().c_str(), character->slot);
        }
    }

    Client::setState(STATE_CHAR_SELECT);
}
Example #11
0
void TradeRecv::processTradeResponse(Net::MessageIn &msg)
{
    const uint8_t type = msg.readUInt8("type");
    msg.readInt32("char id");
    msg.readInt16("base level");
    Ea::TradeRecv::processTradeResponseContinue(type);
}
Example #12
0
void EffectHandler::handleCreateEffectPos(Net::MessageIn &msg)
{
    int id = msg.readInt16();
    Uint16 x = msg.readInt16();
    Uint16 y = msg.readInt16();
    effectManager->trigger(id, x, y);
}
Example #13
0
void TradeHandler::processTradeRequest(Net::MessageIn &msg)
{
    const std::string &partner = msg.readString(24, "name");
    msg.readInt32("char id");
    msg.readInt16("base level");
    processTradeRequestContinue(partner);
}
Example #14
0
void GameHandler::processMapLogin(Net::MessageIn &msg)
{
    unsigned char direction;
    uint16_t x, y;
    msg.readInt32("tick");
    msg.readCoordinates(x, y, direction, "position");
    msg.readInt16("unknown?");
    logger->log("Protocol: Player start position: (%d, %d),"
                " Direction: %d", x, y, direction);

    mLastHost &= 0xffffff;

    GameHandler *const g = static_cast<GameHandler*>(gameHandler);
    if (g)
    {
        Network *const network = g->mNetwork;
        if (network)
            network->pauseDispatch();
    }

    // Switch now or we'll have problems
    client->setState(STATE_GAME);
    if (localPlayer)
        localPlayer->setTileCoords(x, y);
}
Example #15
0
void SkillRecv::processSkillProduceEffect(Net::MessageIn &msg)
{
    UNIMPLEMENTEDPACKET;

    msg.readInt16("flag");
    msg.readInt16("item id");
}
void SkillHandler::processPlayerSkills(Net::MessageIn &msg) const
{
    msg.readInt16();  // length
    const int skillCount = (msg.getLength() - 4) / 37;
    int updateSkill = 0;

    for (int k = 0; k < skillCount; k++)
    {
        const int skillId = msg.readInt16();
        msg.readInt16();  // target type
        msg.skip(2);  // skill pool flags
        const int level = msg.readInt16();
        msg.readInt16();  // sp
        const int range = msg.readInt16();
        msg.skip(24);  // 0 unused
        const int up = msg.readInt8();
        const int oldLevel = PlayerInfo::getSkillLevel(skillId);
        if (oldLevel && oldLevel != level)
            updateSkill = skillId;
        PlayerInfo::setSkillLevel(skillId, level);
        if (skillDialog)
        {
            if (!skillDialog->updateSkill(skillId, range, up))
                skillDialog->addSkill(skillId, level, range, up);
        }
    }
    if (updateSkill && skillDialog)
        skillDialog->playUpdateEffect(updateSkill);
}
Example #17
0
void SkillRecv::processSkillCoolDown(Net::MessageIn &msg)
{
    const int skillId = msg.readInt16("skill id");
    const int duration = msg.readInt32("duration");
    if (skillDialog)
        skillDialog->setSkillDuration(SkillOwner::Player, skillId, duration);
}
Example #18
0
void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg)
{
    // Trade: New Item add response (was 0x00ea, now 01b1)
    const int index = msg.readInt16("index") - INVENTORY_OFFSET;
    Item *item = nullptr;
    if (PlayerInfo::getInventory())
        item = PlayerInfo::getInventory()->getItem(index);

    if (!item)
    {
        if (tradeWindow)
            tradeWindow->receivedOk(true);
        return;
    }
    const int quantity = msg.readInt16("amount");

    const uint8_t res = msg.readUInt8("status");
    switch (res)
    {
        case 0:
            // Successfully added item
            if (tradeWindow)
            {
                tradeWindow->addItem2(item->getId(),
                    item->getType(),
                    item->getCards(),
                    4,
                    true,
                    quantity,
                    item->getRefine(),
                    item->getColor(),
                    item->getIdentified(),
                    item->getDamaged(),
                    item->getFavorite(),
                    item->isEquipment());
            }
            item->increaseQuantity(-quantity);
            break;
        case 1:
            // Add item failed - player overweighted
            NotifyManager::notify(NotifyTypes::
                TRADE_ADD_PARTNER_OVER_WEIGHT);
            break;
        case 2:
            // Add item failed - player has no free slot
            NotifyManager::notify(NotifyTypes::TRADE_ADD_PARTNER_NO_SLOTS);
            break;
        case 3:
            // Add item failed - non tradable item
            NotifyManager::notify(NotifyTypes::TRADE_ADD_UNTRADABLE_ITEM);
            break;
        default:
            NotifyManager::notify(NotifyTypes::TRADE_ADD_ERROR);
            UNIMPLIMENTEDPACKET;
            logger->log("QQQ SMSG_TRADE_ITEM_ADD_RESPONSE: "
                        + toString(res));
            break;
    }
}
Example #19
0
void NpcHandler::processNpcShowProgressBar(Net::MessageIn &msg)
{
    UNIMPLIMENTEDPACKET;
    mRequestLang = false;
    // +++ probably need show progress bar in npc dialog
    msg.readInt32("color");
    msg.readInt32("seconds");
}
Example #20
0
void NpcRecv::processNpcCutin(Net::MessageIn &msg)
{
    Ea::NpcRecv::mRequestLang = false;
    const std::string image = msg.readString(64, "image name");
    const CutInT cutin = static_cast<CutInT>(msg.readUInt8("type"));
    if (cutInWindow)
        cutInWindow->show(image, cutin);
}
Example #21
0
void NpcRecv::processNpcSkin(Net::MessageIn &msg)
{
    const int len = msg.readInt16("len");
    npcHandler->getNpc(msg, NpcAction::Other);
    const std::string skin = msg.readString(len - 8, "skin");
    if (Ea::NpcRecv::mDialog)
        Ea::NpcRecv::mDialog->setSkin(skin);
}
Example #22
0
void BankRecv::processBankStatus(Net::MessageIn &msg)
{
    const int money = CAST_S32(msg.readInt64("money"));
    const int reason = msg.readInt16("reason");
    BankListener::distributeEvent(money);
    if (reason != 0)
        NotifyManager::notify(NotifyTypes::BANK_CHECK_FAILED);
}
Example #23
0
void CashShopHandler::processCashShopBuy(Net::MessageIn &msg)
{
    UNIMPLIMENTEDPACKET;
    msg.readInt32("id");
    msg.readInt16("result");
    msg.readInt32("cash points");
    msg.readInt32("kafra points");
}
Example #24
0
void SkillRecv::processSkillArrowCreateList(Net::MessageIn &msg)
{
    UNIMPLEMENTEDPACKET;

    const int count = (msg.readInt16("len") - 4) / 2;
    for (int f = 0; f < count; f ++)
        msg.readInt16("item id");
}
void GuildHandler::processGuildSkillUp(Net::MessageIn &msg) const
{
    msg.readInt16();  // Skill ID
    msg.readInt16();  // Level
    msg.readInt16();  // SP
    msg.readInt16();  // 'Range'
    msg.readInt8();   // unused? (always 1)
}
Example #26
0
void GuildHandler::processGuildInvite(Net::MessageIn &msg)
{
    const int guildId = msg.readInt32("guild id");
    const std::string guildName = msg.readString(24, "guild name");

    if (socialWindow)
        socialWindow->showGuildInvite(guildName, guildId, "");
}
Example #27
0
void VendingHandler::processShowBoard(Net::MessageIn &msg)
{
    const BeingId id = msg.readBeingId("owner id");
    const std::string shopName = msg.readString(80, "shop name");
    Being *const dstBeing = actorManager->findBeing(id);
    if (dstBeing)
        dstBeing->setSellBoard(shopName);
}
Example #28
0
void BuyingStoreRecv::processBuyingStoreShowBoard(Net::MessageIn &msg)
{
    const BeingId id = msg.readBeingId("owner id");
    const std::string shopName = msg.readString(80, "shop name");
    Being *const dstBeing = actorManager->findBeing(id);
    if (dstBeing)
        dstBeing->setBuyBoard(shopName);
}
Example #29
0
void ChatHandler::handleQuitChannelResponse(Net::MessageIn &msg)
{
    if(msg.readInt8() == ERRMSG_OK)
    {
        short channelId = msg.readInt16();
        Channel *channel = channelManager->findById(channelId);
        channelManager->removeChannel(channel);
    }
}
Example #30
0
void ChatHandler::handleChatMessage(Net::MessageIn &msg)
{
    short channelId = msg.readInt16();
    std::string userNick = msg.readString();
    std::string chatMsg = msg.readString();

    Channel *channel = channelManager->findById(channelId);
    channel->getTab()->chatLog(userNick, chatMsg);
}