aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp127
1 files changed, 58 insertions, 69 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index c2020bbba10..3761fd2b142 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -353,12 +353,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;
@@ -367,19 +363,21 @@ void ObjectMgr::LoadGossipMenuItemsLocales()
{
Field* fields = result->Fetch();
- uint16 menuId = fields[0].GetUInt16();
- uint16 id = fields[1].GetUInt16();
- GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[MAKE_PAIR32(menuId, id)];
+ 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();
- for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --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());
+ 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);
+ } while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u gossip_menu_option locale strings in %u ms", uint32(_gossipMenuItemsLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
}
@@ -442,12 +440,10 @@ void ObjectMgr::LoadCreatureTemplates()
}
_creatureTemplateStore.rehash(result->GetRowCount());
- uint32 count = 0;
do
{
Field* fields = result->Fetch();
LoadCreatureTemplate(fields);
- ++count;
}
while (result->NextRow());
@@ -455,7 +451,7 @@ void ObjectMgr::LoadCreatureTemplates()
for (CreatureTemplateContainer::const_iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
CheckCreatureTemplate(&itr->second);
- TC_LOG_INFO("server.loading", ">> Loaded %u creature definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+ TC_LOG_INFO("server.loading", ">> Loaded %u creature definitions in %u ms", uint32(_creatureTemplateStore.size()), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadCreatureTemplate(Field* fields)
@@ -8798,38 +8794,35 @@ void ObjectMgr::LoadGossipMenu()
_gossipMenusStore.clear();
- QueryResult result = WorldDatabase.Query("SELECT entry, text_id FROM gossip_menu");
+
+ // 0 1
+ QueryResult result = WorldDatabase.Query("SELECT MenuID, TextID FROM gossip_menu");
if (!result)
{
- TC_LOG_ERROR("server.loading", ">> Loaded 0 gossip_menu entries. DB table `gossip_menu` is empty!");
+ TC_LOG_ERROR("server.loading", ">> Loaded 0 gossip_menu IDs. DB table `gossip_menu` is empty!");
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 (!GetNpcText(gMenu.text_id))
+ if (!GetNpcText(gMenu.TextID))
{
- TC_LOG_ERROR("sql.sql", "Table gossip_menu entry %u are using non-existing text_id %u", gMenu.entry, gMenu.text_id);
+ TC_LOG_ERROR("sql.sql", "Table gossip_menu: ID %u is using non-existing TextID %u", gMenu.MenuID, gMenu.TextID);
continue;
}
- _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.entry, gMenu));
-
- ++count;
- }
- while (result->NextRow());
+ _gossipMenusStore.insert(GossipMenusContainer::value_type(gMenu.MenuID, gMenu));
+ } while (result->NextRow());
- TC_LOG_INFO("server.loading", ">> Loaded %u gossip_menu entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+ TC_LOG_INFO("server.loading", ">> Loaded %u gossip_menu IDs in %u ms", uint32(_gossipMenusStore.size()), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadGossipMenuItems()
@@ -8840,93 +8833,89 @@ void ObjectMgr::LoadGossipMenuItems()
QueryResult result = WorldDatabase.Query(
// 0 1 2 3 4 5 6
- "SELECT o.MenuId, o.OptionIndex, o.OptionIcon, o.OptionText, o.OptionBroadcastTextId, o.OptionType, o.OptionNpcflag, "
+ "SELECT o.MenuID, o.OptionID, o.OptionIcon, o.OptionText, o.OptionBroadcastTextId, o.OptionType, o.OptionNpcflag, "
// 7 8
- "oa.ActionMenuId, oa.ActionPoiId, "
+ "oa.ActionMenuID, oa.ActionPoiID, "
// 9 10 11 12
"ob.BoxCoded, ob.BoxMoney, ob.BoxText, ob.BoxBroadcastTextId, "
// 13
"ot.TrainerId "
"FROM gossip_menu_option o "
- "LEFT JOIN gossip_menu_option_action oa ON o.MenuId = oa.MenuId AND o.OptionIndex = oa.OptionIndex "
- "LEFT JOIN gossip_menu_option_box ob ON o.MenuId = ob.MenuId AND o.OptionIndex = ob.OptionIndex "
- "LEFT JOIN gossip_menu_option_trainer ot ON o.MenuId = ot.MenuId AND o.OptionIndex = ot.OptionIndex "
- "ORDER BY o.MenuId, o.OptionIndex");
+ "LEFT JOIN gossip_menu_option_action oa ON o.MenuID = oa.MenuID AND o.OptionID = oa.OptionID "
+ "LEFT JOIN gossip_menu_option_box ob ON o.MenuID = ob.MenuID AND o.OptionID = ob.OptionID "
+ "LEFT JOIN gossip_menu_option_trainer ot ON o.MenuID = ot.MenuID AND o.OptionID = ot.OptionID "
+ "ORDER BY o.MenuId, o.OptionID");
if (!result)
{
- TC_LOG_ERROR("server.loading", ">> Loaded 0 gossip_menu_option entries. DB table `gossip_menu_option` is empty!");
+ TC_LOG_ERROR("server.loading", ">> Loaded 0 gossip_menu_option IDs. DB table `gossip_menu_option` is empty!");
return;
}
- uint32 count = 0;
-
do
{
Field* fields = result->Fetch();
GossipMenuItems gMenuItem;
- gMenuItem.MenuId = fields[0].GetUInt32();
- gMenuItem.OptionIndex = fields[1].GetUInt32();
+ gMenuItem.MenuID = fields[0].GetUInt32();
+ gMenuItem.OptionID = fields[1].GetUInt32();
gMenuItem.OptionIcon = fields[2].GetUInt8();
gMenuItem.OptionText = fields[3].GetString();
- gMenuItem.OptionBroadcastTextId = fields[4].GetUInt32();
+ gMenuItem.OptionBroadcastTextID = fields[4].GetUInt32();
gMenuItem.OptionType = fields[5].GetUInt32();
- gMenuItem.OptionNpcflag = fields[6].GetUInt64();
- gMenuItem.ActionMenuId = fields[7].GetUInt32();
- gMenuItem.ActionPoiId = fields[8].GetUInt32();
+ gMenuItem.OptionNpcFlag = fields[6].GetUInt64();
+ 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();
+ gMenuItem.BoxBroadcastTextID = fields[12].GetUInt32();
gMenuItem.TrainerId = fields[13].GetUInt32();
if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
{
- TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuId %u, OptionIndex %u has unknown icon id %u. Replacing with GOSSIP_ICON_CHAT", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionIcon);
+ TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuId %u, OptionID %u has unknown icon id %u. Replacing with GOSSIP_ICON_CHAT", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionIcon);
gMenuItem.OptionIcon = GOSSIP_ICON_CHAT;
}
- if (gMenuItem.OptionBroadcastTextId)
+ if (gMenuItem.OptionBroadcastTextID)
{
- if (!sBroadcastTextStore.LookupEntry(gMenuItem.OptionBroadcastTextId))
+ if (!sBroadcastTextStore.LookupEntry(gMenuItem.OptionBroadcastTextID))
{
- TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuId %u, OptionIndex %u has non-existing or incompatible OptionBroadcastTextId %u, ignoring.", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionBroadcastTextId);
- gMenuItem.OptionBroadcastTextId = 0;
+ TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuId %u, OptionID %u has non-existing or incompatible OptionBroadcastTextID %u, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID);
+ gMenuItem.OptionBroadcastTextID = 0;
}
}
if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX)
- TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuId %u, OptionIndex %u has unknown option id %u. Option will not be used", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionType);
+ TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuID %u, OptionID %u has unknown option id %u. Option will not be used", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionType);
- if (gMenuItem.ActionPoiId && !GetPointOfInterest(gMenuItem.ActionPoiId))
+ if (gMenuItem.ActionPoiID && !GetPointOfInterest(gMenuItem.ActionPoiID))
{
- TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuId %u, OptionIndex %u use non-existing action_poi_id %u, ignoring", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.ActionPoiId);
- gMenuItem.ActionPoiId = 0;
+ TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuID %u, OptionID %u use non-existing action_poi_id %u, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
+ gMenuItem.ActionPoiID = 0;
}
- if (gMenuItem.BoxBroadcastTextId)
+ if (gMenuItem.BoxBroadcastTextID)
{
- if (!sBroadcastTextStore.LookupEntry(gMenuItem.BoxBroadcastTextId))
+ if (!sBroadcastTextStore.LookupEntry(gMenuItem.BoxBroadcastTextID))
{
- TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuId %u, OptionIndex %u has non-existing or incompatible BoxBroadcastTextId %u, ignoring.", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.BoxBroadcastTextId);
- gMenuItem.BoxBroadcastTextId = 0;
+ TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for MenuId %u, OptionID %u has non-existing or incompatible BoxBroadcastTextId %u, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID);
+ gMenuItem.BoxBroadcastTextID = 0;
}
}
if (gMenuItem.TrainerId && !GetTrainer(gMenuItem.TrainerId))
{
- TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option_trainer` for MenuId %u, OptionIndex %u use non-existing TrainerId %u, ignoring", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.TrainerId);
+ TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option_trainer` for MenuId %u, OptionIndex %u use non-existing TrainerId %u, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.TrainerId);
gMenuItem.TrainerId = 0;
}
- _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuId, gMenuItem));
- ++count;
- }
- while (result->NextRow());
+ _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem));
+ } while (result->NextRow());
- TC_LOG_INFO("server.loading", ">> Loaded %u gossip_menu_option entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+ TC_LOG_INFO("server.loading", ">> Loaded %u gossip_menu_option entries in %u ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime));
}
Trainer::Trainer const* ObjectMgr::GetTrainer(uint32 trainerId) const