From 6d25d89e2bc930184b196ae4080d56cf93531e6d Mon Sep 17 00:00:00 2001 From: Aokromes Date: Tue, 18 Apr 2017 14:11:21 +0200 Subject: [PATCH] Core/Misc: Sync database schema with master --- .../world/4.3.4/2017_04_18_00_world.sql | 86 ++++++++++++++++ .../game/Achievements/AchievementMgr.cpp | 8 +- .../game/AuctionHouse/AuctionHouseMgr.cpp | 6 +- src/server/game/Entities/Creature/Creature.h | 2 +- .../game/Entities/Creature/GossipDef.cpp | 98 +++++++++---------- src/server/game/Entities/Player/Player.cpp | 18 ++-- src/server/game/Globals/ObjectMgr.cpp | 58 ++++++----- src/server/game/Globals/ObjectMgr.h | 14 +-- src/server/game/Handlers/QueryHandler.cpp | 8 +- 9 files changed, 195 insertions(+), 103 deletions(-) create mode 100644 sql/updates/world/4.3.4/2017_04_18_00_world.sql diff --git a/sql/updates/world/4.3.4/2017_04_18_00_world.sql b/sql/updates/world/4.3.4/2017_04_18_00_world.sql new file mode 100644 index 00000000000..fdc9f454de1 --- /dev/null +++ b/sql/updates/world/4.3.4/2017_04_18_00_world.sql @@ -0,0 +1,86 @@ +-- +DROP TABLE IF EXISTS `points_of_interest_locale`; +CREATE TABLE IF NOT EXISTS `points_of_interest_locale` ( + `ID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0', + `locale` VARCHAR(4) NOT NULL, + `Name` TEXT, + `VerifiedBuild` SMALLINT(5) DEFAULT '0', + PRIMARY KEY (`ID`, `locale`) +) ENGINE=MYISAM DEFAULT CHARSET=utf8; + +-- koKR +INSERT INTO `points_of_interest_locale` (`ID`, `locale`, `Name`) + (SELECT `entry`, "koKR", `icon_name_loc1` FROM `locales_points_of_interest` WHERE LENGTH(Name_loc1) > 0); + +-- frFR +INSERT INTO `points_of_interest_locale` (`ID`, `locale`, `Name`) + (SELECT `entry`, "frFR", `icon_name_loc2` FROM `locales_points_of_interest` WHERE LENGTH(Name_loc2) > 0); + +-- deDE +INSERT INTO `points_of_interest_locale` (`ID`, `locale`, `Name`) + (SELECT `entry`, "deDE", `icon_name_loc3` FROM `locales_points_of_interest` WHERE LENGTH(Name_loc3) > 0); + +-- zhCN +INSERT INTO `points_of_interest_locale` (`ID`, `locale`, `Name`) + (SELECT `entry`, "zhCN", `icon_name_loc4` FROM `locales_points_of_interest` WHERE LENGTH(Name_loc4) > 0); + +-- zhTW +INSERT INTO `points_of_interest_locale` (`ID`, `locale`, `Name`) + (SELECT `entry`, "zhTW", `icon_name_loc5` FROM `locales_points_of_interest` WHERE LENGTH(Name_loc5) > 0); + +-- esES +INSERT INTO `points_of_interest_locale` (`ID`, `locale`, `Name`) + (SELECT `entry`, "esES", `icon_name_loc6` FROM `locales_points_of_interest` WHERE LENGTH(Name_loc6) > 0); + +-- esMX +INSERT INTO `points_of_interest_locale` (`ID`, `locale`, `Name`) + (SELECT `entry`, "esMX", `icon_name_loc7` FROM `locales_points_of_interest` WHERE LENGTH(Name_loc7) > 0); + +-- ruRU +INSERT INTO `points_of_interest_locale` (`ID`, `locale`, `Name`) + (SELECT `entry`, "ruRU", `icon_name_loc8` FROM `locales_points_of_interest` WHERE LENGTH(Name_loc8) > 0); + +DROP TABLE IF EXISTS `locales_points_of_interest`; + +DROP TABLE IF EXISTS `page_text_locale`; +CREATE TABLE IF NOT EXISTS `page_text_locale` ( + `ID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0', + `locale` VARCHAR(4) NOT NULL, + `Text` TEXT, + `VerifiedBuild` SMALLINT(5) DEFAULT '0', + PRIMARY KEY (`ID`, `locale`) +) ENGINE=MYISAM DEFAULT CHARSET=utf8; + +-- koKR +INSERT INTO `page_text_locale` (`ID`, `locale`, `Text`) + (SELECT `entry`, "koKR", `text_loc1` FROM `locales_page_text` WHERE LENGTH(Text_loc1) > 0); + +-- frFR +INSERT INTO `page_text_locale` (`ID`, `locale`, `Text`) + (SELECT `entry`, "frFR", `text_loc2` FROM `locales_page_text` WHERE LENGTH(Text_loc2) > 0); + +-- deDE +INSERT INTO `page_text_locale` (`ID`, `locale`, `Text`) + (SELECT `entry`, "deDE", `text_loc3` FROM `locales_page_text` WHERE LENGTH(Text_loc3) > 0); + +-- zhCN +INSERT INTO `page_text_locale` (`ID`, `locale`, `Text`) + (SELECT `entry`, "zhCN", `text_loc4` FROM `locales_page_text` WHERE LENGTH(Text_loc4) > 0); + +-- zhTW +INSERT INTO `page_text_locale` (`ID`, `locale`, `Text`) + (SELECT `entry`, "zhTW", `text_loc5` FROM `locales_page_text` WHERE LENGTH(Text_loc5) > 0); + +-- esES +INSERT INTO `page_text_locale` (`ID`, `locale`, `Text`) + (SELECT `entry`, "esES", `text_loc6` FROM `locales_page_text` WHERE LENGTH(Text_loc6) > 0); + +-- esMX +INSERT INTO `page_text_locale` (`ID`, `locale`, `Text`) + (SELECT `entry`, "esMX", `text_loc7` FROM `locales_page_text` WHERE LENGTH(Text_loc7) > 0); + +-- ruRU +INSERT INTO `page_text_locale` (`ID`, `locale`, `Text`) + (SELECT `entry`, "ruRU", `text_loc8` FROM `locales_page_text` WHERE LENGTH(Text_loc8) > 0); + +DROP TABLE IF EXISTS `locales_page_text`; diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 01a2c76c006..a0fc2983244 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -1977,13 +1977,13 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achiev std::string subject = reward->subject; std::string text = reward->text; - int locIdx = GetOwner()->GetSession()->GetSessionDbLocaleIndex(); - if (locIdx >= 0) + LocaleConstant localeConstant = GetOwner()->GetSession()->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_enUS) { if (AchievementRewardLocale const* loc = sAchievementMgr->GetAchievementRewardLocale(achievement)) { - ObjectMgr::GetLocaleString(loc->subject, locIdx, subject); - ObjectMgr::GetLocaleString(loc->text, locIdx, text); + ObjectMgr::GetLocaleString(loc->subject, localeConstant, subject); + ObjectMgr::GetLocaleString(loc->text, localeConstant, text); } } diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 3c9a7257b4f..f4fbb36e9c6 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -684,7 +684,7 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool getall) { - int loc_idx = player->GetSession()->GetSessionDbLocaleIndex(); + LocaleConstant localeConstant = player->GetSession()->GetSessionDbLocaleIndex(); int locdbc_idx = player->GetSession()->GetSessionDbcLocale(); time_t curTime = GameTime::GetGameTime(); @@ -756,9 +756,9 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player continue; // local name - if (loc_idx >= 0) + if (localeConstant >= LOCALE_ENUS) if (ItemLocale const* il = sObjectMgr->GetItemLocale(proto->ItemId)) - ObjectMgr::GetLocaleString(il->Name, loc_idx, name); + ObjectMgr::GetLocaleString(il->Name, localeConstant, name); // DO NOT use GetItemEnchantMod(proto->RandomProperty) as it may return a result // that matches the search but it may not equal item->GetItemRandomPropertyId() diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 69774053a43..789f2fe64d5 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -253,7 +253,7 @@ struct GossipMenuItemsLocale struct PointOfInterestLocale { - StringVector IconName; + StringVector Name; }; #define MAX_EQUIPMENT_ITEMS 3 diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index b751e101894..b223c48ab28 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -228,10 +228,10 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation std::string title = quest->GetTitle(); - int32 locale = _session->GetSessionDbLocaleIndex(); - if (locale >= 0) + LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) - ObjectMgr::GetLocaleString(localeData->Title, locale, title); + ObjectMgr::GetLocaleString(localeData->Title, localeConstant, title); if (questLevelInTitle) AddQuestLevelToTitle(title, quest->GetQuestLevel()); @@ -252,20 +252,20 @@ void PlayerMenu::SendCloseGossip() _session->SendPacket(&data); } -void PlayerMenu::SendPointOfInterest(uint32 poiId) const +void PlayerMenu::SendPointOfInterest(uint32 id) const { - PointOfInterest const* poi = sObjectMgr->GetPointOfInterest(poiId); + PointOfInterest const* poi = sObjectMgr->GetPointOfInterest(id); if (!poi) { - TC_LOG_ERROR("sql.sql", "Request to send non-existing POI (Id: %u), ignored.", poiId); + TC_LOG_ERROR("sql.sql", "Request to send non-existing POI (Id: %u), ignored.", id); return; } - std::string iconText = poi->Name; - int32 locale = _session->GetSessionDbLocaleIndex(); - if (locale >= 0) - if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(poiId)) - ObjectMgr::GetLocaleString(localeData->IconName, locale, iconText); + std::string name = poi->Name; + LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) + if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(id)) + ObjectMgr::GetLocaleString(localeData->Name, localeConstant, name); WorldPacket data(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 10); // guess size data << uint32(poi->Flags); @@ -273,7 +273,7 @@ void PlayerMenu::SendPointOfInterest(uint32 poiId) const data << float(poi->PositionY); data << uint32(poi->Icon); data << uint32(poi->Importance); - data << iconText; + data << name; _session->SendPacket(&data); } @@ -347,10 +347,10 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string ++count; std::string title = quest->GetTitle(); - int32 locale = _session->GetSessionDbLocaleIndex(); - if (locale >= 0) + LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) - ObjectMgr::GetLocaleString(localeData->Title, locale, title); + ObjectMgr::GetLocaleString(localeData->Title, localeConstant, title); if (questLevelInTitle) AddQuestLevelToTitle(title, quest->GetQuestLevel()); @@ -390,19 +390,19 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU std::string questTurnTextWindow = quest->GetQuestTurnTextWindow(); std::string questTurnTargetName = quest->GetQuestTurnTargetName(); - int32 locale = _session->GetSessionDbLocaleIndex(); - if (locale >= 0) + LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) { - ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle); - ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails); - ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives); - ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription); - ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, locale, questGiverTextWindow); - ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, locale, questGiverTargetName); - ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, locale, questTurnTextWindow); - ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, locale, questTurnTargetName); + ObjectMgr::GetLocaleString(localeData->Title, localeConstant, questTitle); + ObjectMgr::GetLocaleString(localeData->Details, localeConstant, questDetails); + ObjectMgr::GetLocaleString(localeData->Objectives, localeConstant, questObjectives); + ObjectMgr::GetLocaleString(localeData->AreaDescription, localeConstant, questAreaDescription); + ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, localeConstant, questGiverTextWindow); + ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, localeConstant, questGiverTargetName); + ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, localeConstant, questTurnTextWindow); + ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, localeConstant, questTurnTargetName); } } @@ -458,23 +458,23 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) questObjectiveText[i] = quest->ObjectiveText[i]; - int32 locale = _session->GetSessionDbLocaleIndex(); - if (locale >= 0) + LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) { - ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle); - ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails); - ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives); - ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription); - ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText); - ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, locale, questGiverTextWindow); - ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, locale, questGiverTargetName); - ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, locale, questTurnTextWindow); - ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, locale, questTurnTargetName); + ObjectMgr::GetLocaleString(localeData->Title, localeConstant, questTitle); + ObjectMgr::GetLocaleString(localeData->Details, localeConstant, questDetails); + ObjectMgr::GetLocaleString(localeData->Objectives, localeConstant, questObjectives); + ObjectMgr::GetLocaleString(localeData->AreaDescription, localeConstant, questAreaDescription); + ObjectMgr::GetLocaleString(localeData->CompletedText, localeConstant, questCompletedText); + ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, localeConstant, questGiverTextWindow); + ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, localeConstant, questGiverTargetName); + ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, localeConstant, questTurnTextWindow); + ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, localeConstant, questTurnTargetName); for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]); + ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], localeConstant, questObjectiveText[i]); } } @@ -622,17 +622,17 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUI std::string questTurnTextWindow = quest->GetQuestTurnTextWindow(); std::string questTurnTargetName = quest->GetQuestTurnTargetName(); - int32 locale = _session->GetSessionDbLocaleIndex(); - if (locale >= 0) + LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) { - ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle); - ObjectMgr::GetLocaleString(localeData->OfferRewardText, locale, questOfferRewardText); - ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, locale, questGiverTextWindow); - ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, locale, questGiverTargetName); - ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, locale, questTurnTextWindow); - ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, locale, questTurnTargetName); + ObjectMgr::GetLocaleString(localeData->Title, localeConstant, questTitle); + ObjectMgr::GetLocaleString(localeData->OfferRewardText, localeConstant, questOfferRewardText); + ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, localeConstant, questGiverTextWindow); + ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, localeConstant, questGiverTargetName); + ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, localeConstant, questTurnTextWindow); + ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, localeConstant, questTurnTargetName); } } @@ -685,13 +685,13 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGU std::string questTitle = quest->GetTitle(); std::string requestItemsText = quest->GetRequestItemsText(); - int32 locale = _session->GetSessionDbLocaleIndex(); - if (locale >= 0) + LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) { - ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle); - ObjectMgr::GetLocaleString(localeData->RequestItemsText, locale, requestItemsText); + ObjectMgr::GetLocaleString(localeData->Title, localeConstant, questTitle); + ObjectMgr::GetLocaleString(localeData->RequestItemsText, localeConstant, requestItemsText); } } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a11566e1ade..34d7d4937fe 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -14632,19 +14632,19 @@ void Player::SendPreparedQuest(ObjectGuid guid) { title = gossiptext->Options[0].Text_0; - int loc_idx = GetSession()->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) + LocaleConstant localeConstant = GetSession()->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) if (NpcTextLocale const* nl = sObjectMgr->GetNpcTextLocale(textid)) - ObjectMgr::GetLocaleString(nl->Text_0[0], loc_idx, title); + ObjectMgr::GetLocaleString(nl->Text_0[0], localeConstant, title); } else { title = gossiptext->Options[0].Text_1; - int loc_idx = GetSession()->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) + LocaleConstant localeConstant = GetSession()->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) if (NpcTextLocale const* nl = sObjectMgr->GetNpcTextLocale(textid)) - ObjectMgr::GetLocaleString(nl->Text_1[0], loc_idx, title); + ObjectMgr::GetLocaleString(nl->Text_1[0], localeConstant, title); } } } @@ -16813,10 +16813,10 @@ void Player::SendQuestConfirmAccept(const Quest* quest, Player* pReceiver) const { std::string strTitle = quest->GetTitle(); - int loc_idx = pReceiver->GetSession()->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) + LocaleConstant localeConstant = pReceiver->GetSession()->GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) if (const QuestLocale* pLocale = sObjectMgr->GetQuestLocale(quest->GetQuestId())) - ObjectMgr::GetLocaleString(pLocale->Title, loc_idx, strTitle); + ObjectMgr::GetLocaleString(pLocale->Title, localeConstant, strTitle); WorldPacket data(SMSG_QUEST_CONFIRM_ACCEPT, (4 + strTitle.size() + 8)); data << uint32(quest->GetQuestId()); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 96c19e5b56c..75a8c602b20 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -276,14 +276,14 @@ ObjectMgr::~ObjectMgr() delete itr->second; } -void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data) +void ObjectMgr::AddLocaleString(std::string const& value, LocaleConstant localeConstant, StringVector& data) { - if (!s.empty()) + if (!value.empty()) { - if (data.size() <= size_t(locale)) - data.resize(locale + 1); + if (data.size() <= size_t(localeConstant)) + data.resize(localeConstant + 1); - data[locale] = s; + data[localeConstant] = value; } } @@ -394,7 +394,8 @@ void ObjectMgr::LoadPointOfInterestLocales() _pointOfInterestLocaleStore.clear(); // need for reload case - QueryResult result = WorldDatabase.Query("SELECT ID, Name_loc1, Name_loc2, Name_loc3, Name_loc4, Name_loc5, Name_loc6, Name_loc7, 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; @@ -403,12 +404,14 @@ 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); - for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --i) - AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.IconName); + AddLocaleString(name, locale, data.Name); } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u points_of_interest locale strings in %u ms", uint32(_pointOfInterestLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); @@ -5432,7 +5435,8 @@ void ObjectMgr::LoadPageTextLocales() _pageTextLocaleStore.clear(); // needed for reload case - QueryResult result = WorldDatabase.Query("SELECT ID, 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; @@ -5441,12 +5445,14 @@ 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); - for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --i) - AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Text); + AddLocaleString(text, locale, data.Text); } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u PageText locale strings in %u ms", uint32(_pageTextLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); @@ -7422,24 +7428,24 @@ void ObjectMgr::LoadPointsOfInterest() { Field* fields = result->Fetch(); - uint32 point_id = fields[0].GetUInt32(); + uint32 id = fields[0].GetUInt32(); - PointOfInterest POI; - POI.ID = point_id; - POI.PositionX = fields[1].GetFloat(); - POI.PositionY = fields[2].GetFloat(); - POI.Icon = fields[3].GetUInt32(); - POI.Flags = fields[4].GetUInt32(); - POI.Importance = fields[5].GetUInt32(); - POI.Name = fields[6].GetString(); + PointOfInterest pointOfInterest; + pointOfInterest.ID = id; + pointOfInterest.PositionX = fields[1].GetFloat(); + pointOfInterest.PositionY = fields[2].GetFloat(); + pointOfInterest.Icon = fields[3].GetUInt32(); + pointOfInterest.Flags = fields[4].GetUInt32(); + pointOfInterest.Importance = fields[5].GetUInt32(); + pointOfInterest.Name = fields[6].GetString(); - if (!Trinity::IsValidMapCoord(POI.PositionX, POI.PositionY)) + if (!Trinity::IsValidMapCoord(pointOfInterest.PositionX, pointOfInterest.PositionY)) { TC_LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: %u) have invalid coordinates (PositionX: %f PositionY: %f), ignored.", point_id, POI.PositionX, POI.PositionY); continue; } - _pointsOfInterestStore[point_id] = POI; + _pointsOfInterestStore[id] = pointOfInterest; ++count; } while (result->NextRow()); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 12cd2a1982a..e9f0c9d8bae 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -1062,7 +1062,7 @@ class TC_GAME_API ObjectMgr void LoadVendors(); void LoadTrainerSpell(); - void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 Index); + void AddSpellToTrainer(uint32 ID, uint32 SpellID, uint32 MoneyCost, uint32 ReqSkillLine, uint32 ReqSkillRank, uint32 ReqLevel, uint32 Index); void LoadTerrainPhaseInfo(); void LoadTerrainSwapDefaults(); @@ -1210,9 +1210,9 @@ class TC_GAME_API ObjectMgr if (itr == _gossipMenuItemsLocaleStore.end()) return nullptr; return &itr->second; } - PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const + PointOfInterestLocale const* GetPointOfInterestLocale(uint32 id) const { - PointOfInterestLocaleContainer::const_iterator itr = _pointOfInterestLocaleStore.find(poi_id); + PointOfInterestLocaleContainer::const_iterator itr = _pointOfInterestLocaleStore.find(id); if (itr == _pointOfInterestLocaleStore.end()) return nullptr; return &itr->second; } @@ -1362,11 +1362,11 @@ class TC_GAME_API ObjectMgr // for wintergrasp only GraveYardContainer GraveYardStore; - static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data); - static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value) + static void AddLocaleString(std::string const& value, LocaleConstant localeConstant, StringVector& data); + static inline void GetLocaleString(const StringVector const& data, LocaleConstant localeConstant, std::string& value) { - if (data.size() > size_t(loc_idx) && !data[loc_idx].empty()) - value = data[loc_idx]; + if (data.size() > size_t(localeConstant) && !data[localeConstant].empty()) + value = data[localeConstant]; } CharacterConversionMap FactionChangeAchievements; diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index 76d3ce21fbd..35fdeff32c6 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -396,10 +396,10 @@ void WorldSession::HandlePageTextQueryOpcode(WorldPacket& recvData) { std::string Text = pageText->Text; - int loc_idx = GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - if (PageTextLocale const* player = sObjectMgr->GetPageTextLocale(pageID)) - ObjectMgr::GetLocaleString(player->Text, loc_idx, Text); + LocaleConstant localeConstant = GetSessionDbLocaleIndex(); + if (localeConstant >= LOCALE_ENUS) + if (PageTextLocale const* pageTextLocale = sObjectMgr->GetPageTextLocale(pageID)) + ObjectMgr::GetLocaleString(pageTextLocale->Text, localeConstant, Text); data << Text; data << uint32(pageText->NextPageID);