diff options
-rw-r--r-- | src/game/BattleGroundAB.cpp | 30 | ||||
-rw-r--r-- | src/game/BattleGroundAB.h | 50 | ||||
-rw-r--r-- | src/game/BattleGroundEY.cpp | 17 | ||||
-rw-r--r-- | src/game/BattleGroundEY.h | 51 | ||||
-rw-r--r-- | src/game/BattleGroundHandler.cpp | 137 |
5 files changed, 145 insertions, 140 deletions
diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp index 4c882a46f78..90bbd411773 100644 --- a/src/game/BattleGroundAB.cpp +++ b/src/game/BattleGroundAB.cpp @@ -62,7 +62,7 @@ void BattleGroundAB::Update(uint32 diff) if( GetStatus() == STATUS_IN_PROGRESS ) { - int team_points[2] = { 0, 0 }; + int team_points[BG_TEAMS_COUNT] = { 0, 0 }; for (int node = 0; node < BG_AB_DYNAMIC_NODES_COUNT; ++node) { @@ -102,24 +102,24 @@ void BattleGroundAB::Update(uint32 diff) { // FIXME: team and node names not localized SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_ALLIANCE,NULL,LANG_BG_AB_ALLY,_GetNodeNameId(node)); - PlaySoundToAll(SOUND_NODE_CAPTURED_ALLIANCE); + PlaySoundToAll(BG_AB_SOUND_NODE_CAPTURED_ALLIANCE); } else { // FIXME: team and node names not localized SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_HORDE,NULL,LANG_BG_AB_HORDE,_GetNodeNameId(node)); - PlaySoundToAll(SOUND_NODE_CAPTURED_HORDE); + PlaySoundToAll(BG_AB_SOUND_NODE_CAPTURED_HORDE); } } } - for (int team = 0; team < 2; ++team) + for (int team = 0; team < BG_TEAMS_COUNT; ++team) if( m_Nodes[node] == team + BG_AB_NODE_TYPE_OCCUPIED ) ++team_points[team]; } // Accumulate points - for (int team = 0; team < 2; ++team) + for (int team = 0; team < BG_TEAMS_COUNT; ++team) { int points = team_points[team]; if( !points ) @@ -141,18 +141,18 @@ void BattleGroundAB::Update(uint32 diff) RewardHonorToTeam(GetBonusHonorFromKill(1), (team == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE); m_HonorScoreTics[team] -= m_HonorTics; } - if( !m_IsInformedNearVictory && m_TeamScores[team] > 1800 ) + if( !m_IsInformedNearVictory && m_TeamScores[team] > BG_AB_WARNING_NEAR_VICTORY_SCORE ) { if( team == BG_TEAM_ALLIANCE ) SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); else SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); - PlaySoundToAll(SOUND_NEAR_VICTORY); + PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY); m_IsInformedNearVictory = true; } - if( m_TeamScores[team] > 2000 ) - m_TeamScores[team] = 2000; + if( m_TeamScores[team] > BG_AB_MAX_TEAM_SCORE ) + m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE; if( team == BG_TEAM_ALLIANCE ) UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]); if( team == BG_TEAM_HORDE ) @@ -161,9 +161,9 @@ void BattleGroundAB::Update(uint32 diff) } // Test win condition - if( m_TeamScores[BG_TEAM_ALLIANCE] >= 2000 ) + if( m_TeamScores[BG_TEAM_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE ) EndBattleGround(ALLIANCE); - if( m_TeamScores[BG_TEAM_HORDE] >= 2000 ) + if( m_TeamScores[BG_TEAM_HORDE] >= BG_AB_MAX_TEAM_SCORE ) EndBattleGround(HORDE); } } @@ -327,7 +327,7 @@ void BattleGroundAB::FillInitialWorldStates(WorldPacket& data) // Team scores data << uint32(BG_AB_OP_RESOURCES_MAX) << uint32(BG_AB_MAX_TEAM_SCORE); - data << uint32(BG_AB_OP_RESOURCES_WARNING) << uint32(BG_AB_WARNING_SCORE); + data << uint32(BG_AB_OP_RESOURCES_WARNING) << uint32(BG_AB_WARNING_NEAR_VICTORY_SCORE); data << uint32(BG_AB_OP_RESOURCES_ALLY) << uint32(m_TeamScores[BG_TEAM_ALLIANCE]); data << uint32(BG_AB_OP_RESOURCES_HORDE) << uint32(m_TeamScores[BG_TEAM_HORDE]); @@ -454,7 +454,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ else SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_AB_HORDE); - sound = SOUND_NODE_CLAIMED; + sound = BG_AB_SOUND_NODE_CLAIMED; } // If node is contested else if( (m_Nodes[node] == BG_AB_NODE_STATUS_ALLY_CONTESTED) || (m_Nodes[node] == BG_AB_NODE_STATUS_HORDE_CONTESTED) ) @@ -498,7 +498,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ else SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } - sound = (teamIndex == 0) ? SOUND_NODE_ASSAULTED_ALLIANCE : SOUND_NODE_ASSAULTED_HORDE; + sound = (teamIndex == 0) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } // If node is occupied, change to enemy-contested else @@ -520,7 +520,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ else SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED,CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); - sound = (teamIndex == 0) ? SOUND_NODE_ASSAULTED_ALLIANCE : SOUND_NODE_ASSAULTED_HORDE; + sound = (teamIndex == 0) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } // If node is occupied again, send "X has taken the Y" msg. diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h index 00328949bc5..5307a436f12 100644 --- a/src/game/BattleGroundAB.h +++ b/src/game/BattleGroundAB.h @@ -77,17 +77,17 @@ enum BG_AB_NodeObjectId enum BG_AB_ObjectType { // for all 5 node points 8*5=40 objects - BG_AB_OBJECT_BANNER_NEUTRAL = 0, - BG_AB_OBJECT_BANNER_CONT_A = 1, - BG_AB_OBJECT_BANNER_CONT_H = 2, - BG_AB_OBJECT_BANNER_ALLY = 3, - BG_AB_OBJECT_BANNER_HORDE = 4, - BG_AB_OBJECT_AURA_ALLY = 5, - BG_AB_OBJECT_AURA_HORDE = 6, - BG_AB_OBJECT_AURA_CONTESTED = 7, + BG_AB_OBJECT_BANNER_NEUTRAL = 0, + BG_AB_OBJECT_BANNER_CONT_A = 1, + BG_AB_OBJECT_BANNER_CONT_H = 2, + BG_AB_OBJECT_BANNER_ALLY = 3, + BG_AB_OBJECT_BANNER_HORDE = 4, + BG_AB_OBJECT_AURA_ALLY = 5, + BG_AB_OBJECT_AURA_HORDE = 6, + BG_AB_OBJECT_AURA_CONTESTED = 7, //gates - BG_AB_OBJECT_GATE_A = 40, - BG_AB_OBJECT_GATE_H = 41, + BG_AB_OBJECT_GATE_A = 40, + BG_AB_OBJECT_GATE_H = 41, //buffs BG_AB_OBJECT_SPEEDBUFF_STABLES = 42, BG_AB_OBJECT_REGENBUFF_STABLES = 43, @@ -130,8 +130,8 @@ enum BG_AB_Timers enum BG_AB_Score { - BG_AB_MAX_TEAM_SCORE = 2000, - BG_AB_WARNING_SCORE = 1800 + BG_AB_WARNING_NEAR_VICTORY_SCORE = 1800, + BG_AB_MAX_TEAM_SCORE = 2000 }; /* do NOT change the order, else wrong behaviour */ @@ -164,18 +164,18 @@ enum BG_AB_NodeStatus enum BG_AB_Sounds { - SOUND_NODE_CLAIMED = 8192, - SOUND_NODE_CAPTURED_ALLIANCE = 8173, - SOUND_NODE_CAPTURED_HORDE = 8213, - SOUND_NODE_ASSAULTED_ALLIANCE = 8174, - SOUND_NODE_ASSAULTED_HORDE = 8212, - SOUND_NEAR_VICTORY = 8456 + BG_AB_SOUND_NODE_CLAIMED = 8192, + BG_AB_SOUND_NODE_CAPTURED_ALLIANCE = 8173, + BG_AB_SOUND_NODE_CAPTURED_HORDE = 8213, + BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE = 8174, + BG_AB_SOUND_NODE_ASSAULTED_HORDE = 8212, + BG_AB_SOUND_NEAR_VICTORY = 8456 }; -#define BG_AB_NotABBGWeekendHonorTicks 330 -#define BG_AB_ABBGWeekendHonorTicks 200 +#define BG_AB_NotABBGWeekendHonorTicks 330 +#define BG_AB_ABBGWeekendHonorTicks 200 #define BG_AB_NotABBGWeekendReputationTicks 200 -#define BG_AB_ABBGWeekendReputationTicks 150 +#define BG_AB_ABBGWeekendReputationTicks 150 // x, y, z, o const float BG_AB_NodePositions[BG_AB_DYNAMIC_NODES_COUNT][4] = { @@ -285,10 +285,10 @@ class BattleGroundAB : public BattleGround uint8 m_prevNodes[BG_AB_DYNAMIC_NODES_COUNT]; BG_AB_BannerTimer m_BannerTimers[BG_AB_DYNAMIC_NODES_COUNT]; int32 m_NodeTimers[BG_AB_DYNAMIC_NODES_COUNT]; - uint32 m_TeamScores[2]; - uint32 m_lastTick[2]; - uint32 m_HonorScoreTics[2]; - uint32 m_ReputationScoreTics[2]; + uint32 m_TeamScores[BG_TEAMS_COUNT]; + uint32 m_lastTick[BG_TEAMS_COUNT]; + uint32 m_HonorScoreTics[BG_TEAMS_COUNT]; + uint32 m_ReputationScoreTics[BG_TEAMS_COUNT]; bool m_IsInformedNearVictory; uint32 m_HonorTics; uint32 m_ReputationTics; diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp index 55e5d002a91..a9402fd6c67 100644 --- a/src/game/BattleGroundEY.cpp +++ b/src/game/BattleGroundEY.cpp @@ -267,9 +267,20 @@ void BattleGroundEY::UpdatePointStatuses() void BattleGroundEY::UpdateTeamScore(uint32 Team) { uint32 score = GetTeamScore(Team); - if(score >= EY_MAX_TEAM_SCORE) + //TODO there should be some sound played when one team is near victory!! - and define variables + /*if( !m_IsInformedNearVictory && score >= BG_EY_WARNING_NEAR_VICTORY_SCORE ) { - score = EY_MAX_TEAM_SCORE; + if( Team == ALLIANCE ) + SendMessageToAll(LANG_BG_EY_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); + else + SendMessageToAll(LANG_BG_EY_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); + PlaySoundToAll(BG_EY_SOUND_NEAR_VICTORY); + m_IsInformedNearVictory = true; + }*/ + + if( score >= BG_EY_MAX_TEAM_SCORE ) + { + score = BG_EY_MAX_TEAM_SCORE; EndBattleGround(Team); } @@ -518,7 +529,7 @@ void BattleGroundEY::Reset() m_PointAddingTimer = 0; m_TowerCapCheckTimer = 0; bool isBGWeekend = false; //TODO FIXME - call sBattleGroundMgr.IsBGWeekend(m_TypeID); - you must also implement that call! - uint32 m_HonorTics = (isBGWeekend) ? BG_EY_EYWeekendHonorTicks : BG_EY_NotEYWeekendHonorTicks; + m_HonorTics = (isBGWeekend) ? BG_EY_EYWeekendHonorTicks : BG_EY_NotEYWeekendHonorTicks; for(uint8 i = 0; i < EY_POINTS_MAX; ++i) { diff --git a/src/game/BattleGroundEY.h b/src/game/BattleGroundEY.h index ffefe543060..c4ffb57fba3 100644 --- a/src/game/BattleGroundEY.h +++ b/src/game/BattleGroundEY.h @@ -25,9 +25,8 @@ class BattleGround; -#define EY_MAX_TEAM_SCORE 2000 -#define BG_EY_FLAG_RESPAWN_TIME (10*IN_MILISECONDS) //10 seconds -#define BG_EY_FPOINTS_TICK_TIME (2*IN_MILISECONDS) //2 seconds +#define BG_EY_FLAG_RESPAWN_TIME (10*IN_MILISECONDS) //10 seconds +#define BG_EY_FPOINTS_TICK_TIME (2*IN_MILISECONDS) //2 seconds enum BG_EY_WorldStates { @@ -73,11 +72,11 @@ enum BG_EY_ProgressBarConsts enum BG_EY_Sounds { //strange ids, but sure about them - BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE = 8212, - BG_EY_SOUND_FLAG_CAPTURED_HORDE = 8213, - BG_EY_SOUND_FLAG_PICKED_UP_HORDE = 8174, - BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE = 8173, - BG_EY_SOUND_FLAG_RESET = 8192 + BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE = 8212, + BG_EY_SOUND_FLAG_CAPTURED_HORDE = 8213, + BG_EY_SOUND_FLAG_PICKED_UP_HORDE = 8174, + BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE = 8173, + BG_EY_SOUND_FLAG_RESET = 8192 }; enum BG_EY_Spells @@ -88,18 +87,18 @@ enum BG_EY_Spells enum EYBattleGroundObjectEntry { - BG_OBJECT_A_DOOR_EY_ENTRY = 184719, //Alliance door - BG_OBJECT_H_DOOR_EY_ENTRY = 184720, //Horde door - BG_OBJECT_FLAG1_EY_ENTRY = 184493, //Netherstorm flag (generic) - BG_OBJECT_FLAG2_EY_ENTRY = 184141, //Netherstorm flag (flagstand) - BG_OBJECT_FLAG3_EY_ENTRY = 184142, //Netherstorm flag (flagdrop) - BG_OBJECT_A_BANNER_EY_ENTRY = 184381, //Visual Banner (Alliance) - BG_OBJECT_H_BANNER_EY_ENTRY = 184380, //Visual Banner (Horde) - BG_OBJECT_N_BANNER_EY_ENTRY = 184382, //Visual Banner (Neutral) - BG_OBJECT_BE_TOWER_CAP_EY_ENTRY = 184080, //BE Tower Cap Pt - BG_OBJECT_FR_TOWER_CAP_EY_ENTRY = 184081, //Fel Reaver Cap Pt - BG_OBJECT_HU_TOWER_CAP_EY_ENTRY = 184082, //Human Tower Cap Pt - BG_OBJECT_DR_TOWER_CAP_EY_ENTRY = 184083 //Draenei Tower Cap Pt + BG_OBJECT_A_DOOR_EY_ENTRY = 184719, //Alliance door + BG_OBJECT_H_DOOR_EY_ENTRY = 184720, //Horde door + BG_OBJECT_FLAG1_EY_ENTRY = 184493, //Netherstorm flag (generic) + BG_OBJECT_FLAG2_EY_ENTRY = 184141, //Netherstorm flag (flagstand) + BG_OBJECT_FLAG3_EY_ENTRY = 184142, //Netherstorm flag (flagdrop) + BG_OBJECT_A_BANNER_EY_ENTRY = 184381, //Visual Banner (Alliance) + BG_OBJECT_H_BANNER_EY_ENTRY = 184380, //Visual Banner (Horde) + BG_OBJECT_N_BANNER_EY_ENTRY = 184382, //Visual Banner (Neutral) + BG_OBJECT_BE_TOWER_CAP_EY_ENTRY = 184080, //BE Tower Cap Pt + BG_OBJECT_FR_TOWER_CAP_EY_ENTRY = 184081, //Fel Reaver Cap Pt + BG_OBJECT_HU_TOWER_CAP_EY_ENTRY = 184082, //Human Tower Cap Pt + BG_OBJECT_DR_TOWER_CAP_EY_ENTRY = 184083 //Draenei Tower Cap Pt }; enum EYBattleGroundPointsTrigger @@ -131,7 +130,7 @@ enum EYBattleGroundPoints DRAENEI_RUINS = 2, MAGE_TOWER = 3, - EY_PLAYERS_OUT_OF_POINTS = 4, + EY_PLAYERS_OUT_OF_POINTS = 4, EY_POINTS_MAX = 4 }; @@ -212,8 +211,14 @@ enum EYBattleGroundObjectTypes BG_EY_OBJECT_MAX = 59 }; -#define BG_EY_NotEYWeekendHonorTicks 330 -#define BG_EY_EYWeekendHonorTicks 200 +#define BG_EY_NotEYWeekendHonorTicks 330 +#define BG_EY_EYWeekendHonorTicks 200 + +enum BG_EY_Score +{ + BG_EY_WARNING_NEAR_VICTORY_SCORE = 1800, + BG_EY_MAX_TEAM_SCORE = 2000 +}; enum BG_EY_FlagState { diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 912c1349d05..e11ca8c9cea 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -129,7 +129,7 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data ) if( !_player->CanJoinToBattleground() ) { WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4); - data << (uint32) 0xFFFFFFFE; + data << uint32(0xFFFFFFFE); _player->GetSession()->SendPacket(&data); return; } @@ -301,25 +301,25 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) 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. // 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) - if(_player->InBattleGroundQueue()) + if( _player->InBattleGroundQueue() ) { // update all queues, send invitation info if player is invited, queue info if queued for (uint32 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) { BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i); - if(!bgQueueTypeId) + if( !bgQueueTypeId ) continue; BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId); BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers; 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(itrPlayerStatus == qpMap.end() || !itrPlayerStatus->second.GroupInfo) + if( itrPlayerStatus == qpMap.end() || !itrPlayerStatus->second.GroupInfo ) continue; BattleGround * bg = NULL; @@ -328,7 +328,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) uint8 israted = itrPlayerStatus->second.GroupInfo->IsRated; uint8 status = 0; - if(!itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID) + if( !itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID ) { // not invited to bg, get template bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); @@ -341,12 +341,8 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) status = STATUS_WAIT_JOIN; } - // if bg not found, then continue - if(!bg) - continue; - - // don't invite if already in the instance - if(_player->InBattleGround() && _player->GetBattleGround() && _player->GetBattleGround()->GetInstanceID() == bg->GetInstanceID()) + // if bg not found, then continue, don't invite if already in the instance + if( !bg || (_player->InBattleGround() && _player->GetBattleGround() && _player->GetBattleGround()->GetInstanceID() == bg->GetInstanceID()) ) continue; // re - invite player with proper data @@ -358,22 +354,20 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) return; } + //get GroupQueueInfo from BattleGroundQueue BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_); - - BattleGroundQueueTypeId bgQueueTypeId = BATTLEGROUND_QUEUE_NONE; - // get the bg what we were invited to - bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, type); + BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, type); BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers; BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID()); - if(itrPlayerStatus == qpMap.end()) + if( itrPlayerStatus == qpMap.end() ) { sLog.outError("Battleground: itrplayerstatus not found."); return; } - instanceId = itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID; - // if action == 1, then instanceId is _required_ - if(!instanceId && action == 1) + instanceId = itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID; + // if action == 1, then instanceId is required + if( !instanceId && action == 1 ) { sLog.outError("Battleground: instance not found."); return; @@ -382,56 +376,52 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId, bgTypeId); // 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); - - 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; } - bgTypeId = bg->GetTypeID(); - - if(_player->InBattleGroundQueue()) + 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& qpMap2 = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers; - BattleGroundQueue::QueuedPlayersMap::iterator pitr = qpMap2.find(_player->GetGUID()); - if (pitr !=qpMap2.end() && pitr->second.GroupInfo) + //we must use temporary variables, because GroupQueueInfo pointer can be deleted in BattleGroundQueue::RemovePlayer() function! + uint32 team = itrPlayerStatus->second.GroupInfo->Team; + uint32 arenaType = itrPlayerStatus->second.GroupInfo->ArenaType; + uint32 isRated = itrPlayerStatus->second.GroupInfo->IsRated; + uint32 rating = itrPlayerStatus->second.GroupInfo->ArenaTeamRating; + uint32 opponentsRating = itrPlayerStatus->second.GroupInfo->OpponentsTeamRating; + + //some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it + if( action == 1 && arenaType == 0) { - 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; + //if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue + 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); + action = 0; + 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; + } } + uint32 queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId); WorldPacket data; - switch(action) + switch( action ) { - case 1: // port to battleground - if(!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId)) - return; // cheating? + case 1: // port to battleground + if( !_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId) ) + return; // cheating? // resurrect the player - if(!_player->isAlive()) + if( !_player->isAlive() ) { _player->ResurrectPlayer(1.0f); _player->SpawnCorpseBones(); @@ -442,14 +432,15 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) _player->GetMotionMaster()->MovementExpired(); _player->m_taxi.ClearTaxiDestinations(); } + //TODO FIX ME this call must be removed! _player->RemoveFromGroup(); - queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId); + sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime()); _player->GetSession()->SendPacket(&data); // remove battleground queue status from BGmgr sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].RemovePlayer(_player->GetGUID(), false); // 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() ) currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true); @@ -461,30 +452,28 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) sBattleGroundMgr.SendToBattleGround(_player, instanceId, bgTypeId); // add only in HandleMoveWorldPortAck() // 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; 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); - 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); at->MemberLost(_player, opponentsRating); 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); + _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, arenaType); sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].RemovePlayer(_player->GetGUID(), true); - // player left queue, we should update it, maybe now his group fits in - sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId,_player->GetBattleGroundQueueIdFromLevel(bgTypeId),arenatype,israted,rating); + // player left queue, we should update it - do not update Arena Queue + if( !arenaType ) + sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId), arenaType, isRated, rating); 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; default: sLog.outError("Battleground port: unknown action %u", action); |