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.cpp117
1 files changed, 52 insertions, 65 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index ab86079bd6e..f094933efd7 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -333,12 +333,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;
@@ -347,19 +343,20 @@ 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;
- for (uint8 i = 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());
+ 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));
}
@@ -422,12 +419,10 @@ void ObjectMgr::LoadCreatureTemplates()
}
_creatureTemplateStore.rehash(result->GetRowCount());
- uint32 count = 0;
do
{
Field* fields = result->Fetch();
LoadCreatureTemplate(fields);
- ++count;
}
while (result->NextRow());
@@ -435,7 +430,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)
@@ -8429,38 +8424,34 @@ 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 (!GetGossipText(gMenu.text_id))
+ if (!GetGossipText(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()
@@ -8470,77 +8461,73 @@ void ObjectMgr::LoadGossipMenuItems()
_gossipMenuItemsStore.clear();
QueryResult result = WorldDatabase.Query(
- // 0 1 2 3 4 5 6 7 8 9 10 11 12
- "SELECT menu_id, id, option_icon, option_text, OptionBroadcastTextID, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text, BoxBroadcastTextID "
- "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)
{
- 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].GetUInt16();
- gMenuItem.OptionIndex = fields[1].GetUInt16();
+ 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.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.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();
+ gMenuItem.BoxBroadcastTextID = fields[12].GetUInt32();
if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX)
{
- TC_LOG_ERROR("sql.sql", "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);
+ TC_LOG_ERROR("sql.sql", "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.OptionBroadcastTextId)
+ if (gMenuItem.OptionBroadcastTextID)
{
- if (!GetBroadcastText(gMenuItem.OptionBroadcastTextId))
+ if (!GetBroadcastText(gMenuItem.OptionBroadcastTextID))
{
- TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %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 menu %u, id %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 menu %u, id %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 menu %u, id %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 menu %u, id %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 menu %u, id %u use non-existing ActionPoiID %u, ignoring", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.ActionPoiID);
+ gMenuItem.ActionPoiID = 0;
}
- if (gMenuItem.BoxBroadcastTextId)
+ if (gMenuItem.BoxBroadcastTextID)
{
- if (!GetBroadcastText(gMenuItem.BoxBroadcastTextId))
+ if (!GetBroadcastText(gMenuItem.BoxBroadcastTextID))
{
- TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %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 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));
- ++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));
}
void ObjectMgr::AddVendorItem(uint32 entry, uint32 item, int32 maxcount, uint32 incrtime, uint32 extendedCost, bool persist /*= true*/)