Dungeon Finder: Simplify 'Offer to continue' checks and allow to join non-random dungeon after a random one is assigned

--HG--
branch : trunk
This commit is contained in:
Spp
2010-08-17 11:26:31 +02:00
parent 46d06a859b
commit 6009ac3f45
2 changed files with 30 additions and 71 deletions
+12 -29
View File
@@ -467,9 +467,13 @@ void LFGMgr::Join(Player *plr)
for (GroupReference *itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
{
plrg = itr->getSource(); // Not null, checked earlier
dungeons = plrg->GetLfgDungeons();
for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon)
dungeons->insert(*itDungeon);
if (plrg != plr)
{
dungeons = plrg->GetLfgDungeons();
dungeons->clear();
for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon)
dungeons->insert(*itDungeon);
}
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL);
}
UpdateRoleCheck(grp, plr);
@@ -839,32 +843,11 @@ void LFGMgr::UpdateRoleCheck(Group *grp, Player *plr /* = NULL*/)
if (Player *plrg = itr->getSource())
pRoleCheck->roles[plrg->GetGUIDLow()] = 0;
// Check if it's offer continue (random + current one)
if (grp->isLFGGroup() && dungeons->size() == 2)
{
LfgDungeonSet::const_iterator itDungeon = dungeons->begin();
uint32 aDungeon = *itDungeon;
uint32 rDungeon = *(++itDungeon);
// it's a Offer to continue (Actual dungeon + random dungeon in the list)
// Rolecheck will be using the actual dungeon - Players random
if (aDungeon == grp->GetLfgDungeonEntry() && isRandomDungeon(rDungeon))
{
for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player *plrg = itr->getSource())
{
plrg->GetLfgDungeons()->clear();
plrg->GetLfgDungeons()->insert(rDungeon);
}
}
pRoleCheck->dungeons.insert(aDungeon);
}
}
if (pRoleCheck->dungeons.empty())
for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon)
// Check if it's offer continue or trying to find a new instance after a random assigned (Join Random + LfgGroup)
if (grp->isLFGGroup() && dungeons->size() == 1 && isRandomDungeon(*dungeons->begin()))
pRoleCheck->dungeons.insert(grp->GetLfgDungeonEntry());
else
for (LfgDungeonSet::const_iterator itDungeon = dungeons->begin(); itDungeon != dungeons->end(); ++itDungeon)
pRoleCheck->dungeons.insert(*itDungeon);
}
else
@@ -35,6 +35,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
uint32 dungeon;
uint32 roles;
std::string comment;
LfgDungeonSet newDungeons;
recv_data >> roles;
recv_data.read_skip<uint8>(); // unk - always 0
@@ -47,48 +48,10 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
return;
}
GetPlayer()->SetLfgRoles(uint8(roles));
// Check if it's offer continue
Group *grp = GetPlayer()->GetGroup();
if (grp && grp->isLFGGroup())
for (int8 i = 0 ; i < numDungeons; ++i)
{
LfgDungeonSet *dungeons = GetPlayer()->GetLfgDungeons();
if (grp->GetLfgStatus() == LFG_STATUS_COMPLETE) // Dungeon complete add all dungeons
{
dungeons->clear();
for (int8 i = 0 ; i < numDungeons; ++i)
{
recv_data >> dungeon;
dungeons->insert((dungeon & 0x00FFFFFF));
}
}
else if (dungeons->size() > 1 || dungeons->size() ==1 && !sLFGMgr.isRandomDungeon(*dungeons->begin()))
{
dungeons->clear();
// ignore the list and select the current dungeon
for (int8 i = 0 ; i < numDungeons; ++i)
recv_data.read_skip<uint32>();
dungeons->insert(grp->GetLfgDungeonEntry());
}
else // currently added to random Dungeon
{
for (int8 i = 0 ; i < numDungeons; ++i)
{
recv_data >> dungeon;
// remove the type from the dungeon entry
GetPlayer()->GetLfgDungeons()->insert((dungeon & 0x00FFFFFF));
}
}
}
else
{
for (int8 i = 0 ; i < numDungeons; ++i)
{
recv_data >> dungeon;
// remove the type from the dungeon entry
GetPlayer()->GetLfgDungeons()->insert((dungeon & 0x00FFFFFF));
}
recv_data >> dungeon;
newDungeons.insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry
}
recv_data >> numDungeons; // unk - always 3
@@ -97,6 +60,19 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
recv_data >> comment;
LfgDungeonSet *dungeons = GetPlayer()->GetLfgDungeons();
Group *grp = GetPlayer()->GetGroup();
bool isRandomDungeon = dungeons->size() == 1 && sLFGMgr.isRandomDungeon(*dungeons->begin());
bool isCurrentDungeon = newDungeons.size() == 1 && grp && grp->isLFGGroup() && grp->GetLfgDungeonEntry() == *newDungeons.begin();
if (!isRandomDungeon || !isCurrentDungeon) // is not offer to continue - clear old dungeons and use new dungeons
{
dungeons->clear();
for (LfgDungeonSet::const_iterator it = newDungeons.begin(); it != newDungeons.end(); ++it)
dungeons->insert(*it);
}
newDungeons.clear();
GetPlayer()->SetLfgRoles(uint8(roles));
GetPlayer()->SetLfgComment(comment);
sLFGMgr.Join(GetPlayer());
}