mirror of
https://github.com/mangosfour/server.git
synced 2025-12-26 07:37:02 +00:00
Implement quest_relations table. Based on work by @Hozen
This commit is contained in:
parent
25fac44c28
commit
a479a2ccc5
5 changed files with 44 additions and 31 deletions
|
|
@ -5332,7 +5332,7 @@ void ObjectMgr::LoadQuestAreaTriggers()
|
|||
{
|
||||
mQuestAreaTriggerMap.clear(); // need for reload case
|
||||
|
||||
QueryResult* result = WorldDatabase.Query("SELECT id,quest FROM areatrigger_involvedrelation");
|
||||
QueryResult* result = WorldDatabase.PQuery("SELECT entry, quest FROM quest_relations WHERE actor = %d", QA_AREATRIGGER);
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
|
|
@ -5361,20 +5361,20 @@ void ObjectMgr::LoadQuestAreaTriggers()
|
|||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(trigger_ID);
|
||||
if (!atEntry)
|
||||
{
|
||||
sLog.outErrorDb("Table `areatrigger_involvedrelation` has area trigger (ID: %u) not listed in `AreaTrigger.dbc`.", trigger_ID);
|
||||
sLog.outErrorDb("Table `quest_relations` has area trigger (ID: %u) not listed in `AreaTrigger.dbc`.", trigger_ID);
|
||||
continue;
|
||||
}
|
||||
|
||||
Quest const* quest = GetQuestTemplate(quest_ID);
|
||||
if (!quest)
|
||||
{
|
||||
sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not existing quest %u", trigger_ID, quest_ID);
|
||||
sLog.outErrorDb("Table `quest_relations` has record (id: %u) for not existing quest %u", trigger_ID, quest_ID);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!quest->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT))
|
||||
{
|
||||
sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not quest %u, but quest not have flag QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT. Trigger or quest flags must be fixed, quest modified to require objective.", trigger_ID, quest_ID);
|
||||
sLog.outErrorDb("Table `quest_relations` has record (id: %u) for not quest %u, but quest not have flag QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT. Trigger or quest flags must be fixed, quest modified to require objective.", trigger_ID, quest_ID);
|
||||
|
||||
// this will prevent quest completing without objective
|
||||
const_cast<Quest*>(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT);
|
||||
|
|
@ -7506,13 +7506,13 @@ void ObjectMgr::DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_
|
|||
cell_guids.corpses.erase(player_guid);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* table)
|
||||
void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, QuestActor actor, QuestRole role)
|
||||
{
|
||||
map.clear(); // need for reload case
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult* result = WorldDatabase.PQuery("SELECT id,quest FROM %s", table);
|
||||
QueryResult* result = WorldDatabase.PQuery("SELECT entry, quest FROM quest_relations WHERE actor = %d AND role = %d", actor, role);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
|
|
@ -7521,7 +7521,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab
|
|||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outErrorDb(">> Loaded 0 quest relations from %s. DB table `%s` is empty.", table, table);
|
||||
sLog.outErrorDb(">> Loaded 0 quest relations. DB table `quest_relations` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -7537,7 +7537,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab
|
|||
|
||||
if (mQuestTemplates.find(quest) == mQuestTemplates.end())
|
||||
{
|
||||
sLog.outErrorDb("Table `%s: Quest %u listed for entry %u does not exist.", table, quest, id);
|
||||
sLog.outErrorDb("Table `quest_relations`: Quest %u listed for entry %u does not exist.", quest, id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -7550,62 +7550,62 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab
|
|||
delete result;
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %u quest relations from %s", count, table);
|
||||
sLog.outString(">> Loaded %u %s quest %s from `quest_relations`", count, (actor == 1) ? "gameobject" : "creature", (role == 1) ? "takers" : "givers");
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGameobjectQuestRelations()
|
||||
{
|
||||
LoadQuestRelationsHelper(m_GOQuestRelations, "gameobject_questrelation");
|
||||
LoadQuestRelationsHelper(m_GOQuestRelations, QA_GAMEOBJECT, QR_START);
|
||||
|
||||
for (QuestRelationsMap::iterator itr = m_GOQuestRelations.begin(); itr != m_GOQuestRelations.end(); ++itr)
|
||||
{
|
||||
GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first);
|
||||
if (!goInfo)
|
||||
sLog.outErrorDb("Table `gameobject_questrelation` have data for nonexistent gameobject entry (%u) and existing quest %u", itr->first, itr->second);
|
||||
{ sLog.outErrorDb("Table `quest_relations` have data for nonexistent gameobject entry (%u) and existing quest %u", itr->first, itr->second); }
|
||||
else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
|
||||
sLog.outErrorDb("Table `gameobject_questrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
|
||||
{ sLog.outErrorDb("Table `quest_relations` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second); }
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGameobjectInvolvedRelations()
|
||||
{
|
||||
LoadQuestRelationsHelper(m_GOQuestInvolvedRelations, "gameobject_involvedrelation");
|
||||
LoadQuestRelationsHelper(m_GOQuestInvolvedRelations, QA_GAMEOBJECT, QR_END);
|
||||
|
||||
for (QuestRelationsMap::iterator itr = m_GOQuestInvolvedRelations.begin(); itr != m_GOQuestInvolvedRelations.end(); ++itr)
|
||||
{
|
||||
GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first);
|
||||
if (!goInfo)
|
||||
sLog.outErrorDb("Table `gameobject_involvedrelation` have data for nonexistent gameobject entry (%u) and existing quest %u", itr->first, itr->second);
|
||||
{ sLog.outErrorDb("Table `quest_relations` have data for nonexistent gameobject entry (%u) and existing quest %u", itr->first, itr->second); }
|
||||
else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
|
||||
sLog.outErrorDb("Table `gameobject_involvedrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
|
||||
{ sLog.outErrorDb("Table `quest_relations` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second); }
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureQuestRelations()
|
||||
{
|
||||
LoadQuestRelationsHelper(m_CreatureQuestRelations, "creature_questrelation");
|
||||
LoadQuestRelationsHelper(m_CreatureQuestRelations, QA_CREATURE, QR_START);
|
||||
|
||||
for (QuestRelationsMap::iterator itr = m_CreatureQuestRelations.begin(); itr != m_CreatureQuestRelations.end(); ++itr)
|
||||
{
|
||||
CreatureInfo const* cInfo = GetCreatureTemplate(itr->first);
|
||||
if (!cInfo)
|
||||
sLog.outErrorDb("Table `creature_involvedrelation` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second);
|
||||
{ sLog.outErrorDb("Table `quest_relations` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second); }
|
||||
else if (!(cInfo->NpcFlags & UNIT_NPC_FLAG_QUESTGIVER))
|
||||
sLog.outErrorDb("Table `creature_involvedrelation` has creature entry (%u) for quest %u, but NpcFlags does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second);
|
||||
{ sLog.outErrorDb("Table `quest_relations` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second); }
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureInvolvedRelations()
|
||||
{
|
||||
LoadQuestRelationsHelper(m_CreatureQuestInvolvedRelations, "creature_involvedrelation");
|
||||
LoadQuestRelationsHelper(m_CreatureQuestInvolvedRelations, QA_CREATURE, QR_END);
|
||||
|
||||
for (QuestRelationsMap::iterator itr = m_CreatureQuestInvolvedRelations.begin(); itr != m_CreatureQuestInvolvedRelations.end(); ++itr)
|
||||
{
|
||||
CreatureInfo const* cInfo = GetCreatureTemplate(itr->first);
|
||||
if (!cInfo)
|
||||
sLog.outErrorDb("Table `creature_involvedrelation` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second);
|
||||
{ sLog.outErrorDb("Table `quest_relations` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second); }
|
||||
else if (!(cInfo->NpcFlags & UNIT_NPC_FLAG_QUESTGIVER))
|
||||
sLog.outErrorDb("Table `creature_involvedrelation` has creature entry (%u) for quest %u, but NpcFlags does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second);
|
||||
{ sLog.outErrorDb("Table `quest_relations` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1313,7 +1313,7 @@ class ObjectMgr
|
|||
private:
|
||||
void LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment);
|
||||
void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr);
|
||||
void LoadQuestRelationsHelper(QuestRelationsMap& map, char const* table);
|
||||
void LoadQuestRelationsHelper(QuestRelationsMap& map, QuestActor actor, QuestRole role);
|
||||
void LoadVendors(char const* tableName, bool isTemplates);
|
||||
void LoadTrainers(char const* tableName, bool isTemplates);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue