本文整理汇总了C++中ArenaTeam类的典型用法代码示例。如果您正苦于以下问题:C++ ArenaTeam类的具体用法?C++ ArenaTeam怎么用?C++ ArenaTeam使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArenaTeam类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_INVITE");
#endif
uint32 arenaTeamId; // arena team id
std::string invitedName;
Player* player = NULL;
recvData >> arenaTeamId >> invitedName;
if (!invitedName.empty())
{
if (!normalizePlayerName(invitedName))
return;
player = ObjectAccessor::FindPlayerByName(invitedName, false);
}
if (!player)
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", invitedName, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S);
return;
}
if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", invitedName, ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
return;
}
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
if (!arenaTeam)
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM);
return;
}
if (GetPlayer()->GetArenaTeamId(arenaTeam->GetSlot()) != arenaTeamId)
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PERMISSIONS);
return;
}
// OK result but don't send invite
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
return;
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeamId() != GetPlayer()->GetTeamId())
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
return;
}
if (player->GetArenaTeamId(arenaTeam->GetSlot()))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", invitedName, ERR_ALREADY_IN_ARENA_TEAM_S);
return;
}
if (player->GetArenaTeamIdInvited())
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", invitedName, ERR_ALREADY_INVITED_TO_ARENA_TEAM_S);
return;
}
if (arenaTeam->GetMembersSize() >= arenaTeam->GetType() * 2)
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, arenaTeam->GetName(), "", ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S);
return;
}
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName().c_str(), invitedName.c_str());
#endif
player->SetArenaTeamIdInvited(arenaTeam->GetId());
WorldPacket data(SMSG_ARENA_TEAM_INVITE, (8+10));
data << GetPlayer()->GetName();
data << arenaTeam->GetName();
player->GetSession()->SendPacket(&data);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_INVITE");
#endif
}
示例2: GetPlayer
void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
uint64 guid; // arena Battlemaster guid
uint8 arenaslot; // 2v2, 3v3 or 5v5
uint8 asGroup; // asGroup
uint8 isRated; // isRated
Group * grp = NULL;
recv_data >> guid >> arenaslot >> asGroup >> isRated;
// ignore if we already in BG or BG queue
if (_player->InBattleground())
return;
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit)
return;
if (!unit->isBattleMaster()) // it's not battle master
return;
uint8 arenatype = 0;
uint32 arenaRating = 0;
uint32 matchmakerRating = 0;
switch(arenaslot)
{
case 0:
arenatype = ARENA_TYPE_2v2;
break;
case 1:
arenatype = ARENA_TYPE_3v3;
break;
case 2:
arenatype = ARENA_TYPE_5v5;
break;
default:
sLog->outError("Unknown arena slot %u at HandleBattlemasterJoinArena()", arenaslot);
return;
}
//check existance
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
sLog->outError("Battleground: template bg (all arenas) not found");
return;
}
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, NULL))
{
ChatHandler(this).PSendSysMessage(LANG_ARENA_DISABLED);
return;
}
BattlegroundTypeId bgTypeId = bg->GetTypeID();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenatype);
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
GroupJoinBattlegroundResult err = ERR_GROUP_JOIN_BATTLEGROUND_FAIL;
if (!asGroup)
{
// check if already in queue
if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattlegroundQueueId())
return;
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGUID() != _player->GetGUID())
return;
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
}
uint32 ateamId = 0;
if (isRated)
{
ateamId = _player->GetArenaTeamId(arenaslot);
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queueing
arenaRating = at->GetRating();
//.........这里部分代码省略.........
示例3: DEBUG_LOG
void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
{
DEBUG_LOG("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
//recv_data.hexlike();
ObjectGuid guid; // arena Battlemaster guid
uint8 arenaslot; // 2v2, 3v3 or 5v5
uint8 asGroup; // asGroup
uint8 isRated; // isRated
recv_data >> guid >> arenaslot >> asGroup >> isRated;
// ignore if we already in BG or BG queue
if (_player->InBattleGround())
return;
Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit)
return;
if(!unit->isBattleMaster()) // it's not battle master
return;
ArenaType arenatype;
uint32 arenaRating = 0;
switch(arenaslot)
{
case 0:
arenatype = ARENA_TYPE_2v2;
break;
case 1:
arenatype = ARENA_TYPE_3v3;
break;
case 2:
arenatype = ARENA_TYPE_5v5;
break;
default:
sLog.outError("Unknown arena slot %u at HandleBattlemasterJoinArena()", arenaslot);
return;
}
// check existence
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
sLog.outError("Battleground: template bg (all arenas) not found");
return;
}
BattleGroundTypeId bgTypeId = bg->GetTypeID();
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype);
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),_player->getLevel());
if (!bracketEntry)
return;
GroupJoinBattlegroundResult err;
Group * grp = NULL;
// check queue conditions
if (!asGroup)
{
// you can't join in this way by client
if (isRated)
return;
// check if already in queue
if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattleGroundQueueId())
return;
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGuid() != _player->GetObjectGuid())
return;
// may be Group::CanJoinBattleGroundQueue should be moved to player class...
err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
}
uint32 ateamId = 0;
if (isRated)
{
ateamId = _player->GetArenaTeamId(arenaslot);
// check real arena team existence only here (if it was moved to group->CanJoin .. () then we would have to get it twice)
ArenaTeam * at = sObjectMgr.GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queue
//.........这里部分代码省略.........
示例4: SendPacket
//.........这里部分代码省略.........
return;
}
BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId);
// bg template might and must be used in case of leaving queue, when instance is not created yet
if (!bg && action == 0)
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
if (!bg)
{
sLog.outError("Battleground: bg not found.");
return;
}
bgTypeId = bg->GetTypeID();
if (_player->InBattleGroundQueue())
{
uint32 queueSlot = 0;
uint32 team = 0;
uint32 arenatype = 0;
uint32 israted = 0;
uint32 rating = 0;
uint32 opponentsRating = 0;
// get the team info from the queue
BattleGroundQueue::QueuedPlayersMap::iterator pitr = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers[_player->GetBattleGroundQueueIdFromLevel()].find(_player->GetGUID());
if (pitr != sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers[_player->GetBattleGroundQueueIdFromLevel()].end()
&& pitr->second.GroupInfo)
{
team = pitr->second.GroupInfo->Team;
arenatype = pitr->second.GroupInfo->ArenaType;
israted = pitr->second.GroupInfo->IsRated;
rating = pitr->second.GroupInfo->ArenaTeamRating;
opponentsRating = pitr->second.GroupInfo->OpponentsTeamRating;
}
else
{
sLog.outError("Battleground: Invalid player queue info!");
return;
}
// if player is trying to enter battleground (not arena) and he has deserter debuff, we must just remove him from queue
if (arenatype == 0 && !_player->CanJoinToBattleground())
{
sLog.outDebug("Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName(), _player->GetGUIDLow());
action = 0;
}
WorldPacket data;
switch(action)
{
case 1: // port to battleground
if (!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId))
return; // cheating?
if (sWorld.getConfig(CONFIG_BATTLEGROUND_WRATH_LEAVE_MODE))
_player->SetBattleGroundEntryPoint();
// resurrect the player
if (!_player->isAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
// stop taxi flight at port
if (_player->isInFlight())
{
示例5: GetOtherTeam
void Arena::EndBattleground(uint32 winner)
{
// arena rating calculation
if (isRated())
{
uint32 loserTeamRating = 0;
uint32 loserMatchmakerRating = 0;
int32 loserChange = 0;
int32 loserMatchmakerChange = 0;
uint32 winnerTeamRating = 0;
uint32 winnerMatchmakerRating = 0;
int32 winnerChange = 0;
int32 winnerMatchmakerChange = 0;
// In case of arena draw, follow this logic:
// winnerArenaTeam => ALLIANCE, loserArenaTeam => HORDE
ArenaTeam* winnerArenaTeam = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(winner == 0 ? ALLIANCE : winner));
ArenaTeam* loserArenaTeam = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(winner == 0 ? HORDE : GetOtherTeam(winner)));
if (winnerArenaTeam && loserArenaTeam && winnerArenaTeam != loserArenaTeam)
{
// In case of arena draw, follow this logic:
// winnerMatchmakerRating => ALLIANCE, loserMatchmakerRating => HORDE
loserTeamRating = loserArenaTeam->GetRating();
loserMatchmakerRating = GetArenaMatchmakerRating(winner == 0 ? HORDE : GetOtherTeam(winner));
winnerTeamRating = winnerArenaTeam->GetRating();
winnerMatchmakerRating = GetArenaMatchmakerRating(winner == 0 ? ALLIANCE : winner);
if (winner != 0)
{
winnerMatchmakerChange = winnerArenaTeam->WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, winnerChange);
loserMatchmakerChange = loserArenaTeam->LostAgainst(loserMatchmakerRating, winnerMatchmakerRating, loserChange);
TC_LOG_DEBUG("bg.arena", "match Type: %u --- Winner: old rating: %u, rating gain: %d, old MMR: %u, MMR gain: %d --- Loser: old rating: %u, rating loss: %d, old MMR: %u, MMR loss: %d ---",
GetArenaType(), winnerTeamRating, winnerChange, winnerMatchmakerRating, winnerMatchmakerChange,
loserTeamRating, loserChange, loserMatchmakerRating, loserMatchmakerChange);
SetArenaMatchmakerRating(winner, winnerMatchmakerRating + winnerMatchmakerChange);
SetArenaMatchmakerRating(GetOtherTeam(winner), loserMatchmakerRating + loserMatchmakerChange);
// bg team that the client expects is different to TeamId
// alliance 1, horde 0
uint8 winnerTeam = winner == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE;
uint8 loserTeam = winner == ALLIANCE ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE;
_arenaTeamScores[winnerTeam].Assign(winnerChange, winnerMatchmakerRating, winnerArenaTeam->GetName());
_arenaTeamScores[loserTeam].Assign(loserChange, loserMatchmakerRating, loserArenaTeam->GetName());
TC_LOG_DEBUG("bg.arena", "Arena match Type: %u for Team1Id: %u - Team2Id: %u ended. WinnerTeamId: %u. Winner rating: +%d, Loser rating: %d",
GetArenaType(), GetArenaTeamIdByIndex(TEAM_ALLIANCE), GetArenaTeamIdByIndex(TEAM_HORDE), winnerArenaTeam->GetId(), winnerChange, loserChange);
if (sWorld->getBoolConfig(CONFIG_ARENA_LOG_EXTENDED_INFO))
for (auto const& score : PlayerScores)
if (Player* player = ObjectAccessor::FindConnectedPlayer(ObjectGuid(HighGuid::Player, score.first)))
{
TC_LOG_DEBUG("bg.arena", "Statistics match Type: %u for %s (GUID: %u, Team: %d, IP: %s): %s",
GetArenaType(), player->GetName().c_str(), score.first, player->GetArenaTeamId(GetArenaType() == 5 ? 2 : GetArenaType() == 3),
player->GetSession()->GetRemoteAddress().c_str(), score.second->ToString().c_str());
}
}
// Deduct 16 points from each teams arena-rating if there are no winners after 45+2 minutes
else
{
_arenaTeamScores[BG_TEAM_ALLIANCE].Assign(ARENA_TIMELIMIT_POINTS_LOSS, winnerMatchmakerRating, winnerArenaTeam->GetName());
_arenaTeamScores[BG_TEAM_HORDE].Assign(ARENA_TIMELIMIT_POINTS_LOSS, loserMatchmakerRating, loserArenaTeam->GetName());
winnerArenaTeam->FinishGame(ARENA_TIMELIMIT_POINTS_LOSS);
loserArenaTeam->FinishGame(ARENA_TIMELIMIT_POINTS_LOSS);
}
uint8 aliveWinners = GetAlivePlayersCountByTeam(winner);
for (auto const& i : GetPlayers())
{
uint32 team = i.second.Team;
if (i.second.OfflineRemoveTime)
{
// if rated arena match - make member lost!
if (team == winner)
winnerArenaTeam->OfflineMemberLost(i.first, loserMatchmakerRating, winnerMatchmakerChange);
else
{
if (winner == 0)
winnerArenaTeam->OfflineMemberLost(i.first, loserMatchmakerRating, winnerMatchmakerChange);
loserArenaTeam->OfflineMemberLost(i.first, winnerMatchmakerRating, loserMatchmakerChange);
}
continue;
}
Player* player = _GetPlayer(i.first, i.second.OfflineRemoveTime != 0, "Arena::EndBattleground");
if (!player)
continue;
// per player calculation
if (team == winner)
{
// update achievement BEFORE personal rating update
uint32 rating = player->GetArenaPersonalRating(winnerArenaTeam->GetSlot());
//.........这里部分代码省略.........
示例6: OnGossipSelect
bool OnGossipSelect(Player* player, Creature* me, uint32 /*uiSender*/, uint32 uiAction)
{
player->PlayerTalkClass->ClearMenus();
switch (uiAction)
{
case 1: // Create new Arenateam
{
if(ARENA_1V1_MIN_LEVEL <= player->getLevel())
{
if(player->GetMoney() >= ARENA_1V1_COST && CreateArenateam(player, me))
player->ModifyMoney(-(int32)ARENA_1V1_COST);
}
else
{
ChatHandler(player->GetSession()).PSendSysMessage("You need level %u+ to create an 1v1 Arena Team.", ARENA_1V1_MIN_LEVEL);
player->CLOSE_GOSSIP_MENU();
return true;
}
}
break;
case 2: // Join Queue Arena
{
if(JoinQueueArena(player, me) == false)
ChatHandler(player->GetSession()).SendSysMessage("Something went wrong while join queue.");
player->CLOSE_GOSSIP_MENU();
return true;
}
break;
case 3: // Leave Queue
{
WorldPacket Data;
Data << (uint8)0x1 << (uint8)0x0 << (uint32)BATTLEGROUND_AA << (uint16)0x0 << (uint8)0x0;
player->GetSession()->HandleBattleFieldPortOpcode(Data);
player->CLOSE_GOSSIP_MENU();
return true;
}
break;
case 4: // get statistics
{
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(player->GetArenaTeamId(ArenaTeam::GetSlotByType(ARENA_TEAM_1v1)));
if(at)
{
std::stringstream s;
s << "Rating: " << at->GetStats().Rating;
s << "\nRank: " << at->GetStats().Rank;
s << "\nSeason Games: " << at->GetStats().SeasonGames;
s << "\nSeason Wins: " << at->GetStats().SeasonWins;
s << "\nWeek Games: " << at->GetStats().WeekGames;
s << "\nWeek Wins: " << at->GetStats().WeekWins;
ChatHandler(player->GetSession()).PSendSysMessage(s.str().c_str());
}
}
break;
case 5: // Disband arenateam
{
WorldPacket Data;
Data << (uint32)player->GetArenaTeamId(ArenaTeam::GetSlotByType(ARENA_TEAM_1v1));
player->GetSession()->HandleArenaTeamLeaveOpcode(Data);
ChatHandler(player->GetSession()).PSendSysMessage("Arena team deleted!");
player->CLOSE_GOSSIP_MENU();
return true;
}
break;
case 8: // Script Info
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Click on Create new 1v1 Arena team", GOSSIP_SENDER_MAIN, uiAction);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Join 1v1 Arena and ready!", GOSSIP_SENDER_MAIN, uiAction);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Enjoy!", GOSSIP_SENDER_MAIN, uiAction);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "<- Back", GOSSIP_SENDER_MAIN, 7);
player->SEND_GOSSIP_MENU(68, me->GetGUID());
return true;
}
break;
}
OnGossipHello(player, me);
return true;
}
示例7: HandleArenaCaptainCommand
static bool HandleArenaCaptainCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* idStr;
char* nameStr;
handler->extractOptFirstArg((char*)args, &idStr, &nameStr);
if (!idStr)
return false;
uint32 teamId = atoi(idStr);
if (!teamId)
return false;
Player* target;
uint64 targetGuid;
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid))
return false;
ArenaTeam* arena = sArenaTeamMgr->GetArenaTeamById(teamId);
if (!arena)
{
handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_FOUND, teamId);
handler->SetSentErrorMessage(true);
return false;
}
if (!target)
{
handler->PSendSysMessage(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, nameStr);
handler->SetSentErrorMessage(true);
return false;
}
if (arena->IsFighting())
{
handler->SendSysMessage(LANG_ARENA_ERROR_COMBAT);
handler->SetSentErrorMessage(true);
return false;
}
if (!arena->IsMember(targetGuid))
{
handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_MEMBER, nameStr, arena->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
if (arena->GetCaptain() == targetGuid)
{
handler->PSendSysMessage(LANG_ARENA_ERROR_CAPTAIN, nameStr, arena->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
arena->SetCaptain(targetGuid);
CharacterNameData const* oldCaptainNameData = sWorld->GetCharacterNameData(GUID_LOPART(arena->GetCaptain()));
if (!oldCaptainNameData)
{
handler->SetSentErrorMessage(true);
return false;
}
handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->m_name.c_str(), target->GetName().c_str());
if (handler->GetSession())
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "GameMaster: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]",
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), target->GetName().c_str(), target->GetGUIDLow(), arena->GetName().c_str(), arena->GetId());
else
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Console: promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]",
target->GetName().c_str(), target->GetGUIDLow(), arena->GetName().c_str(), arena->GetId());
return true;
}
示例8: GetPlayer
//.........这里部分代码省略.........
// check if group can queue:
else
{
Group* grp = _player->GetGroup();
// no group or not a leader
if (!grp || grp->GetLeaderGUID() != _player->GetGUID())
return;
// pussywizard: for party members - remove queues for which leader is not queued to!
std::set<uint32> leaderQueueTypeIds;
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
leaderQueueTypeIds.insert((uint32)_player->GetBattlegroundQueueTypeId(i));
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->GetSource())
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (BattlegroundQueueTypeId mqtid = member->GetBattlegroundQueueTypeId(i))
if (leaderQueueTypeIds.count((uint32)mqtid) == 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(mqtid);
if (bgQueue.IsPlayerInvitedToRatedArena(member->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
bgQueue.RemovePlayer(member->GetGUID(), false, i);
member->RemoveBattlegroundQueueId(mqtid);
}
uint32 ateamId = 0;
uint32 arenaRating = 0;
uint32 matchmakerRating = 0;
// additional checks for rated arenas
if (isRated)
{
// pussywizard: for rated matches check if season is in progress!
if (!sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS))
return;
ateamId = _player->GetArenaTeamId(arenaslot);
// check team existence
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ateamId);
if (!at)
{
SendNotInArenaTeamPacket(arenatype);
return;
}
// get team rating for queueing
arenaRating = at->GetRating();
matchmakerRating = at->GetAverageMMR(grp);
if (arenaRating <= 0)
arenaRating = 1;
}
err = grp->CanJoinBattlegroundQueue(bgt, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
uint32 avgWaitTime = 0;
if (err > 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bracketEntry, isRated, false, arenaRating, matchmakerRating, ateamId);
avgWaitTime = bgQueue.GetAverageQueueWaitTime(ginfo);
}
WorldPacket data;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue;
if (err <= 0)
{
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
continue;
}
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
// send status packet
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, queueSlot, STATUS_WAIT_QUEUE, avgWaitTime, 0, arenatype, TEAM_NEUTRAL, isRated);
member->GetSession()->SendPacket(&data);
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
}
// pussywizard: schedule update for rated arena
if (ateamId)
sBattlegroundMgr->ScheduleArenaQueueUpdate(ateamId, bgQueueTypeId, bracketEntry->GetBracketId());
}
}
示例9: OnGossipSelect
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
uint8 mode = ARENA_TYPE_2v2;
if (action == (GOSSIP_ACTION_INFO_DEF + 3)) // 3v3
mode = ARENA_TYPE_3v3;
if (action == (GOSSIP_ACTION_INFO_DEF + 5)) // 5v5
mode = ARENA_TYPE_5v5;
if (action <= GOSSIP_OFFSET)
{
BattlegroundSet arenasSet = sBattlegroundMgr->GetAllBattlegroundsWithTypeId(BATTLEGROUND_AA);
// Check for matches of chosen type
bool bracketMatchs = false;
for (BattlegroundSet::const_iterator itr = arenasSet.begin(); itr != arenasSet.end(); ++itr)
{
if (Battleground* bg = itr->second)
{
if (bg->GetArenaType() == mode)
{
bracketMatchs = true;
break;
}
}
}
if (!bracketMatchs)
{
std::stringstream errMsg;
errMsg << "Sorry " << player->GetName() << ", There are no current matches of the type you selected.";
creature->MonsterWhisper(errMsg.str().c_str(), player->GetGUID());
player->PlayerTalkClass->ClearMenus();
player->CLOSE_GOSSIP_MENU();
}
else
{
// team 1 and 2!
for (BattlegroundSet::const_iterator itr = arenasSet.begin(); itr != arenasSet.end(); ++itr)
{
if (Battleground* bg = itr->second)
{
ArenaTeam* teamOne = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(0));
ArenaTeam* teamTwo = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(1));
if (teamOne && teamTwo)
{
std::stringstream gossipItem;
gossipItem << teamOne->GetName() << " (";
gossipItem << teamOne->GetRating() << ") VS ";
gossipItem << teamTwo->GetName() << " (";
gossipItem << teamTwo->GetRating() << ")";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, gossipItem.str(), GOSSIP_SENDER_MAIN + 1, itr->first + GOSSIP_OFFSET);
}
}
}
player->PlayerTalkClass->SendGossipMenu(player->GetGossipTextId(creature), creature->GetGUID());
}
}
else
{
uint32 arenaId = action - GOSSIP_OFFSET;
// Don't really bother about WPE injection here, we are allowing pretty much any arena selection
BattlegroundSet arenasSet = sBattlegroundMgr->GetAllBattlegroundsWithTypeId(BATTLEGROUND_AA);
if (arenasSet[arenaId] != NULL)
{
Battleground* arenaChosen = arenasSet[arenaId];
// spectator crap
if (arenaChosen->GetStatus() != STATUS_NONE && arenaChosen->GetStatus() != STATUS_IN_PROGRESS)
{
std::stringstream errMsg;
errMsg << "Sorry " << player->GetName() << ", the chosen arena has ended";
creature->MonsterWhisper(errMsg.str().c_str(), player->GetGUID());
player->PlayerTalkClass->ClearMenus();
player->CLOSE_GOSSIP_MENU();
return false;
}
// OK. In the case of a selected arena, we teleport in the center of the arena.
player->SetBattlegroundId(arenaChosen->GetInstanceID(), arenaChosen->GetTypeID());
player->SetBattlegroundEntryPoint();
float x, y, z;
switch (arenaChosen->GetMapId())
{
case 617:
x = 1299.046f;
y = 784.825f;
z = 9.338f;
break; // Dalaran Sewers
case 618:
x = 763.5f;
y = -284;
z = 28.276f;
break; // Ring of Valor
case 572:
x = 1285.810547f;
y = 1667.896851f;
//.........这里部分代码省略.........
示例10: HandleArenaRenameCommand
static bool HandleArenaRenameCommand(ChatHandler* handler, char const* _args)
{
if (!*_args)
return false;
char* args = (char *)_args;
char const* oldArenaStr = handler->extractQuotedArg(args);
if (!oldArenaStr)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
char const* newArenaStr = handler->extractQuotedArg(strtok(NULL, ""));
if (!newArenaStr)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
ArenaTeam* arena = sArenaTeamMgr->GetArenaTeamByName(oldArenaStr);
if (!arena)
{
handler->PSendSysMessage(LANG_AREAN_ERROR_NAME_NOT_FOUND, oldArenaStr);
handler->SetSentErrorMessage(true);
return false;
}
if (sArenaTeamMgr->GetArenaTeamByName(newArenaStr))
{
handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, oldArenaStr);
handler->SetSentErrorMessage(true);
return false;
}
if (arena->IsFighting())
{
handler->SendSysMessage(LANG_ARENA_ERROR_COMBAT);
handler->SetSentErrorMessage(true);
return false;
}
if (!arena->SetName(newArenaStr))
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
handler->PSendSysMessage(LANG_ARENA_RENAME, arena->GetId(), oldArenaStr, newArenaStr);
if (handler->GetSession())
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "GameMaster: %s [GUID: %u] rename arena team \"%s\"[Id: %u] to \"%s\"",
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), oldArenaStr, arena->GetId(), newArenaStr);
else
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Console: rename arena team \"%s\"[Id: %u] to \"%s\"", oldArenaStr, arena->GetId(), newArenaStr);
return true;
}
示例11: DEBUG_LOG
void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
// recv_data.hexlike();
uint8 arenaslot; // 2v2, 3v3 or 5v5
recv_data >> arenaslot;
// ignore if we already in BG or BG queue
if (_player->InBattleGround())
return;
ArenaType arenatype = ArenaTeam::GetTypeBySlot(arenaslot);
uint32 arenaRating = 0;
if (!IsArenaTypeValid(arenatype))
{
sLog.outError("Unknown arena slot %u at HandleBattlemasterJoinArena()", arenaslot);
return;
}
// check existence
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
sLog.outError("Battleground: template bg (all arenas) not found");
return;
}
BattleGroundTypeId bgTypeId = bg->GetTypeID();
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype);
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
Group* grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGuid() != _player->GetObjectGuid())
return;
uint32 ateamId = _player->GetArenaTeamId(arenaslot);
// check real arena team existence only here (if it was moved to group->CanJoin .. () then we would have to get it twice)
ArenaTeam* at = sObjectMgr.GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queue
arenaRating = at->GetRating();
// the arena team id must match for everyone in the group
// get the personal ratings for queue
uint32 avg_pers_rating = 0;
for (Group::member_citerator citr = grp->GetMemberSlots().begin(); citr != grp->GetMemberSlots().end(); ++citr)
{
ArenaTeamMember const* at_member = at->GetMember(citr->guid);
if (!at_member) // group member joining to arena must be in leader arena team
return;
avg_pers_rating += at_member->matchmaker_rating;
}
avg_pers_rating /= grp->GetMembersCount();
/* Save mmr before enter arena (matchmaker rating fix) */
at->SetBattleRating(avg_pers_rating);
arenaRating = avg_pers_rating;
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
uint32 avgTime = 0;
// may be Group::CanJoinBattleGroundQueue should be moved to player class...
GroupJoinBattlegroundResult err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, arenatype, arenatype, true, arenaslot);
if (!err)
{
DEBUG_LOG("Battleground: arena join as group start");
DEBUG_LOG("Battleground: arena team id %u, leader %s queued with rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName(), arenaRating, arenatype);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, true, false, arenaRating, ateamId);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue;
WorldPacket data;
if (err)
{
sBattleGroundMgr.BuildBattleGroundStatusFailedPacket(&data, bg, member, 0, err);
member->GetSession()->SendPacket(&data);
continue;
//.........这里部分代码省略.........
示例12: TC_LOG_DEBUG
void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
{
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
uint8 arenaslot; // 2v2, 3v3 or 5v5
recvData >> arenaslot;
// ignore if we already in BG or BG queue
if (_player->InBattleground())
return;
uint32 arenaRating = 0;
uint32 matchmakerRating = 0;
uint8 arenatype = ArenaTeam::GetTypeBySlot(arenaslot);
//check existance
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "Battleground: template bg (all arenas) not found");
return;
}
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, NULL))
{
ChatHandler(this).PSendSysMessage(LANG_ARENA_DISABLED);
return;
}
BattlegroundTypeId bgTypeId = bg->GetTypeID();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenatype);
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
GroupJoinBattlegroundResult err = ERR_BATTLEGROUND_NONE;
Group* grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGUID() != _player->GetGUID())
return;
uint32 ateamId = _player->GetArenaTeamId(arenaslot);
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queueing
arenaRating = at->GetRating();
matchmakerRating = at->GetAverageMMR(grp);
// the arenateam id must match for everyone in the group
if (arenaRating <= 0)
arenaRating = 1;
BattlegroundQueue &bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
uint32 avgTime = 0;
GroupQueueInfo* ginfo = NULL;
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, arenatype, arenatype, true, arenaslot);
if (!err)
{
TC_LOG_DEBUG(LOG_FILTER_BATTLEGROUND, "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName().c_str(), matchmakerRating, arenatype);
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, true, false, arenaRating, matchmakerRating, ateamId);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue;
if (err)
{
WorldPacket data;
sBattlegroundMgr->BuildStatusFailedPacket(&data, bg, _player, 0, err);
member->GetSession()->SendPacket(&data);
continue;
}
// add to queue
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
// add joined time data
member->AddBattlegroundQueueJoinTime(bgTypeId, ginfo->JoinTime);
WorldPacket data; // send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, member, queueSlot, STATUS_WAIT_QUEUE, avgTime, ginfo->JoinTime, arenatype);
member->GetSession()->SendPacket(&data);
//.........这里部分代码省略.........
示例13: if
void DayWatcherThread::update_arena()
{
Log.Notice("DayWatcherThread", "Running Weekly Arena Point Maintenance...");
QueryResult * result = CharacterDatabase.Query("SELECT guid, arenaPoints FROM characters"); /* this one is a little more intensive. */
Player * plr;
uint32 guid, arenapoints, orig_arenapoints;
ArenaTeam * team;
uint32 arenapointsPerTeam[3] = { 0 };
double X, Y;
if (result)
{
do
{
Field * f = result->Fetch();
guid = f[0].GetUInt32();
arenapoints = f[1].GetUInt32();
orig_arenapoints = arenapoints;
for (uint32 i = 0; i < 3; ++i)
arenapointsPerTeam[i] = 0;
/* are we in any arena teams? */
for (uint32 i = 0; i < 3; ++i) // 3 arena team types
{
team = objmgr.GetArenaTeamByGuid(guid, i);
if (team)
{
ArenaTeamMember *member = team->GetMemberByGuid(guid);
if (member == NULL || team->m_stat_gamesplayedweek < 10 || ((member->Played_ThisWeek * 100) / team->m_stat_gamesplayedweek < 30))
continue;
/* we're in an arena team of this type! */
/* Source: http://www.wowwiki.com/Arena_point */
X = (double)team->m_stat_rating;
if (X <= 510.0) // "if X<=510"
continue; // no change
else if (X > 510.0 && X <= 1500.0) // "if 510 < X <= 1500"
{
Y = (0.22 * X) + 14.0;
}
else // "if X > 1500"
{
// http://eu.wowarmory.com/arena-calculator.xml
// 1511.26
// ---------------------------
// -0.00412*X
// 1+1639.28*2.71828
double power = ((-0.00412) * X);
//if(power < 1.0)
// power = 1.0;
double divisor = pow(((double)(2.71828)), power);
divisor *= 1639.28;
divisor += 1.0;
//if(divisor < 1.0)
// divisor = 1.0;
Y = 1511.26 / divisor;
}
// 2v2 teams only earn 70% (Was 60% until 13th March 07) of the arena points, 3v3 teams get 80%, while 5v5 teams get 100% of the arena points.
// 2v2 - 76%, 3v3 - 88% as of patch 2.2
if (team->m_type == ARENA_TEAM_TYPE_2V2)
{
Y *= 0.76;
Y *= sWorld.getRate(RATE_ARENAPOINTMULTIPLIER2X);
}
else if (team->m_type == ARENA_TEAM_TYPE_3V3)
{
Y *= 0.88;
Y *= sWorld.getRate(RATE_ARENAPOINTMULTIPLIER3X);
}
else
{
Y *= sWorld.getRate(RATE_ARENAPOINTMULTIPLIER5X);
}
if (Y > 1.0)
arenapointsPerTeam[i] += long2int32(double(ceil(Y)));
}
}
arenapointsPerTeam[0] = (uint32)std::max(arenapointsPerTeam[0], arenapointsPerTeam[1]);
arenapoints += (uint32)std::max(arenapointsPerTeam[0], arenapointsPerTeam[2]);
if (arenapoints > 5000) arenapoints = 5000;
if (orig_arenapoints != arenapoints)
{
plr = objmgr.GetPlayer(guid);
if (plr)
{
plr->m_arenaPoints = arenapoints;
/* update visible fields (must be done through an event because of no uint lock */
sEventMgr.AddEvent(plr, &Player::RecalculateHonor, EVENT_PLAYER_UPDATE, 100, 1, 0);
/* send a little message :> */
sChatHandler.SystemMessage(plr->GetSession(), "Your arena points have been updated! Check your PvP tab!");
}
//.........这里部分代码省略.........
示例14: TC_LOG_DEBUG
//.........这里部分代码省略.........
if (action == 1 && ginfo.ArenaType == 0)
{
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
if (!_player->CanJoinToBattleground(bg))
{
//send bg command result to show nice message
WorldPacket data2;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data2, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
_player->SendDirectMessage(&data2);
action = 0;
TC_LOG_DEBUG("bg.battleground", "Player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUID().GetCounter());
}
//if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue
if (_player->getLevel() > bg->GetMaxLevel())
{
TC_LOG_ERROR("network", "Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!",
_player->GetName().c_str(), _player->GetGUID().GetCounter(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
action = 0;
}
}
uint32 queueSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
WorldPacket data;
if (action)
{
// check Freeze debuff
if (_player->HasAura(9454))
return;
if (!_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId))
return; // cheating?
if (!_player->InBattleground())
_player->SetBattlegroundEntryPoint();
// resurrect the player
if (!_player->IsAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
// stop taxi flight at port
_player->FinishTaxiFlight();
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), ginfo.Team);
_player->SendDirectMessage(&data);
// remove battleground queue status from BGmgr
bgQueue.RemovePlayer(_player->GetGUID(), false);
// this is still needed here if battleground "jumping" shouldn't add deserter debuff
// also this is required to prevent stuck at old battleground after SetBattlegroundId set to new
if (Battleground* currentBg = _player->GetBattleground())
currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
// set the destination instance id
_player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId);
// set the destination team
_player->SetBGTeam(ginfo.Team);
// bg->HandleBeforeTeleportToBattleground(_player);
sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
// add only in HandleMoveWorldPortAck()
// bg->AddPlayer(_player, team);
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().GetCounter(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
}
else // leave queue
{
if (bg->isArena() && bg->GetStatus() > STATUS_WAIT_QUEUE)
return;
// if player leaves rated arena match before match start, it is counted as he played but he lost
if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
{
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team);
if (at)
{
TC_LOG_DEBUG("bg.battleground", "UPDATING memberLost's personal arena rating for %s by opponents rating: %u, because he has left queue!", _player->GetGUID().ToString().c_str(), ginfo.OpponentsTeamRating);
at->MemberLost(_player, ginfo.OpponentsMatchmakerRating);
at->SaveToDB();
}
}
_player->RemoveBattlegroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0, 0);
bgQueue.RemovePlayer(_player->GetGUID(), true);
// player left queue, we should update it - do not update Arena Queue
if (!ginfo.ArenaType)
sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
SendPacket(&data);
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().GetCounter(), bg->GetTypeID(), bgQueueTypeId);
// track if player refuses to join the BG after being invited
if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
(bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE);
CharacterDatabase.Execute(stmt);
}
}
}
示例15: CHECK_PACKET_SIZE
//.........这里部分代码省略.........
}
return;
break;
case BG_JOIN_ERR_GROUP_DESERTER:
{
WorldPacket data;
ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, GetTrinityString(LANG_BG_GROUP_MEMBER_DESERTER), NULL);
SendPacket(&data);
}
return;
break;
case BG_JOIN_ERR_ALL_QUEUES_USED:
{
WorldPacket data;
ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, GetTrinityString(LANG_BG_GROUP_MEMBER_NO_FREE_QUEUE_SLOTS), NULL);
SendPacket(&data);
}
return;
break;
// all ok, can join
case BG_JOIN_ERR_OK:
break;
// not the above? shouldn't happen, don't let join
default:
return;
break;
};
}
uint32 ateamId = 0;
if(isRated)
{
ateamId = _player->GetArenaTeamId(type);
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
ArenaTeam * at = objmgr.GetArenaTeamById(ateamId);
if(!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queueing
arenaRating = at->GetRating();
// the arenateam id must match for everyone in the group
// get the personal ratings for queueing
uint32 avg_pers_rating = 0;
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *member = itr->getSource();
// calc avg personal rating
avg_pers_rating += member->GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (type*6) + 5);
}
if( arenatype )
avg_pers_rating /= arenatype;
// if avg personal rating is more than 150 points below the team’s rating, the team will be queued against an opponent matching or similar to the average personal rating
if(avg_pers_rating + 150 < arenaRating)
arenaRating = avg_pers_rating;
}
if(asGroup)
{
GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, arenatype, isRated, arenaRating, ateamId);
sLog.outDebug("Battleground: arena join as group start");