There was a memory corruption bug in remove() because I get a reference to the slot string, then remove it from by_entity, but that deletes the string so then later using it to remove by_slot silently fails because map.erase() silently fails. Closes. #54.

This commit is contained in:
Zed A. Shaw 2025-07-03 13:07:04 -04:00
parent 970905fcd5
commit 87e69bebde
3 changed files with 23 additions and 8 deletions

View file

@ -10,7 +10,7 @@ namespace inventory {
std::unordered_map<std::string, DinkyECS::Entity> by_slot;
std::unordered_map<DinkyECS::Entity, std::string> by_entity;
bool add(const std::string &in_slot, DinkyECS::Entity ent);
bool add(const std::string in_slot, DinkyECS::Entity ent);
const std::string& get(DinkyECS::Entity ent);
DinkyECS::Entity get(const std::string& slot);
bool has(DinkyECS::Entity ent);