• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetMembersSize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetMembersSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GetMembersSize函数的具体用法?C++ GetMembersSize怎么用?C++ GetMembersSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: data

void ArenaTeam::Roster(WorldSession *session)
{
    Player *pl = NULL;

    WorldPacket data(SMSG_ARENA_TEAM_ROSTER, 100);
    data << uint32(GetId());                                // arena team id
    data << uint32(GetMembersSize());                       // members count
    data << uint32(GetType());                              // arena team type?

    for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        pl = sObjectMgr->GetPlayer(itr->guid);

        data << uint64(itr->guid);                          // guid
        data << uint8((pl ? 1 : 0));                        // online flag
        data << itr->name;                                  // member name
        data << uint32((itr->guid == GetCaptain() ? 0 : 1));// captain flag 0 captain 1 member
        data << uint8((pl ? pl->getLevel() : 0));           // unknown, level?
        data << uint8(itr->Class);                          // class
        data << uint32(itr->games_week);                    // played this week
        data << uint32(itr->wins_week);                     // wins this week
        data << uint32(itr->games_season);                  // played this season
        data << uint32(itr->wins_season);                   // wins this season
        data << uint32(itr->personal_rating);               // personal rating
    }

    session->SendPacket(&data);
    sLog->outDebug("WORLD: Sent SMSG_ARENA_TEAM_ROSTER");
}
开发者ID:Blumfield,项目名称:TBCPvP,代码行数:29,代码来源:ArenaTeam.cpp


示例2: data

void ArenaTeam::Roster(WorldSession* session)
{
    uint8 unk308 = 0;

    WorldPacket data(SMSG_ARENA_TEAM_ROSTER, 100);
    data << uint32(GetId());                                // team id
    data << uint8(unk308);                                  // 308 unknown value but affect packet structure
    data << uint32(GetMembersSize());                       // members count
    data << uint32(GetType());                              // arena team type?

    for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        Player* pl = sObjectMgr.GetPlayer(itr->guid);

        data << itr->guid;                                  // guid
        data << uint8((pl ? 1 : 0));                        // online flag
        data << itr->name;                                  // member name
        data << uint32((itr->guid == GetCaptainGuid() ? 0 : 1));// captain flag 0 captain 1 member
        data << uint8((pl ? pl->getLevel() : 0));           // unknown, level?
        data << uint8(itr->Class);                          // class
        data << uint32(itr->games_week);                    // played this week
        data << uint32(itr->wins_week);                     // wins this week
        data << uint32(itr->games_season);                  // played this season
        data << uint32(itr->wins_season);                   // wins this season
        data << uint32(itr->personal_rating);               // personal rating
        if (unk308)
        {
            data << float(0.0);                             // 308 unk
            data << float(0.0);                             // 308 unk
        }
    }

    session->SendPacket(&data);
    DEBUG_LOG("WORLD: Sent SMSG_ARENA_TEAM_ROSTER");
}
开发者ID:mangostwo,项目名称:server,代码行数:35,代码来源:ArenaTeam.cpp


示例3: AddMemberNoSave

bool ArenaTeam::AddMemberNoSave(Player* pl)
{
    if (GetMembersSize() >= GetMaxMembersSize())
        return false;

    if (pl->GetArenaTeamId(GetSlot()))
    {
        sLog.outError("Arena::AddMember() : player already in this sized team");
        return false;
    }

    Player::RemovePetitionsAndSigns(pl->GetObjectGuid(), GetType());

    ArenaTeamMember newmember;
    newmember.name              = pl->GetName();
    newmember.guid              = pl->GetObjectGuid();
    newmember.Class             = pl->getClass();
    newmember.games_season      = 0;
    newmember.games_week        = 0;
    newmember.wins_season       = 0;
    newmember.wins_week         = 0;

    int32 conf_value = sWorld.getConfig(CONFIG_INT32_ARENA_STARTPERSONALRATING);
    if (conf_value < 0)                                     // -1 = select by season id
    {
        if (sWorld.getConfig(CONFIG_UINT32_ARENA_SEASON_ID) >= 6)
        {
            if (m_stats.rating < 1000)
                newmember.personal_rating = 0;
            else
                newmember.personal_rating = 1000;
        }
        else
        {
            newmember.personal_rating = 1500;
        }
    }
    else
        newmember.personal_rating = uint32(conf_value);

    m_members.push_back(newmember);

    if(pl)
    {
        uint8 arenaSlot = GetSlot();
        pl->SetInArenaTeam(m_TeamId, arenaSlot, GetType());
        pl->SetArenaTeamIdInvited(0);
        pl->SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_ID, m_TeamId);
        pl->SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_TYPE, GetType());
        pl->SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_MEMBER, (GetCaptainGuid() == pl->GetObjectGuid()) ? 0 : 1);
        pl->SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_GAMES_WEEK, newmember.games_week);
        pl->SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_GAMES_SEASON, newmember.games_season);
        pl->SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_WINS_SEASON, newmember.wins_season);
        pl->SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_PERSONAL_RATING, newmember.personal_rating);
    }
    return true;
}
开发者ID:Archives,项目名称:easy-mangos,代码行数:57,代码来源:ArenaTeam.cpp


示例4: data

void ArenaTeam::Roster(WorldSession *session)
{
    Player *pl = NULL;

    WorldPacket data(SMSG_ARENA_TEAM_ROSTER, 100);
    data << uint32(GetId());                                // arena team id
    data << uint32(GetMembersSize());                       // members count
    data << uint32(GetType());                              // arena team type?

    for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
    {
        pl = objmgr.GetPlayer(itr->guid);
        if(pl)
        {
            data << uint64(pl->GetGUID());                  // guid
            data << uint8(1);                               // online flag
            data << pl->GetName();                          // member name
            data << uint32(itr->guid == GetCaptain() ? 0 : 1);// unknown
            data << uint8(pl->getLevel());                  // unknown, probably level
            data << uint8(pl->getClass());                  // class
            data << uint32(itr->games_week);                // played this week
            data << uint32(itr->wins_week);                 // wins this week
            data << uint32(itr->games_season);              // played this season
            data << uint32(itr->wins_season);               // wins this season
            data << uint32(itr->personal_rating);           // personal rating
        }
        else
        {
            data << uint64(itr->guid);                      // guid
            data << uint8(0);                               // online flag
            data << itr->name;                              // member name
            data << uint32(itr->guid == GetCaptain() ? 0 : 1);// unknown
            data << uint8(0);                               // unknown, level?
            data << uint8(itr->Class);                      // class
            data << uint32(itr->games_week);                // played this week
            data << uint32(itr->wins_week);                 // wins this week
            data << uint32(itr->games_season);              // played this season
            data << uint32(itr->wins_season);               // wins this season
            data << uint32(itr->personal_rating);           // personal rating
        }
    }
    session->SendPacket(&data);
    sLog.outDebug("WORLD: Sent SMSG_ARENA_TEAM_ROSTER");
}
开发者ID:Cha0Sxx,项目名称:mangos,代码行数:44,代码来源:ArenaTeam.cpp


示例5: data

void ArenaTeam::Roster(WorldSession* session)
{
    Player* player = NULL;

    uint8 unk308 = 0;
    std::string tempName;

    WorldPacket data(SMSG_ARENA_TEAM_ROSTER, 100);
    data << uint32(GetId());                                // team id
    data << uint8(unk308);                                  // 308 unknown value but affect packet structure
    data << uint32(GetMembersSize());                       // members count
    data << uint32(GetType());                              // arena team type?

    for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
    {
        player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid);

        data << uint64(itr->Guid);                          // guid
        data << uint8((player ? 1 : 0));                        // online flag
        tempName = "";
        sObjectMgr->GetPlayerNameByGUID(itr->Guid, tempName);
        data << tempName;                                  // member name
        data << uint32((itr->Guid == GetCaptain() ? 0 : 1));// captain flag 0 captain 1 member
        data << uint8((player ? player->getLevel() : 0));           // unknown, level?
        data << uint8(itr->Class);                         // class
        data << uint32(itr->WeekGames);                    // played this week
        data << uint32(itr->WeekWins);                     // wins this week
        data << uint32(itr->SeasonGames);                  // played this season
        data << uint32(itr->SeasonWins);                   // wins this season
        data << uint32(itr->PersonalRating);               // personal rating
        if (unk308)
        {
            data << float(0.0f);                           // 308 unk
            data << float(0.0f);                           // 308 unk
        }
    }

    session->SendPacket(&data);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_ROSTER");
#endif
}
开发者ID:Helias,项目名称:azerothcore-wotlk,代码行数:42,代码来源:ArenaTeam.cpp


示例6: data

void ArenaTeam::Roster(WorldSession* session)
{
    Player* player = nullptr;

    uint8 unk308 = 0;

    WorldPacket data(SMSG_ARENA_TEAM_ROSTER, 100);
    data << uint32(GetId());                                    // team id
    data << uint8(unk308);                                      // 3.0.8 unknown value but affect packet structure
    data << uint32(GetMembersSize());                           // members count
    data << uint32(GetType());                                  // arena team type?

    for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
    {
        player = ObjectAccessor::FindConnectedPlayer(itr->Guid);

        data << uint64(itr->Guid);                              // guid
        data << uint8((player ? 1 : 0));                        // online flag
        data << itr->Name;                                      // member name
        data << uint32((itr->Guid == GetCaptain() ? 0 : 1));    // captain flag 0 captain 1 member
        data << uint8((player ? player->getLevel() : 0));       // unknown, level?
        data << uint8(itr->Class);                              // class
        data << uint32(itr->WeekGames);                         // played this week
        data << uint32(itr->WeekWins);                          // wins this week
        data << uint32(itr->SeasonGames);                       // played this season
        data << uint32(itr->SeasonWins);                        // wins this season
        data << uint32(itr->PersonalRating);                    // personal rating
        //if (unk308)
        //{
        //    data << float(0.0f);                              // 308 unk
        //    data << float(0.0f);                              // 308 unk
        //}
    }

    session->SendPacket(&data);
    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_ARENA_TEAM_ROSTER");
}
开发者ID:ElunaLuaEngine,项目名称:ElunaTrinityWotlk,代码行数:37,代码来源:ArenaTeam.cpp


示例7: data

void ArenaTeam::Roster(WorldSession* session)
{
    Player* pl = NULL;

    uint8 unk308 = 0;

    WorldPacket data(SMSG_ARENA_TEAM_ROSTER, 100);
    data << uint32(GetId());                                // team id
    data << uint8(unk308);                                  // 308 unknown value but affect packet structure
    data << uint32(GetMembersSize());                       // members count
    data << uint32(GetType());                              // arena team type?

    for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
    {
        pl = sObjectMgr->GetPlayer(itr->Guid);

        data << uint64(itr->Guid);                          // guid
        data << uint8((pl ? 1 : 0));                        // online flag
        data << itr->Name;                                  // member name
        data << uint32((itr->Guid == GetCaptain() ? 0 : 1));// captain flag 0 captain 1 member
        data << uint8((pl ? pl->getLevel() : 0));           // unknown, level?
        data << uint8(itr->Class);                          // class
        data << uint32(itr->WeekGames);                    // played this week
        data << uint32(itr->WeekWins);                     // wins this week
        data << uint32(itr->SeasonGames);                  // played this season
        data << uint32(itr->SeasonWins);                   // wins this season
        data << uint32(itr->PersonalRating);               // personal rating
        if (unk308)
        {
            data << float(0.0);                             // 308 unk
            data << float(0.0);                             // 308 unk
        }
    }

    session->SendPacket(&data);
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_ROSTER");
}
开发者ID:hodobaj,项目名称:ChaosCore,代码行数:37,代码来源:ArenaTeam.cpp


示例8: AddMember

bool ArenaTeam::AddMember(const uint64& playerGuid)
{
    std::string playerName;
    uint8 playerClass;

    // Check if arena team is full (Can't have more than type * 2 players)
    if (GetMembersSize() >= GetType() * 2)
        return false;

    // Get player name and class either from db or ObjectMgr
    Player* player = ObjectAccessor::FindPlayer(playerGuid);
    if (player)
    {
        playerClass = player->getClass();
        playerName = player->GetName();
    }
    else
    {
        //          0     1
        // SELECT name, class FROM characters WHERE guid = ?
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHARACTER_SELECT_CHARACTER_NAME_CLASS);
        stmt->setUInt32(0, GUID_LOPART(playerGuid));
        PreparedQueryResult result = CharacterDatabase.Query(stmt);

        if (!result)
            return false;

        playerName = (*result)[0].GetString();
        playerClass = (*result)[1].GetUInt8();
    }

    // Check if player is already in a similar arena team
    if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromDB(playerGuid, GetType()) != 0)
    {
        sLog->outError("Arena: Player %s (guid: %u) already has an arena team of type %u", playerName.c_str(), GUID_LOPART(playerGuid), GetType());
        return false;
    }

    // Set player's personal rating
    uint32 personalRating = 0;

    if (sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) >= 0)
        personalRating = sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);
    else if (GetRating() >= 1000)
        personalRating = 1000;

    // Try to get player's match maker rating from db and fall back to config setting if not found
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHARACTER_SELECT_MATCH_MAKER_RATING);
    stmt->setUInt32(0, GUID_LOPART(playerGuid));
    stmt->setUInt8(1, GetSlot());
    PreparedQueryResult result = CharacterDatabase.Query(stmt);

    uint32 matchMakerRating;
    if (result)
        matchMakerRating = (*result)[0].GetUInt32();
    else
        matchMakerRating = sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);

    // Remove all player signatures from other petitions
    // This will prevent player from joining too many arena teams and corrupt arena team data integrity
    Player::RemovePetitionsAndSigns(playerGuid, GetType());

    // Feed data to the struct
    ArenaTeamMember newmember;
    newmember.Name             = playerName;
    newmember.Guid             = playerGuid;
    newmember.Class            = playerClass;
    newmember.SeasonGames      = 0;
    newmember.WeekGames        = 0;
    newmember.SeasonWins       = 0;
    newmember.WeekWins         = 0;
    newmember.PersonalRating   = personalRating;
    newmember.MatchMakerRating = matchMakerRating;

    Members.push_back(newmember);

    // Save player's arena team membership to db
    stmt = CharacterDatabase.GetPreparedStatement(CHARACTER_INSERT_ARENA_TEAM_MEMBER);
    stmt->setUInt32(0, TeamId);
    stmt->setUInt32(1, GUID_LOPART(playerGuid));
    CharacterDatabase.Execute(stmt);

    // Inform player if online
    if (player)
    {
        player->SetInArenaTeam(TeamId, GetSlot(), GetType());
        player->SetArenaTeamIdInvited(0);

        // Hide promote/remove buttons
        if (CaptainGuid != playerGuid)
            player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
    }

    sLog->outArena("Player: %s [GUID: %u] joined arena team type: %u [Id: %u].", playerName.c_str(), GUID_LOPART(playerGuid), GetType(), GetId());

    return true;
}
开发者ID:Crash911,项目名称:RaptoredSkyFire,代码行数:97,代码来源:ArenaTeam.cpp


示例9: AddMember

bool ArenaTeam::AddMember(const uint64& PlayerGuid)
{
    std::string plName;
    uint8 plClass;
    uint32 plPRating;
    uint32 plMMRating;

    // arena team is full (can't have more than type * 2 players!)
    if (GetMembersSize() >= GetType() * 2)
        return false;

    Player *pl = sObjectMgr.GetPlayer(PlayerGuid);
    if (pl)
    {
        if (pl->GetArenaTeamId(GetSlot()))
        {
            sLog.outError("Arena::AddMember() : player already in this sized team");
            return false;
        }

        plClass = pl->getClass();
        plName = pl->GetName();
    }
    else
    {
        //                                                     0     1
        QueryResult result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", GUID_LOPART(PlayerGuid));
        if (!result)
            return false;

        plName = (*result)[0].GetString();
        plClass = (*result)[1].GetUInt8();

        // check if player already in arenateam of that size
        if (Player::GetArenaTeamIdFromDB(PlayerGuid, GetType()) != 0)
        {
            sLog.outError("Arena::AddMember() : player already in this sized team");
            return false;
        }
    }

    plMMRating = sWorld.getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);
    plPRating = 0;
    
    if (sWorld.getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) > 0)
        plPRating = sWorld.getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);
    else if (GetRating() >= 1000)
        plPRating = 1000;

    sWorld.getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);

    QueryResult result = CharacterDatabase.PQuery("SELECT matchmaker_rating FROM character_arena_stats WHERE guid='%u' AND slot='%u'", GUID_LOPART(PlayerGuid), GetSlot());
    if (result)
        plMMRating = (*result)[0].GetUInt32();

    // remove all player signs from another petitions
    // this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
    Player::RemovePetitionsAndSigns(PlayerGuid, GetType());

    ArenaTeamMember newmember;
    newmember.name              = plName;
    newmember.guid              = PlayerGuid;
    newmember.Class             = plClass;
    newmember.games_season      = 0;
    newmember.games_week        = 0;
    newmember.wins_season       = 0;
    newmember.wins_week         = 0;
    newmember.personal_rating   = plPRating;
    newmember.matchmaker_rating = plMMRating;

    m_members.push_back(newmember);

    CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid) VALUES ('%u', '%u')", m_TeamId, GUID_LOPART(newmember.guid));

    if (pl)
    {
        pl->SetInArenaTeam(m_TeamId, GetSlot(), GetType());
        pl->SetArenaTeamIdInvited(0);

        // hide promote/remove buttons
        if (m_CaptainGuid != PlayerGuid)
            pl->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
        sLog.outArena("Player: %s [GUID: %u] joined arena team type: %u [Id: %u].", pl->GetName(), pl->GetGUIDLow(), GetType(), GetId());
    }
    return true;
}
开发者ID:Ballwinkle,项目名称:SkyFireEMU,代码行数:86,代码来源:ArenaTeam.cpp


示例10: AddMember

bool ArenaTeam::AddMember(ObjectGuid playerGuid)
{
    std::string playerName;
    uint8 playerClass;

    // Check if arena team is full (Can't have more than type * 2 players)
    if (GetMembersSize() >= GetType() * 2)
        return false;

    // Get player name and class either from db or character cache
    Player* player = ObjectAccessor::FindPlayer(playerGuid);
    if (player)
    {
        playerClass = player->getClass();
        playerName = player->GetName();
    }
    else
    {
        CharacterCacheEntry const* cInfo = sCharacterCache->GetCharacterCacheByGuid(playerGuid);
        if (!cInfo)
            return false;

        playerName = cInfo->Name;
        playerClass = cInfo->Class;
    }

    // Check if player is already in a similar arena team
    if ((player && player->GetArenaTeamId(GetSlot())) || sCharacterCache->GetCharacterArenaTeamIdByGuid(playerGuid, GetType()) != 0)
    {
        TC_LOG_DEBUG("bg.arena", "Arena: %s %s already has an arena team of type %u", playerGuid.ToString().c_str(), playerName.c_str(), GetType());
        return false;
    }

    // Set player's personal rating
    uint32 personalRating = 0;

    if (sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) > 0)
        personalRating = sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);
    else if (GetRating() >= 1000)
        personalRating = 1000;

    // Try to get player's match maker rating from db and fall back to config setting if not found
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MATCH_MAKER_RATING);
    stmt->setUInt32(0, playerGuid.GetCounter());
    stmt->setUInt8(1, GetSlot());
    PreparedQueryResult result = CharacterDatabase.Query(stmt);

    uint32 matchMakerRating;
    if (result)
        matchMakerRating = (*result)[0].GetUInt16();
    else
        matchMakerRating = sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);

    // Remove all player signatures from other petitions
    // This will prevent player from joining too many arena teams and corrupt arena team data integrity
    Player::RemovePetitionsAndSigns(playerGuid, static_cast<CharterTypes>(GetType()));

    // Feed data to the struct
    ArenaTeamMember newMember;
    newMember.Name             = playerName;
    newMember.Guid             = playerGuid;
    newMember.Class            = playerClass;
    newMember.SeasonGames      = 0;
    newMember.WeekGames        = 0;
    newMember.SeasonWins       = 0;
    newMember.WeekWins         = 0;
    newMember.PersonalRating   = personalRating;
    newMember.MatchMakerRating = matchMakerRating;

    Members.push_back(newMember);
    sCharacterCache->UpdateCharacterArenaTeamId(playerGuid, GetSlot(), GetId());

    // Save player's arena team membership to db
    stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER);
    stmt->setUInt32(0, TeamId);
    stmt->setUInt32(1, playerGuid.GetCounter());
    CharacterDatabase.Execute(stmt);

    // Inform player if online
    if (player)
    {
        player->SetInArenaTeam(TeamId, GetSlot(), GetType());
        player->SetArenaTeamIdInvited(0);

        // Hide promote/remove buttons
        if (CaptainGuid != playerGuid)
            player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
    }

    TC_LOG_DEBUG("bg.arena", "Player: %s [%s] joined arena team type: %u [Id: %u, Name: %s].", playerName.c_str(), playerGuid.ToString().c_str(), GetType(), GetId(), GetName().c_str());

    return true;
}
开发者ID:ElunaLuaEngine,项目名称:ElunaTrinityWotlk,代码行数:93,代码来源:ArenaTeam.cpp


示例11: ObjectGuid

bool ArenaTeam::LoadMembersFromDB(QueryResult *arenaTeamMembersResult)
{
    if(!arenaTeamMembersResult)
        return false;

    bool captainPresentInTeam = false;

    do
    {
        Field *fields = arenaTeamMembersResult->Fetch();
        //prevent crash if db records are broken, when all members in result are already processed and current team hasn't got any members
        if (!fields)
            break;
        uint32 arenaTeamId        = fields[0].GetUInt32();
        if (arenaTeamId < m_TeamId)
        {
            //there is in table arena_team_member record which doesn't have arenateamid in arena_team table, report error
            sLog.outErrorDb("ArenaTeam %u does not exist but it has record in arena_team_member table, deleting it!", arenaTeamId);
            CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u'", arenaTeamId);
            continue;
        }

        if (arenaTeamId > m_TeamId)
            //we loaded all members for this arena_team already, break cycle
            break;

        ArenaTeamMember newmember;
        newmember.guid            = ObjectGuid(HIGHGUID_PLAYER, fields[1].GetUInt32());
        newmember.games_week      = fields[2].GetUInt32();
        newmember.wins_week       = fields[3].GetUInt32();
        newmember.games_season    = fields[4].GetUInt32();
        newmember.wins_season     = fields[5].GetUInt32();
        newmember.personal_rating = fields[6].GetUInt32();
        newmember.name            = fields[7].GetCppString();
        newmember.Class           = fields[8].GetUInt8();

        if (GetType() == ARENA_TYPE_2v2)
        {
            QueryResult *result = CharacterDatabase.PQuery("SELECT rating2 FROM hidden_rating WHERE guid='%u'", fields[1].GetUInt32());

            if (!result)
            {
                CharacterDatabase.PExecute("INSERT INTO hidden_rating (guid, rating2, rating3, rating5) VALUES""('%u', '%u', '%u', '%u')", fields[1].GetUInt32(), 1500, 1500, 1500);
                newmember.matchmaker_rating = 1500;
            }  
            else
            {
                newmember.matchmaker_rating = (*result)[0].GetUInt32();
                delete result;
            }
        }
        if (GetType() == ARENA_TYPE_3v3)
        {
            QueryResult *result = CharacterDatabase.PQuery("SELECT rating3 FROM hidden_rating WHERE guid='%u'", fields[1].GetUInt32());

            if (!result)
            {
                CharacterDatabase.PExecute("INSERT INTO hidden_rating (guid, rating2, rating3, rating5) VALUES""('%u', '%u', '%u', '%u')", fields[1].GetUInt32(), 1500, 1500, 1500);
                newmember.matchmaker_rating = 1500;
            }
            else
            {
                newmember.matchmaker_rating = (*result)[0].GetUInt32();
                delete result;
            }
        }
        if (GetType() == ARENA_TYPE_5v5)
        {
            QueryResult *result = CharacterDatabase.PQuery("SELECT rating5 FROM hidden_rating WHERE guid='%u'", fields[1].GetUInt32());

            if (!result)
            {
                CharacterDatabase.PExecute("INSERT INTO hidden_rating (guid, rating2, rating3, rating5) VALUES""('%u', '%u', '%u', '%u')", fields[1].GetUInt32(), 1500, 1500, 1500);
                newmember.matchmaker_rating = 1500;
            }
            else
            {
                newmember.matchmaker_rating = (*result)[0].GetUInt32();
                delete result;
            }
        }

        //check if member exists in characters table
        if (newmember.name.empty())
        {
            CharacterDatabase.PExecute("DELETE FROM hidden_rating where guid = '%u'", fields[1].GetUInt32());
            sLog.outErrorDb("ArenaTeam %u has member with empty name - probably player %s doesn't exist, deleting him from memberlist!", arenaTeamId, newmember.guid.GetString().c_str());
            DelMember(newmember.guid);
            continue;
        }

        // arena team can't be > 2 * arenatype (2 for 2x2, 3 for 3x3, 5 for 5x5)
        if (GetMembersSize() >= GetMaxMembersSize())
            return false;

        if (newmember.guid == GetCaptainGuid())
            captainPresentInTeam = true;

        m_members.push_back(newmember);
    } while (arenaTeamMembersResult->NextRow());
//.........这里部分代码省略.........
开发者ID:Archives,项目名称:easy-mangos,代码行数:101,代码来源:ArenaTeam.cpp


示例12: AddMember

bool ArenaTeam::AddMember(ObjectGuid playerGuid)
{
    std::string plName;
    uint8 plClass;

    // arena team is full (can't have more than type * 2 players!)
    if (GetMembersSize() >= GetMaxMembersSize())
        return false;

    Player *pl = sObjectMgr.GetPlayer(playerGuid);
    if (pl)
    {
        if (pl->GetArenaTeamId(GetSlot()))
        {
            sLog.outError("Arena::AddMember() : player already in this sized team");
            return false;
        }

        plClass = pl->getClass();
        plName = pl->GetName();
    }
    else
    {
        //                                                     0     1
        QueryResult *result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", playerGuid.GetCounter());
        if (!result)
            return false;

        plName = (*result)[0].GetCppString();
        plClass = (*result)[1].GetUInt8();
        delete result;

        // check if player already in arenateam of that size
        if (Player::GetArenaTeamIdFromDB(playerGuid, GetType()) != 0)
        {
            sLog.outError("Arena::AddMember() : player %s already in this sized team", playerGuid.GetString().c_str());
            return false;
        }
    }

    // remove all player signs from another petitions
    // this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
    Player::RemovePetitionsAndSigns(playerGuid, GetType());

    ArenaTeamMember newmember;
    newmember.name              = plName;
    newmember.guid              = playerGuid;
    newmember.Class             = plClass;
    newmember.games_season      = 0;
    newmember.games_week        = 0;
    newmember.wins_season       = 0;
    newmember.wins_week         = 0;

    if (GetType() == ARENA_TYPE_2v2)
    {
        QueryResult *result = CharacterDatabase.PQuery("SELECT rating2 FROM hidden_rating WHERE guid='%u'", playerGuid.GetCounter());

        if (!result)
        {
            CharacterDatabase.PExecute("INSERT INTO hidden_rating (guid, rating2, rating3, rating5) VALUES""('%u', '%u', '%u', '%u')", playerGuid.GetCounter(), 1500, 1500, 1500);
            newmember.matchmaker_rating = 1500;
        }
        else
        {
            newmember.matchmaker_rating = (*result)[0].GetUInt32();
            delete result;
        }
    }
    if (GetType() == ARENA_TYPE_3v3)
    {
        QueryResult *result = CharacterDatabase.PQuery("SELECT rating3 FROM hidden_rating WHERE guid='%u'", playerGuid.GetCounter());

        if (!result)
        {
            CharacterDatabase.PExecute("INSERT INTO hidden_rating (guid, rating2, rating3, rating5) VALUES""('%u', '%u', '%u', '%u')", playerGuid.GetCounter(), 1500, 1500, 1500);
            newmember.matchmaker_rating = 1500;
        }
        else
        {
            newmember.matchmaker_rating = (*result)[0].GetUInt32();
            delete result;
        }
    }
    if (GetType() == ARENA_TYPE_5v5)
    {
        QueryResult *result = CharacterDatabase.PQuery("SELECT rating5 FROM hidden_rating WHERE guid='%u'", playerGuid.GetCounter());

        if (!result)
        {
            CharacterDatabase.PExecute("INSERT INTO hidden_rating (guid, rating2, rating3, rating5) VALUES""('%u', '%u', '%u', '%u')", playerGuid.GetCounter(), 1500, 1500, 1500);
            newmember.matchmaker_rating = 1500;
        }
        else
        {
            newmember.matchmaker_rating = (*result)[0].GetUInt32();
            delete result;
        }
    }

    int32 conf_value = sWorld.getConfig(CONFIG_INT32_ARENA_STARTPERSONALRATING);
//.........这里部分代码省略.........
开发者ID:Archives,项目名称:easy-mangos,代码行数:101,代码来源:ArenaTeam.cpp


示例13: AddMember

bool ArenaTeam::AddMember(const uint64& PlayerGuid)
{
    std::string plName;
    uint8 plClass;

    // arena team is full (can't have more than type * 2 players!)
    if(GetMembersSize() >= GetType() * 2)
        return false;

    Player *pl = objmgr.GetPlayer(PlayerGuid);
    if(pl)
    {
        if(pl->GetArenaTeamId(GetSlot()))
        {
            sLog.outError("Arena::AddMember() : player already in this sized team");
            return false;
        }

        plClass = pl->getClass();
        plName = pl->GetName();
    }
    else
    {
        //                                                     0     1
        QueryResult *result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", GUID_LOPART(PlayerGuid));
        if(!result)
            return false;

        plName = (*result)[0].GetCppString();
        plClass = (*result)[1].GetUInt8();
        delete result;

        // check if player already in arenateam of that size
        if(Player::GetArenaTeamIdFromDB(PlayerGuid, GetType()) != 0)
        {
            sLog.outError("Arena::AddMember() : player already in this sized team");
            return false;
        }
    }

    // remove all player signs from another petitions
    // this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
    Player::RemovePetitionsAndSigns(PlayerGuid, GetType());

    ArenaTeamMember newmember;
    newmember.name              = plName;
    newmember.guid              = PlayerGuid;
    newmember.Class             = plClass;
    newmember.games_season      = 0;
    newmember.games_week        = 0;
    newmember.wins_season       = 0;
    newmember.wins_week         = 0;
    if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6)
    {
        if (m_stats.rating < 1000)
            newmember.personal_rating = m_stats.rating;
        else
            newmember.personal_rating = 1000;
    }
    else
    {
        newmember.personal_rating = 1500;
    }
    m_members.push_back(newmember);

    CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid, personal_rating) VALUES ('%u', '%u', '%u')", m_TeamId, GUID_LOPART(newmember.guid), newmember.personal_rating );

    if(pl)
    {
        pl->SetInArenaTeam(m_TeamId, GetSlot(), GetType());
        pl->SetArenaTeamIdInvited(0);
        pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING, newmember.personal_rating );

        // hide promote/remove buttons
        if(m_CaptainGuid != PlayerGuid)
            pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_MEMBER, 1);
    }
    return true;
}
开发者ID:1thew,项目名称:mangos,代码行数:79,代码来源:ArenaTeam.cpp


示例14: AddMember

bool ArenaTeam::AddMember(uint64 playerGuid)
{
    std::string playerName;
    uint8 playerClass;

    // Check if arena team is full (Can't have more than type * 2 players)
    if (GetMembersSize() >= GetType() * 2)
        return false;

    // xinef: Get player name and class from player storage or global data storage
    Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(playerGuid);
    if (player)
    {
        playerClass = player->getClass();
        playerName = player->GetName();
    }
    else
    {
        GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(playerGuid));
        if (!playerData)
            return false;

        playerName = playerData->name;
        playerClass = playerData->playerClass;
    }

    // Check if player is already in a similar arena team
    if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromStorage(GUID_LOPART(playerGuid), GetSlot()) != 0)
    {
        sLog->outError("Arena: Player %s (guid: %u) already has an arena team of type %u", playerName.c_str(), GUID_LOPART(playerGuid), GetType());
        return false;
    }

    // Set player's personal rating
    uint32 personalRating = 0;

    if (sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) > 0)
        personalRating = sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);
    else if (GetRating() >= 1000)
        personalRating = 1000;

    // xinef: zomg! sync query
    // Try to get player's match maker rating from db and fall back to config setting if not found
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MATCH_MAKER_RATING);
    stmt->setUInt32(0, GUID_LOPART(playerGuid));
    stmt->setUInt8(1, GetSlot());
    PreparedQueryResult result = CharacterDatabase.Query(stmt);

    uint16 matchMakerRating;
    uint16 maxMMR;
    if (result)
    {
        matchMakerRating = (*result)[0].GetUInt16();
        uint16 Max = (*result)[1].GetUInt16();
        maxMMR = std::max(Max, matchMakerRating);
    }
    else
    {
        matchMakerRating = sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);
        maxMMR = matchMakerRating;
    }

    // Remove all player signatures from other petitions
    // This will prevent player from joining too many arena teams and corrupt arena team data integrity
    Player::RemovePetitionsAndSigns(playerGuid, GetType());

    // Feed data to the struct
    ArenaTeamMember newMember;
    //newMember.Name             = playerName;
    newMember.Guid             = playerGuid;
    newMember.Class            = playerClass;
    newMember.SeasonGames      = 0;
    newMember.WeekGames        = 0;
    newMember.SeasonWins       = 0;
    newMember.WeekWins         = 0;
    newMember.PersonalRating   = personalRating;
    newMember.MatchMakerRating = matchMakerRating;
    newMember.MaxMMR           = maxMMR;

    Members.push_back(newMember);
    sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(playerGuid), GetSlot(), GetId());

    // Save player's arena team membership to db
    stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER);
    stmt->setUInt32(0, TeamId);
    stmt->setUInt32(1, GUID_LOPART(playerGuid));
    CharacterDatabase.Execute(stmt);

    // Inform player if online
    if (player)
    {
        player->SetInArenaTeam(TeamId, GetSlot(), GetType());
        player->SetArenaTeamIdInvited(0);

        // Hide promote/remove buttons
        if (CaptainGuid != playerGuid)
            player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
    }

    return true;
//.........这里部分代码省略.........
开发者ID:AzerothShard-Dev,项目名称:azerothcore,代码行数:101,代码来源:ArenaTeam.cpp


示例15: AddMember

bool ArenaTeam::AddMember(const uint64& playerGuid)
{
    std::string plName;
    uint8 plClass;

    // arena team is full (can't have more than type * 2 players!)
    if (GetMembersSize() >= GetType() * 2)
        return false;

    Player *pl = objmgr.GetPlayer(playerGuid);
    if (pl)
    {
        if (pl->GetArenaTeamId(GetSlot()))
        {
            sLog.outError("Arena::AddMember() : player already in this sized team");
            return false;
        }

        plClass = pl->getClass();
        plName = pl->GetName();
    }
    else
    {
        //                                                            0     1
        QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", GUID_LOPART(playerGuid));
        if (!result)
            return false;

        plName = (*result)[0].GetCppString();
        plClass = (*result)[1].GetUInt8();

        // check if player already in arenateam of that size
        if (Player::GetArenaTeamIdFromDB(playerGuid, GetType()) != 0)
        {
            sLog.outError("Arena::AddMember() : player %llu already in this sized team", playerGuid);
            return false;
        }
    }

    // remove all player signs from another petitions
    // this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
    Player::RemovePetitionsAndSigns(playerGuid, GetType());

    ArenaTeamMember newmember;
    newmember.name              = plName;
    newmember.guid              = playerGuid;
    newmember.Class             = plClass;
    newmember.games_season      = 0;
    newmember.games_week        = 0;
    newmember.wins_season       = 0;
    newmember.wins_week         = 0;
    newmember.personal_rating   = ARENA_NEW_PERSONAL_RATING;
    m_members.push_back(newmember);

    CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid, personal_rating) VALUES ('%u', '%u', '%u')", m_TeamId, GUID_LOPART(newmember.guid), newmember.personal_rating);

    if (pl)
    {
        pl->SetInArenaTeam(m_TeamId, GetSlot());
        pl->SetArenaTeamIdInvited(0);
        pl->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_PERSONAL_RATING, newmember.personal_rating);

        // hide promote/remove buttons
        if (m_CaptainGuid != playerGuid)
            pl->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
        sLog.outArena("Player: %s [GUID: %u] joined arena team type: %u [Id: %u].", pl->GetName(), pl->GetGUIDLow(), GetType(), GetId());
    }
    return true;
}
开发者ID:Anonymus123,项目名称:AtomicCore-2.4.3,代码行数:69,代码来源:ArenaTeam.cpp


示例16: AddMember


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetMemory函数代码示例发布时间:2022-05-30
下一篇:
C++ GetMember函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap