summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Beller <stefanbeller@googlemail.com>2012-07-31 12:27:53 +0200
committerStefan Beller <stefanbeller@googlemail.com>2012-07-31 12:27:53 +0200
commit85324882f195cfe3e1328e5a062ad6807d70f92e (patch)
tree0f574703e5d66ec0286685c79805a06abeb665b2 /src
parentd9d5ebbcd623e97f9b13a9c1046b08be34e1302e (diff)
downloadmanaserv-85324882f195cfe3e1328e5a062ad6807d70f92e.tar.gz
manaserv-85324882f195cfe3e1328e5a062ad6807d70f92e.tar.bz2
manaserv-85324882f195cfe3e1328e5a062ad6807d70f92e.tar.xz
manaserv-85324882f195cfe3e1328e5a062ad6807d70f92e.zip
Fix Inventory::getNewEquipItemInstance to yield really unique ids.
Diffstat (limited to 'src')
-rw-r--r--src/game-server/inventory.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/game-server/inventory.cpp b/src/game-server/inventory.cpp
index c568c58d..532b3f42 100644
--- a/src/game-server/inventory.cpp
+++ b/src/game-server/inventory.cpp
@@ -527,18 +527,17 @@ void Inventory::updateEquipmentTrigger(ItemClass *oldI, ItemClass *newI)
unsigned int Inventory::getNewEquipItemInstance()
{
- unsigned int itemInstance = 1;
-
- for (EquipData::const_iterator it = mPoss->equipSlots.begin(),
- it_end = mPoss->equipSlots.end(); it != it_end; ++it)
+ std::set<int> alreadyUsed;
+ for (EquipData::const_iterator it = mPoss->equipSlots.begin();
+ it != mPoss->equipSlots.end(); ++it)
{
- if (it->second.itemInstance == itemInstance)
- {
- ++itemInstance;
- it = mPoss->equipSlots.begin();
- }
+ alreadyUsed.insert(it->second.itemInstance);
}
+ unsigned int itemInstance = 1;
+ while (alreadyUsed.count(itemInstance))
+ itemInstance++;
+
return itemInstance;
}