コード例 #1
0
ファイル: gamerecv.cpp プロジェクト: mekolat/ManaPlus
void GameRecv::processMapLogin(Net::MessageIn &msg)
{
    unsigned char direction;
    uint16_t x;
    uint16_t y;
    msg.readInt32("start time");
    msg.readCoordinates(x, y, direction, "position");
    msg.readInt8("x size");
    msg.readInt8("y size");
    logger->log("Protocol: Player start position: "
        "(%d, %d), Direction: %d",
        x, y, direction);
    if (msg.getVersion() >= 20080102)
        msg.readInt16("font");
    if (msg.getVersion() >= 20141022 && msg.getVersion() < 20160330)
        msg.readUInt8("sex");

    mLastHost &= 0xffffff;

    Network *const network = Network::mInstance;
    if (network != nullptr)
        network->pauseDispatch();

    // Switch now or we'll have problems
    client->setState(State::GAME);
    if (localPlayer != nullptr)
        localPlayer->setTileCoords(x, y);
}
コード例 #2
0
void TradeRecv::processTradeItemAdd(Net::MessageIn &msg)
{
    const int type = msg.readInt16("type");
    ItemTypeT itemType = ItemType::Unknown;
    if (msg.getVersion() >= 20100223)
    {
        itemType = static_cast<ItemTypeT>(
            msg.readUInt8("item type"));
    }
    const int amount = msg.readInt32("amount");
    const uint8_t identify = msg.readUInt8("identify");
    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");
    if ((serverVersion >= 8 || serverVersion == 0) &&
        msg.getVersion() >= 20150226)
    {
        for (int f = 0; f < 5; f ++)
        {
            msg.readInt16("rnd index");
            msg.readInt16("rnd value");
            msg.readUInt8("rnd param");
        }
    }

    if (tradeWindow)
    {
        if (type == 0)
        {
            tradeWindow->setMoney(amount);
        }
        else
        {
            tradeWindow->addItem2(type,
                itemType,
                cards,
                4,
                false,
                amount,
                refine,
                ItemColorManager::getColorFromCards(&cards[0]),
                fromBool(identify, Identified),
                damaged,
                Favorite_false,
                Equipm_false);
        }
    }
}
コード例 #3
0
void ItemRecv::processItemDropped(Net::MessageIn &msg)
{
    const BeingId id = msg.readBeingId("id");
    const int itemId = msg.readInt16("item id");
    ItemTypeT itemType = ItemType::Unknown;
    if (msg.getVersion() >= 20130000)
        itemType = static_cast<ItemTypeT>(msg.readInt16("type"));
    const Identified identified = fromInt(
        msg.readUInt8("identify"), Identified);
    const int x = msg.readInt16("x");
    const int y = msg.readInt16("y");
    const int subX = CAST_S32(msg.readInt8("subx"));
    const int subY = CAST_S32(msg.readInt8("suby"));
    const int amount = msg.readInt16("count");

    if (actorManager)
    {
        actorManager->createItem(id,
            itemId,
            x, y,
            itemType,
            amount,
            0,
            ItemColor_one,
            identified,
            Damaged_false,
            subX, subY,
            nullptr);
    }
}
コード例 #4
0
void TradeRecv::processTradeRequest(Net::MessageIn &msg)
{
    const std::string &partner = msg.readString(24, "name");
    if (msg.getVersion() >= 6)
    {
        msg.readInt32("char id");
        msg.readInt16("base level");
    }
    Ea::TradeRecv::processTradeRequestContinue(partner);
}
コード例 #5
0
ファイル: skillrecv.cpp プロジェクト: dreamsxin/ManaPlus
void SkillRecv::processSkillCoolDownList(Net::MessageIn &msg)
{
    int packetLen;
    if (msg.getVersion() >= 20120604)
        packetLen = 10;
    else
        packetLen = 6;
    const int count = (msg.readInt16("len") - 4) / packetLen;
    for (int f = 0; f < count; f ++)
    {
        const int skillId = msg.readInt16("skill id");
        if (msg.getVersion() >= 20120604)
            msg.readInt32("total");
        const int duration = msg.readInt32("duration");
        if (skillDialog)
        {
            skillDialog->setSkillDuration(SkillOwner::Player,
                skillId, duration);
        }
    }
}
コード例 #6
0
void BattleGroundRecv::processBattleUpdateHp(Net::MessageIn &msg)
{
    UNIMPLEMENTEDPACKET;
    msg.readBeingId("account id");
    if (msg.getVersion() >= 20140613)
    {
        msg.readInt32("hp");
        msg.readInt32("max hp");
    }
    else
    {
        msg.readString(24, "name");
        msg.readInt16("hp");
        msg.readInt16("max hp");
    }
}
コード例 #7
0
void BuyingStoreRecv::processBuyingStoreReport(Net::MessageIn &msg)
{
    UNIMPLEMENTEDPACKET;
    msg.readInt16("item id");
    msg.readInt16("amount");
    if (msg.getVersion() >= 20141016)
    {
        msg.readInt32("money");
        msg.readInt32("money limit");
        msg.readInt32("char id");
        msg.readInt32("date");
    }
    else
    {
        msg.readInt32("money limit");
    }
}
コード例 #8
0
ファイル: partyrecv.cpp プロジェクト: ManaPlus/ManaPlus
void PartyRecv::processPartyMemberInfo(Net::MessageIn &msg)
{
    const BeingId id = msg.readBeingId("account id");
    if (msg.getVersion() >= 20171207)
        msg.readBeingId("char id");
    const bool leader = msg.readInt32("leader") == 0U;
    int level = 0;
    if (msg.getVersionMain() >= 20170524 ||
        msg.getVersionRe() >= 20170502 ||
        packets_zero == true)
    {
        msg.readInt16("class");
        level = msg.readInt16("level");
    }
    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("pickup item share (&1)");
    msg.readInt8("get item share (&2)");

    if (Ea::taParty == nullptr)
        return;

    PartyMember *const member = Ea::taParty->addMember(id, nick);
    if (member != nullptr)
    {
        if ((partyTab != nullptr) && member->getOnline() != online)
            partyTab->showOnline(nick, fromBool(online, Online));
        member->setLeader(leader);
        member->setOnline(online);
        member->setMap(map);
        member->setX(x);
        member->setY(y);
        if (level != 0)
            member->setLevel(level);
    }
}
コード例 #9
0
ファイル: partyrecv.cpp プロジェクト: ManaPlus/ManaPlus
void PartyRecv::processPartySettings(Net::MessageIn &msg)
{
    if (partyTab == nullptr)
    {
        if (chatWindow == nullptr)
            return;

        Ea::PartyRecv::createTab();
    }

    const PartyShareT exp = static_cast<PartyShareT>(
        msg.readInt32("party exp"));
    Ea::PartyRecv::processPartyExpSettingsContinue(msg, exp);
    if (msg.getVersion() >= 20090603)
    {
        const PartyShareT item = static_cast<PartyShareT>(
            msg.readInt8("pickup item share (&1)"));
        Ea::PartyRecv::processPartyItemSettingsContinue(msg, item);
        const PartyShareT autoItem = static_cast<PartyShareT>(
            msg.readInt8("get auto item share (&2)"));
        processPartyAutoItemSettingsContinue(msg, autoItem);
    }
}
コード例 #10
0
ファイル: guildrecv.cpp プロジェクト: ManaPlus/ManaPlus
void GuildRecv::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 castle;
    std::string master;
    if (msg.getVersion() >= 20160622)
    {
        castle = msg.readString(16, "castles");
        msg.readInt32("money, unused");
        msg.readBeingId("leader char id");
    }
    else
    {
        master = msg.readString(24, "master name");
        castle = msg.readString(16, "castles");
        msg.readInt32("money, unused");
    }

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

    Guild *const g = Guild::getGuild(CAST_S16(guildId));
    if (g == nullptr)
        return;
    g->setName(name);
    g->setEmblemId(emblem);
}
コード例 #11
0
ファイル: guildrecv.cpp プロジェクト: ManaPlus/ManaPlus
void GuildRecv::processGuildMemberList(Net::MessageIn &msg)
{
    if (actorManager == nullptr)
        return;

    const int length = msg.readInt16("len");
    if (length < 4)
        return;
    int guildSize = 0;
    if (msg.getVersion() >= 20161026)
    {
        guildSize = 34;
    }
    else
    {
        guildSize = 104;
    }

    const int count = (length - 4) / guildSize;
    if (taGuild == nullptr)
    {
        logger->log1("!taGuild");
        return;
    }

    taGuild->clearMembers();

    int onlineNum = 0;
    int totalNum = 0;
    for (int i = 0; i < count; i++)
    {
        const BeingId id = msg.readBeingId("account id");
        const int charId = msg.readInt32("char id");
        msg.readInt16("hair");
        msg.readInt16("hair color");
        const int gender = msg.readInt16("gender");
        const int race = msg.readInt16("class");
        const int level = msg.readInt16("level");
        const int exp = msg.readInt32("exp");
        const int online = msg.readInt32("online");
        const int pos = msg.readInt32("position");
        std::string name;
        if (msg.getVersion() < 20161026)
        {
            msg.skip(50, "unused");
            name = msg.readString(24, "name");
        }
        else
        {
            msg.readInt32("last login");  // for now unused
            name = actorManager->findCharById(charId);
            if (name.empty())
            {
                beingHandler->requestNameByCharId(charId);
            }
        }

        GuildMember *const m = taGuild->addMember(id, charId, name);
        if (m != nullptr)
        {
            m->setOnline(online != 0);
            m->setID(id);
            m->setCharId(charId);
            m->setGender(Being::intToGender(CAST_U8(gender)));
            m->setLevel(level);
            m->setExp(exp);
            m->setPos(pos);
            m->setRace(race);
            Being *const being = actorManager->findBeingByName(
                name, ActorType::Player);
            if (being != nullptr)
            {
                being->setGuildName(taGuild->getName());
                if (being->getLevel() != level)
                {
                    being->setLevel(level);
                    being->updateName();
                }
            }
            if (online != 0)
                onlineNum ++;
            totalNum ++;
        }
    }
    taGuild->sort();
    actorManager->updatePlayerGuild();
    actorManager->updatePlayerColors();
    if (socialWindow != nullptr)
        socialWindow->updateGuildCounter(onlineNum, totalNum);
}
コード例 #12
0
ファイル: loginrecv.cpp プロジェクト: mekolat/ManaPlus
void LoginRecv::processLoginData(Net::MessageIn &msg)
{
    msg.readInt16("len");

    loginHandler->clearWorlds();

    int offset = 0;
    int serverLen = 0;
    if (msg.getVersion() >= 20170315)
    {
        offset = 47 + 17;
        serverLen = 32 + 128;
    }
    else
    {
        offset = 47;
        serverLen = 32;
    }

    const int worldCount = (msg.getLength() - offset) / serverLen;

    Ea::LoginRecv::mToken.session_ID1 = msg.readInt32("session id1");
    Ea::LoginRecv::mToken.account_ID = msg.readBeingId("accound id");
    Ea::LoginRecv::mToken.session_ID2 = msg.readInt32("session id2");
    msg.readInt32("old ip");
    loginData.lastLogin = msg.readString(24, "last login");
    msg.readInt16("unused");

    // reserve bits for future usage
    Ea::LoginRecv::mToken.sex = Being::intToGender(CAST_U8(
        msg.readUInt8("gender") & 3U));

    if (msg.getVersion() >= 20170315)
    {
        msg.readString(16, "twitter auth token");
        msg.readUInt8("twitter flag");
    }

    for (int i = 0; i < worldCount; i++)
    {
        WorldInfo *const world = new WorldInfo;

        world->address = msg.readInt32("ip address");
        world->port = msg.readInt16("port");
        world->name = msg.readString(20, "name");
        world->online_users = msg.readInt16("online number");
        config.setValue("updatehost", Ea::LoginRecv::mUpdateHost);
        world->updateHost = Ea::LoginRecv::mUpdateHost;
        msg.readInt16("maintenance");
        msg.readInt16("new");
        if (msg.getVersion() >= 20170315)
        {
            for (int f = 0; f < 32; f ++)
                msg.readInt32("unused2");
        }

        logger->log("Network: Server: %s (%s:%d)", world->name.c_str(),
            ipToString(world->address), world->port);

        Ea::LoginRecv::mWorlds.push_back(world);
    }
    client->setState(State::WORLD_SELECT);
}