Skip to content

Commit

Permalink
Fix startup errors due to broadcast_text migration
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Nov 14, 2021
1 parent e8fb3a8 commit d5e5b94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
41 changes: 11 additions & 30 deletions src/game/DBScripts/ScriptMgr.cpp
Expand Up @@ -245,14 +245,6 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
sLog.outErrorDb("Table `%s` has invalid talk text id (dataint = %i) in SCRIPT_COMMAND_TALK for script id %u", tablename, tmp.textId[0], tmp.id);
continue;
}

for (int i = 0; i < MAX_TEXT_ID; ++i)
{
if (tmp.textId[i] && (tmp.textId[i] < MIN_DB_SCRIPT_STRING_ID || tmp.textId[i] >= MAX_DB_SCRIPT_STRING_ID))
{
sLog.outErrorDb("Table `%s` has out of range text_id%u (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u", tablename, i + 1, tmp.textId[i], MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, tmp.id);
}
}
}

// if (!GetMangosStringLocale(tmp.dataint)) will be checked after dbscript_string loading
Expand Down Expand Up @@ -971,27 +963,16 @@ void ScriptMgr::LoadDbScriptStrings()
sObjectMgr.LoadMangosStrings(WorldDatabase, "dbscript_string", MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, true);
sObjectMgr.LoadMangosStrings(WorldDatabase, "creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID, true);

std::set<int32> ids;

for (int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i)
if (sObjectMgr.GetMangosStringLocale(i))
ids.insert(i);

CheckRandomStringTemplates(ids);

CheckScriptTexts(sQuestEndScripts, ids);
CheckScriptTexts(sQuestStartScripts, ids);
CheckScriptTexts(sSpellScripts, ids);
CheckScriptTexts(sGameObjectScripts, ids);
CheckScriptTexts(sGameObjectTemplateScripts, ids);
CheckScriptTexts(sEventScripts, ids);
CheckScriptTexts(sGossipScripts, ids);
CheckScriptTexts(sCreatureDeathScripts, ids);
CheckScriptTexts(sCreatureMovementScripts, ids);
CheckScriptTexts(sRelayScripts, ids);

for (int32 id : ids)
sLog.outErrorDb("Table `dbscript_string` has unused string id %u", id);
CheckScriptTexts(sQuestEndScripts);
CheckScriptTexts(sQuestStartScripts);
CheckScriptTexts(sSpellScripts);
CheckScriptTexts(sGameObjectScripts);
CheckScriptTexts(sGameObjectTemplateScripts);
CheckScriptTexts(sEventScripts);
CheckScriptTexts(sGossipScripts);
CheckScriptTexts(sCreatureDeathScripts);
CheckScriptTexts(sCreatureMovementScripts);
CheckScriptTexts(sRelayScripts);
}

void ScriptMgr::LoadDbScriptRandomTemplates()
Expand Down Expand Up @@ -1041,7 +1022,7 @@ void ScriptMgr::CheckRandomRelayTemplates()
sLog.outErrorDb("Table `dbscript_random_templates` entry (%u) uses nonexistent relay ID (%u).", templateData.first, data.first);
}

void ScriptMgr::CheckScriptTexts(ScriptMapMapName const& scripts, std::set<int32>& ids)
void ScriptMgr::CheckScriptTexts(ScriptMapMapName const& scripts)
{
for (ScriptMapMap::const_iterator itrMM = scripts.second.begin(); itrMM != scripts.second.end(); ++itrMM)
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/DBScripts/ScriptMgr.h
Expand Up @@ -643,7 +643,7 @@ class ScriptMgr

private:
void LoadScripts(ScriptMapMapName& scripts, const char* tablename);
void CheckScriptTexts(ScriptMapMapName const& scripts, std::set<int32>& ids);
void CheckScriptTexts(ScriptMapMapName const& scripts);

typedef std::vector<std::string> ScriptNameMap;
typedef std::unordered_map<uint32, uint32> AreaTriggerScriptMap;
Expand Down

0 comments on commit d5e5b94

Please sign in to comment.