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);
+31 -1
View File
@@ -557,7 +557,27 @@ struct LanguageDesc
};
extern LanguageDesc lang_description[LANGUAGES_COUNT];
LanguageDesc const* GetLanguageDescByID(uint32 lang);
LanguageDesc const* GetLanguageDescByID(uint32 lang);
enum EncounterCreditType
{
ENCOUNTER_CREDIT_KILL_CREATURE = 0,
ENCOUNTER_CREDIT_CAST_SPELL = 1,
};
struct DungeonEncounter
{
DungeonEncounter(DungeonEncounterEntry const* _dbcEntry, EncounterCreditType _creditType, uint32 _creditEntry, uint32 _lastEncounterDungeon)
: dbcEntry(_dbcEntry), creditType(_creditType), creditEntry(_creditEntry), lastEncounterDungeon(_lastEncounterDungeon) { }
DungeonEncounterEntry const* dbcEntry;
EncounterCreditType creditType;
uint32 creditEntry;
uint32 lastEncounterDungeon;
};
typedef std::list<DungeonEncounter const*> DungeonEncounterList;
typedef UNORDERED_MAP<uint32,DungeonEncounterList> DungeonEncounterMap;
class PlayerDumpReader;
@@ -796,6 +816,14 @@ class ObjectMgr
return NULL;
}
DungeonEncounterList const* GetDungeonEncounterList(uint32 mapId, Difficulty difficulty)
{
UNORDERED_MAP<uint32, DungeonEncounterList>::const_iterator itr = mDungeonEncounters.find(MAKE_PAIR32(mapId, difficulty));
if (itr != mDungeonEncounters.end())
return &itr->second;
return NULL;
}
void LoadGuilds();
void LoadArenaTeams();
void LoadGroups();
@@ -884,6 +912,7 @@ class ObjectMgr
void LoadGossipMenuItemsLocales();
void LoadPointOfInterestLocales();
void LoadInstanceTemplate();
void LoadInstanceEncounters();
void LoadMailLevelRewards();
void LoadVehicleAccessories();
void LoadVehicleScaling();
@@ -1253,6 +1282,7 @@ class ObjectMgr
AreaTriggerMap mAreaTriggers;
AreaTriggerScriptMap mAreaTriggerScripts;
AccessRequirementMap mAccessRequirements;
DungeonEncounterMap mDungeonEncounters;
RepRewardRateMap m_RepRewardRateMap;
RepOnKillMap mRepOnKill;