aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-01-09 15:15:42 +0100
committerSpp <spp@jorge.gr>2013-01-09 15:15:42 +0100
commit677ed180802541d4bf487eeaa554c01aa3dc5ceb (patch)
tree6e5d87548c65c6d5cb3e574f0571c7fb363280e7 /src
parentecfb7623469c4da0e70a53294a53e8f1e3f70537 (diff)
Core/Dungeon Finder: Fix group (5) unable to do new dungeon after finished last dungeon
- Some optimizations here and there - Drop unused columns related to dungeon rewards - Simplify Group reward. All people inside the dungeon should get the reward, no matter how far it's from the boss
Diffstat (limited to 'src')
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.cpp253
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.h49
-rw-r--r--src/server/game/DungeonFinding/LFGPlayerData.cpp4
-rw-r--r--src/server/game/DungeonFinding/LFGQueue.cpp6
-rw-r--r--src/server/game/DungeonFinding/LFGQueue.h4
-rw-r--r--src/server/game/DungeonFinding/LFGScripts.cpp10
-rw-r--r--src/server/game/Handlers/BattleGroundHandler.cpp2
-rw-r--r--src/server/game/Handlers/LFGHandler.cpp91
-rw-r--r--src/server/game/Instances/InstanceScript.cpp38
-rw-r--r--src/server/game/Server/Protocol/Opcodes.cpp2
-rw-r--r--src/server/game/Server/WorldSession.h40
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp6
12 files changed, 257 insertions, 248 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 2550f909a8b..9d5d8e40b54 100644
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -188,7 +188,7 @@ void LFGMgr::LoadRewards()
RewardMapStore.clear();
// ORDER BY is very important for GetRandomDungeonReward!
- QueryResult result = WorldDatabase.Query("SELECT dungeonId, maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar FROM lfg_dungeon_rewards ORDER BY dungeonId, maxLevel ASC");
+ QueryResult result = WorldDatabase.Query("SELECT dungeonId, maxLevel, firstQuestId, otherQuestId FROM lfg_dungeon_rewards ORDER BY dungeonId, maxLevel ASC");
if (!result)
{
@@ -205,11 +205,7 @@ void LFGMgr::LoadRewards()
uint32 dungeonId = fields[0].GetUInt32();
uint32 maxLevel = fields[1].GetUInt8();
uint32 firstQuestId = fields[2].GetUInt32();
- uint32 firstMoneyVar = fields[3].GetUInt32();
- uint32 firstXPVar = fields[4].GetUInt32();
- uint32 otherQuestId = fields[5].GetUInt32();
- uint32 otherMoneyVar = fields[6].GetUInt32();
- uint32 otherXPVar = fields[7].GetUInt32();
+ uint32 otherQuestId = fields[3].GetUInt32();
if (!GetLFGDungeon(dungeonId))
{
@@ -223,10 +219,10 @@ void LFGMgr::LoadRewards()
maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
}
- if (firstQuestId && !sObjectMgr->GetQuestTemplate(firstQuestId))
+ if (!firstQuestId || !sObjectMgr->GetQuestTemplate(firstQuestId))
{
sLog->outError(LOG_FILTER_SQL, "First quest %u specified for dungeon %u in table `lfg_dungeon_rewards` does not exist!", firstQuestId, dungeonId);
- firstQuestId = 0;
+ continue;
}
if (otherQuestId && !sObjectMgr->GetQuestTemplate(otherQuestId))
@@ -235,9 +231,10 @@ void LFGMgr::LoadRewards()
otherQuestId = 0;
}
- RewardMapStore.insert(LfgRewardContainer::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar)));
+ RewardMapStore.insert(LfgRewardContainer::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, otherQuestId)));
++count;
- } while (result->NextRow());
+ }
+ while (result->NextRow());
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg dungeon rewards in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
@@ -434,7 +431,7 @@ void LFGMgr::Update(uint32 diff)
}
else
SendLfgUpdatePlayer(guid, LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid)));
- SendLfgUpdateProposal(guid, m_lfgProposalId, proposal);
+ SendLfgUpdateProposal(guid, proposal);
}
if (proposal.state == LFG_PROPOSAL_SUCCESS)
@@ -552,27 +549,8 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
LfgState state = GetState(gguid);
if (state == LFG_STATE_QUEUED)
{
- LfgDungeonSet const& playerDungeons = GetSelectedDungeons(guid);
- if (playerDungeons == dungeons) // Joining the same dungeons -- Send OK
- {
- player->GetSession()->SendLfgJoinResult(joinData); // Default value of joinData.result = LFG_JOIN_OK
- if (grp)
- {
- LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment);
- for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
- if (itr->getSource() && itr->getSource()->GetSession())
- itr->getSource()->GetSession()->SendLfgUpdateParty(updateData);
- }
- else
- player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment));
-
- return;
- }
- else // Remove from queue and rejoin
- {
- LFGQueue& queue = GetQueue(gguid);
- queue.RemoveFromQueue(gguid);
- }
+ LFGQueue& queue = GetQueue(gguid);
+ queue.RemoveFromQueue(gguid);
}
// Check player or group member restrictions
@@ -620,7 +598,8 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
bool isDungeon = false;
for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end() && joinData.result == LFG_JOIN_OK; ++it)
{
- switch (GetDungeonType(*it))
+ LfgType type = GetDungeonType(*it);
+ switch (type)
{
case LFG_TYPE_RANDOM:
if (dungeons.size() > 1) // Only allow 1 random dungeon
@@ -640,6 +619,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
isRaid = true;
break;
default:
+ sLog->outError(LOG_FILTER_LFG, "Wrong dungeon type %u for dungeon %u", type, *it);
joinData.result = LFG_JOIN_DUNGEON_INVALID;
break;
}
@@ -719,8 +699,8 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
{
LfgRolesMap rolesMap;
rolesMap[guid] = roles;
- LFGQueue& queue = GetQueue(gguid);
- queue.AddQueueData(guid, time_t(time(NULL)), dungeons, rolesMap);
+ LFGQueue& queue = GetQueue(guid);
+ queue.AddQueueData(guid, time(NULL), dungeons, rolesMap);
if (!isContinue)
{
@@ -873,7 +853,7 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /*
{
uint64 pguid = it->first;
- if (!sendRoleChosen)
+ if (sendRoleChosen)
SendLfgRoleChosen(pguid, guid, roles);
SendLfgRoleCheckUpdate(pguid, roleCheck);
@@ -916,7 +896,7 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /*
@param[in] players Set of players to check their dungeon restrictions
@param[out] lockMap Map of players Lock status info of given dungeons (Empty if dungeons is not empty)
*/
-void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, const LfgGuidSet& players, LfgLockPartyMap& lockMap)
+void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, LfgGuidSet const& players, LfgLockPartyMap& lockMap)
{
lockMap.clear();
for (LfgGuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it)
@@ -1083,9 +1063,10 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
grp->SendUpdate();
}
-uint32 LFGMgr::AddProposal(LfgProposal const& proposal)
+uint32 LFGMgr::AddProposal(LfgProposal& proposal)
{
- ProposalsStore[++m_lfgProposalId] = proposal;
+ proposal.id = ++m_lfgProposalId;
+ ProposalsStore[m_lfgProposalId] = proposal;
return m_lfgProposalId;
}
@@ -1129,16 +1110,14 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
if (!allAnswered)
{
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
- {
- uint64 guid = it->first;
- SendLfgUpdateProposal(guid, proposalId, proposal);
- }
+ SendLfgUpdateProposal(it->first, proposal);
+
return;
}
bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS;
proposal.state = LFG_PROPOSAL_SUCCESS;
- time_t joinTime = time_t(time(NULL));
+ time_t joinTime = time(NULL);
LFGQueue& queue = GetQueue(guid);
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND);
@@ -1149,7 +1128,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
uint32 dungeonId = (*GetSelectedDungeons(pguid).begin());
int32 waitTime = -1;
if (sendUpdate)
- SendLfgUpdateProposal(pguid, proposalId, proposal);
+ SendLfgUpdateProposal(pguid, proposal);
if (gguid)
{
@@ -1236,7 +1215,7 @@ void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdate
uint64 guid = it->first;
uint64 gguid = it->second.group ? it->second.group : guid;
- SendLfgUpdateProposal(guid, itProposal->first, proposal);
+ SendLfgUpdateProposal(guid, proposal);
if (toRemove.find(gguid) != toRemove.end()) // Didn't accept or in same group that someone that didn't accept
{
@@ -1465,106 +1444,126 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*
}
}
- if (error == LFG_TELEPORTERROR_OK)
- {
- if (!player->GetMap()->IsDungeon())
- player->SetBattlegroundEntryPoint();
-
- if (player->isInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
+ if (!player->GetMap()->IsDungeon())
+ player->SetBattlegroundEntryPoint();
- if (!player->TeleportTo(mapid, x, y, z, orientation))
- {
- error = LFG_TELEPORTERROR_INVALID_LOCATION;
- sLog->outError(LOG_FILTER_LFG, "TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u (x: %f, y: %f, z: %f)", player->GetGUID(), mapid, x, y, z);
- }
+ if (player->isInFlight())
+ {
+ player->GetMotionMaster()->MovementExpired();
+ player->CleanupAfterTaxiFlight();
}
+
+ if (!player->TeleportTo(mapid, x, y, z, orientation))
+ error = LFG_TELEPORTERROR_INVALID_LOCATION;
}
+ else
+ error = LFG_TELEPORTERROR_INVALID_LOCATION;
if (error != LFG_TELEPORTERROR_OK)
player->GetSession()->SendLfgTeleportError(uint8(error));
- sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s is being teleported in. Result: %u",
- player->GetName().c_str(), error);
+ sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s is being teleported in to map %u "
+ "(x: %f, y: %f, z: %f) Result: %u", player->GetName().c_str(), dungeon->map,
+ dungeon->x, dungeon->y, dungeon->z, error);
}
/**
- Give completion reward to player
+ Finish a dungeon and give reward, if any.
- @param[in] dungeonId Id of the dungeon finished
- @param[in] player Player to reward
+ @param[in] guid Group guid
+ @param[in] dungeonId Dungeonid
*/
-void LFGMgr::RewardDungeonDoneFor(const uint32 dungeonId, Player* player)
+void LFGMgr::FinishDungeon(uint64 gguid, const uint32 dungeonId)
{
- Group* group = player->GetGroup();
- if (!group || !group->isLFGGroup())
- {
- sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] is not in a group or not a LFGGroup. Ignoring", player->GetGUID());
- return;
- }
-
- uint64 guid = player->GetGUID();
- uint64 gguid = player->GetGroup()->GetGUID();
uint32 gDungeonId = GetDungeon(gguid);
if (gDungeonId != dungeonId)
{
- sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] Finished dungeon %u but group queued for %u. Ignoring", guid, dungeonId, gDungeonId);
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::FinishDungeon: [" UI64FMTD "] Finished dungeon %u but group queued for %u. Ignoring", gguid, dungeonId, gDungeonId);
return;
}
- if (GetState(guid) == LFG_STATE_FINISHED_DUNGEON)
+ if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
{
- sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] Already rewarded player. Ignoring", guid);
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::FinishDungeon: [" UI64FMTD "] Already rewarded group. Ignoring", gguid);
return;
}
- // Mark dungeon as finished
SetState(gguid, LFG_STATE_FINISHED_DUNGEON);
- // Clear player related lfg stuff
- uint32 rDungeonId = (*GetSelectedDungeons(guid).begin());
- SetState(guid, LFG_STATE_FINISHED_DUNGEON);
-
- // Give rewards only if its a random or seasonal dungeon
- LFGDungeonData const* dungeon = GetLFGDungeon(rDungeonId);
- if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
+ const LfgGuidSet& players = GetPlayers(gguid);
+ for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
{
- sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] dungeon %u is not random nor seasonal", guid, rDungeonId);
- return;
- }
+ uint64 guid = (*it);
+ if (GetState(guid) == LFG_STATE_FINISHED_DUNGEON)
+ {
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::FinishDungeon: [" UI64FMTD "] Already rewarded player. Ignoring", guid);
+ continue;
+ }
- // Update achievements
- if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
- player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, 1);
+ uint32 rDungeonId = 0;
+ const LfgDungeonSet& dungeons = GetSelectedDungeons(guid);
+ if (!dungeons.empty())
+ rDungeonId = (*dungeons.begin());
- LfgReward const* reward = GetRandomDungeonReward(rDungeonId, player->getLevel());
- if (!reward)
- return;
+ SetState(guid, LFG_STATE_FINISHED_DUNGEON);
- uint8 index = 0;
- Quest const* qReward = sObjectMgr->GetQuestTemplate(reward->reward[index].questId);
- if (!qReward)
- return;
+ // Give rewards only if its a random dungeon
+ LFGDungeonData const* dungeon = GetLFGDungeon(rDungeonId);
- // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
- if (player->CanRewardQuest(qReward, false))
- player->RewardQuest(qReward, 0, NULL, false);
- else
- {
- index = 1;
- qReward = sObjectMgr->GetQuestTemplate(reward->reward[index].questId);
- if (!qReward)
- return;
- // we give reward without informing client (retail does this)
- player->RewardQuest(qReward, 0, NULL, false);
- }
+ if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
+ {
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::FinishDungeon: [" UI64FMTD "] dungeon %u is not random or seasonal", guid, rDungeonId);
+ continue;
+ }
+
+ Player* player = ObjectAccessor::FindPlayer(guid);
+ if (!player || !player->IsInWorld())
+ {
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::FinishDungeon: [" UI64FMTD "] not found in world", guid);
+ continue;
+ }
+
+ LFGDungeonData const* dungeonDone = GetLFGDungeon(dungeonId);
+ uint32 mapId = dungeonDone ? uint32(dungeonDone->map) : 0;
- // Give rewards
- sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] done dungeon %u, %s previously done.", player->GetGUID(), GetDungeon(gguid), index > 0 ? " " : " not");
- player->GetSession()->SendLfgPlayerReward(dungeon->Entry(), GetDungeon(gguid, false), index, reward, qReward);
+ if (player->GetMapId() != mapId)
+ {
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::FinishDungeon: [" UI64FMTD "] is in map %u and should be in %u to get reward", guid, player->GetMapId(), mapId);
+ continue;
+ }
+
+ // Update achievements
+ if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
+ player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, 1);
+
+ LfgReward const* reward = GetRandomDungeonReward(rDungeonId, player->getLevel());
+ if (!reward)
+ continue;
+
+ bool done = false;
+ Quest const* quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
+ if (!quest)
+ continue;
+
+ // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
+ if (player->CanRewardQuest(quest, false))
+ player->RewardQuest(quest, 0, NULL, false);
+ else
+ {
+ done = true;
+ quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
+ if (!quest)
+ continue;
+ // we give reward without informing client (retail does this)
+ player->RewardQuest(quest, 0, NULL, false);
+ }
+
+ // Give rewards
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::FinishDungeon: [" UI64FMTD "] done dungeon %u, %s previously done.", player->GetGUID(), GetDungeon(gguid), done? " " : " not");
+ LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest);
+ player->GetSession()->SendLfgPlayerReward(data);
+ }
+ SetDungeon(gguid, 0);
}
// --------------------------------------------------------------------------//
@@ -1577,7 +1576,7 @@ void LFGMgr::RewardDungeonDoneFor(const uint32 dungeonId, Player* player)
@param[in] randomdungeon Random dungeon id (if value = 0 will return all dungeons)
@returns Set of dungeons that can be done.
*/
-const LfgDungeonSet& LFGMgr::GetDungeonsByRandom(uint32 randomdungeon)
+LfgDungeonSet const& LFGMgr::GetDungeonsByRandom(uint32 randomdungeon)
{
LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon);
uint32 group = dungeon ? dungeon->group : 0;
@@ -1675,13 +1674,13 @@ bool LFGMgr::IsTeleported(uint64 pguid)
return false;
}
-const LfgDungeonSet& LFGMgr::GetSelectedDungeons(uint64 guid)
+LfgDungeonSet const& LFGMgr::GetSelectedDungeons(uint64 guid)
{
sLog->outTrace(LOG_FILTER_LFG, "LFGMgr::GetSelectedDungeons: [" UI64FMTD "]", guid);
return PlayersStore[guid].GetSelectedDungeons();
}
-const LfgLockMap& LFGMgr::GetLockedDungeons(uint64 guid)
+LfgLockMap const& LFGMgr::GetLockedDungeons(uint64 guid)
{
sLog->outTrace(LOG_FILTER_LFG, "LFGMgr::GetLockedDungeons: [" UI64FMTD "]", guid);
return PlayersStore[guid].GetLockedDungeons();
@@ -1728,7 +1727,7 @@ void LFGMgr::SetState(uint64 guid, LfgState state)
if (IS_GROUP_GUID(guid))
{
LfgGroupData& data = GroupsStore[guid];
- if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG))
+ if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_TRACE))
{
std::string const& ns = GetStateString(state);
std::string const& ps = GetStateString(data.GetState());
@@ -1741,7 +1740,7 @@ void LFGMgr::SetState(uint64 guid, LfgState state)
else
{
LfgPlayerData& data = PlayersStore[guid];
- if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG))
+ if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_TRACE))
{
std::string const& ns = GetStateString(state);
std::string const& ps = GetStateString(data.GetState());
@@ -1765,19 +1764,19 @@ void LFGMgr::SetRoles(uint64 guid, uint8 roles)
PlayersStore[guid].SetRoles(roles);
}
-void LFGMgr::SetComment(uint64 guid, const std::string& comment)
+void LFGMgr::SetComment(uint64 guid, std::string const& comment)
{
sLog->outTrace(LOG_FILTER_LFG, "LFGMgr::SetComment: [" UI64FMTD "] comment: %s", guid, comment.c_str());
PlayersStore[guid].SetComment(comment);
}
-void LFGMgr::SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons)
+void LFGMgr::SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons)
{
- sLog->outTrace(LOG_FILTER_LFG, "LFGMgr::SetSelectedDungeons: [" UI64FMTD "]", guid);
+ sLog->outTrace(LOG_FILTER_LFG, "LFGMgr::SetSelectedDungeons: [" UI64FMTD "] Dungeons: %s", guid, ConcatenateDungeons(dungeons).c_str());
PlayersStore[guid].SetSelectedDungeons(dungeons);
}
-void LFGMgr::SetLockedDungeons(uint64 guid, const LfgLockMap& lock)
+void LFGMgr::SetLockedDungeons(uint64 guid, LfgLockMap const& lock)
{
sLog->outTrace(LOG_FILTER_LFG, "LFGMgr::SetLockedDungeons: [" UI64FMTD "]", guid);
PlayersStore[guid].SetLockedDungeons(lock);
@@ -1918,10 +1917,10 @@ void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot)
player->GetSession()->SendLfgBootProposalUpdate(boot);
}
-void LFGMgr::SendLfgUpdateProposal(uint64 guid, uint32 proposalId, LfgProposal const& proposal)
+void LFGMgr::SendLfgUpdateProposal(uint64 guid, LfgProposal const& proposal)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
- player->GetSession()->SendLfgUpdateProposal(proposalId, proposal);
+ player->GetSession()->SendLfgUpdateProposal(proposal);
}
void LFGMgr::SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data)
@@ -1940,7 +1939,7 @@ LFGQueue& LFGMgr::GetQueue(uint64 guid)
uint8 queueId = 0;
if (IS_GROUP_GUID(guid))
{
- const LfgGuidSet& players = GetPlayers(guid);
+ LfgGuidSet const& players = GetPlayers(guid);
uint64 pguid = players.empty() ? 0 : (*players.begin());
if (pguid)
queueId = GetTeam(pguid);
diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h
index 2041c18a081..0a1b90ee04d 100644
--- a/src/server/game/DungeonFinding/LFGMgr.h
+++ b/src/server/game/DungeonFinding/LFGMgr.h
@@ -28,6 +28,7 @@
class Group;
class Player;
+class Quest;
enum LfgOptions
{
@@ -37,9 +38,9 @@ enum LfgOptions
enum LFGMgrEnum
{
- LFG_TIME_ROLECHECK = 40 * IN_MILLISECONDS,
+ LFG_TIME_ROLECHECK = 45 * IN_MILLISECONDS,
LFG_TIME_BOOT = 120,
- LFG_TIME_PROPOSAL = 120,
+ LFG_TIME_PROPOSAL = 45,
LFG_QUEUEUPDATE_INTERVAL = 15 * IN_MILLISECONDS,
LFG_SPELL_DUNGEON_COOLDOWN = 71328,
LFG_SPELL_DUNGEON_DESERTER = 71041,
@@ -188,27 +189,25 @@ struct LfgQueueStatusData
uint8 dps;
};
+struct LfgPlayerRewardData
+{
+ LfgPlayerRewardData(uint32 random, uint32 current, bool _done, Quest const* _quest):
+ rdungeonEntry(random), sdungeonEntry(current), done(_done), quest(_quest) { }
+ uint32 rdungeonEntry;
+ uint32 sdungeonEntry;
+ bool done;
+ Quest const* quest;
+};
+
/// Reward info
struct LfgReward
{
+ LfgReward(uint32 _maxLevel = 0, uint32 _firstQuest = 0, uint32 _otherQuest = 0):
+ maxLevel(_maxLevel), firstQuest(_firstQuest), otherQuest(_otherQuest) { }
+
uint32 maxLevel;
- struct
- {
- uint32 questId;
- uint32 variableMoney;
- uint32 variableXP;
- } reward[2];
-
- LfgReward(uint32 _maxLevel = 0, uint32 firstQuest = 0, uint32 firstVarMoney = 0, uint32 firstVarXp = 0, uint32 otherQuest = 0, uint32 otherVarMoney = 0, uint32 otherVarXp = 0)
- : maxLevel(_maxLevel)
- {
- reward[0].questId = firstQuest;
- reward[0].variableMoney = firstVarMoney;
- reward[0].variableXP = firstVarXp;
- reward[1].questId = otherQuest;
- reward[1].variableMoney = otherVarMoney;
- reward[1].variableXP = otherVarXp;
- }
+ uint32 firstQuest;
+ uint32 otherQuest;
};
/// Stores player data related to proposal to join
@@ -223,10 +222,11 @@ struct LfgProposalPlayer
/// Stores group data related to proposal to join
struct LfgProposal
{
- LfgProposal(uint32 dungeon = 0): dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING),
+ LfgProposal(uint32 dungeon = 0): id(0), dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING),
group(0), leader(0), cancelTime(0), encounters(0), isNew(true)
{ }
+ uint32 id; ///< Proposal Id
uint32 dungeonId; ///< Dungeon to join
LfgProposalState state; ///< State of the proposal
uint64 group; ///< Proposal group (0 if new)
@@ -235,7 +235,8 @@ struct LfgProposal
uint32 encounters; ///< Dungeon Encounters
bool isNew; ///< Determines if it's new group or not
LfgGuidList queues; ///< Queue Ids to remove/readd
- LfgProposalPlayerContainer players; ///< Players data
+ LfgGuidList showorder; ///< Show order in update window
+ LfgProposalPlayerContainer players; ///< Players data
};
/// Stores all rolecheck info of a group that wants to join
@@ -299,7 +300,7 @@ class LFGMgr
// Reward
void LoadRewards();
- void RewardDungeonDoneFor(uint32 const dungeonId, Player* player);
+ void FinishDungeon(uint64 gguid, uint32 dungeonId);
LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level);
// Queue
@@ -314,7 +315,7 @@ class LFGMgr
void GetCompatibleDungeons(LfgDungeonSet& dungeons, LfgGuidSet const& players, LfgLockPartyMap& lockMap);
// Proposals
- uint32 AddProposal(LfgProposal const& proposal);
+ uint32 AddProposal(LfgProposal& proposal);
void UpdateProposal(uint32 proposalId, uint64 guid, bool accept);
// Teleportation
@@ -403,7 +404,7 @@ class LFGMgr
void SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck);
void SendLfgUpdateParty(uint64 guid, LfgUpdateData const& data);
void SendLfgUpdatePlayer(uint64 guid, LfgUpdateData const& data);
- void SendLfgUpdateProposal(uint64 guid, uint32 proposalId, LfgProposal const& proposal);
+ void SendLfgUpdateProposal(uint64 guid, LfgProposal const& proposal);
// General variables
uint32 m_QueueTimer; ///< used to check interval of update
diff --git a/src/server/game/DungeonFinding/LFGPlayerData.cpp b/src/server/game/DungeonFinding/LFGPlayerData.cpp
index 0a7f812d03a..410076f7e75 100644
--- a/src/server/game/DungeonFinding/LFGPlayerData.cpp
+++ b/src/server/game/DungeonFinding/LFGPlayerData.cpp
@@ -113,12 +113,12 @@ uint8 LfgPlayerData::GetRoles() const
return m_Roles;
}
-const std::string& LfgPlayerData::GetComment() const
+std::string const& LfgPlayerData::GetComment() const
{
return m_Comment;
}
-const LfgDungeonSet& LfgPlayerData::GetSelectedDungeons() const
+LfgDungeonSet const& LfgPlayerData::GetSelectedDungeons() const
{
return m_SelectedDungeons;
}
diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp
index dae789b2eb4..e75a1bdc4b3 100644
--- a/src/server/game/DungeonFinding/LFGQueue.cpp
+++ b/src/server/game/DungeonFinding/LFGQueue.cpp
@@ -139,7 +139,7 @@ void LFGQueue::RemoveFromCurrentQueue(uint64 guid)
currentQueueStore.remove(guid);
}
-void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, const LfgDungeonSet &dungeons, const LfgRolesMap &rolesMap)
+void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap)
{
QueueDataStore[guid] = LfgQueueData(joinTime, dungeons, rolesMap);
AddToQueue(guid);
@@ -217,7 +217,6 @@ void LFGQueue::SetCompatibilityData(std::string const& key, LfgCompatibilityData
CompatibleMapStore[key] = data;
}
-
/**
Get the compatibility of a group of guids
@@ -482,8 +481,9 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
return LFG_COMPATIBLES_WITH_LESS_PLAYERS;
}
+ uint64 gguid = *check.begin();
proposal.queues = check;
- proposal.isNew = numLfgGroups != 1;
+ proposal.isNew = numLfgGroups != 1 || !sLFGMgr->GetDungeon(gguid);
if (!sLFGMgr->AllQueued(check))
{
diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h
index a8b41c39ab0..acb78d2c0f2 100644
--- a/src/server/game/DungeonFinding/LFGQueue.h
+++ b/src/server/game/DungeonFinding/LFGQueue.h
@@ -52,7 +52,7 @@ struct LfgQueueData
healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED)
{ }
- LfgQueueData(time_t _joinTime, const LfgDungeonSet &_dungeons, LfgRolesMap const& _roles):
+ LfgQueueData(time_t _joinTime, LfgDungeonSet const& _dungeons, LfgRolesMap const& _roles):
joinTime(_joinTime), tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED),
dps(LFG_DPS_NEEDED), dungeons(_dungeons), roles(_roles)
{ }
@@ -87,7 +87,7 @@ class LFGQueue
// Add/Remove from queue
void AddToQueue(uint64 guid);
void RemoveFromQueue(uint64 guid);
- void AddQueueData(uint64 guid, time_t joinTime, const LfgDungeonSet &dungeons, const LfgRolesMap &rolesMap);
+ void AddQueueData(uint64 guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap);
void RemoveQueueData(uint64 guid);
// Update Timers (when proposal success)
diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp
index 39750536863..568b61eef2f 100644
--- a/src/server/game/DungeonFinding/LFGScripts.cpp
+++ b/src/server/game/DungeonFinding/LFGScripts.cpp
@@ -107,20 +107,10 @@ void LFGGroupScript::OnAddMember(Group* group, uint64 guid)
LfgState gstate = sLFGMgr->GetState(gguid);
LfgState state = sLFGMgr->GetState(guid);
sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "] leader " UI64FMTD "] gstate: %u, state: %u", gguid, guid, leader, gstate, state);
- LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS);
- for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
- {
- if (Player* plrg = itr->getSource())
- {
- plrg->GetSession()->SendLfgUpdatePlayer(updateData);
- plrg->GetSession()->SendLfgUpdateParty(updateData);
- }
- }
if (state == LFG_STATE_QUEUED)
sLFGMgr->LeaveLfg(guid);
- // TODO - if group is queued and new player is added convert to rolecheck without notify the current players queued
if (gstate == LFG_STATE_QUEUED)
sLFGMgr->LeaveLfg(gguid);
}
diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp
index aadbf245243..a7df171b1c5 100644
--- a/src/server/game/Handlers/BattleGroundHandler.cpp
+++ b/src/server/game/Handlers/BattleGroundHandler.cpp
@@ -499,7 +499,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
}
}
-void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket& recvData)
+void WorldSession::HandleBattlefieldLeaveOpcode(WorldPacket& recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message");
diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp
index a6f89f353a0..0654ae326f9 100644
--- a/src/server/game/Handlers/LFGHandler.cpp
+++ b/src/server/game/Handlers/LFGHandler.cpp
@@ -23,7 +23,7 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-void BuildPlayerLockDungeonBlock(WorldPacket& data, const LfgLockMap& lock)
+void BuildPlayerLockDungeonBlock(WorldPacket& data, LfgLockMap const& lock)
{
data << uint32(lock.size()); // Size of lock dungeons
for (LfgLockMap::const_iterator it = lock.begin(); it != lock.end(); ++it)
@@ -54,7 +54,6 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData)
}
uint8 numDungeons;
- uint32 dungeon;
uint32 roles;
recvData >> roles;
@@ -70,6 +69,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData)
LfgDungeonSet newDungeons;
for (int8 i = 0; i < numDungeons; ++i)
{
+ uint32 dungeon;
recvData >> dungeon;
newDungeons.insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry
}
@@ -80,20 +80,21 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData)
recvData >> comment;
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN %s roles: %u, Dungeons: %u, Comment: %s",
GetPlayerInfo().c_str(), roles, uint8(newDungeons.size()), comment.c_str());
+
sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment);
}
void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/)
{
- Group* grp = GetPlayer()->GetGroup();
+ Group* group = GetPlayer()->GetGroup();
uint64 guid = GetPlayer()->GetGUID();
- uint64 gguid = grp ? grp->GetGUID() : guid;
+ uint64 gguid = group ? group->GetGUID() : guid;
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LEAVE %s in group: %u",
- GetPlayerInfo().c_str(), grp ? 1 : 0);
+ GetPlayerInfo().c_str(), group ? 1 : 0);
// Check cheating - only leader can leave the queue
- if (!grp || grp->GetLeaderGUID() == GetPlayer()->GetGUID())
+ if (!group || group->GetLeaderGUID() == GetPlayer()->GetGUID())
sLFGMgr->LeaveLfg(gguid);
}
@@ -114,14 +115,14 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recvData)
uint8 roles;
recvData >> roles; // Player Group Roles
uint64 guid = GetPlayer()->GetGUID();
- Group* grp = GetPlayer()->GetGroup();
- if (!grp)
+ Group* group = GetPlayer()->GetGroup();
+ if (!group)
{
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES %s Not in group",
GetPlayerInfo().c_str());
return;
}
- uint64 gguid = grp->GetGUID();
+ uint64 gguid = group->GetGUID();
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES: Group %u, Player %s, Roles: %u",
GUID_LOPART(gguid), GetPlayerInfo().c_str(), roles);
sLFGMgr->UpdateRoleCheck(gguid, guid, roles);
@@ -131,11 +132,11 @@ void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recvData)
{
std::string comment;
recvData >> comment;
- uint64 guid = GetPlayer()->GetGUID();
+
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_COMMENT %s comment: %s",
GetPlayerInfo().c_str(), comment.c_str());
- sLFGMgr->SetComment(guid, comment);
+ sLFGMgr->SetComment(GetPlayer()->GetGUID(), comment);
}
void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recvData)
@@ -193,15 +194,15 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData*
data << uint32(*it); // Dungeon Entry (id + type)
LfgReward const* reward = sLFGMgr->GetRandomDungeonReward(*it, level);
Quest const* quest = NULL;
- uint8 done = 0;
+ bool done = false;
if (reward)
{
- quest = sObjectMgr->GetQuestTemplate(reward->reward[0].questId);
+ quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
if (quest)
{
done = !GetPlayer()->CanRewardQuest(quest, false);
if (done)
- quest = sObjectMgr->GetQuestTemplate(reward->reward[1].questId);
+ quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
}
}
@@ -210,8 +211,8 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData*
data << uint8(done);
data << uint32(quest->GetRewOrReqMoney());
data << uint32(quest->XPValue(GetPlayer()));
- data << uint32(reward->reward[done].variableMoney);
- data << uint32(reward->reward[done].variableXP);
+ data << uint32(0);
+ data << uint32(0);
data << uint8(quest->GetRewItemsCount());
if (quest->GetRewItemsCount())
{
@@ -244,13 +245,13 @@ void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData*
uint64 guid = GetPlayer()->GetGUID();
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST %s", GetPlayerInfo().c_str());
- Group* grp = GetPlayer()->GetGroup();
- if (!grp)
+ Group* group = GetPlayer()->GetGroup();
+ if (!group)
return;
// Get the locked dungeons of the other party members
LfgLockPartyMap lockMap;
- for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
+ for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* plrg = itr->getSource();
if (!plrg)
@@ -312,7 +313,7 @@ void WorldSession::HandleLfgGetStatus(WorldPacket& /*recvData*/)
}
}
-void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData)
+void WorldSession::SendLfgUpdatePlayer(LfgUpdateData const& updateData)
{
bool queued = false;
uint8 size = uint8(updateData.dungeons.size());
@@ -457,7 +458,7 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck)
SendPacket(&data);
}
-void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData)
+void WorldSession::SendLfgJoinResult(LfgJoinResultData const& joinData)
{
uint32 size = 0;
for (LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it)
@@ -465,6 +466,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData)
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_JOIN_RESULT %s checkResult: %u checkValue: %u",
GetPlayerInfo().c_str(), joinData.result, joinData.state);
+
WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size);
data << uint32(joinData.result); // Check Result
data << uint32(joinData.state); // Check Value
@@ -473,10 +475,14 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData)
SendPacket(&data);
}
-void WorldSession::SendLfgQueueStatus(const LfgQueueStatusData& queueData)
+void WorldSession::SendLfgQueueStatus(LfgQueueStatusData const& queueData)
{
- sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS %s dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u",
- GetPlayerInfo().c_str(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps);
+ sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS %s dungeon: %u, waitTime: %d, "
+ "avgWaitTime: %d, waitTimeTanks: %d, waitTimeHealer: %d, waitTimeDps: %d, "
+ "queuedTime: %u, tanks: %u, healers: %u, dps: %u",
+ GetPlayerInfo().c_str(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg,
+ queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps,
+ queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps);
WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 +4 + 1 + 1 + 1 + 4);
data << uint32(queueData.dungeonId); // Dungeon
@@ -492,40 +498,41 @@ void WorldSession::SendLfgQueueStatus(const LfgQueueStatusData& queueData)
SendPacket(&data);
}
-void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward* reward, const Quest* quest)
+void WorldSession::SendLfgPlayerReward(LfgPlayerRewardData const& rewardData)
{
- if (!rdungeonEntry || !sdungeonEntry || !quest)
+ if (!rewardData.rdungeonEntry || !rewardData.sdungeonEntry || !rewardData.quest)
return;
- uint8 itemNum = uint8(quest ? quest->GetRewItemsCount() : 0);
+ sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD %s rdungeonEntry: %u, sdungeonEntry: %u, done: %u",
+ GetPlayerInfo().c_str(), rewardData.rdungeonEntry, rewardData.sdungeonEntry, rewardData.done);
+
+ uint8 itemNum = rewardData.quest->GetRewItemsCount();
- sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD %s rdungeonEntry: %u - sdungeonEntry: %u - done: %u",
- GetPlayerInfo().c_str(), rdungeonEntry, sdungeonEntry, done);
WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4));
- data << uint32(rdungeonEntry); // Random Dungeon Finished
- data << uint32(sdungeonEntry); // Dungeon Finished
- data << uint8(done);
+ data << uint32(rewardData.rdungeonEntry); // Random Dungeon Finished
+ data << uint32(rewardData.sdungeonEntry); // Dungeon Finished
+ data << uint8(rewardData.done);
data << uint32(1);
- data << uint32(quest->GetRewOrReqMoney());
- data << uint32(quest->XPValue(GetPlayer()));
- data << uint32(reward->reward[done].variableMoney);
- data << uint32(reward->reward[done].variableXP);
+ data << uint32(rewardData.quest->GetRewOrReqMoney());
+ data << uint32(rewardData.quest->XPValue(GetPlayer()));
+ data << uint32(0);
+ data << uint32(0);
data << uint8(itemNum);
if (itemNum)
{
for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
- if (uint32 itemId = quest->RewardItemId[i])
+ if (uint32 itemId = rewardData.quest->RewardItemId[i])
{
ItemTemplate const* item = sObjectMgr->GetItemTemplate(itemId);
data << uint32(itemId);
data << uint32(item ? item->DisplayInfoID : 0);
- data << uint32(quest->RewardItemIdCount[i]);
+ data << uint32(rewardData.quest->RewardItemIdCount[i]);
}
}
SendPacket(&data);
}
-void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot)
+void WorldSession::SendLfgBootProposalUpdate(LfgPlayerBoot const& boot)
{
uint64 guid = GetPlayer()->GetGUID();
LfgAnswer playerVote = boot.votes.find(guid)->second;
@@ -560,7 +567,7 @@ void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot)
SendPacket(&data);
}
-void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& proposal)
+void WorldSession::SendLfgUpdateProposal(LfgProposal const& proposal)
{
uint64 guid = GetPlayer()->GetGUID();
uint64 gguid = proposal.players.find(guid)->second.group;
@@ -569,7 +576,6 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PROPOSAL_UPDATE %s state: %u",
GetPlayerInfo().c_str(), proposal.state);
- WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1));
// show random dungeon if player selected random dungeon and it's not lfg group
if (!silent)
@@ -582,9 +588,10 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p
if (LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(dungeonEntry))
dungeonEntry = dungeon->Entry();
+ WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1));
data << uint32(dungeonEntry); // Dungeon
data << uint8(proposal.state); // Proposal state
- data << uint32(proposalId); // Proposal ID
+ data << uint32(proposal.id); // Proposal ID
data << uint32(proposal.encounters); // encounters done
data << uint8(silent); // Show proposal window
data << uint8(proposal.players.size()); // Group size
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp
index 3deec5a880a..bfd9bd62647 100644
--- a/src/server/game/Instances/InstanceScript.cpp
+++ b/src/server/game/Instances/InstanceScript.cpp
@@ -20,6 +20,7 @@
#include "CreatureAI.h"
#include "DatabaseEnv.h"
#include "GameObject.h"
+#include "Group.h"
#include "InstanceScript.h"
#include "LFGMgr.h"
#include "Log.h"
@@ -422,28 +423,41 @@ void InstanceScript::SendEncounterUnit(uint32 type, Unit* unit /*= NULL*/, uint8
instance->SendToPlayers(&data);
}
-void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* source)
+void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* /*source*/)
{
DungeonEncounterList const* encounters = sObjectMgr->GetDungeonEncounterList(instance->GetId(), instance->GetDifficulty());
if (!encounters)
return;
+ uint32 dungeonId = 0;
+
for (DungeonEncounterList::const_iterator itr = encounters->begin(); itr != encounters->end(); ++itr)
{
- if ((*itr)->creditType == type && (*itr)->creditEntry == creditEntry)
+ DungeonEncounter const* encounter = *itr;
+ if (encounter->creditType == type && encounter->creditEntry == creditEntry)
{
- completedEncounters |= 1 << (*itr)->dbcEntry->encounterIndex;
- sLog->outDebug(LOG_FILTER_TSCR, "Instance %s (instanceId %u) completed encounter %s", instance->GetMapName(), instance->GetInstanceId(), (*itr)->dbcEntry->encounterName[0]);
- if (uint32 dungeonId = (*itr)->lastEncounterDungeon)
+ completedEncounters |= 1 << encounter->dbcEntry->encounterIndex;
+ if (encounter->lastEncounterDungeon)
{
- Map::PlayerList const& players = instance->GetPlayers();
- if (!players.isEmpty())
- for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
- if (Player* player = i->getSource())
- if (!source || player->IsAtGroupRewardDistance(source))
- sLFGMgr->RewardDungeonDoneFor(dungeonId, player);
+ dungeonId = encounter->lastEncounterDungeon;
+ sLog->outDebug(LOG_FILTER_LFG, "UpdateEncounterState: Instance %s (instanceId %u) completed encounter %s. Credit Dungeon: %u", instance->GetMapName(), instance->GetInstanceId(), encounter->dbcEntry->encounterName[0], dungeonId);
+ break;
}
- return;
+ }
+ }
+
+ if (dungeonId)
+ {
+ Map::PlayerList const& players = instance->GetPlayers();
+ for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
+ {
+ if (Player* player = i->getSource())
+ if (Group* grp = player->GetGroup())
+ if (grp->isLFGGroup())
+ {
+ sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId);
+ return;
+ }
}
}
}
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index 468fe769857..7237d5f74f7 100644
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -763,7 +763,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x2DE*/ { "SMSG_FORCE_TURN_RATE_CHANGE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x2DF*/ { "CMSG_FORCE_TURN_RATE_CHANGE_ACK", STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleForceSpeedChangeAck },
/*0x2E0*/ { "MSG_PVP_LOG_DATA", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandlePVPLogDataOpcode },
- /*0x2E1*/ { "CMSG_LEAVE_BATTLEFIELD", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleLeaveBattlefieldOpcode },
+ /*0x2E1*/ { "CMSG_LEAVE_BATTLEFIELD", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlefieldLeaveOpcode },
/*0x2E2*/ { "CMSG_AREA_SPIRIT_HEALER_QUERY", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAreaSpiritHealerQueryOpcode},
/*0x2E3*/ { "CMSG_AREA_SPIRIT_HEALER_QUEUE", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAreaSpiritHealerQueueOpcode},
/*0x2E4*/ { "SMSG_AREA_SPIRIT_HEALER_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 5561834303d..39f5425d9df 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -53,7 +53,7 @@ struct LfgLockStatus;
struct LfgPlayerBoot;
struct LfgProposal;
struct LfgQueueStatusData;
-struct LfgReward;
+struct LfgPlayerRewardData;
struct LfgRoleCheck;
struct LfgUpdateData;
struct MovementInfo;
@@ -270,7 +270,7 @@ class WorldSession
void SendAttackStop(Unit const* enemy);
- void SendBattleGroundList(uint64 guid, BattlegroundTypeId bgTypeId);
+ void SendBattleGroundList(uint64 guid, BattlegroundTypeId bgTypeId = BATTLEGROUND_RB);
void SendTradeStatus(TradeStatus status);
void SendUpdateTrade(bool trader_data = true);
@@ -327,7 +327,7 @@ class WorldSession
void SendDiscoverNewTaxiNode(uint32 nodeid);
// Guild/Arena Team
- void SendArenaTeamCommandResult(uint32 team_action, std::string const& team, std::string const& player, uint32 error_id);
+ void SendArenaTeamCommandResult(uint32 team_action, std::string const& team, std::string const& player, uint32 error_id = 0);
void SendNotInArenaTeamPacket(uint8 type);
void SendPetitionShowList(uint64 guid);
@@ -741,7 +741,7 @@ class WorldSession
void HandlePVPLogDataOpcode(WorldPacket& recvData);
void HandleBattleFieldPortOpcode(WorldPacket& recvData);
void HandleBattlefieldListOpcode(WorldPacket& recvData);
- void HandleLeaveBattlefieldOpcode(WorldPacket& recvData);
+ void HandleBattlefieldLeaveOpcode(WorldPacket& recvData);
void HandleBattlemasterJoinArena(WorldPacket& recvData);
void HandleReportPvPAFK(WorldPacket& recvData);
@@ -762,14 +762,14 @@ class WorldSession
void HandleInstanceLockResponse(WorldPacket& recvPacket);
// Battlefield
- void SendBfInvitePlayerToWar(uint32 BattleId,uint32 ZoneId,uint32 time);
- void SendBfInvitePlayerToQueue(uint32 BattleId);
- void SendBfQueueInviteResponse(uint32 BattleId,uint32 ZoneId, bool CanQueue = true, bool Full = false);
- void SendBfEntered(uint32 BattleId);
- void SendBfLeaveMessage(uint32 BattleId, BFLeaveReason reason = BF_LEAVE_REASON_EXITED);
- void HandleBfQueueInviteResponse(WorldPacket &recvData);
- void HandleBfEntryInviteResponse(WorldPacket &recvData);
- void HandleBfExitRequest(WorldPacket &recvData);
+ void SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 time);
+ void SendBfInvitePlayerToQueue(uint32 battleId);
+ void SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue = true, bool full = false);
+ void SendBfEntered(uint32 battleId);
+ void SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason = BF_LEAVE_REASON_EXITED);
+ void HandleBfQueueInviteResponse(WorldPacket& recvData);
+ void HandleBfEntryInviteResponse(WorldPacket& recvData);
+ void HandleBfExitRequest(WorldPacket& recvData);
// Looking for Dungeon/Raid
void HandleLfgSetCommentOpcode(WorldPacket& recvData);
@@ -785,16 +785,16 @@ class WorldSession
void HandleLfrLeaveOpcode(WorldPacket& recvData);
void HandleLfgGetStatus(WorldPacket& recvData);
- void SendLfgUpdatePlayer(const LfgUpdateData& updateData);
- void SendLfgUpdateParty(const LfgUpdateData& updateData);
+ void SendLfgUpdatePlayer(LfgUpdateData const& updateData);
+ void SendLfgUpdateParty(LfgUpdateData const& updateData);
void SendLfgRoleChosen(uint64 guid, uint8 roles);
- void SendLfgRoleCheckUpdate(const LfgRoleCheck& pRoleCheck);
+ void SendLfgRoleCheckUpdate(LfgRoleCheck const& pRoleCheck);
void SendLfgLfrList(bool update);
- void SendLfgJoinResult(const LfgJoinResultData& joinData);
- void SendLfgQueueStatus(const LfgQueueStatusData& queueData);
- void SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward* reward, const Quest *qRew);
- void SendLfgBootProposalUpdate(const LfgPlayerBoot& boot);
- void SendLfgUpdateProposal(uint32 proposalId, const LfgProposal& proposal);
+ void SendLfgJoinResult(LfgJoinResultData const& joinData);
+ void SendLfgQueueStatus(LfgQueueStatusData const& queueData);
+ void SendLfgPlayerReward(LfgPlayerRewardData const& lfgPlayerRewardData);
+ void SendLfgBootProposalUpdate(LfgPlayerBoot const& boot);
+ void SendLfgUpdateProposal(LfgProposal const& proposal);
void SendLfgDisabled();
void SendLfgOfferContinue(uint32 dungeonEntry);
void SendLfgTeleportError(uint8 err);
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
index 6733200e44d..4927666073b 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
@@ -29,6 +29,7 @@ EndScriptData */
#include "scarlet_monastery.h"
#include "LFGMgr.h"
#include "Player.h"
+#include "Group.h"
#include "SpellInfo.h"
//this texts are already used by 3975 and 3976
@@ -576,10 +577,7 @@ public:
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
- for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
- if (Player* player = i->getSource())
- if (player->IsAtGroupRewardDistance(me))
- sLFGMgr->RewardDungeonDoneFor(285, player);
+ sLFGMgr->FinishDungeon(players.begin()->getSource()->GetGroup()->GetGUID(), 285);
}
void SpellHit(Unit* caster, const SpellInfo* spell)