mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40: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
|
|
@ -413,6 +413,38 @@ bool Application::initialize() {
|
|||
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)");
|
||||
} else {
|
||||
LOG_WARNING("Failed to initialize addon system");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue