mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 01:37:01 +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;
|
||||||
}
|
}
|
||||||
|
|
@ -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,11 +352,9 @@ 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() )
|
||||||
|
|
@ -368,9 +362,9 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
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 action == 1, then instanceId is required
|
||||||
if( !instanceId && action == 1 )
|
if( !instanceId && action == 1 )
|
||||||
{
|
{
|
||||||
sLog.outError("Battleground: instance not found.");
|
sLog.outError("Battleground: instance not found.");
|
||||||
|
|
@ -382,46 +376,39 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
// 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;
|
|
||||||
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 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() )
|
if( !_player->CanJoinToBattleground() )
|
||||||
{
|
{
|
||||||
|
//send bg command result to show nice message
|
||||||
|
WorldPacket data2(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
|
||||||
|
data2 << uint32(0xFFFFFFFE);
|
||||||
|
_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.outDebug("Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName(), _player->GetGUIDLow());
|
||||||
|
}
|
||||||
|
//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() )
|
||||||
|
sLog.outError("Battleground: Player %s (%u) has level higher than maxlevel of battleground! 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 )
|
||||||
{
|
{
|
||||||
|
|
@ -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);
|
||||||
|
|
||||||
|
|
@ -462,11 +450,8 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
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 )
|
||||||
|
|
@ -477,10 +462,11 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_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;
|
||||||
|
|
|
||||||
|
|
@ -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