diff options
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
| -rwxr-xr-x | src/server/game/Globals/ObjectMgr.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 013c8afe6e8..940f3c5ad1a 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -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); |
