mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[7447] Fixed - do not let player who has higher level than Battleground->GetMaxLevel to enter battleground.
Signed-off-by: Triply <triply@getmangos.com>
This commit is contained in:
parent
424c8b39df
commit
b94c78474b
2 changed files with 59 additions and 73 deletions
|
|
@ -127,7 +127,7 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
|
||||||
if( !_player->CanJoinToBattleground() )
|
if( !_player->CanJoinToBattleground() )
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
|
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
|
||||||
data << (uint32) 0xFFFFFFFE;
|
data << uint32(0xFFFFFFFE);
|
||||||
_player->GetSession()->SendPacket(&data);
|
_player->GetSession()->SendPacket(&data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -299,25 +299,25 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
|
|
||||||
recv_data >> type >> unk2 >> bgTypeId_ >> unk >> action;
|
recv_data >> type >> unk2 >> bgTypeId_ >> unk >> action;
|
||||||
|
|
||||||
if(!sBattlemasterListStore.LookupEntry(bgTypeId_))
|
if( !sBattlemasterListStore.LookupEntry(bgTypeId_) )
|
||||||
{
|
{
|
||||||
sLog.outError("Battleground: invalid bgtype (%u) received.",bgTypeId_);
|
sLog.outError("Battleground: invalid bgtype (%u) received.", bgTypeId_);
|
||||||
// update battleground slots for the player to fix his UI and sent data.
|
// update battleground slots for the player to fix his UI and sent data.
|
||||||
// this is a HACK, I don't know why the client starts sending invalid packets in the first place.
|
// this is a HACK, I don't know why the client starts sending invalid packets in the first place.
|
||||||
// it usually happens with extremely high latency (if debugging / stepping in the code for example)
|
// it usually happens with extremely high latency (if debugging / stepping in the code for example)
|
||||||
if(_player->InBattleGroundQueue())
|
if( _player->InBattleGroundQueue() )
|
||||||
{
|
{
|
||||||
// update all queues, send invitation info if player is invited, queue info if queued
|
// update all queues, send invitation info if player is invited, queue info if queued
|
||||||
for (uint32 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
|
for (uint32 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
|
||||||
{
|
{
|
||||||
BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i);
|
BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i);
|
||||||
if(!bgQueueTypeId)
|
if( !bgQueueTypeId )
|
||||||
continue;
|
continue;
|
||||||
BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId);
|
BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId);
|
||||||
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
||||||
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
||||||
// if the player is not in queue, continue or no group information - this should never happen
|
// if the player is not in queue, continue or no group information - this should never happen
|
||||||
if(itrPlayerStatus == qpMap.end() || !itrPlayerStatus->second.GroupInfo)
|
if( itrPlayerStatus == qpMap.end() || !itrPlayerStatus->second.GroupInfo )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BattleGround * bg = NULL;
|
BattleGround * bg = NULL;
|
||||||
|
|
@ -326,7 +326,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
uint8 israted = itrPlayerStatus->second.GroupInfo->IsRated;
|
uint8 israted = itrPlayerStatus->second.GroupInfo->IsRated;
|
||||||
uint8 status = 0;
|
uint8 status = 0;
|
||||||
|
|
||||||
if(!itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID)
|
if( !itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID )
|
||||||
{
|
{
|
||||||
// not invited to bg, get template
|
// not invited to bg, get template
|
||||||
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
|
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
|
||||||
|
|
@ -339,12 +339,8 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
status = STATUS_WAIT_JOIN;
|
status = STATUS_WAIT_JOIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if bg not found, then continue
|
// if bg not found, then continue, don't invite if already in the instance
|
||||||
if(!bg)
|
if( !bg || (_player->InBattleGround() && _player->GetBattleGround() && _player->GetBattleGround()->GetInstanceID() == bg->GetInstanceID()) )
|
||||||
continue;
|
|
||||||
|
|
||||||
// don't invite if already in the instance
|
|
||||||
if(_player->InBattleGround() && _player->GetBattleGround() && _player->GetBattleGround()->GetInstanceID() == bg->GetInstanceID())
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// re - invite player with proper data
|
// re - invite player with proper data
|
||||||
|
|
@ -356,22 +352,20 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get GroupQueueInfo from BattleGroundQueue
|
||||||
BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
|
BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
|
||||||
|
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, type);
|
||||||
BattleGroundQueueTypeId bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
|
|
||||||
// get the bg what we were invited to
|
|
||||||
bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, type);
|
|
||||||
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
||||||
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
||||||
if(itrPlayerStatus == qpMap.end())
|
if( itrPlayerStatus == qpMap.end() )
|
||||||
{
|
{
|
||||||
sLog.outError("Battleground: itrplayerstatus not found.");
|
sLog.outError("Battleground: itrplayerstatus not found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instanceId = itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID;
|
|
||||||
|
|
||||||
// if action == 1, then instanceId is _required_
|
instanceId = itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID;
|
||||||
if(!instanceId && action == 1)
|
// if action == 1, then instanceId is required
|
||||||
|
if( !instanceId && action == 1 )
|
||||||
{
|
{
|
||||||
sLog.outError("Battleground: instance not found.");
|
sLog.outError("Battleground: instance not found.");
|
||||||
return;
|
return;
|
||||||
|
|
@ -380,56 +374,49 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId, bgTypeId);
|
BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId, bgTypeId);
|
||||||
|
|
||||||
// bg template might and must be used in case of leaving queue, when instance is not created yet
|
// bg template might and must be used in case of leaving queue, when instance is not created yet
|
||||||
if(!bg && action == 0)
|
if( !bg && action == 0 )
|
||||||
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
|
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
|
||||||
|
if( !bg )
|
||||||
if(!bg)
|
|
||||||
{
|
{
|
||||||
sLog.outError("Battleground: bg not found for type id %u.",bgTypeId);
|
sLog.outError("Battleground: bg_template not found for type id %u.", bgTypeId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bgTypeId = bg->GetTypeID();
|
if( _player->InBattleGroundQueue() )
|
||||||
|
|
||||||
if(_player->InBattleGroundQueue())
|
|
||||||
{
|
{
|
||||||
uint32 queueSlot = 0;
|
//we must use temporary variables, because GroupQueueInfo pointer can be deleted in BattleGroundQueue::RemovePlayer() function!
|
||||||
uint32 team = 0;
|
uint32 team = itrPlayerStatus->second.GroupInfo->Team;
|
||||||
uint32 arenatype = 0;
|
uint32 arenaType = itrPlayerStatus->second.GroupInfo->ArenaType;
|
||||||
uint32 israted = 0;
|
uint32 isRated = itrPlayerStatus->second.GroupInfo->IsRated;
|
||||||
uint32 rating = 0;
|
uint32 rating = itrPlayerStatus->second.GroupInfo->ArenaTeamRating;
|
||||||
uint32 opponentsRating = 0;
|
uint32 opponentsRating = itrPlayerStatus->second.GroupInfo->OpponentsTeamRating;
|
||||||
// get the team info from the queue
|
|
||||||
|
|
||||||
BattleGroundQueue::QueuedPlayersMap& qpMap2 = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
//some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
|
||||||
BattleGroundQueue::QueuedPlayersMap::iterator pitr = qpMap2.find(_player->GetGUID());
|
if( action == 1 && arenaType == 0)
|
||||||
if (pitr !=qpMap2.end() && pitr->second.GroupInfo)
|
|
||||||
{
|
{
|
||||||
team = pitr->second.GroupInfo->Team;
|
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
|
||||||
arenatype = pitr->second.GroupInfo->ArenaType;
|
if( !_player->CanJoinToBattleground() )
|
||||||
israted = pitr->second.GroupInfo->IsRated;
|
{
|
||||||
rating = pitr->second.GroupInfo->ArenaTeamRating;
|
//send bg command result to show nice message
|
||||||
opponentsRating = pitr->second.GroupInfo->OpponentsTeamRating;
|
WorldPacket data2(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
|
||||||
}
|
data2 << uint32(0xFFFFFFFE);
|
||||||
else
|
_player->GetSession()->SendPacket(&data2);
|
||||||
{
|
sLog.outDebug("Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName(), _player->GetGUIDLow());
|
||||||
sLog.outError("Battleground: Invalid player queue info!");
|
}
|
||||||
return;
|
//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() )
|
||||||
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
|
sLog.outError("Battleground: Player %s (%u) has level higher than maxlevel of battleground! Do not port him to battleground!", _player->GetName(), _player->GetGUIDLow());
|
||||||
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;
|
action = 0;
|
||||||
}
|
}
|
||||||
|
uint32 queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId);
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
switch(action)
|
switch( action )
|
||||||
{
|
{
|
||||||
case 1: // port to battleground
|
case 1: // port to battleground
|
||||||
if(!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId))
|
if( !_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId) )
|
||||||
return; // cheating?
|
return; // cheating?
|
||||||
// resurrect the player
|
// resurrect the player
|
||||||
if(!_player->isAlive())
|
if( !_player->isAlive() )
|
||||||
{
|
{
|
||||||
_player->ResurrectPlayer(1.0f);
|
_player->ResurrectPlayer(1.0f);
|
||||||
_player->SpawnCorpseBones();
|
_player->SpawnCorpseBones();
|
||||||
|
|
@ -440,14 +427,15 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
_player->GetMotionMaster()->MovementExpired();
|
_player->GetMotionMaster()->MovementExpired();
|
||||||
_player->m_taxi.ClearTaxiDestinations();
|
_player->m_taxi.ClearTaxiDestinations();
|
||||||
}
|
}
|
||||||
|
//TODO FIX ME this call must be removed!
|
||||||
_player->RemoveFromGroup();
|
_player->RemoveFromGroup();
|
||||||
queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId);
|
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime());
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime());
|
||||||
_player->GetSession()->SendPacket(&data);
|
_player->GetSession()->SendPacket(&data);
|
||||||
// remove battleground queue status from BGmgr
|
// remove battleground queue status from BGmgr
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].RemovePlayer(_player->GetGUID(), false);
|
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].RemovePlayer(_player->GetGUID(), false);
|
||||||
// this is still needed here if battleground "jumping" shouldn't add deserter debuff
|
// this is still needed here if battleground "jumping" shouldn't add deserter debuff
|
||||||
// also this required to prevent stuck at old battleground after SetBattleGroundId set to new
|
// also this is required to prevent stuck at old battleground after SetBattleGroundId set to new
|
||||||
if( BattleGround *currentBg = _player->GetBattleGround() )
|
if( BattleGround *currentBg = _player->GetBattleGround() )
|
||||||
currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
|
currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
|
||||||
|
|
||||||
|
|
@ -459,30 +447,28 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
sBattleGroundMgr.SendToBattleGround(_player, instanceId, bgTypeId);
|
sBattleGroundMgr.SendToBattleGround(_player, instanceId, bgTypeId);
|
||||||
// add only in HandleMoveWorldPortAck()
|
// add only in HandleMoveWorldPortAck()
|
||||||
// bg->AddPlayer(_player,team);
|
// bg->AddPlayer(_player,team);
|
||||||
sLog.outDebug("Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.",_player->GetName(),_player->GetGUIDLow(),bg->GetInstanceID(),bg->GetTypeID(),bgQueueTypeId);
|
sLog.outDebug("Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
|
||||||
break;
|
break;
|
||||||
case 0: // leave queue
|
case 0: // leave queue
|
||||||
queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId);
|
// if player leaves rated arena match before match start, it is counted as he played but he lost
|
||||||
/*
|
if( isRated )
|
||||||
if player leaves rated arena match before match start, it is counted as he played but he lost
|
|
||||||
*/
|
|
||||||
if (israted)
|
|
||||||
{
|
{
|
||||||
ArenaTeam * at = objmgr.GetArenaTeamById(team);
|
ArenaTeam * at = objmgr.GetArenaTeamById(team);
|
||||||
if (at)
|
if( at )
|
||||||
{
|
{
|
||||||
sLog.outDebug("UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!", GUID_LOPART(_player->GetGUID()), opponentsRating);
|
sLog.outDebug("UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!", GUID_LOPART(_player->GetGUID()), opponentsRating);
|
||||||
at->MemberLost(_player, opponentsRating);
|
at->MemberLost(_player, opponentsRating);
|
||||||
at->SaveToDB();
|
at->SaveToDB();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_player->RemoveBattleGroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
|
_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);
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, arenaType);
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].RemovePlayer(_player->GetGUID(), true);
|
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].RemovePlayer(_player->GetGUID(), true);
|
||||||
// player left queue, we should update it, maybe now his group fits in
|
// player left queue, we should update it - do not update Arena Queue
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId,_player->GetBattleGroundQueueIdFromLevel(bgTypeId),arenatype,israted,rating);
|
if( !arenaType )
|
||||||
|
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId), arenaType, isRated, rating);
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
sLog.outDebug("Battleground: player %s (%u) left queue for bgtype %u, queue type %u.",_player->GetName(),_player->GetGUIDLow(),bg->GetTypeID(),bgQueueTypeId);
|
sLog.outDebug("Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sLog.outError("Battleground port: unknown action %u", action);
|
sLog.outError("Battleground port: unknown action %u", action);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7446"
|
#define REVISION_NR "7447"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue