diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 1d352035aa..fe38c1da09 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -288,7 +288,7 @@ namespace MWClass return !(ref->mBase->mFlags & ESM::Container::Organic); } - void Container::modifyBaseInventory(const std::string& containerId, const std::string& itemId, int amount) const + void Container::modifyBaseInventory(std::string_view containerId, std::string_view itemId, int amount) const { MWMechanics::modifyBaseInventory(containerId, itemId, amount); } diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 029e86c9e2..b9573700d6 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -89,7 +89,7 @@ namespace MWClass bool useAnim() const override; - void modifyBaseInventory(const std::string& containerId, const std::string& itemId, int amount) const override; + void modifyBaseInventory(std::string_view containerId, std::string_view itemId, int amount) const override; }; } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 36076f100b..da105686f7 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -898,7 +898,7 @@ namespace MWClass MWMechanics::setBaseAISetting(id, setting, value); } - void Creature::modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const + void Creature::modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const { MWMechanics::modifyBaseInventory(actorId, itemId, amount); } diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index d578e262b6..73b716d1ed 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -138,7 +138,7 @@ namespace MWClass void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const override; - void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const override; + void modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const override; float getWalkSpeed(const MWWorld::Ptr& ptr) const override; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 823babe83a..f188c672a2 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1495,7 +1495,7 @@ namespace MWClass MWMechanics::setBaseAISetting(id, setting, value); } - void Npc::modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const + void Npc::modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const { MWMechanics::modifyBaseInventory(actorId, itemId, amount); } diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 5b05b0cdc2..cb1b146faf 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -166,7 +166,7 @@ namespace MWClass void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const override; - void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const override; + void modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const override; float getWalkSpeed(const MWWorld::Ptr& ptr) const override; diff --git a/apps/openmw/mwmechanics/inventory.hpp b/apps/openmw/mwmechanics/inventory.hpp index 6ce04a675b..517eb24820 100644 --- a/apps/openmw/mwmechanics/inventory.hpp +++ b/apps/openmw/mwmechanics/inventory.hpp @@ -10,12 +10,12 @@ #include #include -#include +#include namespace MWMechanics { template - void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) + void modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) { T copy = *MWBase::Environment::get().getWorld()->getStore().get().find(actorId); for (auto& it : copy.mInventory.mList) diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index c042727edb..68d714d58b 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -118,7 +118,7 @@ namespace MWScript // Explicit calls to non-unique actors affect the base record if(!R::implicit && ptr.getClass().isActor() && MWBase::Environment::get().getWorld()->getStore().getRefCount(ptr.getCellRef().getRefId()) > 1) { - ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), std::string{item}, count); + ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, count); return; } @@ -126,7 +126,7 @@ namespace MWScript if(ptr.getClass().getType() == ESM::Container::sRecordId && (!ptr.getRefData().getCustomData() || !ptr.getClass().getContainerStore(ptr).isResolved())) { - ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), std::string{item}, count); + ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, count); const ESM::Container* baseRecord = MWBase::Environment::get().getWorld()->getStore().get().find(ptr.getCellRef().getRefId()); const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId()); for(const auto& container : ptrs) @@ -231,14 +231,14 @@ namespace MWScript // Explicit calls to non-unique actors affect the base record if(!R::implicit && ptr.getClass().isActor() && MWBase::Environment::get().getWorld()->getStore().getRefCount(ptr.getCellRef().getRefId()) > 1) { - ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), std::string{item}, -count); + ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, -count); return; } // Calls to unresolved containers affect the base record instead else if(ptr.getClass().getType() == ESM::Container::sRecordId && (!ptr.getRefData().getCustomData() || !ptr.getClass().getContainerStore(ptr).isResolved())) { - ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), std::string{item}, -count); + ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, -count); const ESM::Container* baseRecord = MWBase::Environment::get().getWorld()->getStore().get().find(ptr.getCellRef().getRefId()); const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId()); for(const auto& container : ptrs) diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 5ba808c217..cb289d83b0 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -64,7 +64,7 @@ namespace } ESM::LevelledListBase::LevelItem item; - item.mId = std::string{itemId}; + item.mId = itemId; item.mLevel = level; list->mList.push_back(item); } diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 928383698f..7639b5d8b6 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -531,7 +531,7 @@ namespace MWWorld throw std::runtime_error ("class does not have creature stats"); } - void Class::modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const + void Class::modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const { throw std::runtime_error ("class does not have an inventory store"); } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index e6e656299d..4cc16ee7f2 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -368,7 +368,7 @@ namespace MWWorld virtual void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const; - virtual void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const; + virtual void modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const; }; }