From a1933e7bc2b057fedf201524a4079a46022b4031 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 11 Aug 2018 15:28:03 +0300 Subject: [PATCH] [Client] Don't declare variable twice in LocalPlayer's setEquipment() The variable equipmentItem is identical to currentItem, so it should not have been added in commit 58a6a8c3bc946d94484beb54b80dcbbaca5e67f1 Addditionally, use a more descriptive variable name than "a" for item Ptrs. --- apps/openmw/mwmp/LocalPlayer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 46d44cedb..aa562a442 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -530,6 +530,7 @@ void LocalPlayer::updateInventory(bool forceUpdate) item.charge = iter.getCellRef().getCharge(); item.enchantmentCharge = iter.getCellRef().getEnchantmentCharge(); item.soul = iter.getCellRef().getSoul(); + return false; }; @@ -1111,22 +1112,21 @@ void LocalPlayer::setEquipment() if (!currentItem.refId.empty()) { - auto it = find_if(ptrInventory.begin(), ptrInventory.end(), [¤tItem](const MWWorld::Ptr &a) { - return Misc::StringUtils::ciEqual(a.getCellRef().getRefId(), currentItem.refId); + auto it = find_if(ptrInventory.begin(), ptrInventory.end(), [¤tItem](const MWWorld::Ptr &itemPtr) { + return Misc::StringUtils::ciEqual(itemPtr.getCellRef().getRefId(), currentItem.refId); }); if (it == ptrInventory.end()) // If the item is not in our inventory, add it { - auto equipmentItem = equipmentItems[slot]; - try { - auto addIter = ptrInventory.ContainerStore::add(equipmentItem.refId.c_str(), equipmentItem.count, ptrPlayer); + auto addIter = ptrInventory.ContainerStore::add(currentItem.refId.c_str(), currentItem.count, ptrPlayer); + ptrInventory.equip(slot, addIter, ptrPlayer); } catch (std::exception&) { - LOG_APPEND(Log::LOG_INFO, "- Ignored addition of invalid equipment item %s", equipmentItem.refId.c_str()); + LOG_APPEND(Log::LOG_INFO, "- Ignored addition of invalid equipment item %s", currentItem.refId.c_str()); } } else