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
This commit is contained in:
Spp
2013-01-09 15:15:42 +01:00
parent ecfb762346
commit 677ed18080
13 changed files with 267 additions and 252 deletions

View File

@@ -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;
}
}
}
}