mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
Added enum for SMSG_GROUP_JOINED_BATTLEGROUND opcode.
Use this enum where possible. Some misc fixes.
This commit is contained in:
parent
4f6006b9db
commit
9836bcbbaa
9 changed files with 135 additions and 137 deletions
|
|
@ -120,14 +120,16 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
|
|||
if (!bracketEntry)
|
||||
return;
|
||||
|
||||
// check queueing conditions
|
||||
GroupJoinBattlegroundResult err;
|
||||
|
||||
// check queue conditions
|
||||
if (!joinAsGroup)
|
||||
{
|
||||
// check Deserter debuff
|
||||
if (!_player->CanJoinToBattleground())
|
||||
{
|
||||
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
|
||||
data << uint32(0xFFFFFFFE);
|
||||
WorldPacket data;
|
||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
|
||||
_player->GetSession()->SendPacket(&data);
|
||||
return;
|
||||
}
|
||||
|
|
@ -145,35 +147,49 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
|
|||
// no group found, error
|
||||
if (!grp)
|
||||
return;
|
||||
uint32 err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
|
||||
isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
|
||||
if (err != BG_JOIN_ERR_OK)
|
||||
{
|
||||
SendBattleGroundOrArenaJoinError(err);
|
||||
if(grp->GetLeaderGUID() != _player->GetGUID())
|
||||
return;
|
||||
}
|
||||
err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
|
||||
isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
|
||||
}
|
||||
// if we're here, then the conditions to join a bg are met. We can proceed in joining.
|
||||
|
||||
// _player->GetGroup() was already checked, grp is already initialized
|
||||
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
|
||||
if (joinAsGroup /* && _player->GetGroup()*/)
|
||||
if (joinAsGroup)
|
||||
{
|
||||
sLog.outDebug("Battleground: the following players are joining as group:");
|
||||
GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0);
|
||||
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
|
||||
GroupQueueInfo * ginfo;
|
||||
uint32 avgTime;
|
||||
|
||||
if(err > 0)
|
||||
{
|
||||
sLog.outDebug("Battleground: the following players are joining as group:");
|
||||
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0);
|
||||
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
|
||||
}
|
||||
|
||||
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player *member = itr->getSource();
|
||||
if(!member) continue; // this should never happen
|
||||
|
||||
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId); // add to queue
|
||||
if(!member)
|
||||
continue; // this should never happen
|
||||
|
||||
WorldPacket data;
|
||||
// send status packet (in queue)
|
||||
|
||||
if(err <= 0)
|
||||
{
|
||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err);
|
||||
member->GetSession()->SendPacket(&data);
|
||||
continue;
|
||||
}
|
||||
|
||||
// add to queue
|
||||
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);
|
||||
|
||||
// send status packet (in queue)
|
||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType);
|
||||
member->GetSession()->SendPacket(&data);
|
||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
|
||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err);
|
||||
member->GetSession()->SendPacket(&data);
|
||||
sLog.outDebug("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,member->GetGUIDLow(), member->GetName());
|
||||
}
|
||||
|
|
@ -208,8 +224,8 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv
|
|||
{
|
||||
case BATTLEGROUND_WS:
|
||||
{
|
||||
uint32 count1 = 0; //always constant zero?
|
||||
uint32 count2 = 0; //count of next fields
|
||||
uint32 count1 = 0; // always constant zero?
|
||||
uint32 count2 = 0; // count of next fields
|
||||
|
||||
Player *ali_plr = sObjectMgr.GetPlayer(((BattleGroundWS*)bg)->GetAllianceFlagPickerGUID());
|
||||
if (ali_plr)
|
||||
|
|
@ -367,8 +383,8 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
|
|||
if (!_player->CanJoinToBattleground())
|
||||
{
|
||||
//send bg command result to show nice message
|
||||
WorldPacket data2(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
|
||||
data2 << uint32(0xFFFFFFFE);
|
||||
WorldPacket data2;
|
||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data2, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
|
||||
_player->GetSession()->SendPacket(&data2);
|
||||
action = 0;
|
||||
sLog.outDebug("Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName(), _player->GetGUIDLow());
|
||||
|
|
@ -621,7 +637,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
|
|||
return;
|
||||
}
|
||||
|
||||
//check existance
|
||||
// check existence
|
||||
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA);
|
||||
if (!bg)
|
||||
{
|
||||
|
|
@ -635,7 +651,9 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
|
|||
if (!bracketEntry)
|
||||
return;
|
||||
|
||||
// check queueing conditions
|
||||
GroupJoinBattlegroundResult err;
|
||||
|
||||
// check queue conditions
|
||||
if (!asGroup)
|
||||
{
|
||||
// check if already in queue
|
||||
|
|
@ -652,12 +670,10 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
|
|||
// no group found, error
|
||||
if (!grp)
|
||||
return;
|
||||
uint32 err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
|
||||
if (err != BG_JOIN_ERR_OK)
|
||||
{
|
||||
SendBattleGroundOrArenaJoinError(err);
|
||||
if(grp->GetLeaderGUID() != _player->GetGUID())
|
||||
return;
|
||||
}
|
||||
// may be Group::CanJoinBattleGroundQueue should be moved to player class...
|
||||
err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
|
||||
}
|
||||
|
||||
uint32 ateamId = 0;
|
||||
|
|
@ -665,17 +681,17 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
|
|||
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)
|
||||
// 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 queueing
|
||||
// get the team rating for queue
|
||||
arenaRating = at->GetRating();
|
||||
// the arenateam id must match for everyone in the group
|
||||
// get the personal ratings for queueing
|
||||
// the arena team id must match for everyone in the group
|
||||
// get the personal ratings for queue
|
||||
uint32 avg_pers_rating = 0;
|
||||
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
|
|
@ -696,29 +712,44 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
|
|||
BattleGroundQueue &bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
|
||||
if (asGroup)
|
||||
{
|
||||
sLog.outDebug("Battleground: arena join as group start");
|
||||
if (isRated)
|
||||
sLog.outDebug("Battleground: arena team id %u, leader %s queued with rating %u for type %u",_player->GetArenaTeamId(arenaslot),_player->GetName(),arenaRating,arenatype);
|
||||
uint32 avgTime;
|
||||
|
||||
if(err > 0)
|
||||
{
|
||||
sLog.outDebug("Battleground: arena join as group start");
|
||||
if (isRated)
|
||||
sLog.outDebug("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, isRated, false, arenaRating, ateamId);
|
||||
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
|
||||
}
|
||||
|
||||
GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, ateamId);
|
||||
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
|
||||
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player *member = itr->getSource();
|
||||
if(!member) continue;
|
||||
|
||||
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);// add to queue
|
||||
if(!member)
|
||||
continue;
|
||||
|
||||
WorldPacket data;
|
||||
|
||||
if(err <= 0)
|
||||
{
|
||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err);
|
||||
member->GetSession()->SendPacket(&data);
|
||||
continue;
|
||||
}
|
||||
|
||||
// add to queue
|
||||
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);
|
||||
|
||||
// send status packet (in queue)
|
||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
|
||||
member->GetSession()->SendPacket(&data);
|
||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
|
||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err);
|
||||
member->GetSession()->SendPacket(&data);
|
||||
sLog.outDebug("Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,member->GetGUIDLow(), member->GetName());
|
||||
sLog.outDebug("Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName());
|
||||
}
|
||||
sLog.outDebug("Battleground: arena join as group end");
|
||||
//announce to world ... removed
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -751,41 +782,3 @@ void WorldSession::HandleReportPvPAFK( WorldPacket & recv_data )
|
|||
|
||||
reportedPlayer->ReportedAfkBy(_player);
|
||||
}
|
||||
|
||||
void WorldSession::SendBattleGroundOrArenaJoinError(uint8 err)
|
||||
{
|
||||
WorldPacket data;
|
||||
int32 msg;
|
||||
switch (err)
|
||||
{
|
||||
case BG_JOIN_ERR_OFFLINE_MEMBER:
|
||||
msg = LANG_BG_GROUP_OFFLINE_MEMBER;
|
||||
break;
|
||||
case BG_JOIN_ERR_GROUP_TOO_MANY:
|
||||
msg = LANG_BG_GROUP_TOO_LARGE;
|
||||
break;
|
||||
case BG_JOIN_ERR_MIXED_FACTION:
|
||||
msg = LANG_BG_GROUP_MIXED_FACTION;
|
||||
break;
|
||||
case BG_JOIN_ERR_MIXED_LEVELS:
|
||||
msg = LANG_BG_GROUP_MIXED_LEVELS;
|
||||
break;
|
||||
case BG_JOIN_ERR_GROUP_MEMBER_ALREADY_IN_QUEUE:
|
||||
msg = LANG_BG_GROUP_MEMBER_ALREADY_IN_QUEUE;
|
||||
break;
|
||||
case BG_JOIN_ERR_GROUP_DESERTER:
|
||||
msg = LANG_BG_GROUP_MEMBER_DESERTER;
|
||||
break;
|
||||
case BG_JOIN_ERR_ALL_QUEUES_USED:
|
||||
msg = LANG_BG_GROUP_MEMBER_NO_FREE_QUEUE_SLOTS;
|
||||
break;
|
||||
case BG_JOIN_ERR_GROUP_NOT_ENOUGH:
|
||||
case BG_JOIN_ERR_MIXED_ARENATEAM:
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, GetMangosString(msg), NULL);
|
||||
SendPacket(&data);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue