fix(Core/Chat): accept uppercase link colors and the 'found' tag (#27580)

Co-authored-by: bashermens <[email protected]>
Co-authored-by: sudlud <[email protected]>
This commit is contained in:
Keleborn
2026-09-11 12:53:45 +02:00
committed by GitHub
co-authored by bashermens sudlud
parent dbacb5bb1b
commit 527e91b9b2
3 changed files with 52 additions and 1 deletions
+10
View File
@@ -259,3 +259,13 @@ bool Acore::Hyperlinks::LinkTags::trade::StoreTo(TradeskillLinkData& val, std::s
return (val.Spell && val.Spell->Effects[0].Effect == SPELL_EFFECT_TRADE_SKILL && t.TryConsumeTo(val.CurValue) &&
t.TryConsumeTo(val.MaxValue) && t.TryConsumeTo(val.Owner) && t.TryConsumeTo(val.KnownRecipes) && t.IsEmpty());
}
bool Acore::Hyperlinks::LinkTags::found::StoreTo(FoundLinkData& val, std::string_view text)
{
// format is "<rawguid>:<entry>:"
if (!text.ends_with(HYPERLINK_DATA_DELIMITER))
return false;
HyperlinkDataTokenizer t(text);
return t.TryConsumeTo(val.RawGuid) && t.TryConsumeTo(val.Entry) && t.IsEmpty();
}
+28 -1
View File
@@ -27,7 +27,19 @@
using namespace Acore::Hyperlinks;
inline uint8 toHex(char c) { return (c >= '0' && c <= '9') ? c - '0' + 0x10 : (c >= 'a' && c <= 'f') ? c - 'a' + 0x1a : 0x00; }
inline uint8 toHex(char c)
{
if (c >= '0' && c <= '9')
return c - '0' + 0x10;
if (c >= 'a' && c <= 'f')
return c - 'a' + 0x1a;
if (c >= 'A' && c <= 'F')
return c - 'A' + 0x1a;
return 0x00;
}
// Validates a single hyperlink
HyperlinkInfo Acore::Hyperlinks::ParseSingleHyperlink(std::string_view str)
@@ -323,6 +335,20 @@ struct LinkValidator<LinkTags::trade>
}
};
template <>
struct LinkValidator<LinkTags::found>
{
static bool IsTextValid(FoundLinkData const&, std::string_view text)
{
return !text.empty();
}
static bool IsColorValid(FoundLinkData const&, HyperlinkColor c)
{
return c == CHAT_LINK_COLOR_ACHIEVEMENT; // 0xffffff00 - yellow
}
};
template <typename TAG>
static bool ValidateAs(HyperlinkInfo const& info)
{
@@ -356,6 +382,7 @@ static bool ValidateLinkInfo(HyperlinkInfo const& info)
TryValidateAs(creature);
TryValidateAs(creature_entry);
TryValidateAs(enchant);
TryValidateAs(found);
TryValidateAs(gameevent);
TryValidateAs(gameobject);
TryValidateAs(gameobject_entry);
+14
View File
@@ -87,6 +87,13 @@ namespace Acore::Hyperlinks
std::string KnownRecipes;
};
// "found" link: |cffffff00|Hfound:<rawguid>:<entry>:|h[name]|h|r - a world object, shift-clicked back as a command
struct FoundLinkData
{
uint64 RawGuid;
uint32 Entry;
};
namespace LinkTags
{
@@ -170,6 +177,13 @@ namespace Acore::Hyperlinks
static bool StoreTo(SpellInfo const*& val, std::string_view data);
};
struct AC_GAME_API found
{
using value_type = FoundLinkData const&;
static constexpr std::string_view tag() { return "found"; }
static bool StoreTo(FoundLinkData& val, std::string_view data);
};
struct AC_GAME_API glyph
{
using value_type = GlyphLinkData const&;