diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-09-01 22:02:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-01 22:02:22 +0200 |
commit | d0b91f69279a823be159590c09945bc426f50d3e (patch) | |
tree | 1545fbeca0c4e86c3b3db22fe8a46f4b466afcde /src/server/game/Chat/Hyperlinks.cpp | |
parent | 3fbbe7cfbe1bc51db12bdc1ec7b21c16d1716366 (diff) |
Core/Misc: More DBC std::array refactors, stricter |Hitem checks, and more hyperlink unit tests
Diffstat (limited to 'src/server/game/Chat/Hyperlinks.cpp')
-rw-r--r-- | src/server/game/Chat/Hyperlinks.cpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/server/game/Chat/Hyperlinks.cpp b/src/server/game/Chat/Hyperlinks.cpp index 308ec33d46d..8b82cb1e38c 100644 --- a/src/server/game/Chat/Hyperlinks.cpp +++ b/src/server/game/Chat/Hyperlinks.cpp @@ -132,21 +132,11 @@ struct LinkValidator<LinkTags::item> { ItemLocale const* locale = sObjectMgr->GetItemLocale(data.Item->ItemId); - char const* const* randomSuffixes = nullptr; // this is a c-style array of c strings (and i don't want to touch DBCStructure.h right now) - if (data.RandomPropertyId < 0) - { - if (ItemRandomSuffixEntry const* suffixEntry = sItemRandomSuffixStore.LookupEntry(-data.RandomPropertyId)) - randomSuffixes = suffixEntry->Name; - else - return false; - } - else if (data.RandomPropertyId > 0) - { - if (ItemRandomPropertiesEntry const* propEntry = sItemRandomPropertiesStore.LookupEntry(data.RandomPropertyId)) - randomSuffixes = propEntry->Name; - else - return false; - } + std::array<char const*, 16> const* randomSuffixes = nullptr; + if (data.RandomProperty) + randomSuffixes = &data.RandomProperty->Name; + else if (data.RandomSuffix) + randomSuffixes = &data.RandomSuffix->Name; for (uint8 i = 0; i < TOTAL_LOCALES; ++i) { @@ -157,8 +147,9 @@ struct LinkValidator<LinkTags::item> continue; if (randomSuffixes) { - std::string_view randomSuffix(randomSuffixes[i]); + std::string_view randomSuffix((*randomSuffixes)[i]); if ( + (!randomSuffix.empty()) && (text.length() == (name.length() + 1 + randomSuffix.length())) && (text.substr(0, name.length()) == name) && (text[name.length()] == ' ') && |