Ejemplo n.º 1
0
void MailRecv::processReadMail(Net::MessageIn &msg)
{
    const int sz = msg.readInt16("len") - 101;
    MailMessage *const mail = new MailMessage;
    mail->id = msg.readInt32("message id");
    mail->title = msg.readString(40, "title");
    mail->sender = msg.readString(24, "sender name");
    msg.readInt32("unused");
    mail->money = msg.readInt32("money");
    mail->itemAmount = msg.readInt32("item amount");
    mail->itemId = msg.readInt16("item id");
    mail->itemType = msg.readInt16("item type");
    mail->itemIdentify = msg.readUInt8("identify");
    mail->itemAttribute = msg.readUInt8("attribute");
    mail->itemRefine = msg.readUInt8("refine");
    for (int f = 0; f < maxCards; f ++)
        mail->card[f] = msg.readUInt16("card");
    const int msgLen = msg.readUInt8("msg len");
    if (msgLen != sz)
        logger->log("error: wrong message size");
    mail->text = msg.readString(sz, "message");
    msg.readUInt8("zero");
    mail->strTime = timeToStr(mail->time);
    mailWindow->showMessage(mail);
}
Ejemplo n.º 2
0
void PartyRecv::processPartyMemberInfo(Net::MessageIn &msg)
{
    const BeingId id = msg.readBeingId("account id");
    const bool leader = msg.readInt32("leader") == 0U;
    const int x = msg.readInt16("x");
    const int y = msg.readInt16("y");
    const bool online = msg.readInt8("online") == 0U;
    msg.readString(24, "party name");
    const std::string nick = msg.readString(24, "player name");
    const std::string map = msg.readString(16, "map name");
    msg.readInt8("party.item&1");
    msg.readInt8("party.item&2");

    if (!Ea::taParty)
        return;

    PartyMember *const member = Ea::taParty->addMember(id, nick);
    if (member)
    {
        if (partyTab && member->getOnline() != online)
            partyTab->showOnline(nick, fromBool(online, Online));
        member->setLeader(leader);
        member->setOnline(online);
        member->setMap(map);
        member->setX(x);
        member->setY(y);
    }
}
Ejemplo n.º 3
0
void GuildRecv::processGuildLeave(Net::MessageIn &msg)
{
    const std::string nick = msg.readString(24, "nick");
    msg.readString(40, "message");

    if (taGuild != nullptr)
        taGuild->removeMember(nick);

    if (localPlayer == nullptr)
        return;

    if (nick == localPlayer->getName())
    {
        if (taGuild != nullptr)
        {
            taGuild->removeFromMembers();
            taGuild->clearMembers();
            localPlayer->removeGuild(taGuild->getId());
        }
        NotifyManager::notify(NotifyTypes::GUILD_LEFT);
        delete2(guildTab)

        if ((socialWindow != nullptr) && (taGuild != nullptr))
            socialWindow->removeTab(taGuild);
        if (actorManager != nullptr)
            actorManager->updatePlayerColors();
    }
    else
    {
Ejemplo n.º 4
0
void AuctionRecv::processAuctionResults(Net::MessageIn &msg)
{
    UNIMPLEMENTEDPACKET;
    msg.readInt16("len");
    msg.readInt32("pages");
    const int itemCount = msg.readInt32("items count");
    for (int f = 0; f < itemCount; f ++)
    {
        msg.readInt32("auction id");
        msg.readString(24, "seller name");
        msg.readInt16("item id");  // here item always 16 bit
        msg.readInt32("auction type");
        msg.readInt16("item amount");  // always 1
        msg.readUInt8("identify");
        msg.readUInt8("attribute");
        msg.readUInt8("refine");
        for (int d = 0; d < maxCards; d ++)
            msg.readUInt16("card");  // here item always 16 bit
        msg.readInt32("price");
        msg.readInt32("buy now");
        msg.readString(24, "buyer name");
        msg.readInt32("timestamp");
        // +++ need use ItemColorManager for color
    }
}
Ejemplo n.º 5
0
void NpcHandler::handleMessage(Net::MessageIn &msg)
{
    if (msg.getId() == SMSG_NPC_CHOICE || msg.getId() == SMSG_NPC_MESSAGE)
    {
        msg.readInt16();  // length
    }

    int npcId = msg.readInt32();
    Event *event = 0;

    switch (msg.getId())
    {
    case SMSG_NPC_CHOICE:
        event = new Event(Event::Menu);
        event->setInt("id", npcId);
        parseMenu(event, msg.readString(msg.getLength() - 8));
        event->trigger(Event::NpcChannel);
        break;

    case SMSG_NPC_MESSAGE:
        event = new Event(Event::Message);
        event->setInt("id", npcId);
        event->setString("text", msg.readString(msg.getLength() - 8));
        event->trigger(Event::NpcChannel);
        break;

     case SMSG_NPC_CLOSE:
        // Show the close button
        event = new Event(Event::Close);
        event->setInt("id", npcId);
        event->trigger(Event::NpcChannel);
        break;

    case SMSG_NPC_NEXT:
        // Show the next button
        event = new Event(Event::Next);
        event->setInt("id", npcId);
        event->trigger(Event::NpcChannel);
        break;

    case SMSG_NPC_INT_INPUT:
        // Request for an integer
        event = new Event(Event::IntegerInput);
        event->setInt("id", npcId);
        event->trigger(Event::NpcChannel);
        break;

    case SMSG_NPC_STR_INPUT:
        // Request for a string
        event = new Event(Event::StringInput);
        event->setInt("id", npcId);
        event->trigger(Event::NpcChannel);
        break;
    }

    delete event;

    if (local_player->getCurrentAction() != Being::SIT)
        local_player->setAction(Being::STAND);
}
Ejemplo n.º 6
0
void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
{
    if(msg.readInt8() == ERRMSG_OK)
    {
        short channelId = msg.readInt16();
        std::string channelName = msg.readString();
        std::string announcement = msg.readString();
        Channel *channel = new Channel(channelId, channelName, announcement);
        channelManager->addChannel(channel);
        ChatTab *tab = channel->getTab();
        tab->chatLog(strprintf(_("Topic: %s"), announcement.c_str()), BY_CHANNEL);

        std::string user;
        std::string userModes;
        tab->chatLog(_("Players in this channel:"), BY_CHANNEL);
        while(msg.getUnreadLength())
        {
            user = msg.readString();
            if (user == "")
                return;
            userModes = msg.readString();
            if (userModes.find('o') != std::string::npos)
            {
                user = "******" + user;
            }
            tab->chatLog(user, BY_CHANNEL);
        }

    }
    else
    {
        localChatTab->chatLog(_("Error joining channel."), BY_SERVER);
    }
}
Ejemplo n.º 7
0
void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
{
    int type = msg.readInt8();
    int id = msg.readInt16();
    Being::Action action = (Being::Action)msg.readInt8();
    int px = msg.readInt16();
    int py = msg.readInt16();
    BeingDirection direction = (BeingDirection)msg.readInt8();
    Being *being;

    if (!Game::instance()->getCurrentMap()->containsPixel(px, py))
    {
        logger->log("Warning: Received GPMSG_BEING_ENTER for being id %i "
                    "with position outside the map boundaries "
                    "(x = %i, y = %i)", id, px, py);
        return;
    }

    switch (type)
    {
        case OBJECT_CHARACTER:
        {
            std::string name = msg.readString();
            if (player_node->getName() == name)
            {
                being = player_node;
                being->setId(id);
            }
            else
            {
                being = actorSpriteManager->createBeing(id,
                                                    ActorSprite::PLAYER, 0);
                being->setName(name);
            }
            int hs = msg.readInt8(), hc = msg.readInt8();
            being->setSprite(SPRITE_HAIR, hs * -1, ColorDB::get(hc));
            being->setGender(msg.readInt8() == GENDER_MALE ?
                             GENDER_MALE : GENDER_FEMALE);
            handleLooks(being, msg);
        } break;

        case OBJECT_MONSTER:
        case OBJECT_NPC:
        {
            int subtype = msg.readInt16();
            being = actorSpriteManager->createBeing(id, type == OBJECT_MONSTER
                           ? ActorSprite::MONSTER : ActorSprite::NPC, subtype);
            std::string name = msg.readString();
            if (name.length() > 0) being->setName(name);
        } break;

        default:
            return;
    }

    being->setPosition(px, py);
    being->setDestination(px, py);
    being->setDirection(direction);
    being->setAction(action);
}
Ejemplo n.º 8
0
void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
{
    std::string userNick = msg.readString();
    std::string chatMsg = msg.readString();

    chatWindow->whisper(userNick, chatMsg);
}
Ejemplo n.º 9
0
void FamilyRecv::processAskForChild(Net::MessageIn &msg)
{
    if (!localPlayer)
    {
        mParent1 = msg.readBeingId("account id who ask");
        mParent2 = msg.readBeingId("acoount id for other parent");
        msg.readString(24, "name who ask");
        return;
    }
    mParent1 = msg.readBeingId("account id who ask");
    mParent2 = msg.readBeingId("acoount id for other parent");
    const std::string name1 = msg.readString(24, "name who ask");
    const Party *const party = localPlayer->getParty();
    if (party)
    {
        const PartyMember *const member = party->getMember(mParent2);
        if (member)
        {
            const std::string name2 = member->getName();
            CREATEWIDGETV(confirmDlg, ConfirmDialog,
                // TRANSLATORS: adopt child message
                _("Request parents"),
                // TRANSLATORS: adopt child message
                strprintf(_("Do you accept %s and %s as parents?"),
                name1.c_str(), name2.c_str()),
                SOUND_REQUEST,
                false);
            confirmDlg->addActionListener(&listener);
        }
    }
}
Ejemplo n.º 10
0
void PartyHandler::processPartyMove(Net::MessageIn &msg)
{
    int id = msg.readInt32();    // id
    PartyMember *m = nullptr;
    if (Ea::taParty)
        m = Ea::taParty->getMember(id);
    if (m)
    {
        msg.skip(4);        // 0
        m->setX(msg.readInt16());    // x
        m->setY(msg.readInt16());    // y
        m->setOnline(msg.readInt8());     // online (if 0)
        msg.readString(24); // party
        msg.readString(24); // nick
        m->setMap(msg.readString(16)); // map
    }
    else
    {
        msg.skip(4);        // 0
        msg.readInt16();    // x
        msg.readInt16();    // y
        msg.readInt8();     // online (if 0)
        msg.readString(24); // party
        msg.readString(24); // nick
        msg.readString(16); // map
    }
}
Ejemplo n.º 11
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);
}
Ejemplo n.º 12
0
void MailHandler::processNewMail(Net::MessageIn &msg)
{
    msg.readInt32("message id");
    const std::string subj = msg.readString(40, "title");
    const std::string sender = msg.readString(24, "sender name");
    NotifyManager::notify(NotifyTypes::NEW_MAIL,
        strprintf(_("You have new mail from %s with subject %s"),
        sender.c_str(), subj.c_str()));
    mailHandler->refresh();
}
Ejemplo n.º 13
0
void GuildHandler::processGuildNotice(Net::MessageIn &msg)
{
    const std::string msg1 = msg.readString(60, "msg1");
    const std::string msg2 = msg.readString(120, "msg2");
    if (guildTab)
    {
        guildTab->chatLog(msg1, ChatMsgType::BY_SERVER);
        guildTab->chatLog(msg2, ChatMsgType::BY_SERVER);
    }
}
Ejemplo n.º 14
0
void GuildHandler::processGuildNotice(Net::MessageIn &msg) const
{
    const std::string msg1 = msg.readString(60);   // Mes1
    const std::string msg2 = msg.readString(120);  // Mes2
    if (guildTab)
    {
        guildTab->chatLog(msg1, BY_SERVER);
        guildTab->chatLog(msg2, BY_SERVER);
    }
}
Ejemplo n.º 15
0
void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
{
    const int guildId = msg.readInt32("guild id");
    const int level = msg.readInt32("guild level");
    const int members = msg.readInt32("connect member");
    const int maxMembers = msg.readInt32("max member");
    const int avgLevel = msg.readInt32("average level");
    const int exp = msg.readInt32("exp");
    const int nextExp = msg.readInt32("next exp");
    msg.skip(12, "unused");
    const int emblem = msg.readInt32("emblem id");
    std::string name = msg.readString(24, "guild name");
    std::string master = msg.readString(24, "master name");
    std::string castle = msg.readString(16, "castles");
    msg.readInt32("unused");

    if (guildTab && showBasicInfo)
    {
        showBasicInfo = false;
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild name: %s"),
            name.c_str()), ChatMsgType::BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild master: %s"),
            master.c_str()), ChatMsgType::BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild level: %d"), level),
            ChatMsgType::BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Online members: %d"),
            members), ChatMsgType::BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Max members: %d"),
            maxMembers), ChatMsgType::BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Average level: %d"),
            avgLevel), ChatMsgType::BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild exp: %d"), exp),
            ChatMsgType::BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild next exp: %d"),
            nextExp), ChatMsgType::BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild castle: %s"),
            castle.c_str()), ChatMsgType::BY_SERVER);
    }

    Guild *const g = Guild::getGuild(static_cast<int16_t>(guildId));
    if (!g)
        return;
    g->setName(name);
    g->setEmblemId(emblem);
}
Ejemplo n.º 16
0
void ItemRecv::processItemMvpDropped(Net::MessageIn &msg)
{
    UNIMPLIMENTEDPACKET;
    msg.readInt16("len");
    msg.readUInt8("type");
    msg.readInt16("item id");
    msg.readUInt8("len");
    msg.readString(24, "name");
    msg.readUInt8("monster name len");
    msg.readString(24, "monster name");
}
Ejemplo n.º 17
0
void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
{
    const int guildId = msg.readInt32();      // Guild ID
    const int level = msg.readInt32();        // Guild level
    const int members = msg.readInt32();      // 'Connect member'
    const int maxMembers = msg.readInt32();   // 'Max member'
    const int avgLevel = msg.readInt32();     // Average level
    const int exp = msg.readInt32();          // Exp
    const int nextExp = msg.readInt32();      // Next exp
    msg.skip(16);                             // 0 unused
    std::string name = msg.readString(24);    // Name
    std::string master = msg.readString(24);  // Master's name
    std::string castle = msg.readString(20);  // Castles
                            // (ie: "Six Castles" or "None Taken")

    if (guildTab && showBasicInfo)
    {
        showBasicInfo = false;
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild name: %s"),
            name.c_str()), BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild master: %s"),
            master.c_str()), BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild level: %d"), level), BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Online members: %d"),
            members), BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Max members: %d"),
            maxMembers), BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Average level: %d"),
            avgLevel), BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild exp: %d"), exp), BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild next exp: %d"),
            nextExp), BY_SERVER);
        // TRANSLATORS: guild info message
        guildTab->chatLog(strprintf(_("Guild castle: %s"),
            castle.c_str()), BY_SERVER);
    }

    Guild *const g = Guild::getGuild(static_cast<int16_t>(guildId));
    if (!g)
        return;
    g->setName(name);
}
Ejemplo n.º 18
0
void GuildRecv::processGuildInvite(Net::MessageIn &msg)
{
    const int guildId = msg.readInt32("guild id");

    if (socialWindow != nullptr)
    {
        const std::string guildName = msg.readString(24, "guild name");
        socialWindow->showGuildInvite(guildName, guildId, "");
    }
    else
    {
        msg.readString(24, "guild name");
    }
}
Ejemplo n.º 19
0
void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg) const
{
    const int length = msg.readInt16();
    if (length < 4)
        return;

    const int count = (length - 4) / 88;

    for (int i = 0; i < count; i++)
    {
        msg.readString(24);  // Name (of expulsed?)
        msg.readString(24);  // 'Acc' (name of expulser?)
        msg.readString(24);  // Message
    }
}
Ejemplo n.º 20
0
void BattleGroundRecv::processBattleEmblem(Net::MessageIn &msg)
{
    UNIMPLEMENTEDPACKET;
    msg.readBeingId("account id");
    msg.readString(24, "name");
    msg.readInt16("bg id");
}
Ejemplo n.º 21
0
void LoginHandler::processUpdateHost2(Net::MessageIn &msg)
{
    int len;

    len = msg.readInt16() - 4;
    std::string updateHost = msg.readString(len);

    splitToStringVector(loginData.updateHosts, updateHost, '|');
    for (StringVectIter it = loginData.updateHosts.begin(),
         it_end = loginData.updateHosts.end(); it != it_end; ++ it)
    {
        if (!checkPath(*it))
        {
            logger->log1("Warning: incorrect update server name");
            loginData.updateHosts.clear();
            break;
        }
    }

    logger->log("Received update hosts \"%s\" from login server.",
        updateHost.c_str());

    if (Client::getState() == STATE_PRE_LOGIN)
        Client::setState(STATE_LOGIN);
}
Ejemplo n.º 22
0
void SkillRecv::processSkillAdd2(Net::MessageIn &msg)
{
    int updateSkill = 0;
    msg.readInt16("len");  // for now unused
    const int skillId = msg.readInt16("skill id");
    const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
        msg.readInt32("inf"));
    msg.readInt32("inf2");
    const int level = msg.readInt16("skill level");
    const int sp = msg.readInt16("sp");
    const int range = msg.readInt16("range");
    const std::string name = msg.readString(24, "skill name");
    const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
    const int oldLevel = PlayerInfo::getSkillLevel(skillId);
    if (oldLevel && oldLevel != level)
        updateSkill = skillId;
    PlayerInfo::setSkillLevel(skillId, level);
    if (skillDialog)
    {
        if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
        {
            skillDialog->addSkill(SkillOwner::Player,
                skillId, name, level, range, up, inf, sp);
        }
        skillDialog->update();
        if (updateSkill)
            skillDialog->playUpdateEffect(updateSkill);
    }
}
Ejemplo n.º 23
0
void NpcHandler::processNpcCutin(Net::MessageIn &msg)
{
    UNIMPLIMENTEDPACKET;
    mRequestLang = false;
    msg.readString(64, "image name");
    msg.readUInt8("type");
}
Ejemplo n.º 24
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);
}
Ejemplo n.º 25
0
void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg)
{
    const int count = (msg.readInt16("len") - 6) / 37;
    msg.readInt16("skill points");

    if (skillDialog != nullptr)
        skillDialog->hideSkills(SkillOwner::Guild);
    for (int i = 0; i < count; i++)
    {
        const int skillId = msg.readInt16("skill id");
        const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
            msg.readInt32("inf"));
        const int level = msg.readInt16("skill level");
        const int sp = msg.readInt16("sp");
        const int range = msg.readInt16("range");
        const std::string name = msg.readString(24, "skill name");
        const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
        PlayerInfo::setSkillLevel(skillId, level);
        if (skillDialog != nullptr)
        {
            if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
            {
                skillDialog->addSkill(SkillOwner::Guild,
                    skillId, name, level, range, up, inf, sp);
            }
        }
    }
    if (skillDialog != nullptr)
        skillDialog->updateModels();
}
Ejemplo n.º 26
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);
}
Ejemplo n.º 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);
}
Ejemplo n.º 28
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, "");
}
Ejemplo n.º 29
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);
}
Ejemplo n.º 30
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);
}