diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/inventory.cpp | 17 |
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; } |