diff options
-rw-r--r-- | src/common/Utilities/Util.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Chat/Hyperlinks.cpp | 44 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/GossipDef.cpp | 23 | ||||
-rw-r--r-- | src/server/game/Quests/QuestDef.cpp | 3 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 1 | ||||
-rw-r--r-- | src/server/game/World/World.h | 1 | ||||
-rw-r--r-- | src/server/worldserver/worldserver.conf.dist | 20 |
7 files changed, 37 insertions, 57 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 511153200b0..b6066e9505b 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -657,7 +657,7 @@ bool StringEqualI(std::string_view str1, std::string_view str2) bool StringStartsWith(std::string_view haystack, std::string_view needle) { - return (haystack.rfind(needle, 0) == 0); + return (haystack.substr(0, needle.length()) == needle); } bool StringContainsStringI(std::string_view haystack, std::string_view needle) diff --git a/src/server/game/Chat/Hyperlinks.cpp b/src/server/game/Chat/Hyperlinks.cpp index 06fe42b1fb1..3ed3c478077 100644 --- a/src/server/game/Chat/Hyperlinks.cpp +++ b/src/server/game/Chat/Hyperlinks.cpp @@ -174,11 +174,16 @@ struct LinkValidator<LinkTags::quest> { static bool IsTextValid(QuestLinkData const& data, std::string_view text) { - QuestLocale const* locale = sObjectMgr->GetQuestLocale(data.Quest->GetQuestId()); + if (text.empty()) + return false; if (text == data.Quest->GetTitle()) return true; + QuestLocale const* locale = sObjectMgr->GetQuestLocale(data.Quest->GetQuestId()); + if (!locale) + return false; + for (uint8 i = 0; i < TOTAL_LOCALES; ++i) { if (i == DEFAULT_LOCALE) @@ -305,25 +310,32 @@ struct LinkValidator<LinkTags::trade> } }; -#define TryValidateAs(tagname) \ -{ \ - static_assert(LinkTags::tagname::tag() == #tagname); \ - if (info.tag == LinkTags::tagname::tag()) \ - { \ - advstd::remove_cvref_t<typename LinkTags::tagname::value_type> t; \ - if (!LinkTags::tagname::StoreTo(t, info.data)) \ - return false; \ - if (!LinkValidator<LinkTags::tagname>::IsColorValid(t, info.color)) \ - return false; \ - if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY)) \ - if (!LinkValidator<LinkTags::tagname>::IsTextValid(t, info.text)) \ - return false; \ - return true; \ - } \ +template <typename TAG> +static bool ValidateAs(HyperlinkInfo const& info) +{ + std::decay_t<typename TAG::value_type> t; + if (!TAG::StoreTo(t, info.data)) + return false; + + int32 const severity = static_cast<int32>(sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY)); + if (severity >= 0) + { + if (!LinkValidator<TAG>::IsColorValid(t, info.color)) + return false; + if (severity >= 1) + { + if (!LinkValidator<TAG>::IsTextValid(t, info.text)) + return false; + } + } + return true; } +#define TryValidateAs(T) do { if (info.tag == T::tag()) return ValidateAs<T>(info); } while (0); + static bool ValidateLinkInfo(HyperlinkInfo const& info) { + using namespace LinkTags; TryValidateAs(achievement); TryValidateAs(area); TryValidateAs(areatrigger); diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index d5da3361284..3c3b41c728e 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -212,10 +212,6 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) size_t count_pos = data.wpos(); data << uint32(0); // max count 0x20 uint32 count = 0; - - // Store this instead of checking the Singleton every loop iteration - bool questLevelInTitle = sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS); - for (uint8 i = 0; i < _questMenu.GetMenuItemCount(); ++i) { QuestMenuItem const& item = _questMenu.GetItem(i); @@ -235,9 +231,6 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) ObjectMgr::GetLocaleString(localeData->Title, localeConstant, title); - if (questLevelInTitle) - Quest::AddQuestLevelToTitle(title, quest->GetQuestLevel()); - data << title; // max 0x200 } } @@ -351,10 +344,6 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string size_t count_pos = data.wpos(); data << uint8(0); uint32 count = 0; - - // Store this instead of checking the Singleton every loop iteration - bool questLevelInTitle = sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS); - for (uint32 i = 0; i < _questMenu.GetMenuItemCount(); ++i) { QuestMenuItem const& questMenuItem = _questMenu.GetItem(i); @@ -371,9 +360,6 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string if (QuestLocale const* questTemplateLocaleData = sObjectMgr->GetQuestLocale(questID)) ObjectMgr::GetLocaleString(questTemplateLocaleData->Title, localeConstant, title); - if (questLevelInTitle) - Quest::AddQuestLevelToTitle(title, quest->GetQuestLevel()); - data << uint32(questID); data << uint32(questMenuItem.QuestIcon); data << int32(quest->GetQuestLevel()); @@ -418,9 +404,6 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU } } - if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS)) - Quest::AddQuestLevelToTitle(packet.Title, quest->GetQuestLevel()); - packet.QuestGiverGUID = npcGUID; packet.InformUnit = _session->GetPlayer()->GetPlayerSharingQuest(); packet.QuestID = quest->GetQuestId(); @@ -469,9 +452,6 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUI ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, localeConstant, packet.RewardText); } - if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS)) - Quest::AddQuestLevelToTitle(packet.Title, quest->GetQuestLevel()); - packet.QuestGiverGUID = npcGUID; packet.QuestID = quest->GetQuestId(); packet.AutoLaunched = autoLaunched; @@ -512,9 +492,6 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGU return; } - if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS)) - Quest::AddQuestLevelToTitle(questTitle, quest->GetQuestLevel()); - WorldPacket data(SMSG_QUESTGIVER_REQUEST_ITEMS, 50); // guess size data << uint64(npcGUID); data << uint32(quest->GetQuestId()); diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 5c10162a903..ee767d034c2 100644 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -464,9 +464,6 @@ WorldPacket Quest::BuildQueryData(LocaleConstant loc) const response.Info.POIy = GetPOIy(); response.Info.POIPriority = GetPointOpt(); - if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS)) - Quest::AddQuestLevelToTitle(locQuestTitle, GetQuestLevel()); - response.Info.Title = locQuestTitle; response.Info.Objectives = locQuestObjectives; response.Info.Details = locQuestDetails; diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 144b8c9df6a..24abf715fef 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1464,7 +1464,6 @@ void World::LoadConfigSettings(bool reload) // misc m_bool_configs[CONFIG_PDUMP_NO_PATHS] = sConfigMgr->GetBoolDefault("PlayerDump.DisallowPaths", true); m_bool_configs[CONFIG_PDUMP_NO_OVERWRITE] = sConfigMgr->GetBoolDefault("PlayerDump.DisallowOverwrite", true); - m_bool_configs[CONFIG_UI_QUESTLEVELS_IN_DIALOGS] = sConfigMgr->GetBoolDefault("UI.ShowQuestLevelsInDialogs", false); // Wintergrasp battlefield m_bool_configs[CONFIG_WINTERGRASP_ENABLE] = sConfigMgr->GetBoolDefault("Wintergrasp.Enable", false); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index dd8a5ec8ce7..28a064caf8d 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -155,7 +155,6 @@ enum WorldBoolConfigs CONFIG_WARDEN_ENABLED, CONFIG_ENABLE_MMAPS, CONFIG_WINTERGRASP_ENABLE, - CONFIG_UI_QUESTLEVELS_IN_DIALOGS, // Should we add quest levels to the title in the NPC dialogs? CONFIG_EVENT_ANNOUNCE, CONFIG_STATS_LIMITS_ENABLE, CONFIG_INSTANCES_RESET_ANNOUNCE, diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 6f5793c252a..b47272e633a 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -1933,10 +1933,14 @@ ChatFakeMessagePreventing = 1 # # ChatStrictLinkChecking.Severity # Description: Check chat messages for in-game links to spells, items, quests, etc. -# Default: 0 - (Only verify that link format looks valid without checking the text) -# 1 - (Check if color, entry and name don't contradict each other. For this to -# work correctly, please assure that you have extracted locale DBCs of -# every language specific client playing on this server) +# -1 - (Only verify validity of link data, but permit use of custom colors) +# Default: 0 - (Only verify that link data and color are valid without checking text) +# 1 - (Additionally verifies that the link text matches the provided data) +# +# Note: If this is set to '1', you must additionally provide .dbc files for all +# client locales that are in use on your server. +# If any files are missing, messages with links from clients using those +# locales will likely be blocked by the server. ChatStrictLinkChecking.Severity = 0 @@ -3281,14 +3285,6 @@ PlayerDump.DisallowPaths = 1 PlayerDump.DisallowOverwrite = 1 # -# UI.ShowQuestLevelsInDialogs -# Description: Show quest levels next to quest titles in UI dialogs -# Example: [13] Westfall Stew -# Default: 0 - (Do not show) - -UI.ShowQuestLevelsInDialogs = 0 - -# # Calculate.Creature.Zone.Area.Data # Description: Calculate at loading creature zoneId / areaId and save in creature table (WARNING: SLOW WORLD SERVER STARTUP) # Default: 0 - (Do not show) |