From ec3674b40a2272b74abfc6b89f463ab703914690 Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 6 Apr 2022 17:06:55 +0200 Subject: [PATCH] Use unique_ptr instead of shared_ptr for MWWorld::Action, ProjectileManager and ESSImport::Converter. shared_ptr has additional cost of reference counter and requires additional allocation when constructed as shared_ptr(new T). --- apps/essimporter/importer.cpp | 66 ++++++++++---------- apps/openmw/mwclass/activator.cpp | 6 +- apps/openmw/mwclass/activator.hpp | 2 +- apps/openmw/mwclass/apparatus.cpp | 6 +- apps/openmw/mwclass/apparatus.hpp | 4 +- apps/openmw/mwclass/armor.cpp | 6 +- apps/openmw/mwclass/armor.hpp | 4 +- apps/openmw/mwclass/book.cpp | 10 +-- apps/openmw/mwclass/book.hpp | 4 +- apps/openmw/mwclass/clothing.cpp | 6 +- apps/openmw/mwclass/clothing.hpp | 4 +- apps/openmw/mwclass/container.cpp | 14 ++--- apps/openmw/mwclass/container.hpp | 2 +- apps/openmw/mwclass/creature.cpp | 14 ++--- apps/openmw/mwclass/creature.hpp | 2 +- apps/openmw/mwclass/door.cpp | 14 ++--- apps/openmw/mwclass/door.hpp | 2 +- apps/openmw/mwclass/ingredient.cpp | 6 +- apps/openmw/mwclass/ingredient.hpp | 4 +- apps/openmw/mwclass/light.cpp | 10 +-- apps/openmw/mwclass/light.hpp | 4 +- apps/openmw/mwclass/lockpick.cpp | 6 +- apps/openmw/mwclass/lockpick.hpp | 4 +- apps/openmw/mwclass/misc.cpp | 8 +-- apps/openmw/mwclass/misc.hpp | 4 +- apps/openmw/mwclass/npc.cpp | 20 +++--- apps/openmw/mwclass/npc.hpp | 2 +- apps/openmw/mwclass/potion.cpp | 6 +- apps/openmw/mwclass/potion.hpp | 4 +- apps/openmw/mwclass/probe.cpp | 6 +- apps/openmw/mwclass/probe.hpp | 4 +- apps/openmw/mwclass/repair.cpp | 6 +- apps/openmw/mwclass/repair.hpp | 4 +- apps/openmw/mwclass/weapon.cpp | 6 +- apps/openmw/mwclass/weapon.hpp | 4 +- apps/openmw/mwgui/inventorywindow.cpp | 2 +- apps/openmw/mwgui/sortfilteritemmodel.cpp | 2 +- apps/openmw/mwlua/actions.cpp | 2 +- apps/openmw/mwmechanics/aicombat.cpp | 2 +- apps/openmw/mwmechanics/aicombat.hpp | 2 +- apps/openmw/mwmechanics/aicombataction.cpp | 4 +- apps/openmw/mwmechanics/aicombataction.hpp | 2 +- apps/openmw/mwscript/containerextensions.cpp | 2 +- apps/openmw/mwscript/interpretercontext.cpp | 2 +- apps/openmw/mwworld/class.cpp | 16 ++--- apps/openmw/mwworld/class.hpp | 6 +- apps/openmw/mwworld/worldimp.cpp | 2 +- apps/openmw/mwworld/worldimp.hpp | 2 +- 48 files changed, 160 insertions(+), 160 deletions(-) diff --git a/apps/essimporter/importer.cpp b/apps/essimporter/importer.cpp index 9931385f8c..a683bf7047 100644 --- a/apps/essimporter/importer.cpp +++ b/apps/essimporter/importer.cpp @@ -272,39 +272,39 @@ namespace ESSImport const unsigned int recJOUR = ESM::fourCC("JOUR"); const unsigned int recSPLM = ESM::fourCC("SPLM"); - std::map > converters; - converters[ESM::REC_GLOB] = std::shared_ptr(new ConvertGlobal()); - converters[ESM::REC_BOOK] = std::shared_ptr(new ConvertBook()); - converters[ESM::REC_NPC_] = std::shared_ptr(new ConvertNPC()); - converters[ESM::REC_CREA] = std::shared_ptr(new ConvertCREA()); - converters[ESM::REC_NPCC] = std::shared_ptr(new ConvertNPCC()); - converters[ESM::REC_CREC] = std::shared_ptr(new ConvertCREC()); - converters[recREFR ] = std::shared_ptr(new ConvertREFR()); - converters[recPCDT ] = std::shared_ptr(new ConvertPCDT()); - converters[recFMAP ] = std::shared_ptr(new ConvertFMAP()); - converters[recKLST ] = std::shared_ptr(new ConvertKLST()); - converters[recSTLN ] = std::shared_ptr(new ConvertSTLN()); - converters[recGAME ] = std::shared_ptr(new ConvertGAME()); - converters[ESM::REC_CELL] = std::shared_ptr(new ConvertCell()); - converters[ESM::REC_ALCH] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_CLAS] = std::shared_ptr(new ConvertClass()); - converters[ESM::REC_SPEL] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_ARMO] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_WEAP] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_CLOT] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_ENCH] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_WEAP] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_LEVC] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_LEVI] = std::shared_ptr(new DefaultConverter()); - converters[ESM::REC_CNTC] = std::shared_ptr(new ConvertCNTC()); - converters[ESM::REC_FACT] = std::shared_ptr(new ConvertFACT()); - converters[ESM::REC_INFO] = std::shared_ptr(new ConvertINFO()); - converters[ESM::REC_DIAL] = std::shared_ptr(new ConvertDIAL()); - converters[ESM::REC_QUES] = std::shared_ptr(new ConvertQUES()); - converters[recJOUR ] = std::shared_ptr(new ConvertJOUR()); - converters[ESM::REC_SCPT] = std::shared_ptr(new ConvertSCPT()); - converters[ESM::REC_PROJ] = std::shared_ptr(new ConvertPROJ()); - converters[recSPLM] = std::shared_ptr(new ConvertSPLM()); + std::map> converters; + converters[ESM::REC_GLOB] = std::unique_ptr(new ConvertGlobal()); + converters[ESM::REC_BOOK] = std::unique_ptr(new ConvertBook()); + converters[ESM::REC_NPC_] = std::unique_ptr(new ConvertNPC()); + converters[ESM::REC_CREA] = std::unique_ptr(new ConvertCREA()); + converters[ESM::REC_NPCC] = std::unique_ptr(new ConvertNPCC()); + converters[ESM::REC_CREC] = std::unique_ptr(new ConvertCREC()); + converters[recREFR ] = std::unique_ptr(new ConvertREFR()); + converters[recPCDT ] = std::unique_ptr(new ConvertPCDT()); + converters[recFMAP ] = std::unique_ptr(new ConvertFMAP()); + converters[recKLST ] = std::unique_ptr(new ConvertKLST()); + converters[recSTLN ] = std::unique_ptr(new ConvertSTLN()); + converters[recGAME ] = std::unique_ptr(new ConvertGAME()); + converters[ESM::REC_CELL] = std::unique_ptr(new ConvertCell()); + converters[ESM::REC_ALCH] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_CLAS] = std::unique_ptr(new ConvertClass()); + converters[ESM::REC_SPEL] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_ARMO] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_WEAP] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_CLOT] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_ENCH] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_WEAP] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_LEVC] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_LEVI] = std::unique_ptr(new DefaultConverter()); + converters[ESM::REC_CNTC] = std::unique_ptr(new ConvertCNTC()); + converters[ESM::REC_FACT] = std::unique_ptr(new ConvertFACT()); + converters[ESM::REC_INFO] = std::unique_ptr(new ConvertINFO()); + converters[ESM::REC_DIAL] = std::unique_ptr(new ConvertDIAL()); + converters[ESM::REC_QUES] = std::unique_ptr(new ConvertQUES()); + converters[recJOUR ] = std::unique_ptr(new ConvertJOUR()); + converters[ESM::REC_SCPT] = std::unique_ptr(new ConvertSCPT()); + converters[ESM::REC_PROJ] = std::unique_ptr(new ConvertPROJ()); + converters[recSPLM] = std::unique_ptr(new ConvertSPLM()); // TODO: // - REGN (weather in certain regions?) diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index ad9a6c76d9..2d386addb8 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -111,7 +111,7 @@ namespace MWClass return info; } - std::shared_ptr Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const + std::unique_ptr Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const { if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { @@ -119,12 +119,12 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfActivator", prng); - std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; } - return std::shared_ptr(new MWWorld::NullAction); + return std::unique_ptr(new MWWorld::NullAction); } diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index d5c251d9d1..e34786a1f0 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -35,7 +35,7 @@ namespace MWClass std::string getScript (const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr - std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation std::string getModel(const MWWorld::ConstPtr &ptr) const override; diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 021e81346d..99a2d7887b 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -49,7 +49,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Apparatus::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -108,9 +108,9 @@ namespace MWClass return info; } - std::shared_ptr Apparatus::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Apparatus::use (const MWWorld::Ptr& ptr, bool force) const { - return std::shared_ptr(new MWWorld::ActionAlchemy(force)); + return std::unique_ptr(new MWWorld::ActionAlchemy(force)); } MWWorld::Ptr Apparatus::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index ec84a75196..ef21928075 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -23,7 +23,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -45,7 +45,7 @@ namespace MWClass std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override; ///< Return name of inventory icon. - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getModel(const MWWorld::ConstPtr &ptr) const override; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index cffc112641..22c46bf579 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -57,7 +57,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Armor::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -332,9 +332,9 @@ namespace MWClass return std::make_pair(1,""); } - std::shared_ptr Armor::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Armor::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index 00fb23defa..b185596c08 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -23,7 +23,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -69,7 +69,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. \n /// Second item in the pair specifies the error message - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getModel(const MWWorld::ConstPtr &ptr) const override; diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 1c826a049d..c8a05a132e 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -54,7 +54,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Book::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Book::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) @@ -63,13 +63,13 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfItem", prng); - std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; } - return std::shared_ptr(new MWWorld::ActionRead(ptr)); + return std::unique_ptr(new MWWorld::ActionRead(ptr)); } std::string Book::getScript (const MWWorld::ConstPtr& ptr) const @@ -149,9 +149,9 @@ namespace MWClass return record->mId; } - std::shared_ptr Book::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Book::use (const MWWorld::Ptr& ptr, bool force) const { - return std::shared_ptr(new MWWorld::ActionRead(ptr)); + return std::unique_ptr(new MWWorld::ActionRead(ptr)); } MWWorld::Ptr Book::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index d78d9c7500..a5152fa812 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -49,7 +49,7 @@ namespace MWClass std::string applyEnchantment(const MWWorld::ConstPtr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const override; ///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it. - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getModel(const MWWorld::ConstPtr &ptr) const override; diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 02ab337a2b..32396cae35 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -52,7 +52,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Clothing::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -228,9 +228,9 @@ namespace MWClass return std::make_pair (1, ""); } - std::shared_ptr Clothing::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Clothing::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index a044b13804..8e0a0c90bd 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -61,7 +61,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. /// Second item in the pair specifies the error message - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getModel(const MWWorld::ConstPtr &ptr) const override; diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 296813f155..ad0b6169a9 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -131,11 +131,11 @@ namespace MWClass return true; } - std::shared_ptr Container::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Container::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return std::shared_ptr (new MWWorld::NullAction ()); + return std::unique_ptr (new MWWorld::NullAction ()); if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { @@ -143,7 +143,7 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfContainer", prng); - std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; @@ -191,24 +191,24 @@ namespace MWClass { if (canBeHarvested(ptr)) { - std::shared_ptr action (new MWWorld::ActionHarvest(ptr)); + std::unique_ptr action (new MWWorld::ActionHarvest(ptr)); return action; } - std::shared_ptr action (new MWWorld::ActionOpen(ptr)); + std::unique_ptr action (new MWWorld::ActionOpen(ptr)); return action; } else { // Activate trap - std::shared_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); + std::unique_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); action->setSound(trapActivationSound); return action; } } else { - std::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + std::unique_ptr action(new MWWorld::FailedAction(std::string(), ptr)); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 0da53508d2..9ecf323b71 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -50,7 +50,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 68aea5730f..fc3504b947 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -430,7 +430,7 @@ namespace MWClass } } - std::shared_ptr Creature::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Creature::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) @@ -439,7 +439,7 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfCreature", prng); - std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; @@ -453,20 +453,20 @@ namespace MWClass // by default user can loot friendly actors during death animation if (canLoot && !stats.getAiSequence().isInCombat()) - return std::shared_ptr(new MWWorld::ActionOpen(ptr)); + return std::unique_ptr(new MWWorld::ActionOpen(ptr)); // otherwise wait until death animation if(stats.isDeathAnimationFinished()) - return std::shared_ptr(new MWWorld::ActionOpen(ptr)); + return std::unique_ptr(new MWWorld::ActionOpen(ptr)); } else if (!stats.getAiSequence().isInCombat() && !stats.getKnockedDown()) - return std::shared_ptr(new MWWorld::ActionTalk(ptr)); + return std::unique_ptr(new MWWorld::ActionTalk(ptr)); // Tribunal and some mod companions oddly enough must use open action as fallback if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion")) - return std::shared_ptr(new MWWorld::ActionOpen(ptr)); + return std::unique_ptr(new MWWorld::ActionOpen(ptr)); - return std::shared_ptr(new MWWorld::FailedAction("")); + return std::unique_ptr(new MWWorld::FailedAction("")); } MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 3b1c070ce7..558ea00643 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -65,7 +65,7 @@ namespace MWClass void onHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object, const MWWorld::Ptr &attacker, const osg::Vec3f &hitPosition, bool successful) const override; - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index ff4efbc1ba..17f0cadbb6 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -109,7 +109,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Door::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Door::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { MWWorld::LiveCellRef *ref = ptr.get(); @@ -130,7 +130,7 @@ namespace MWClass // Make such activation a no-op for now, like how it is in the vanilla game. if (actor != MWMechanics::getPlayer() && ptr.getCellRef().getTeleport()) { - std::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + std::unique_ptr action(new MWWorld::FailedAction(std::string(), ptr)); action->setSound(lockedSound); return action; } @@ -181,7 +181,7 @@ namespace MWClass if(isTrapped) { // Trap activation - std::shared_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); + std::unique_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); action->setSound(trapActivationSound); return action; } @@ -191,12 +191,12 @@ namespace MWClass if (actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getDistanceToFacedObject() > MWBase::Environment::get().getWorld()->getMaxActivationDistance()) { // player activated teleport door with telekinesis - std::shared_ptr action(new MWWorld::FailedAction); + std::unique_ptr action(new MWWorld::FailedAction); return action; } else { - std::shared_ptr action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true)); + std::unique_ptr action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true)); action->setSound(openSound); return action; } @@ -204,7 +204,7 @@ namespace MWClass else { // animated door - std::shared_ptr action(new MWWorld::ActionDoor(ptr)); + std::unique_ptr action(new MWWorld::ActionDoor(ptr)); const auto doorState = getDoorState(ptr); bool opening = true; float doorRot = ptr.getRefData().getPosition().rot[2] - ptr.getCellRef().getPosition().rot[2]; @@ -238,7 +238,7 @@ namespace MWClass else { // locked, and we can't open. - std::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + std::unique_ptr action(new MWWorld::FailedAction(std::string(), ptr)); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index fd824c4732..d3a369d89e 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -32,7 +32,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index e0e71902c7..2331361477 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -51,7 +51,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Ingredient::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -72,9 +72,9 @@ namespace MWClass } - std::shared_ptr Ingredient::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Ingredient::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action (new MWWorld::ActionEat (ptr)); + std::unique_ptr action (new MWWorld::ActionEat (ptr)); action->setSound ("Swallow"); diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 2abb2f343c..95b3d94e5e 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -34,7 +34,7 @@ namespace MWClass int getValue (const MWWorld::ConstPtr& ptr) const override; ///< Return trade value of the object. Throws an exception, if the object can't be traded. - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 90080784a9..a7d49da54a 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -85,15 +85,15 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Light::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Light::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return std::shared_ptr(new MWWorld::NullAction()); + return std::unique_ptr(new MWWorld::NullAction()); MWWorld::LiveCellRef *ref = ptr.get(); if(!(ref->mBase->mData.mFlags&ESM::Light::Carry)) - return std::shared_ptr(new MWWorld::FailedAction()); + return std::unique_ptr(new MWWorld::FailedAction()); return defaultItemActivate(ptr, actor); } @@ -184,9 +184,9 @@ namespace MWClass return Class::showsInInventory(ptr); } - std::shared_ptr Light::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Light::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index 7a7f670a2a..0104e88b6b 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -34,7 +34,7 @@ namespace MWClass bool showsInInventory (const MWWorld::ConstPtr& ptr) const override; - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -57,7 +57,7 @@ namespace MWClass std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override; ///< Return name of inventory icon. - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu void setRemainingUsageTime (const MWWorld::Ptr& ptr, float duration) const override; diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 1e451ca7fe..c8860df4ce 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -51,7 +51,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Lockpick::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -124,9 +124,9 @@ namespace MWClass return info; } - std::shared_ptr Lockpick::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Lockpick::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index b51aaa05a6..3aac0c70b7 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -49,7 +49,7 @@ namespace MWClass std::pair canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override; - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getModel(const MWWorld::ConstPtr &ptr) const override; diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 759eea5ccc..51e75650fb 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -61,7 +61,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -203,12 +203,12 @@ namespace MWClass return newPtr; } - std::shared_ptr Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const { if (ptr.getCellRef().getSoul().empty() || !MWBase::Environment::get().getWorld()->getStore().get().search(ptr.getCellRef().getSoul())) - return std::shared_ptr(new MWWorld::NullAction()); + return std::unique_ptr(new MWWorld::NullAction()); else - return std::shared_ptr(new MWWorld::ActionSoulgem(ptr)); + return std::unique_ptr(new MWWorld::ActionSoulgem(ptr)); } bool Miscellaneous::canSell (const MWWorld::ConstPtr& item, int npcServices) const diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 59c31a219c..ebf38b10be 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -45,7 +45,7 @@ namespace MWClass std::string getModel(const MWWorld::ConstPtr &ptr) const override; - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu float getWeight (const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index cc4b3f7528..f3fcb848fd 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -860,12 +860,12 @@ namespace MWClass } } - std::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Npc::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { // player got activated by another NPC if(ptr == MWMechanics::getPlayer()) - return std::shared_ptr(new MWWorld::ActionTalk(actor)); + return std::unique_ptr(new MWWorld::ActionTalk(actor)); // Werewolfs can't activate NPCs if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) @@ -874,7 +874,7 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfNPC", prng); - std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; @@ -888,33 +888,33 @@ namespace MWClass // by default user can loot friendly actors during death animation if (canLoot && !stats.getAiSequence().isInCombat()) - return std::shared_ptr(new MWWorld::ActionOpen(ptr)); + return std::unique_ptr(new MWWorld::ActionOpen(ptr)); // otherwise wait until death animation if(stats.isDeathAnimationFinished()) - return std::shared_ptr(new MWWorld::ActionOpen(ptr)); + return std::unique_ptr(new MWWorld::ActionOpen(ptr)); } else if (!stats.getAiSequence().isInCombat()) { if (stats.getKnockedDown() || MWBase::Environment::get().getMechanicsManager()->isSneaking(actor)) - return std::shared_ptr(new MWWorld::ActionOpen(ptr)); // stealing + return std::unique_ptr(new MWWorld::ActionOpen(ptr)); // stealing // Can't talk to werewolves if (!getNpcStats(ptr).isWerewolf()) - return std::shared_ptr(new MWWorld::ActionTalk(ptr)); + return std::unique_ptr(new MWWorld::ActionTalk(ptr)); } else // In combat { const bool stealingInCombat = Settings::Manager::getBool ("always allow stealing from knocked out actors", "Game"); if (stealingInCombat && stats.getKnockedDown()) - return std::shared_ptr(new MWWorld::ActionOpen(ptr)); // stealing + return std::unique_ptr(new MWWorld::ActionOpen(ptr)); // stealing } // Tribunal and some mod companions oddly enough must use open action as fallback if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion")) - return std::shared_ptr(new MWWorld::ActionOpen(ptr)); + return std::unique_ptr(new MWWorld::ActionOpen(ptr)); - return std::shared_ptr (new MWWorld::FailedAction("")); + return std::unique_ptr (new MWWorld::FailedAction("")); } MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 574d133934..ba937a4cfa 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -83,7 +83,7 @@ namespace MWClass void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector& models) const override; ///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel(). - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 6357d8938a..2267f24b37 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -53,7 +53,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Potion::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -123,12 +123,12 @@ namespace MWClass return info; } - std::shared_ptr Potion::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Potion::use (const MWWorld::Ptr& ptr, bool force) const { MWWorld::LiveCellRef *ref = ptr.get(); - std::shared_ptr action ( + std::unique_ptr action ( new MWWorld::ActionApply (ptr, ref->mBase->mId)); action->setSound ("Drink"); diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 2b979e2f37..d5964cff85 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -34,7 +34,7 @@ namespace MWClass int getValue (const MWWorld::ConstPtr& ptr) const override; ///< Return trade value of the object. Throws an exception, if the object can't be traded. - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 7db6a3e955..369f5efd6d 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -50,7 +50,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Probe::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -124,9 +124,9 @@ namespace MWClass return info; } - std::shared_ptr Probe::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Probe::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 06bd2ababb..b048b37f92 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -49,7 +49,7 @@ namespace MWClass std::pair canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override; - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getModel(const MWWorld::ConstPtr &ptr) const override; diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 463257696c..c3a67a6086 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -48,7 +48,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Repair::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -132,9 +132,9 @@ namespace MWClass return MWWorld::Ptr(cell.insert(ref), &cell); } - std::shared_ptr Repair::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Repair::use (const MWWorld::Ptr& ptr, bool force) const { - return std::shared_ptr(new MWWorld::ActionRepair(ptr, force)); + return std::unique_ptr(new MWWorld::ActionRepair(ptr, force)); } bool Repair::canSell (const MWWorld::ConstPtr& item, int npcServices) const diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index b79ad2b124..4ca0dd2511 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -45,7 +45,7 @@ namespace MWClass std::string getModel(const MWWorld::ConstPtr &ptr) const override; - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu (default implementation: return a /// null action). diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 261ada1e75..9290c19d80 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -57,7 +57,7 @@ namespace MWClass return !name.empty() ? name : ref->mBase->mId; } - std::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, + std::unique_ptr Weapon::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -299,9 +299,9 @@ namespace MWClass return std::make_pair(1, ""); } - std::shared_ptr Weapon::use (const MWWorld::Ptr& ptr, bool force) const + std::unique_ptr Weapon::use (const MWWorld::Ptr& ptr, bool force) const { - std::shared_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index 61b2a70c26..f09c590183 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -21,7 +21,7 @@ namespace MWClass std::string getName (const MWWorld::ConstPtr& ptr) const override; ///< \return name or ID; can return an empty string. - std::shared_ptr activate (const MWWorld::Ptr& ptr, + std::unique_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation @@ -67,7 +67,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. /// Second item in the pair specifies the error message - std::shared_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; + std::unique_ptr use (const MWWorld::Ptr& ptr, bool force=false) const override; ///< Generate action for using via inventory menu std::string getModel(const MWWorld::ConstPtr &ptr) const override; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 80e922fb66..680356b353 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -561,7 +561,7 @@ namespace MWGui ptr.getRefData().getLocals().setVarByInt(script, "pcskipequip", 1); } - std::shared_ptr action = ptr.getClass().use(ptr, force); + std::unique_ptr action = ptr.getClass().use(ptr, force); action->execute(player); if (isVisible()) diff --git a/apps/openmw/mwgui/sortfilteritemmodel.cpp b/apps/openmw/mwgui/sortfilteritemmodel.cpp index c804eafb72..acb324baca 100644 --- a/apps/openmw/mwgui/sortfilteritemmodel.cpp +++ b/apps/openmw/mwgui/sortfilteritemmodel.cpp @@ -256,7 +256,7 @@ namespace MWGui if ((mFilter & Filter_OnlyUsableItems) && base.getClass().getScript(base).empty()) { - std::shared_ptr actionOnUse = base.getClass().use(base); + std::unique_ptr actionOnUse = base.getClass().use(base); if (!actionOnUse || actionOnUse->isNullAction()) return false; } diff --git a/apps/openmw/mwlua/actions.cpp b/apps/openmw/mwlua/actions.cpp index 404bae6c6d..0934b92226 100644 --- a/apps/openmw/mwlua/actions.cpp +++ b/apps/openmw/mwlua/actions.cpp @@ -160,7 +160,7 @@ namespace MWLua throw std::runtime_error(std::string("Actor not found: " + idToString(mActor))); MWBase::Environment::get().getLuaManager()->objectActivated(object, actor); - std::shared_ptr action = object.getClass().activate(object, actor); + std::unique_ptr action = object.getClass().activate(object, actor); action->execute(actor); } diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 12671d50dd..cbd62d37ff 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -185,7 +185,7 @@ namespace MWMechanics actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true); float& actionCooldown = storage.mActionCooldown; - std::shared_ptr& currentAction = storage.mCurrentAction; + std::unique_ptr& currentAction = storage.mCurrentAction; if (!forceFlee) { diff --git a/apps/openmw/mwmechanics/aicombat.hpp b/apps/openmw/mwmechanics/aicombat.hpp index 566ec354d6..a51393647c 100644 --- a/apps/openmw/mwmechanics/aicombat.hpp +++ b/apps/openmw/mwmechanics/aicombat.hpp @@ -36,7 +36,7 @@ namespace MWMechanics bool mRotateMove; osg::Vec3f mLastTargetPos; const MWWorld::CellStore* mCell; - std::shared_ptr mCurrentAction; + std::unique_ptr mCurrentAction; float mActionCooldown; float mStrength; bool mForceNoShortcut; diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index 43b43eb9f9..30573c131e 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -141,14 +141,14 @@ namespace MWMechanics return mWeapon.get()->mBase; } - std::shared_ptr prepareNextAction(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy) + std::unique_ptr prepareNextAction(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy) { Spells& spells = actor.getClass().getCreatureStats(actor).getSpells(); float bestActionRating = 0.f; float antiFleeRating = 0.f; // Default to hand-to-hand combat - std::shared_ptr bestAction (new ActionWeapon(MWWorld::Ptr())); + std::unique_ptr bestAction (new ActionWeapon(MWWorld::Ptr())); if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { bestAction->prepare(actor); diff --git a/apps/openmw/mwmechanics/aicombataction.hpp b/apps/openmw/mwmechanics/aicombataction.hpp index d17d5a3137..56d2247e99 100644 --- a/apps/openmw/mwmechanics/aicombataction.hpp +++ b/apps/openmw/mwmechanics/aicombataction.hpp @@ -85,7 +85,7 @@ namespace MWMechanics const ESM::Weapon* getWeapon() const override; }; - std::shared_ptr prepareNextAction (const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); + std::unique_ptr prepareNextAction (const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); float getBestActionRating(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy); float getDistanceMinusHalfExtents(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool minusZDist=false); diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 40ad3b7835..8db1c04551 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -320,7 +320,7 @@ namespace MWScript MWBase::Environment::get().getWindowManager()->useItem(*it, true); else { - std::shared_ptr action = it->getClass().use(*it, true); + std::unique_ptr action = it->getClass().use(*it, true); action->execute(ptr, true); } } diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 0b9833e097..72922aa5f3 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -419,7 +419,7 @@ namespace MWScript void InterpreterContext::executeActivation(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) { MWBase::Environment::get().getLuaManager()->objectActivated(ptr, actor); - std::shared_ptr action = (ptr.getClass().activate(ptr, actor)); + std::unique_ptr action = (ptr.getClass().activate(ptr, actor)); action->execute (actor); if (action->getTarget() != MWWorld::Ptr() && action->getTarget() != ptr) { diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index b67f173ee5..9dc8ba5631 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -115,14 +115,14 @@ namespace MWWorld throw std::runtime_error("class cannot be hit"); } - std::shared_ptr Class::activate (const Ptr& ptr, const Ptr& actor) const + std::unique_ptr Class::activate (const Ptr& ptr, const Ptr& actor) const { - return std::shared_ptr (new NullAction); + return std::unique_ptr (new NullAction); } - std::shared_ptr Class::use (const Ptr& ptr, bool force) const + std::unique_ptr Class::use (const Ptr& ptr, bool force) const { - return std::shared_ptr (new NullAction); + return std::unique_ptr (new NullAction); } ContainerStore& Class::getContainerStore (const Ptr& ptr) const @@ -329,10 +329,10 @@ namespace MWWorld { } - std::shared_ptr Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const + std::unique_ptr Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const { if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return std::shared_ptr(new NullAction()); + return std::unique_ptr(new NullAction()); if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { @@ -340,13 +340,13 @@ namespace MWWorld auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfItem", prng); - std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; } - std::shared_ptr action(new ActionTake(ptr)); + std::unique_ptr action(new ActionTake(ptr)); action->setSound(getUpSoundId(ptr)); return action; diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index f12b7ba192..8c52021256 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -62,7 +62,7 @@ namespace MWWorld explicit Class(unsigned type) : mType(type) {} - std::shared_ptr defaultItemActivate(const Ptr &ptr, const Ptr &actor) const; + std::unique_ptr defaultItemActivate(const Ptr &ptr, const Ptr &actor) const; ///< Generate default action for activating inventory items virtual Ptr copyToCellImpl(const ConstPtr &ptr, CellStore &cell) const; @@ -139,10 +139,10 @@ namespace MWWorld ///< Play the appropriate sound for a blocked attack, depending on the currently equipped shield /// (default implementation: throw an exception) - virtual std::shared_ptr activate (const Ptr& ptr, const Ptr& actor) const; + virtual std::unique_ptr activate (const Ptr& ptr, const Ptr& actor) const; ///< Generate action for activation (default implementation: return a null action). - virtual std::shared_ptr use (const Ptr& ptr, bool force=false) + virtual std::unique_ptr use (const Ptr& ptr, bool force=false) const; ///< Generate action for using via inventory menu (default implementation: return a /// null action). diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 6517694f15..7f652d9520 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3852,7 +3852,7 @@ namespace MWWorld if (object.getRefData().activate()) { MWBase::Environment::get().getLuaManager()->objectActivated(object, actor); - std::shared_ptr action = object.getClass().activate(object, actor); + std::unique_ptr action = object.getClass().activate(object, actor); action->execute (actor); } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index dc07a9117b..399b7232de 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -97,7 +97,7 @@ namespace MWWorld std::unique_ptr mWorldScene; std::unique_ptr mWeatherManager; std::unique_ptr mCurrentDate; - std::shared_ptr mProjectileManager; + std::unique_ptr mProjectileManager; bool mSky; bool mGodMode;