diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp index 3331217852..3df085041e 100644 --- a/src/game/Chat/Chat.cpp +++ b/src/game/Chat/Chat.cpp @@ -583,7 +583,6 @@ ChatCommand* ChatHandler::getCommandTable() { "creature_involvedrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand, "", nullptr }, { "creature_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesCreatureCommand, "", nullptr }, { "creature_questrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestRelationsCommand, "", nullptr }, - { "dbscript_string", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDbScriptStringCommand, "", nullptr }, { "dbscripts_on_creature_death", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDBScriptsOnCreatureDeathCommand, "", nullptr }, { "dbscripts_on_event", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDBScriptsOnEventCommand, "", nullptr }, { "dbscripts_on_gossip", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDBScriptsOnGossipCommand, "", nullptr }, diff --git a/src/game/Chat/Chat.h b/src/game/Chat/Chat.h index b26f386dd9..01dda9e2d0 100644 --- a/src/game/Chat/Chat.h +++ b/src/game/Chat/Chat.h @@ -520,7 +520,6 @@ class ChatHandler bool HandleReloadCreaturesStatsCommand(char* args); bool HandleReloadCreatureQuestRelationsCommand(char* args); bool HandleReloadCreatureQuestInvRelationsCommand(char* args); - bool HandleReloadDbScriptStringCommand(char* args); bool HandleReloadDBScriptsOnCreatureDeathCommand(char* args); bool HandleReloadDBScriptsOnEventCommand(char* args); bool HandleReloadDBScriptsOnGossipCommand(char* args); diff --git a/src/game/Chat/Level3.cpp b/src/game/Chat/Level3.cpp index 00902f2e86..33a6e9a9ef 100644 --- a/src/game/Chat/Level3.cpp +++ b/src/game/Chat/Level3.cpp @@ -259,7 +259,6 @@ bool ChatHandler::HandleReloadAllScriptsCommand(char* /*args*/) HandleReloadDBScriptsOnSpellCommand((char*)"a"); HandleReloadDBScriptsOnRelayCommand((char*)"a"); SendGlobalSysMessage("DB tables `*_scripts` reloaded."); - HandleReloadDbScriptStringCommand((char*)"a"); return true; } @@ -825,14 +824,6 @@ bool ChatHandler::HandleReloadEventAIScriptsCommand(char* /*args*/) return true; } -bool ChatHandler::HandleReloadDbScriptStringCommand(char* /*args*/) -{ - sLog.outString("Re-Loading Script strings from `dbscript_string`..."); - sScriptMgr.LoadDbScriptStrings(); - SendGlobalSysMessage("DB table `dbscript_string` reloaded."); - return true; -} - bool ChatHandler::HandleReloadDBScriptsOnGossipCommand(char* args) { if (sScriptMgr.IsScriptScheduled()) diff --git a/src/game/DBScripts/ScriptMgr.cpp b/src/game/DBScripts/ScriptMgr.cpp index f3b8a96163..2f922b92b9 100644 --- a/src/game/DBScripts/ScriptMgr.cpp +++ b/src/game/DBScripts/ScriptMgr.cpp @@ -245,17 +245,7 @@ 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 break; } case SCRIPT_COMMAND_EMOTE: // 1 @@ -963,31 +953,19 @@ void ScriptMgr::LoadRelayScripts() void ScriptMgr::LoadDbScriptStrings() { - // load both dbscript_strings and creature_ai_texts here because either may be referenced by dbscript_random_templates - sObjectMgr.LoadMangosStrings(WorldDatabase, "dbscript_string", MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, true); + // load creature_ai_texts here because it may be referenced by dbscript_random_templates sObjectMgr.LoadMangosStrings(WorldDatabase, "creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID, true); - std::set 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() @@ -1037,7 +1015,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& ids) +void ScriptMgr::CheckScriptTexts(ScriptMapMapName const& scripts) { for (ScriptMapMap::const_iterator itrMM = scripts.second.begin(); itrMM != scripts.second.end(); ++itrMM) { @@ -1047,11 +1025,8 @@ void ScriptMgr::CheckScriptTexts(ScriptMapMapName const& scripts, std::setsecond.textId) { - if (i && !sObjectMgr.GetMangosStringLocale(i)) - sLog.outErrorDb("Table `dbscript_string` is missing string id %u, used in database script table %s id %u.", i, scripts.first, itrMM->first); - - if (ids.find(i) != ids.end()) - ids.erase(i); + if (i && !sObjectMgr.GetBroadcastText(i)) + sLog.outErrorDb("Table `broadcast_text` is missing string id %u, used in database script table %s id %u.", i, scripts.first, itrMM->first); } if (itrM->second.talk.stringTemplateId) @@ -1059,8 +1034,10 @@ void ScriptMgr::CheckScriptTexts(ScriptMapMapName const& scripts, std::setsecond.talk.stringTemplateId]; for (auto& data : vector) { - if (!sObjectMgr.GetMangosStringLocale(data.first)) - sLog.outErrorDb("Table `%s` is missing string id %d, used in database script template table dbscript_random_templates id %u.", itrM->second.talk.stringTemplateId > 0 ? "dbscript_string" : "creature_ai_texts", data.first, itrM->second.talk.stringTemplateId); + if (data.first < 0 && !sObjectMgr.GetMangosStringLocale(data.first)) + sLog.outErrorDb("Table `creature_ai_texts` is missing string id %d, used in database script template table dbscript_random_templates id %u.", data.first, itrM->second.talk.stringTemplateId); + else if (data.first > 0 && !sObjectMgr.GetBroadcastText(data.first)) + sLog.outErrorDb("Table `broadcast_text` is missing string id %d, used in database script template table dbscript_random_templates id %u.", data.first, itrM->second.talk.stringTemplateId); } } } diff --git a/src/game/DBScripts/ScriptMgr.h b/src/game/DBScripts/ScriptMgr.h index 6ef2a9ac2a..18efc4d327 100644 --- a/src/game/DBScripts/ScriptMgr.h +++ b/src/game/DBScripts/ScriptMgr.h @@ -35,7 +35,7 @@ struct SpellEntry; enum ScriptCommand // resSource, resTarget are the resulting Source/ Target after buddy search is done { SCRIPT_COMMAND_TALK = 0, // resSource = WorldObject, resTarget = Unit/none - // dataint = text entry from dbscript_string -table. dataint2-4 optional for random selected texts. + // dataint = text id from broadcast_text table. dataint2-4 optional for random selected texts. SCRIPT_COMMAND_EMOTE = 1, // resSource = Unit, resTarget = Unit/none // datalong1 = emote_id, dataint1-4 optional for random selected emotes SCRIPT_COMMAND_FIELD_SET = 2, // source = any, datalong = field_id, datalong2 = value @@ -631,7 +631,7 @@ class ScriptMgr private: void LoadScripts(ScriptMapMapName& scripts, const char* tablename); - void CheckScriptTexts(ScriptMapMapName const& scripts, std::set& ids); + void CheckScriptTexts(ScriptMapMapName const& scripts); typedef std::vector ScriptNameMap; typedef std::unordered_map AreaTriggerScriptMap; diff --git a/src/game/Globals/ObjectMgr.cpp b/src/game/Globals/ObjectMgr.cpp index 4a84c1d939..46f7cdc98a 100644 --- a/src/game/Globals/ObjectMgr.cpp +++ b/src/game/Globals/ObjectMgr.cpp @@ -7992,10 +7992,6 @@ inline void _DoStringError(int32 entry, char const* text, ...) sLog.outErrorScriptLib("%s", buf); else if (entry <= MIN_CREATURE_AI_TEXT_STRING_ID) // eventAI error sLog.outErrorEventAI("%s", buf); - else if (entry < MIN_DB_SCRIPT_STRING_ID) // mangos string error - sLog.outError("%s", buf); - else // if (entry > MIN_DB_SCRIPT_STRING_ID) // DB script text error - sLog.outErrorDb("DB-SCRIPTS: %s", buf); } bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value, bool extra_content) @@ -9426,14 +9422,6 @@ void ObjectMgr::GetAreaTriggerLocales(uint32 entry, int32 loc_idx, std::string* // Functions for scripting access bool LoadMangosStrings(DatabaseType& db, char const* table, int32 start_value, int32 end_value, bool extra_content) { - // MAX_DB_SCRIPT_STRING_ID is max allowed negative value for scripts (scrpts can use only more deep negative values - // start/end reversed for negative values - if (start_value > MAX_DB_SCRIPT_STRING_ID || end_value >= start_value) - { - sLog.outErrorDb("Table '%s' attempt loaded with reserved by mangos range (%d - %d), strings not loaded.", table, start_value, end_value + 1); - return false; - } - return sObjectMgr.LoadMangosStrings(db, table, start_value, end_value, extra_content); } diff --git a/src/game/Globals/ObjectMgr.h b/src/game/Globals/ObjectMgr.h index 4f8a54e243..9ebc18fb48 100644 --- a/src/game/Globals/ObjectMgr.h +++ b/src/game/Globals/ObjectMgr.h @@ -140,14 +140,10 @@ typedef std::unordered_map // mangos string ranges #define MIN_MANGOS_STRING_ID 1 // 'mangos_string' #define MAX_MANGOS_STRING_ID 2000000000 -#define MIN_DB_SCRIPT_STRING_ID MAX_MANGOS_STRING_ID // 'dbscript_string' -#define MAX_DB_SCRIPT_STRING_ID 2001000000 #define MIN_CREATURE_AI_TEXT_STRING_ID (-1) // 'creature_ai_texts' #define MAX_CREATURE_AI_TEXT_STRING_ID (-1000000) // Anything below MAX_CREATURE_AI_TEXT_STRING_ID is handled by the external script lib -static_assert(MAX_DB_SCRIPT_STRING_ID < INT_MAX, "Must scope with int32 range"); - struct MangosStringLocale { MangosStringLocale() : SoundId(0), Type(0), LanguageId(LANG_UNIVERSAL), Emote(0), broadcastText(nullptr) { } diff --git a/src/game/Tools/Language.h b/src/game/Tools/Language.h index d2dc6742cd..c3f01cb4dc 100644 --- a/src/game/Tools/Language.h +++ b/src/game/Tools/Language.h @@ -1093,7 +1093,5 @@ enum MangosStrings // Use for custom patches 11000-11999 // NOT RESERVED IDS 12000-1999999999 - // `dbscript_string` table index 2000000000-2000999999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID) - // For other tables maybe 2001000000-2147483647 (max index) }; #endif diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp index 5fbbc77cd8..be029a836a 100644 --- a/src/game/World/World.cpp +++ b/src/game/World/World.cpp @@ -897,7 +897,7 @@ void World::SetInitialWorldSettings() sLog.outString("Loading faction_store..."); sObjectMgr.LoadFactions(); - // Load before npc_text, gossip_menu_option, script_texts, creature_ai_texts, dbscript_string + // Load before npc_text, gossip_menu_option, script_texts, creature_ai_texts sLog.outString("Loading broadcast_text..."); sObjectMgr.LoadBroadcastText();