mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
feat: resolve random property/suffix names for item display
Load ItemRandomProperties.dbc and ItemRandomSuffix.dbc lazily to resolve suffix names like "of the Eagle", "of the Monkey" etc. Add getRandomPropertyName(id) callback on GameHandler wired through Application. Append suffix to item names in SMSG_ITEM_PUSH_RESULT loot notifications so items display as "Leggings of the Eagle" instead of just "Leggings".
This commit is contained in:
parent
23a7d3718c
commit
4b3e377add
3 changed files with 47 additions and 1 deletions
|
|
@ -294,6 +294,14 @@ public:
|
||||||
return spellIconPathResolver_ ? spellIconPathResolver_(spellId) : std::string{};
|
return spellIconPathResolver_ ? spellIconPathResolver_(spellId) : std::string{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Random property/suffix name resolver: randomPropertyId -> suffix name (e.g., "of the Eagle")
|
||||||
|
// Positive IDs → ItemRandomProperties.dbc; negative IDs → ItemRandomSuffix.dbc (abs value)
|
||||||
|
using RandomPropertyNameResolver = std::function<std::string(int32_t)>;
|
||||||
|
void setRandomPropertyNameResolver(RandomPropertyNameResolver r) { randomPropertyNameResolver_ = std::move(r); }
|
||||||
|
std::string getRandomPropertyName(int32_t id) const {
|
||||||
|
return randomPropertyNameResolver_ ? randomPropertyNameResolver_(id) : std::string{};
|
||||||
|
}
|
||||||
|
|
||||||
// Emote animation callback: (entityGuid, animationId)
|
// Emote animation callback: (entityGuid, animationId)
|
||||||
using EmoteAnimCallback = std::function<void(uint64_t, uint32_t)>;
|
using EmoteAnimCallback = std::function<void(uint64_t, uint32_t)>;
|
||||||
void setEmoteAnimCallback(EmoteAnimCallback cb) { emoteAnimCallback_ = std::move(cb); }
|
void setEmoteAnimCallback(EmoteAnimCallback cb) { emoteAnimCallback_ = std::move(cb); }
|
||||||
|
|
@ -2654,6 +2662,7 @@ private:
|
||||||
AddonChatCallback addonChatCallback_;
|
AddonChatCallback addonChatCallback_;
|
||||||
AddonEventCallback addonEventCallback_;
|
AddonEventCallback addonEventCallback_;
|
||||||
SpellIconPathResolver spellIconPathResolver_;
|
SpellIconPathResolver spellIconPathResolver_;
|
||||||
|
RandomPropertyNameResolver randomPropertyNameResolver_;
|
||||||
EmoteAnimCallback emoteAnimCallback_;
|
EmoteAnimCallback emoteAnimCallback_;
|
||||||
|
|
||||||
// Targeting
|
// Targeting
|
||||||
|
|
|
||||||
|
|
@ -413,6 +413,38 @@ bool Application::initialize() {
|
||||||
return pit->second;
|
return pit->second;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Wire random property/suffix name resolver for item display
|
||||||
|
{
|
||||||
|
auto propNames = std::make_shared<std::unordered_map<int32_t, std::string>>();
|
||||||
|
auto propLoaded = std::make_shared<bool>(false);
|
||||||
|
auto* amPtr = assetManager.get();
|
||||||
|
gameHandler->setRandomPropertyNameResolver([propNames, propLoaded, amPtr](int32_t id) -> std::string {
|
||||||
|
if (!amPtr || id == 0) return {};
|
||||||
|
if (!*propLoaded) {
|
||||||
|
*propLoaded = true;
|
||||||
|
// ItemRandomProperties.dbc: ID=0, Name=4 (string)
|
||||||
|
if (auto dbc = amPtr->loadDBC("ItemRandomProperties.dbc"); dbc && dbc->isLoaded()) {
|
||||||
|
uint32_t nameField = (dbc->getFieldCount() > 4) ? 4 : 1;
|
||||||
|
for (uint32_t r = 0; r < dbc->getRecordCount(); ++r) {
|
||||||
|
int32_t rid = static_cast<int32_t>(dbc->getUInt32(r, 0));
|
||||||
|
std::string name = dbc->getString(r, nameField);
|
||||||
|
if (!name.empty() && rid > 0) (*propNames)[rid] = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ItemRandomSuffix.dbc: ID=0, Name=4 (string) — stored as negative IDs
|
||||||
|
if (auto dbc = amPtr->loadDBC("ItemRandomSuffix.dbc"); dbc && dbc->isLoaded()) {
|
||||||
|
uint32_t nameField = (dbc->getFieldCount() > 4) ? 4 : 1;
|
||||||
|
for (uint32_t r = 0; r < dbc->getRecordCount(); ++r) {
|
||||||
|
int32_t rid = static_cast<int32_t>(dbc->getUInt32(r, 0));
|
||||||
|
std::string name = dbc->getString(r, nameField);
|
||||||
|
if (!name.empty() && rid > 0) (*propNames)[-rid] = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto it = propNames->find(id);
|
||||||
|
return (it != propNames->end()) ? it->second : std::string{};
|
||||||
|
});
|
||||||
|
}
|
||||||
LOG_INFO("Addon system initialized, found ", addonManager_->getAddons().size(), " addon(s)");
|
LOG_INFO("Addon system initialized, found ", addonManager_->getAddons().size(), " addon(s)");
|
||||||
} else {
|
} else {
|
||||||
LOG_WARNING("Failed to initialize addon system");
|
LOG_WARNING("Failed to initialize addon system");
|
||||||
|
|
|
||||||
|
|
@ -1978,7 +1978,7 @@ void GameHandler::handlePacket(network::Packet& packet) {
|
||||||
/*uint32_t itemSlot =*/ packet.readUInt32();
|
/*uint32_t itemSlot =*/ packet.readUInt32();
|
||||||
uint32_t itemId = packet.readUInt32();
|
uint32_t itemId = packet.readUInt32();
|
||||||
/*uint32_t suffixFactor =*/ packet.readUInt32();
|
/*uint32_t suffixFactor =*/ packet.readUInt32();
|
||||||
/*int32_t randomProp =*/ static_cast<int32_t>(packet.readUInt32());
|
int32_t randomProp = static_cast<int32_t>(packet.readUInt32());
|
||||||
uint32_t count = packet.readUInt32();
|
uint32_t count = packet.readUInt32();
|
||||||
/*uint32_t totalCount =*/ packet.readUInt32();
|
/*uint32_t totalCount =*/ packet.readUInt32();
|
||||||
|
|
||||||
|
|
@ -1987,6 +1987,11 @@ void GameHandler::handlePacket(network::Packet& packet) {
|
||||||
if (const ItemQueryResponseData* info = getItemInfo(itemId)) {
|
if (const ItemQueryResponseData* info = getItemInfo(itemId)) {
|
||||||
// Item info already cached — emit immediately.
|
// Item info already cached — emit immediately.
|
||||||
std::string itemName = info->name.empty() ? ("item #" + std::to_string(itemId)) : info->name;
|
std::string itemName = info->name.empty() ? ("item #" + std::to_string(itemId)) : info->name;
|
||||||
|
// Append random suffix name (e.g., "of the Eagle") if present
|
||||||
|
if (randomProp != 0) {
|
||||||
|
std::string suffix = getRandomPropertyName(randomProp);
|
||||||
|
if (!suffix.empty()) itemName += " " + suffix;
|
||||||
|
}
|
||||||
uint32_t quality = info->quality;
|
uint32_t quality = info->quality;
|
||||||
std::string link = buildItemLink(itemId, quality, itemName);
|
std::string link = buildItemLink(itemId, quality, itemName);
|
||||||
std::string msg = "Received: " + link;
|
std::string msg = "Received: " + link;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue