summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Beller <stefanbeller@googlemail.com>2012-07-31 12:32:59 +0200
committerStefan Beller <stefanbeller@googlemail.com>2012-07-31 12:32:59 +0200
commitdf2724d7eecf6f462d4a848e96c38e91c4d28090 (patch)
treeed69da97bd406804bdd7b37772939433421c6196
parent4f6f59bfb33bb5814b5489a405074c900b5299ab (diff)
downloadmanaserv-df2724d7eecf6f462d4a848e96c38e91c4d28090.tar.gz
manaserv-df2724d7eecf6f462d4a848e96c38e91c4d28090.tar.bz2
manaserv-df2724d7eecf6f462d4a848e96c38e91c4d28090.tar.xz
manaserv-df2724d7eecf6f462d4a848e96c38e91c4d28090.zip
Fix Inventory::getNewEquipItemInstance to yield really unique ids.
Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Reviewed-by: Erik Schilling
-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;
}