Core/Dungeon Finder: Partial revert of ad6b5fb419

This commit is contained in:
Spp
2012-11-28 08:29:39 +01:00
parent cddc0a09ba
commit a7d8a65bd0
3 changed files with 17 additions and 39 deletions

View File

@@ -809,18 +809,12 @@ void LFGMgr::LeaveLfg(uint64 guid)
RemoveProposal(it, LFG_UPDATETYPE_PROPOSAL_DECLINED);
break;
}
case LFG_STATE_BOOT:
if (guid != gguid) // Player
{
UpdateBoot(guid); // Forcing LFG_ANSWER_PENDING (Removal of player)
SetState(guid, LFG_STATE_NONE);
}
break;
case LFG_STATE_NONE:
case LFG_STATE_RAIDBROWSER:
break;
case LFG_STATE_DUNGEON:
case LFG_STATE_FINISHED_DUNGEON:
case LFG_STATE_BOOT:
if (guid != gguid) // Player
SetState(guid, LFG_STATE_NONE);
break;
@@ -1342,7 +1336,7 @@ void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string co
@param[in] guid Player who has answered
@param[in] player answer
*/
void LFGMgr::UpdateBoot(uint64 guid, LfgAnswer answer)
void LFGMgr::UpdateBoot(uint64 guid, bool accept)
{
uint64 gguid = GetGroup(guid);
if (!gguid)
@@ -1354,42 +1348,26 @@ void LFGMgr::UpdateBoot(uint64 guid, LfgAnswer answer)
LfgPlayerBoot& boot = itBoot->second;
if (boot.votes[guid] != LFG_ANSWER_PENDING) // Cheat check: Player can't vote twice
return;
boot.votes[guid] = LfgAnswer(accept);
uint8 votesNum = 0;
uint8 agreeNum = 0;
if (guid == boot.victim)
agreeNum = LFG_GROUP_KICK_VOTES_NEEDED + 1; // +1 on purpose to skip kick code
else if (answer == LFG_ANSWER_PENDING)
for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
{
boot.votes.erase(guid);
// If we don't have enough members - force boot fail
if (boot.votes.size() <= LFG_GROUP_KICK_VOTES_NEEDED)
if (itVotes->second != LFG_ANSWER_PENDING)
{
agreeNum = 0;
votesNum = boot.votes.size();
++votesNum;
if (itVotes->second == LFG_ANSWER_AGREE)
++agreeNum;
}
}
else
{
if (boot.votes[guid] != LFG_ANSWER_PENDING) // Cheat check: Player can't vote twice
return;
boot.votes[guid] = answer;
for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
{
if (itVotes->second != LFG_ANSWER_PENDING)
{
++votesNum;
if (itVotes->second == LFG_ANSWER_AGREE)
++agreeNum;
}
}
// if we don't have enough votes (agree or deny) do nothing
if (agreeNum < LFG_GROUP_KICK_VOTES_NEEDED && (votesNum - agreeNum) < LFG_GROUP_KICK_VOTES_NEEDED)
return;
}
// if we don't have enough votes (agree or deny) do nothing
if (agreeNum < LFG_GROUP_KICK_VOTES_NEEDED && (votesNum - agreeNum) < LFG_GROUP_KICK_VOTES_NEEDED)
return;
// Send update info to all players
boot.inProgress = false;

View File

@@ -322,7 +322,7 @@ class LFGMgr
// Vote kick
void InitBoot(uint64 gguid, uint64 kguid, uint64 vguid, std::string const& reason);
void UpdateBoot(uint64 guid, LfgAnswer accept = LFG_ANSWER_PENDING);
void UpdateBoot(uint64 guid, bool accept);
void InitializeLockedDungeons(Player* player, uint8 level = 0);

View File

@@ -146,7 +146,7 @@ void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recvData)
uint64 guid = GetPlayer()->GetGUID();
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_BOOT_VOTE %s agree: %u",
GetPlayerInfo().c_str(), agree ? 1 : 0);
sLFGMgr->UpdateBoot(guid, agree ? LFG_ANSWER_AGREE : LFG_ANSWER_DENY);
sLFGMgr->UpdateBoot(guid, agree);
}
void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recvData)