Core/DB: Update all locales to actual TrinityCore (#1160)

* Core/Misc Update all locales table structure to simple system. Port from TrinityCore
Co-Authored-By: Winfidonarleyan <dowlandtop@yandex.com>
* Core/Db/Gossip Update structure gossip_menu and gossip_menu_action to actual TrinityCore
* Core/DB Update Broadcast system to actual TC
* Core/Mail: implement Quest Mail Sender
* Core/Quest Split quest template locales
This commit is contained in:
Kargatum
2019-01-13 05:56:06 +07:00
committed by Viste(Кирилл)
parent 76772e434d
commit b34bc28e5b
26 changed files with 59397 additions and 525 deletions

View File

@@ -305,24 +305,22 @@ void ObjectMgr::LoadCreatureLocales()
{
Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
std::string localeName = fields[1].GetString();
uint32 ID = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
std::string Name = fields[2].GetString();
std::string Title = fields[3].GetString();
std::string name = fields[2].GetString();
std::string title = fields[3].GetString();
CreatureLocale& data = _creatureLocaleStore[id];
LocaleConstant locale = GetLocaleByName(localeName);
CreatureLocale& data = _creatureLocaleStore[ID];
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
AddLocaleString(name, locale, data.Name);
AddLocaleString(title, locale, data.Title);
AddLocaleString(Name, locale, data.Name);
AddLocaleString(Title, locale, data.Title);
} while (result->NextRow());
sLog->outString(">> Loaded %lu creature locale strings in %u ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %lu Сreature Locale strings in %u ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadGossipMenuItemsLocales()
@@ -331,12 +329,8 @@ void ObjectMgr::LoadGossipMenuItemsLocales()
_gossipMenuItemsLocaleStore.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT menu_id, id, "
"option_text_loc1, box_text_loc1, option_text_loc2, box_text_loc2, "
"option_text_loc3, box_text_loc3, option_text_loc4, box_text_loc4, "
"option_text_loc5, box_text_loc5, option_text_loc6, box_text_loc6, "
"option_text_loc7, box_text_loc7, option_text_loc8, box_text_loc8 "
"FROM locales_gossip_menu_option");
// 0 1 2 3 4
QueryResult result = WorldDatabase.Query("SELECT MenuID, OptionID, Locale, OptionText, BoxText FROM gossip_menu_option_locale");
if (!result)
return;
@@ -345,21 +339,23 @@ void ObjectMgr::LoadGossipMenuItemsLocales()
{
Field* fields = result->Fetch();
uint16 menuId = fields[0].GetUInt16();
uint16 id = fields[1].GetUInt16();
uint16 MenuID = fields[0].GetUInt16();
uint16 OptionID = fields[1].GetUInt16();
std::string LocaleName = fields[2].GetString();
std::string OptionText = fields[3].GetString();
std::string BoxText = fields[4].GetString();
GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[MAKE_PAIR32(menuId, id)];
GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[MAKE_PAIR32(MenuID, OptionID)];
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
AddLocaleString(OptionText, locale, data.OptionText);
AddLocaleString(BoxText, locale, data.BoxText);
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
AddLocaleString(fields[2 + 2 * (i - 1)].GetString(), locale, data.OptionText);
AddLocaleString(fields[2 + 2 * (i - 1) + 1].GetString(), locale, data.BoxText);
}
} while (result->NextRow());
sLog->outString(">> Loaded %lu gossip_menu_option locale strings in %u ms", (unsigned long)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %u Gossip Menu Option Locale strings in %u ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadPointOfInterestLocales()
@@ -368,7 +364,8 @@ void ObjectMgr::LoadPointOfInterestLocales()
_pointOfInterestLocaleStore.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT entry, icon_name_loc1, icon_name_loc2, icon_name_loc3, icon_name_loc4, icon_name_loc5, icon_name_loc6, icon_name_loc7, icon_name_loc8 FROM locales_points_of_interest");
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM points_of_interest_locale");
if (!result)
return;
@@ -377,16 +374,20 @@ void ObjectMgr::LoadPointOfInterestLocales()
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 ID = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
std::string Name = fields[2].GetString();
PointOfInterestLocale& data = _pointOfInterestLocaleStore[entry];
PointOfInterestLocale& data = _pointOfInterestLocaleStore[ID];
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
AddLocaleString(Name, locale, data.IconName);
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.IconName);
} while (result->NextRow());
sLog->outString(">> Loaded %lu points_of_interest locale strings in %u ms", (unsigned long)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %u Points Of Interest Locale strings in %u ms", (uint32)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadCreatureTemplates()
@@ -2223,8 +2224,7 @@ void ObjectMgr::LoadItemLocales()
_itemLocaleStore.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT entry, name_loc1, description_loc1, name_loc2, description_loc2, name_loc3, description_loc3, name_loc4, description_loc4, name_loc5, description_loc5, name_loc6, description_loc6, name_loc7, description_loc7, name_loc8, description_loc8 FROM locales_item");
QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale");
if (!result)
return;
@@ -2232,20 +2232,22 @@ void ObjectMgr::LoadItemLocales()
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 ID = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
std::string Name = fields[2].GetString();
std::string Description = fields[3].GetString();
ItemLocale& data = _itemLocaleStore[entry];
ItemLocale& data = _itemLocaleStore[ID];
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
AddLocaleString(Name, locale, data.Name);
AddLocaleString(Description, locale, data.Description);
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
AddLocaleString(fields[1 + 2 * (i - 1)].GetString(), locale, data.Name);
AddLocaleString(fields[1 + 2 * (i - 1) + 1].GetString(), locale, data.Description);
}
} while (result->NextRow());
sLog->outString(">> Loaded %lu Item locale strings in %u ms", (unsigned long)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %u Item Locale strings in %u ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadItemTemplates()
@@ -2849,7 +2851,7 @@ void ObjectMgr::LoadItemSetNameLocales()
_itemSetNameLocaleStore.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT `entry`, `name_loc1`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc5`, `name_loc6`, `name_loc7`, `name_loc8` FROM `locales_item_set_names`");
QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale");
if (!result)
return;
@@ -2858,16 +2860,20 @@ void ObjectMgr::LoadItemSetNameLocales()
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 ID = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
std::string Name = fields[2].GetString();
ItemSetNameLocale& data = _itemSetNameLocaleStore[entry];
ItemSetNameLocale& data = _itemSetNameLocaleStore[ID];
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
AddLocaleString(Name, locale, data.Name);
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Name);
} while (result->NextRow());
sLog->outString(">> Loaded " UI64FMTD " Item set name locale strings in %u ms", uint64(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %u Item Set Name Locale strings in %u ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadItemSetNames()
@@ -3978,8 +3984,8 @@ void ObjectMgr::LoadQuests()
// Load `quest_template_addon`
// 0 1 2 3 4 5 6 7 8
result = WorldDatabase.Query("SELECT ID, MaxLevel, AllowableClasses, SourceSpellID, PrevQuestID, NextQuestID, ExclusiveGroup, RewardMailTemplateID, RewardMailDelay, "
//9 10 11 12 13 14 15 16
"RequiredSkillID, RequiredSkillPoints, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, ProvidedItemCount, SpecialFlags FROM quest_template_addon");
//9 10 11 12 13 14 15 16 17
"RequiredSkillID, RequiredSkillPoints, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, ProvidedItemCount, RewardMailSenderEntry, SpecialFlags FROM quest_template_addon LEFT JOIN quest_mail_sender ON Id=QuestId");
if (!result) {
sLog->outError(">> Loaded 0 quest template addons. DB table `quest_template_addon` is empty.");
@@ -4479,6 +4485,7 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId);
qinfo->RewardMailTemplateId = 0; // no mail will send to player
qinfo->RewardMailDelay = 0; // no mail will send to player
qinfo->RewardMailSenderEntry = 0;
}
else if (usedMailTemplates.find(qinfo->RewardMailTemplateId) != usedMailTemplates.end())
{
@@ -4487,6 +4494,7 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId, used_mt_itr->second);
qinfo->RewardMailTemplateId = 0; // no mail will send to player
qinfo->RewardMailDelay = 0; // no mail will send to player
qinfo->RewardMailSenderEntry = 0;
}
else
usedMailTemplates[qinfo->RewardMailTemplateId] = qinfo->GetQuestId();
@@ -4581,16 +4589,8 @@ void ObjectMgr::LoadQuestLocales()
_questLocaleStore.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT Id, "
"Title_loc1, Details_loc1, Objectives_loc1, OfferRewardText_loc1, RequestItemsText_loc1, EndText_loc1, CompletedText_loc1, ObjectiveText1_loc1, ObjectiveText2_loc1, ObjectiveText3_loc1, ObjectiveText4_loc1, "
"Title_loc2, Details_loc2, Objectives_loc2, OfferRewardText_loc2, RequestItemsText_loc2, EndText_loc2, CompletedText_loc2, ObjectiveText1_loc2, ObjectiveText2_loc2, ObjectiveText3_loc2, ObjectiveText4_loc2, "
"Title_loc3, Details_loc3, Objectives_loc3, OfferRewardText_loc3, RequestItemsText_loc3, EndText_loc3, CompletedText_loc3, ObjectiveText1_loc3, ObjectiveText2_loc3, ObjectiveText3_loc3, ObjectiveText4_loc3, "
"Title_loc4, Details_loc4, Objectives_loc4, OfferRewardText_loc4, RequestItemsText_loc4, EndText_loc4, CompletedText_loc4, ObjectiveText1_loc4, ObjectiveText2_loc4, ObjectiveText3_loc4, ObjectiveText4_loc4, "
"Title_loc5, Details_loc5, Objectives_loc5, OfferRewardText_loc5, RequestItemsText_loc5, EndText_loc5, CompletedText_loc5, ObjectiveText1_loc5, ObjectiveText2_loc5, ObjectiveText3_loc5, ObjectiveText4_loc5, "
"Title_loc6, Details_loc6, Objectives_loc6, OfferRewardText_loc6, RequestItemsText_loc6, EndText_loc6, CompletedText_loc6, ObjectiveText1_loc6, ObjectiveText2_loc6, ObjectiveText3_loc6, ObjectiveText4_loc6, "
"Title_loc7, Details_loc7, Objectives_loc7, OfferRewardText_loc7, RequestItemsText_loc7, EndText_loc7, CompletedText_loc7, ObjectiveText1_loc7, ObjectiveText2_loc7, ObjectiveText3_loc7, ObjectiveText4_loc7, "
"Title_loc8, Details_loc8, Objectives_loc8, OfferRewardText_loc8, RequestItemsText_loc8, EndText_loc8, CompletedText_loc8, ObjectiveText1_loc8, ObjectiveText2_loc8, ObjectiveText3_loc8, ObjectiveText4_loc8"
" FROM locales_quest");
// 0 1 2 3 4 5 6 7 8 9 10
QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale");
if (!result)
return;
@@ -4599,29 +4599,26 @@ void ObjectMgr::LoadQuestLocales()
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 ID = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
QuestLocale& data = _questLocaleStore[entry];
QuestLocale& data = _questLocaleStore[ID];
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
AddLocaleString(fields[2].GetString(), locale, data.Title);
AddLocaleString(fields[3].GetString(), locale, data.Details);
AddLocaleString(fields[4].GetString(), locale, data.Objectives);
AddLocaleString(fields[7].GetString(), locale, data.AreaDescription);
AddLocaleString(fields[8].GetString(), locale, data.CompletedText);
AddLocaleString(fields[1 + 11 * (i - 1)].GetString(), locale, data.Title);
AddLocaleString(fields[1 + 11 * (i - 1) + 1].GetString(), locale, data.Details);
AddLocaleString(fields[1 + 11 * (i - 1) + 2].GetString(), locale, data.Objectives);
AddLocaleString(fields[1 + 11 * (i - 1) + 3].GetString(), locale, data.OfferRewardText);
AddLocaleString(fields[1 + 11 * (i - 1) + 4].GetString(), locale, data.RequestItemsText);
AddLocaleString(fields[1 + 11 * (i - 1) + 5].GetString(), locale, data.AreaDescription);
AddLocaleString(fields[1 + 11 * (i - 1) + 6].GetString(), locale, data.CompletedText);
for (uint8 i = 0; i < 4; ++i)
AddLocaleString(fields[i + 7].GetString(), locale, data.ObjectiveText[i]);
for (uint8 k = 0; k < 4; ++k)
AddLocaleString(fields[1 + 11 * (i - 1) + 7 + k].GetString(), locale, data.ObjectiveText[k]);
}
} while (result->NextRow());
sLog->outString(">> Loaded %lu Quest locale strings in %u ms", (unsigned long)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %u Quest Locale strings in %u ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadScripts(ScriptsType type)
@@ -4691,13 +4688,6 @@ void ObjectMgr::LoadScripts(ScriptsType type)
tableName.c_str(), tmp.Talk.TextID, tmp.id);
continue;
}
if (tmp.Talk.TextID < MIN_DB_SCRIPT_STRING_ID || tmp.Talk.TextID >= MAX_DB_SCRIPT_STRING_ID)
{
sLog->outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u",
tableName.c_str(), tmp.Talk.TextID, MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, tmp.id);
continue;
}
break;
}
@@ -5231,7 +5221,8 @@ void ObjectMgr::LoadPageTextLocales()
_pageTextLocaleStore.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT entry, text_loc1, text_loc2, text_loc3, text_loc4, text_loc5, text_loc6, text_loc7, text_loc8 FROM locales_page_text");
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
if (!result)
return;
@@ -5240,16 +5231,18 @@ void ObjectMgr::LoadPageTextLocales()
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 ID = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
std::string Text = fields[2].GetString();
PageTextLocale& data = _pageTextLocaleStore[entry];
PageTextLocale& data = _pageTextLocaleStore[ID];
LocaleConstant locale = GetLocaleByName(LocaleName);
AddLocaleString(Text, locale, data.Text);
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Text);
} while (result->NextRow());
sLog->outString(">> Loaded %lu PageText locale strings in %u ms", (unsigned long)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %u Page Text Locale strings in %u ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadInstanceTemplate()
@@ -5401,49 +5394,74 @@ void ObjectMgr::LoadGossipText()
{
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT * FROM npc_text");
QueryResult result = WorldDatabase.Query("SELECT ID, "
"text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, "
"text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, "
"text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, "
"text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, "
"text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, "
"text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, "
"text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, "
"text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 "
"FROM npc_text");
int count = 0;
if (!result)
{
sLog->outString(">> Loaded %u npc texts", count);
sLog->outErrorDb(">> Loaded 0 npc texts, table is empty!");
sLog->outString();
return;
}
_gossipTextStore.rehash(result->GetRowCount());
int cic;
uint32 count = 0;
uint8 cic;
do
{
++count;
cic = 0;
Field* fields = result->Fetch();
uint32 Text_ID = fields[cic++].GetUInt32();
if (!Text_ID)
uint32 id = fields[cic++].GetUInt32();
if (!id)
{
sLog->outErrorDb("Table `npc_text` has record wit reserved id 0, ignore.");
continue;
}
GossipText& gText = _gossipTextStore[Text_ID];
GossipText& gText = _gossipTextStore[id];
for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
gText.Options[i].Text_0 = fields[cic++].GetString();
gText.Options[i].Text_1 = fields[cic++].GetString();
gText.Options[i].BroadcastTextID = fields[cic++].GetUInt32();
gText.Options[i].Language = fields[cic++].GetUInt8();
gText.Options[i].Probability = fields[cic++].GetFloat();
for (uint8 j=0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
{
gText.Options[i].Emotes[j]._Delay = fields[cic++].GetUInt16();
gText.Options[i].Emotes[j]._Emote = fields[cic++].GetUInt16();
gText.Options[i].Emotes[j]._Delay = fields[cic++].GetUInt16();
gText.Options[i].Emotes[j]._Emote = fields[cic++].GetUInt16();
}
}
for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
{
if (gText.Options[i].BroadcastTextID)
{
if (!sObjectMgr->GetBroadcastText(gText.Options[i].BroadcastTextID))
{
sLog->outErrorDb("GossipText (Id: %u) in table `npc_text` has non-existing or incompatible BroadcastTextID%u %u.", id, i, gText.Options[i].BroadcastTextID);
gText.Options[i].BroadcastTextID = 0;
}
}
}
count++;
} while (result->NextRow());
sLog->outString(">> Loaded %u npc texts in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
@@ -5456,16 +5474,10 @@ void ObjectMgr::LoadNpcTextLocales()
_npcTextLocaleStore.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT ID, "
"Text0_0_loc1, Text0_1_loc1, Text1_0_loc1, Text1_1_loc1, Text2_0_loc1, Text2_1_loc1, Text3_0_loc1, Text3_1_loc1, Text4_0_loc1, Text4_1_loc1, Text5_0_loc1, Text5_1_loc1, Text6_0_loc1, Text6_1_loc1, Text7_0_loc1, Text7_1_loc1, "
"Text0_0_loc2, Text0_1_loc2, Text1_0_loc2, Text1_1_loc2, Text2_0_loc2, Text2_1_loc2, Text3_0_loc2, Text3_1_loc1, Text4_0_loc2, Text4_1_loc2, Text5_0_loc2, Text5_1_loc2, Text6_0_loc2, Text6_1_loc2, Text7_0_loc2, Text7_1_loc2, "
"Text0_0_loc3, Text0_1_loc3, Text1_0_loc3, Text1_1_loc3, Text2_0_loc3, Text2_1_loc3, Text3_0_loc3, Text3_1_loc1, Text4_0_loc3, Text4_1_loc3, Text5_0_loc3, Text5_1_loc3, Text6_0_loc3, Text6_1_loc3, Text7_0_loc3, Text7_1_loc3, "
"Text0_0_loc4, Text0_1_loc4, Text1_0_loc4, Text1_1_loc4, Text2_0_loc4, Text2_1_loc4, Text3_0_loc4, Text3_1_loc1, Text4_0_loc4, Text4_1_loc4, Text5_0_loc4, Text5_1_loc4, Text6_0_loc4, Text6_1_loc4, Text7_0_loc4, Text7_1_loc4, "
"Text0_0_loc5, Text0_1_loc5, Text1_0_loc5, Text1_1_loc5, Text2_0_loc5, Text2_1_loc5, Text3_0_loc5, Text3_1_loc1, Text4_0_loc5, Text4_1_loc5, Text5_0_loc5, Text5_1_loc5, Text6_0_loc5, Text6_1_loc5, Text7_0_loc5, Text7_1_loc5, "
"Text0_0_loc6, Text0_1_loc6, Text1_0_loc6, Text1_1_loc6, Text2_0_loc6, Text2_1_loc6, Text3_0_loc6, Text3_1_loc1, Text4_0_loc6, Text4_1_loc6, Text5_0_loc6, Text5_1_loc6, Text6_0_loc6, Text6_1_loc6, Text7_0_loc6, Text7_1_loc6, "
"Text0_0_loc7, Text0_1_loc7, Text1_0_loc7, Text1_1_loc7, Text2_0_loc7, Text2_1_loc7, Text3_0_loc7, Text3_1_loc1, Text4_0_loc7, Text4_1_loc7, Text5_0_loc7, Text5_1_loc7, Text6_0_loc7, Text6_1_loc7, Text7_0_loc7, Text7_1_loc7, "
"Text0_0_loc8, Text0_1_loc8, Text1_0_loc8, Text1_1_loc8, Text2_0_loc8, Text2_1_loc8, Text3_0_loc8, Text3_1_loc1, Text4_0_loc8, Text4_1_loc8, Text5_0_loc8, Text5_1_loc8, Text6_0_loc8, Text6_1_loc8, Text7_0_loc8, Text7_1_loc8 "
" FROM locales_npc_text");
QueryResult result = WorldDatabase.Query("SELECT ID, Locale, "
// 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
"Text0_0, Text0_1, Text1_0, Text1_1, Text2_0, Text2_1, Text3_0, Text3_1, Text4_0, Text4_1, Text5_0, Text5_1, Text6_0, Text6_1, Text7_0, Text7_1 "
"FROM npc_text_locale");
if (!result)
return;
@@ -5474,23 +5486,23 @@ void ObjectMgr::LoadNpcTextLocales()
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 ID = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
NpcTextLocale& data = _npcTextLocaleStore[entry];
NpcTextLocale& data = _npcTextLocaleStore[ID];
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
for (uint8 j = 0; j < MAX_LOCALES; ++j)
{
AddLocaleString(fields[1 + 8 * 2 * (i - 1) + 2 * j].GetString(), locale, data.Text_0[j]);
AddLocaleString(fields[1 + 8 * 2 * (i - 1) + 2 * j + 1].GetString(), locale, data.Text_1[j]);
}
AddLocaleString(fields[2 + i * 2].GetString(), locale, data.Text_0[i]);
AddLocaleString(fields[3 + i * 2].GetString(), locale, data.Text_1[i]);
}
} while (result->NextRow());
sLog->outString(">> Loaded %lu NpcText locale strings in %u ms", (unsigned long)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %u Npc Text Locale strings in %u ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
@@ -5677,6 +5689,66 @@ void ObjectMgr::LoadQuestAreaTriggers()
sLog->outString();
}
void ObjectMgr::LoadQuestOfferRewardLocale()
{
uint32 oldMSTime = getMSTime();
_questOfferRewardLocaleStore.clear(); // need for reload case
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale");
if (!result)
return;
do
{
Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
std::string localeName = fields[1].GetString();
LocaleConstant locale = GetLocaleByName(localeName);
if (locale == LOCALE_enUS)
continue;
QuestOfferRewardLocale& data = _questOfferRewardLocaleStore[id];
AddLocaleString(fields[2].GetString(), locale, data.RewardText);
} while (result->NextRow());
sLog->outString(">> Loaded %lu Quest Offer Reward locale strings in %u ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadQuestRequestItemsLocale()
{
uint32 oldMSTime = getMSTime();
_questRequestItemsLocaleStore.clear(); // need for reload case
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT Id, locale, CompletionText FROM quest_request_items_locale");
if (!result)
return;
do
{
Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
std::string localeName = fields[1].GetString();
LocaleConstant locale = GetLocaleByName(localeName);
if (locale == LOCALE_enUS)
continue;
QuestRequestItemsLocale& data = _questRequestItemsLocaleStore[id];
AddLocaleString(fields[2].GetString(), locale, data.CompletionText);
} while (result->NextRow());
sLog->outString(">> Loaded %lu Quest Request Items locale strings in %u ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadTavernAreaTriggers()
{
uint32 oldMSTime = getMSTime();
@@ -6287,24 +6359,22 @@ void ObjectMgr::LoadGameObjectLocales()
{
Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
std::string localeName = fields[1].GetString();
uint32 ID = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
std::string Name = fields[2].GetString();
std::string CastBarCaption = fields[3].GetString();
std::string name = fields[2].GetString();
std::string castBarCaption = fields[3].GetString();
GameObjectLocale& data = _gameObjectLocaleStore[id];
LocaleConstant locale = GetLocaleByName(localeName);
GameObjectLocale& data = _gameObjectLocaleStore[ID];
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
AddLocaleString(name, locale, data.Name);
AddLocaleString(castBarCaption, locale, data.CastBarCaption);
AddLocaleString(Name, locale, data.Name);
AddLocaleString(CastBarCaption, locale, data.CastBarCaption);
} while (result->NextRow());
sLog->outString(">> Loaded %lu gameobject locale strings in %u ms", (unsigned long)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
sLog->outString(">> Loaded %u Gameobject Locale strings in %u ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
inline void CheckGOLockId(GameObjectTemplate const* goInfo, uint32 dataN, uint32 N)
@@ -7578,108 +7648,52 @@ void ObjectMgr::LoadGameObjectForQuests()
sLog->outString();
}
bool ObjectMgr::LoadTrinityStrings(const char* table, int32 min_value, int32 max_value)
bool ObjectMgr::LoadTrinityStrings()
{
uint32 oldMSTime = getMSTime();
int32 start_value = min_value;
int32 end_value = max_value;
// some string can have negative indexes range
if (start_value < 0)
{
if (end_value >= start_value)
{
sLog->outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.", table, min_value, max_value);
return false;
}
// real range (max+1, min+1) exaple: (-10, -1000) -> -999...-10+1
std::swap(start_value, end_value);
++start_value;
++end_value;
}
else
{
if (start_value >= end_value)
{
sLog->outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.", table, min_value, max_value);
return false;
}
}
// cleanup affected map part for reloading case
for (TrinityStringLocaleContainer::iterator itr = _trinityStringLocaleStore.begin(); itr != _trinityStringLocaleStore.end();)
{
if (itr->first >= start_value && itr->first < end_value)
_trinityStringLocaleStore.erase(itr++);
else
++itr;
}
QueryResult result = WorldDatabase.PQuery("SELECT entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8 FROM %s", table);
_trinityStringStore.clear(); // for reload case
QueryResult result = WorldDatabase.PQuery("SELECT entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8 FROM trinity_string");
if (!result)
{
if (min_value == MIN_TRINITY_STRING_ID) // error only in case internal strings
sLog->outErrorDb(">> Loaded 0 trinity strings. DB table `%s` is empty. Cannot continue.", table);
else
sLog->outString(">> Loaded 0 string templates. DB table `%s` is empty.", table);
sLog->outString(">> Loaded 0 trinity strings. DB table `trinity_strings` is empty.");
sLog->outString();
return false;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
int32 entry = fields[0].GetInt32();
uint32 entry = fields[0].GetUInt32();
if (entry == 0)
{
sLog->outErrorDb("Table `%s` contain reserved entry 0, ignored.", table);
continue;
}
else if (entry < start_value || entry >= end_value)
{
sLog->outErrorDb("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.", table, entry, min_value, max_value);
continue;
}
TrinityString& data = _trinityStringStore[entry];
TrinityStringLocale& data = _trinityStringLocaleStore[entry];
if (!data.Content.empty())
{
sLog->outErrorDb("Table `%s` contain data for already loaded entry %i (from another table?), ignored.", table, entry);
continue;
}
data.Content.resize(1);
++count;
data.Content.resize(DEFAULT_LOCALE + 1);
for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
AddLocaleString(fields[i + 1].GetString(), LocaleConstant(i), data.Content);
} while (result->NextRow());
if (min_value == MIN_TRINITY_STRING_ID)
sLog->outString(">> Loaded %u Trinity strings from table %s in %u ms", count, table, GetMSTimeDiffToNow(oldMSTime));
else
sLog->outString(">> Loaded %u string templates from %s in %u ms", count, table, GetMSTimeDiffToNow(oldMSTime));
sLog->outString(">> Loaded %u trinity strings in %u ms", (uint32)_trinityStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
return true;
}
const char *ObjectMgr::GetTrinityString(int32 entry, LocaleConstant /*locale_idx*/) const
char const* ObjectMgr::GetTrinityString(uint32 entry, LocaleConstant locale) const
{
if (TrinityStringLocale const* msl = GetTrinityStringLocale(entry))
return msl->Content[DEFAULT_LOCALE].c_str();
if (TrinityString const* ts = GetTrinityString(entry))
{
if (ts->Content.size() > size_t(locale) && !ts->Content[locale].empty())
return ts->Content[locale].c_str();
return ts->Content[DEFAULT_LOCALE].c_str();
}
sLog->outErrorDb("Trinity string entry %u not found in DB.", entry);
if (entry > 0)
sLog->outErrorDb("Entry %i not found in `trinity_string` table.", entry);
else
sLog->outErrorDb("Trinity string entry %i not found in DB.", entry);
return "<error>";
}
@@ -8231,39 +8245,35 @@ void ObjectMgr::LoadGossipMenu()
_gossipMenusStore.clear();
QueryResult result = WorldDatabase.Query("SELECT entry, text_id FROM gossip_menu");
QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
if (!result)
{
sLog->outErrorDb(">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
sLog->outErrorDb(">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
sLog->outString();
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
GossipMenus gMenu;
gMenu.entry = fields[0].GetUInt16();
gMenu.text_id = fields[1].GetUInt32();
gMenu.MenuID = fields[0].GetUInt16();
gMenu.TextID = fields[1].GetUInt32();
if (!GetGossipText(gMenu.text_id))
if (!GetGossipText(gMenu.TextID))
{
sLog->outErrorDb("Table gossip_menu entry %u are using non-existing text_id %u", gMenu.entry, gMenu.text_id);
sLog->outErrorDb("Table gossip_menu entry %u are using non-existing TextID %u", gMenu.MenuID, gMenu.TextID);
continue;
}
_gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.entry, gMenu));
_gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
++count;
}
while (result->NextRow());
} while (result->NextRow());
sLog->outString(">> Loaded %u gossip_menu entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString(">> Loaded %u gossip_menu entries in %u ms", (uint32)_gossipMenusStore.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
@@ -8274,60 +8284,69 @@ void ObjectMgr::LoadGossipMenuItems()
_gossipMenuItemsStore.clear();
QueryResult result = WorldDatabase.Query(
// 0 1 2 3 4
"SELECT menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, "
// 5 6 7 8 9
"action_menu_id, action_poi_id, box_coded, box_money, box_text "
"FROM gossip_menu_option ORDER BY menu_id, id");
// 0 1 2 3 4 5 6 7 8 9 10 11 12
"SELECT MenuID, OptionID, OptionIcon, OptionText, OptionBroadcastTextID, OptionType, OptionNpcFlag, ActionMenuID, ActionPoiID, BoxCoded, BoxMoney, BoxText, BoxBroadcastTextID "
"FROM gossip_menu_option ORDER BY MenuID, OptionID");
if (!result)
{
sLog->outErrorDb(">> Loaded 0 gossip_menu_option entries. DB table `gossip_menu_option` is empty!");
sLog->outErrorDb(">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
sLog->outString();
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
GossipMenuItems gMenuItem;
gMenuItem.MenuId = fields[0].GetUInt16();
gMenuItem.OptionIndex = fields[1].GetUInt16();
gMenuItem.OptionIcon = fields[2].GetUInt32();
gMenuItem.OptionText = fields[3].GetString();
gMenuItem.OptionType = fields[4].GetUInt8();
gMenuItem.OptionNpcflag = fields[5].GetUInt32();
gMenuItem.ActionMenuId = fields[6].GetUInt32();
gMenuItem.ActionPoiId = fields[7].GetUInt32();
gMenuItem.BoxCoded = fields[8].GetBool();
gMenuItem.BoxMoney = fields[9].GetUInt32();
gMenuItem.BoxText = fields[10].GetString();
gMenuItem.MenuID = fields[0].GetUInt16();
gMenuItem.OptionID = fields[1].GetUInt16();
gMenuItem.OptionIcon = fields[2].GetUInt32();
gMenuItem.OptionText = fields[3].GetString();
gMenuItem.OptionBroadcastTextID = fields[4].GetUInt32();
gMenuItem.OptionType = fields[5].GetUInt8();
gMenuItem.OptionNpcFlag = fields[6].GetUInt32();
gMenuItem.ActionMenuID = fields[7].GetUInt32();
gMenuItem.ActionPoiID = fields[8].GetUInt32();
gMenuItem.BoxCoded = fields[9].GetBool();
gMenuItem.BoxMoney = fields[10].GetUInt32();
gMenuItem.BoxText = fields[11].GetString();
gMenuItem.BoxBroadcastTextID = fields[12].GetUInt32();
if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
{
sLog->outErrorDb("Table gossip_menu_option for menu %u, id %u has unknown icon id %u. Replacing with GOSSIP_ICON_CHAT", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionIcon);
sLog->outErrorDb("Table `gossip_menu_option` for menu %u, id %u has unknown icon id %u. Replacing with GOSSIP_ICON_CHAT", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionIcon);
gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
}
if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
sLog->outErrorDb("Table gossip_menu_option for menu %u, id %u has unknown option id %u. Option will not be used", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionType);
if (gMenuItem.ActionPoiId && !GetPointOfInterest(gMenuItem.ActionPoiId))
if (gMenuItem.OptionBroadcastTextID && !GetBroadcastText(gMenuItem.OptionBroadcastTextID))
{
sLog->outErrorDb("Table gossip_menu_option for menu %u, id %u use non-existing action_poi_id %u, ignoring", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.ActionPoiId);
gMenuItem.ActionPoiId = 0;
sLog->outErrorDb("Table `gossip_menu_option` for menu %u, id %u has non-existing or incompatible OptionBroadcastTextID %u, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
gMenuItem.OptionBroadcastTextID = 0;
}
_gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuId, gMenuItem));
++count;
}
while (result->NextRow());
if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
sLog->outErrorDb("Table `gossip_menu_option` for menu %u, id %u has unknown option id %u. Option will not be used", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionType);
sLog->outString(">> Loaded %u gossip_menu_option entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
{
sLog->outErrorDb("Table `gossip_menu_option` for menu %u, id %u use non-existing ActionPoiID %u, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
gMenuItem.ActionPoiID = 0;
}
if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID))
{
sLog->outErrorDb("Table `gossip_menu_option` for menu %u, id %u has non-existing or incompatible BoxBroadcastTextID %u, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
gMenuItem.BoxBroadcastTextID = 0;
}
_gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
} while (result->NextRow());
sLog->outString(">> Loaded %u gossip_menu_option entries in %u ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
@@ -8606,102 +8625,45 @@ void ObjectMgr::LoadBroadcastTextLocales()
{
uint32 oldMSTime = getMSTime();
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
QueryResult result = WorldDatabase.Query("SELECT Id, MaleText_loc1, MaleText_loc2, MaleText_loc3, MaleText_loc4, MaleText_loc5, MaleText_loc6, MaleText_loc7, MaleText_loc8, FemaleText_loc1, FemaleText_loc2, FemaleText_loc3, FemaleText_loc4, FemaleText_loc5, FemaleText_loc6, FemaleText_loc7, FemaleText_loc8 FROM locales_broadcast_text");
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
if (!result)
{
sLog->outString(">> Loaded 0 broadcast text locales. DB table `locales_broadcast_text` is empty.");
sLog->outString(">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
sLog->outString();
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint32 id = fields[0].GetUInt32();
std::string LocaleName = fields[1].GetString();
std::string MaleText = fields[2].GetString();
std::string FemaleText = fields[3].GetString();
BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
if (bct == _broadcastTextStore.end())
{
sLog->outErrorDb("BroadcastText (Id: %u) in table `locales_broadcast_text` does not exist. Skipped!", id);
sLog->outErrorDb("BroadcastText (Id: %u) in table `broadcast_text_locale` does not exist. Skipped!", id);
continue;
}
for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i)
{
LocaleConstant locale = LocaleConstant(i);
AddLocaleString(fields[1 + (i - 1)].GetString(), locale, bct->second.MaleText);
AddLocaleString(fields[9 + (i - 1)].GetString(), locale, bct->second.FemaleText);
}
LocaleConstant locale = GetLocaleByName(LocaleName);
if (locale == LOCALE_enUS)
continue;
++count;
AddLocaleString(MaleText, locale, bct->second.MaleText);
AddLocaleString(FemaleText, locale, bct->second.FemaleText);
}
while (result->NextRow());
sLog->outString(">> Loaded %u broadcast text locales in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString(">> Loaded %u Broadcast Text Locales in %u ms", uint32(_broadcastTextStore.size()), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
void ObjectMgr::CheckScripts(ScriptsType type, std::set<int32>& ids)
{
ScriptMapMap* scripts = GetScriptsMapByType(type);
if (!scripts)
return;
for (ScriptMapMap::const_iterator itrMM = scripts->begin(); itrMM != scripts->end(); ++itrMM)
{
for (ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM)
{
switch (itrM->second.command)
{
case SCRIPT_COMMAND_TALK:
{
if (!GetTrinityStringLocale (itrM->second.Talk.TextID))
sLog->outErrorDb("Table `%s` references invalid text id %u from `db_script_string`, script id: %u.", GetScriptsTableNameByType(type).c_str(), itrM->second.Talk.TextID, itrMM->first);
if (ids.find(itrM->second.Talk.TextID) != ids.end())
ids.erase(itrM->second.Talk.TextID);
}
default:
break;
}
}
}
}
void ObjectMgr::LoadDbScriptStrings()
{
LoadTrinityStrings("db_script_string", MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID);
std::set<int32> ids;
for (int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i)
if (GetTrinityStringLocale(i))
ids.insert(i);
for (int type = SCRIPTS_FIRST; type < SCRIPTS_LAST; ++type)
CheckScripts(ScriptsType(type), ids);
for (std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr)
sLog->outErrorDb("Table `db_script_string` has unused string id %u", *itr);
}
bool LoadTrinityStrings(const char* table, int32 start_value, int32 end_value)
{
// 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' load attempted with range (%d - %d) reserved by Trinity, strings not loaded.", table, start_value, end_value+1);
return false;
}
return sObjectMgr->LoadTrinityStrings(table, start_value, end_value);
}
CreatureBaseStats const* ObjectMgr::GetCreatureBaseStats(uint8 level, uint8 unitClass)
{
CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass));