Created by: yohjimane
Fixes issue 1359
The root issue is this function:
attachable_hud_item* player_hud::create_hud_item(const shared_str& sect)
{
auto& item = m_pool[sect]; // each key in m_pool is set to hud_sect. These are not unique.
if (!item) // If equipped item 1 hud_sect == equipped item 2 hud_sect, the line below is not called, causing the bug.
item = xr_new<attachable_hud_item>(this, sect, m_model);
return item;
}
The fix:
- Add instance id
m_inst_id
to CHudItem, which gets incremented any time a new item gets loaded. - Add
m_unique_hud_sect
to CHudItem, which =hud_sect + m_inst_id
- Refactor
create_hud_item
to take CHudItem as parameter & keym_pool
bym_unique_hud_sect
to avoid duplicate item bug.