mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-03 20:03:50 +00:00
refactor: consolidate buildItemLink into game_utils.hpp
Three identical copies (game_handler.cpp, spell_handler.cpp, quest_handler.cpp) plus two forward declarations (inventory_handler.cpp, social_handler.cpp) replaced with a single inline definition in game_utils.hpp. All affected files already include this header, so quality color table changes now propagate from one source of truth.
This commit is contained in:
parent
0aff4b155c
commit
dc500fede9
5 changed files with 20 additions and 43 deletions
|
|
@ -23,5 +23,25 @@ inline bool isPreWotlk() {
|
|||
return isClassicLikeExpansion() || isActiveExpansion("tbc");
|
||||
}
|
||||
|
||||
// Shared item link formatter used by inventory, quest, spell, and social handlers.
|
||||
// Centralised here so quality color table changes propagate everywhere.
|
||||
inline std::string buildItemLink(uint32_t itemId, uint32_t quality, const std::string& name) {
|
||||
static const char* kQualHex[] = {
|
||||
"9d9d9d", // 0 Poor
|
||||
"ffffff", // 1 Common
|
||||
"1eff00", // 2 Uncommon
|
||||
"0070dd", // 3 Rare
|
||||
"a335ee", // 4 Epic
|
||||
"ff8000", // 5 Legendary
|
||||
"e6cc80", // 6 Artifact
|
||||
"e6cc80", // 7 Heirloom
|
||||
};
|
||||
uint32_t qi = quality < 8 ? quality : 1u;
|
||||
char buf[512];
|
||||
snprintf(buf, sizeof(buf), "|cff%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r",
|
||||
kQualHex[qi], itemId, name.c_str());
|
||||
return buf;
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
} // namespace wowee
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue