Core/Instances: Implemented DungeonEncounter.dbc for creating completed encounters mask to use in packets

Core/Dungeon Finder: Implemented new way of giving random dungeon rewards, linked to DungeonEncounter.dbc
This commit is contained in:
Shauren
2011-02-03 22:20:40 +01:00
parent 7ea8bad07f
commit c2b0bcbd6c
33 changed files with 941 additions and 152 deletions
+78
View File
@@ -5553,6 +5553,84 @@ void ObjectMgr::LoadInstanceTemplate()
sLog->outString();
}
void ObjectMgr::LoadInstanceEncounters()
{
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT entry, creditType, creditEntry, lastEncounterDungeon FROM instance_encounters");
if (!result)
{
sLog->outErrorDb(">> Loaded 0 instance encounters, table is empty!");
sLog->outString();
return;
}
uint32 count = 0;
std::map<uint32, DungeonEncounterEntry const*> dungeonLastBosses;
do
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
if (!dungeonEncounter)
{
sLog->outErrorDb("Table `instance_encounters` has an invalid encounter id %u, skipped!", entry);
continue;
}
uint8 creditType = fields[1].GetUInt8();
uint32 creditEntry = fields[2].GetUInt32();
switch (creditType)
{
case ENCOUNTER_CREDIT_KILL_CREATURE:
if (!GetCreatureInfo(creditEntry))
{
sLog->outErrorDb("Table `instance_encounters` has an invalid creature (entry %u) linked to the encounter %u (%s), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
continue;
}
break;
case ENCOUNTER_CREDIT_CAST_SPELL:
if (!sSpellStore.LookupEntry(creditEntry))
{
sLog->outErrorDb("Table `instance_encounters` has an invalid spell (entry %u) linked to the encounter %u (%s), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
continue;
}
break;
default:
sLog->outErrorDb("Table `instance_encounters` has an invalid credit type (%u) for encounter %u (%s), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
continue;
}
uint32 lastEncounterDungeon = fields[3].GetUInt32();
if (lastEncounterDungeon && !sLFGDungeonStore.LookupEntry(lastEncounterDungeon))
{
sLog->outErrorDb("Table `instance_encounters` has an encounter %u (%s) marked as final for invalid dungeon id %u, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
continue;
}
std::map<uint32, DungeonEncounterEntry const*>::const_iterator itr = dungeonLastBosses.find(lastEncounterDungeon);
if (lastEncounterDungeon)
{
if (itr != dungeonLastBosses.end())
{
sLog->outErrorDb("Table `instance_encounters` specified encounter %u (%s) as last encounter but %u (%s) is already marked as one, skipped!", entry, dungeonEncounter->encounterName[0], itr->second->id, itr->second->encounterName[0]);
continue;
}
dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
}
DungeonEncounterList& encounters = mDungeonEncounters[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
++count;
} while (result->NextRow());
sLog->outString(">> Loaded %u instance encounters in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
GossipText const *ObjectMgr::GetGossipText(uint32 Text_ID) const
{
GossipTextMap::const_iterator itr = mGossipText.find(Text_ID);