当前位置: 首页>>代码示例>>C++>>正文


C++ IPacket::EndOfStream方法代码示例

本文整理汇总了C++中IPacket::EndOfStream方法的典型用法代码示例。如果您正苦于以下问题:C++ IPacket::EndOfStream方法的具体用法?C++ IPacket::EndOfStream怎么用?C++ IPacket::EndOfStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPacket的用法示例。


在下文中一共展示了IPacket::EndOfStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnStatsStrInc

int StateGame::OnStatsStrInc (IPacket &packet)
{
    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    boost::shared_ptr<Player> player = static_cast<srv::Connection*>(m_connection)->GetPlayer();

    if (!player)
        return MSG_ERROR;

    if  (player->get_stat())
    {
        player->inc_str();

        DB::PLAYER::Stats query;
        query(m_server->DBConnection(),player);

        boost::shared_ptr<OPacket> pkt(new OPacket);
        srv_pkt::IncStr(pkt);
        m_connection->Send(pkt);

        boost::shared_ptr<Party> party = player->get_party();

        if (party)
        {
            party->SendHPMPNotification(player->GetUniqueID(),player->hp(),player->max_hp(),player->mp(),
                player->max_mp());
        }
    }

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:32,代码来源:handler_stats.cpp

示例2: OnRestoreCharacter

int StateLobby::OnRestoreCharacter (IPacket &packet)
{
    if (!m_loaded)
        return MSG_ERROR_ORDER;

    std::string name = packet.Read();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    player_iterator i = FindCharacterIndex(name);

    if ( i != m_player_list.end() )
    {
        (*i)->restore();
        (*i)->set_timeleft(0);

        boost::shared_ptr<OPacket> pkt(new OPacket);
        srv_pkt::Lobby(pkt,srv_pkt::LOBBY_ACTION_RESTORE);
        m_connection->Send(pkt);

        DB::PLAYER::Restore query;
        query(m_server->DBConnection(),(*i)->ID());
    }
    else
        return MSG_ERROR_ARG;

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:29,代码来源:server_state_lobby.cpp

示例3: OnExchangeConfirm

int StateGame::OnExchangeConfirm (IPacket &packet)
{
    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    boost::shared_ptr<Player> player = static_cast<srv::Connection*>(m_connection)->GetPlayer();

    if (!player)
        return MSG_ERROR;

    boost::shared_ptr<Player> target = get_invitation_player(player);

    if(!target)
        return MSG_SUCCESS;

    boost::shared_ptr<OPacket> pkt(new OPacket);
    srv_pkt::ExchangeConfirm(pkt);
    m_connection->Send(pkt);

    pkt.reset(new OPacket);

    srv_pkt::ExchangePlayerConfirm(pkt);
    m_server->Send(pkt,target->ConnectionID());

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:26,代码来源:handler_exchange.cpp

示例4: OnHandshake_Signature

int IStateHandshake::OnHandshake_Signature (const IPacket &packet)
{
    uint8_t signature[KEY_LENGTH] = { 0 };

    for (int i=0; i < KEY_LENGTH; ++i)
        signature[i] = packet.Read<uint8_t>();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    /// Simple check to see if the handshake is good
    if(memcmp(m_srv_signature,signature,KEY_LENGTH))
    {
#if defined DEBUG
        syslog(LOG_DEBUG,"clt::IStateHandshake::OnHandshake_Signature - Invalid Server Signature.");
        syslog(LOG_DEBUG,"Server Key = %i %i, Client Key = %i %i",m_srv_signature[0],m_srv_signature[1],
            signature[0],signature[1]);
#endif
        return MSG_ERROR_ARG;
    }

    Func_X_2(m_base_key, m_S, 0x3);

    boost::shared_ptr<SROAuth> auth =
            boost::shared_static_cast<SROAuth,Authentication>(m_connection->getAuthentication());

    auth->setKey(m_base_key,KEY_LENGTH);

    SendID();

    return MSG_SUCCESS;
}
开发者ID:Favorek,项目名称:ZelosOnline,代码行数:32,代码来源:state_handshake.cpp

示例5: OnExchangeRequest

int StateGame::OnExchangeRequest (IPacket &packet)
{
    uint32_t targetID = packet.Read<uint32_t>();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    World *world = m_server->GetWorld();

    boost::shared_ptr<Player> player = static_cast<srv::Connection*>(m_connection)->GetPlayer();

    if (!player)
        return MSG_ERROR;

    if (player->get_selected_object() != targetID)
        return MSG_ERROR_ARG;

    boost::shared_ptr<Player> target = world->FindPlayer_ByID(targetID);

    if(!target)
        return MSG_SUCCESS;

    player->set_invitation_player(targetID);

    target->set_invitation_player(player->GetUniqueID());
    target->set_invitation(INVITATION_EXCHANGE);

    boost::shared_ptr<OPacket> pkt(new OPacket);
    srv_pkt::Invite(pkt,INVITATION_EXCHANGE,player->GetUniqueID());
    m_server->Send(pkt,target->ConnectionID());

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:33,代码来源:handler_exchange.cpp

示例6: OnGMCommand_SpawnAllUniques

int StateGame::OnGMCommand_SpawnAllUniques (IPacket &packet)
{
    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:7,代码来源:handler_gm.cpp

示例7: OnCertify

int StateCertify::OnCertify (const IPacket &packet)
{
    uint8_t ret = packet.Read<uint8_t>();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    if (ret > ANSWER_ERROR)
        return MSG_ERROR_ARG;

    if (ret == ANSWER_ACCEPT)
    {
        syslog(LOG_INFO,"Certification Successfull.");

        m_service->runServer();

        m_connection->stop();
    }
    else
    {
        syslog(LOG_INFO,"Certification failed.");

        m_service->stop();
    }

    return MSG_SUCCESS;
}
开发者ID:Favorek,项目名称:ZelosOnline,代码行数:27,代码来源:state_certify.cpp

示例8: OnTicket

int StateGlobal::OnTicket (const IPacket &packet)
{
    Ticket ticket;

    ticket.ID = packet.Read<uint32_t>();

    ticket.usr = packet.Read();

    ticket.pw = packet.Read();

    ticket.IP = packet.Read();

    ticket.AccountID = packet.Read<uint32_t>();

    ticket.access_lv  = packet.Read<uint8_t>();

    ticket.sec_lv = packet.Read<uint8_t>();

    ticket.silk = packet.Read<uint32_t>();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    m_service->addTicket(ticket);

    return MSG_SUCCESS;
}
开发者ID:npcdoom,项目名称:ZelosOnline,代码行数:27,代码来源:state_global.cpp

示例9: OnGMCommand_AllowLogout

int StateGame::OnGMCommand_AllowLogout (IPacket &packet)
{
    std::string playerName = packet.Read();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:9,代码来源:handler_gm.cpp

示例10: OnGMCommand_LieName

int StateGame::OnGMCommand_LieName (IPacket &packet)
{
    std::string name = packet.Read();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:9,代码来源:handler_gm.cpp

示例11: OnHandshake_Clean

int IStateHandshake::OnHandshake_Clean (const IPacket &packet)
{
    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    SendID();

    return MSG_SUCCESS;
}
开发者ID:Favorek,项目名称:ZelosOnline,代码行数:9,代码来源:state_handshake.cpp

示例12: OnGMCommand_CreateItem

int StateGame::OnGMCommand_CreateItem (IPacket &packet)
{
    uint32_t itemID = packet.Read<uint32_t>();

    uint8_t arg = packet.Read<uint8_t>();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    boost::shared_ptr<Player> player = static_cast<srv::Connection*>(m_connection)->GetPlayer();

    if (!player)
        return MSG_ERROR;

    World *world = m_server->GetWorld();

    if (!world)
        return MSG_ERROR;

    boost::shared_ptr<OPacket> pkt(new OPacket);

    try
    {
        Item item = world->GetItemFactory()->Create(itemID);

        boost::shared_ptr<Storage> inv = player->get_storage(STORAGE_INVENTORY);

        uint8_t pos = inv->get_empty_position(13);

        if (pos == 255)
        {
            srv_pkt::ItemMove(pkt,srv_pkt::ITEM_ERROR_INVENTORY_FULL);
            m_connection->Send(pkt);
            return MSG_SUCCESS;
        }

        item.set_quantity(1);
        item.set_position(pos);
        item.set_place(STORAGE_INVENTORY);

        if (item.IsWeapon() || item.IsShield() || item.IsArmor() || item.IsAccessory())
            item.set_enchant_lv(arg);
        else
            item.set_quantity(arg);

        inv->InsertItem(item);

        srv_pkt::Item(pkt,srv_pkt::ITEM_MOVE_PICKUP,item);
        m_connection->Send(pkt);
    }
    catch (const Exception::InvalidItemID &error)
    {
        syslog(LOG_INFO,"Failed to create item with ID = %i",itemID);
    }

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:57,代码来源:handler_gm.cpp

示例13: OnGMCommand_RecallGuild

int StateGame::OnGMCommand_RecallGuild (IPacket &packet)
{
    std::string guildName = packet.Read();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:9,代码来源:handler_gm.cpp

示例14: OnValidateCharacterName

int StateLobby::OnValidateCharacterName (IPacket &packet)
{
    std::string name = packet.Read();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    if (IsNameValid(name))
    {
        boost::shared_ptr<OPacket> pkt(new OPacket);
        srv_pkt::Lobby(pkt,srv_pkt::LOBBY_ACTION_VALIDATE_NAME);
        m_connection->Send(pkt);
    }

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:16,代码来源:server_state_lobby.cpp

示例15: OnWhoIs

int IStateHandshake::OnWhoIs (const IPacket &packet)
{
    std::string srvID = packet.Read();

    uint8_t resv = packet.Read<uint8_t>();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    if (resv || srvID != m_SrvID)
        return MSG_ERROR_ARG;

    OnConfig();

    return MSG_SUCCESS;
}
开发者ID:Favorek,项目名称:ZelosOnline,代码行数:16,代码来源:state_handshake.cpp


注:本文中的IPacket::EndOfStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。