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<T>(new T).
pull/3226/head
elsid 3 years ago
parent 320e86156e
commit ec3674b40a
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -272,39 +272,39 @@ namespace ESSImport
const unsigned int recJOUR = ESM::fourCC("JOUR");
const unsigned int recSPLM = ESM::fourCC("SPLM");
std::map<unsigned int, std::shared_ptr<Converter> > converters;
converters[ESM::REC_GLOB] = std::shared_ptr<Converter>(new ConvertGlobal());
converters[ESM::REC_BOOK] = std::shared_ptr<Converter>(new ConvertBook());
converters[ESM::REC_NPC_] = std::shared_ptr<Converter>(new ConvertNPC());
converters[ESM::REC_CREA] = std::shared_ptr<Converter>(new ConvertCREA());
converters[ESM::REC_NPCC] = std::shared_ptr<Converter>(new ConvertNPCC());
converters[ESM::REC_CREC] = std::shared_ptr<Converter>(new ConvertCREC());
converters[recREFR ] = std::shared_ptr<Converter>(new ConvertREFR());
converters[recPCDT ] = std::shared_ptr<Converter>(new ConvertPCDT());
converters[recFMAP ] = std::shared_ptr<Converter>(new ConvertFMAP());
converters[recKLST ] = std::shared_ptr<Converter>(new ConvertKLST());
converters[recSTLN ] = std::shared_ptr<Converter>(new ConvertSTLN());
converters[recGAME ] = std::shared_ptr<Converter>(new ConvertGAME());
converters[ESM::REC_CELL] = std::shared_ptr<Converter>(new ConvertCell());
converters[ESM::REC_ALCH] = std::shared_ptr<Converter>(new DefaultConverter<ESM::Potion>());
converters[ESM::REC_CLAS] = std::shared_ptr<Converter>(new ConvertClass());
converters[ESM::REC_SPEL] = std::shared_ptr<Converter>(new DefaultConverter<ESM::Spell>());
converters[ESM::REC_ARMO] = std::shared_ptr<Converter>(new DefaultConverter<ESM::Armor>());
converters[ESM::REC_WEAP] = std::shared_ptr<Converter>(new DefaultConverter<ESM::Weapon>());
converters[ESM::REC_CLOT] = std::shared_ptr<Converter>(new DefaultConverter<ESM::Clothing>());
converters[ESM::REC_ENCH] = std::shared_ptr<Converter>(new DefaultConverter<ESM::Enchantment>());
converters[ESM::REC_WEAP] = std::shared_ptr<Converter>(new DefaultConverter<ESM::Weapon>());
converters[ESM::REC_LEVC] = std::shared_ptr<Converter>(new DefaultConverter<ESM::CreatureLevList>());
converters[ESM::REC_LEVI] = std::shared_ptr<Converter>(new DefaultConverter<ESM::ItemLevList>());
converters[ESM::REC_CNTC] = std::shared_ptr<Converter>(new ConvertCNTC());
converters[ESM::REC_FACT] = std::shared_ptr<Converter>(new ConvertFACT());
converters[ESM::REC_INFO] = std::shared_ptr<Converter>(new ConvertINFO());
converters[ESM::REC_DIAL] = std::shared_ptr<Converter>(new ConvertDIAL());
converters[ESM::REC_QUES] = std::shared_ptr<Converter>(new ConvertQUES());
converters[recJOUR ] = std::shared_ptr<Converter>(new ConvertJOUR());
converters[ESM::REC_SCPT] = std::shared_ptr<Converter>(new ConvertSCPT());
converters[ESM::REC_PROJ] = std::shared_ptr<Converter>(new ConvertPROJ());
converters[recSPLM] = std::shared_ptr<Converter>(new ConvertSPLM());
std::map<unsigned int, std::unique_ptr<Converter>> converters;
converters[ESM::REC_GLOB] = std::unique_ptr<Converter>(new ConvertGlobal());
converters[ESM::REC_BOOK] = std::unique_ptr<Converter>(new ConvertBook());
converters[ESM::REC_NPC_] = std::unique_ptr<Converter>(new ConvertNPC());
converters[ESM::REC_CREA] = std::unique_ptr<Converter>(new ConvertCREA());
converters[ESM::REC_NPCC] = std::unique_ptr<Converter>(new ConvertNPCC());
converters[ESM::REC_CREC] = std::unique_ptr<Converter>(new ConvertCREC());
converters[recREFR ] = std::unique_ptr<Converter>(new ConvertREFR());
converters[recPCDT ] = std::unique_ptr<Converter>(new ConvertPCDT());
converters[recFMAP ] = std::unique_ptr<Converter>(new ConvertFMAP());
converters[recKLST ] = std::unique_ptr<Converter>(new ConvertKLST());
converters[recSTLN ] = std::unique_ptr<Converter>(new ConvertSTLN());
converters[recGAME ] = std::unique_ptr<Converter>(new ConvertGAME());
converters[ESM::REC_CELL] = std::unique_ptr<Converter>(new ConvertCell());
converters[ESM::REC_ALCH] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Potion>());
converters[ESM::REC_CLAS] = std::unique_ptr<Converter>(new ConvertClass());
converters[ESM::REC_SPEL] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Spell>());
converters[ESM::REC_ARMO] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Armor>());
converters[ESM::REC_WEAP] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Weapon>());
converters[ESM::REC_CLOT] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Clothing>());
converters[ESM::REC_ENCH] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Enchantment>());
converters[ESM::REC_WEAP] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Weapon>());
converters[ESM::REC_LEVC] = std::unique_ptr<Converter>(new DefaultConverter<ESM::CreatureLevList>());
converters[ESM::REC_LEVI] = std::unique_ptr<Converter>(new DefaultConverter<ESM::ItemLevList>());
converters[ESM::REC_CNTC] = std::unique_ptr<Converter>(new ConvertCNTC());
converters[ESM::REC_FACT] = std::unique_ptr<Converter>(new ConvertFACT());
converters[ESM::REC_INFO] = std::unique_ptr<Converter>(new ConvertINFO());
converters[ESM::REC_DIAL] = std::unique_ptr<Converter>(new ConvertDIAL());
converters[ESM::REC_QUES] = std::unique_ptr<Converter>(new ConvertQUES());
converters[recJOUR ] = std::unique_ptr<Converter>(new ConvertJOUR());
converters[ESM::REC_SCPT] = std::unique_ptr<Converter>(new ConvertSCPT());
converters[ESM::REC_PROJ] = std::unique_ptr<Converter>(new ConvertPROJ());
converters[recSPLM] = std::unique_ptr<Converter>(new ConvertSPLM());
// TODO:
// - REGN (weather in certain regions?)

@ -111,7 +111,7 @@ namespace MWClass
return info;
}
std::shared_ptr<MWWorld::Action> Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const
std::unique_ptr<MWWorld::Action> 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<ESM::Sound>().searchRandom("WolfActivator", prng);
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
if(sound) action->setSound(sound->mId);
return action;
}
return std::shared_ptr<MWWorld::Action>(new MWWorld::NullAction);
return std::unique_ptr<MWWorld::Action>(new MWWorld::NullAction);
}

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
///< Generate action for activation
std::string getModel(const MWWorld::ConstPtr &ptr) const override;

@ -49,7 +49,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Apparatus::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Apparatus::use (const MWWorld::Ptr& ptr, bool force) const
{
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy(force));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy(force));
}
MWWorld::Ptr Apparatus::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -57,7 +57,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr, bool force) const
{
std::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
action->setSound(getUpSoundId(ptr));

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -54,7 +54,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<ESM::Sound>().searchRandom("WolfItem", prng);
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
if(sound) action->setSound(sound->mId);
return action;
}
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr));
return std::unique_ptr<MWWorld::Action>(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<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr, bool force) const
{
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr));
}
MWWorld::Ptr Book::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -52,7 +52,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr, bool force) const
{
std::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
action->setSound(getUpSoundId(ptr));

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -131,11 +131,11 @@ namespace MWClass
return true;
}
std::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return std::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
return std::unique_ptr<MWWorld::Action> (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<ESM::Sound>().searchRandom("WolfContainer", prng);
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> action (new MWWorld::ActionHarvest(ptr));
std::unique_ptr<MWWorld::Action> action (new MWWorld::ActionHarvest(ptr));
return action;
}
std::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
std::unique_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
return action;
}
else
{
// Activate trap
std::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr));
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr));
action->setSound(trapActivationSound);
return action;
}
}
else
{
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction(std::string(), ptr));
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction(std::string(), ptr));
action->setSound(lockedSound);
return action;
}

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const override;
///< Generate action for activation

@ -430,7 +430,7 @@ namespace MWClass
}
}
std::shared_ptr<MWWorld::Action> Creature::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<ESM::Sound>().searchRandom("WolfCreature", prng);
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
// otherwise wait until death animation
if(stats.isDeathAnimationFinished())
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
}
else if (!stats.getAiSequence().isInCombat() && !stats.getKnockedDown())
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionTalk(ptr));
return std::unique_ptr<MWWorld::Action>(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<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
return std::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction(""));
return std::unique_ptr<MWWorld::Action>(new MWWorld::FailedAction(""));
}
MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const override;
///< Generate action for activation

@ -109,7 +109,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();
@ -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<MWWorld::Action> action(new MWWorld::FailedAction(std::string(), ptr));
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr));
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> action(new MWWorld::FailedAction);
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction);
return action;
}
else
{
std::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true));
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> action(new MWWorld::ActionDoor(ptr));
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> action(new MWWorld::FailedAction(std::string(), ptr));
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction(std::string(), ptr));
action->setSound(lockedSound);
return action;
}

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const override;
///< Generate action for activation

@ -51,7 +51,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
return defaultItemActivate(ptr, actor);
@ -72,9 +72,9 @@ namespace MWClass
}
std::shared_ptr<MWWorld::Action> Ingredient::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Ingredient::use (const MWWorld::Ptr& ptr, bool force) const
{
std::shared_ptr<MWWorld::Action> action (new MWWorld::ActionEat (ptr));
std::unique_ptr<MWWorld::Action> action (new MWWorld::ActionEat (ptr));
action->setSound ("Swallow");

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -85,15 +85,15 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return std::shared_ptr<MWWorld::Action>(new MWWorld::NullAction());
return std::unique_ptr<MWWorld::Action>(new MWWorld::NullAction());
MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
if(!(ref->mBase->mData.mFlags&ESM::Light::Carry))
return std::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction());
return std::unique_ptr<MWWorld::Action>(new MWWorld::FailedAction());
return defaultItemActivate(ptr, actor);
}
@ -184,9 +184,9 @@ namespace MWClass
return Class::showsInInventory(ptr);
}
std::shared_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr, bool force) const
{
std::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
action->setSound(getUpSoundId(ptr));

@ -34,7 +34,7 @@ namespace MWClass
bool showsInInventory (const MWWorld::ConstPtr& ptr) const override;
std::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -51,7 +51,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr, bool force) const
{
std::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
action->setSound(getUpSoundId(ptr));

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const override;
///< Generate action for activation
@ -49,7 +49,7 @@ namespace MWClass
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override;
std::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -61,7 +61,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const
{
if (ptr.getCellRef().getSoul().empty() || !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ptr.getCellRef().getSoul()))
return std::shared_ptr<MWWorld::Action>(new MWWorld::NullAction());
return std::unique_ptr<MWWorld::Action>(new MWWorld::NullAction());
else
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionSoulgem(ptr));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionSoulgem(ptr));
}
bool Miscellaneous::canSell (const MWWorld::ConstPtr& item, int npcServices) const

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -860,12 +860,12 @@ namespace MWClass
}
}
std::shared_ptr<MWWorld::Action> Npc::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action>(new MWWorld::ActionTalk(actor));
return std::unique_ptr<MWWorld::Action>(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<ESM::Sound>().searchRandom("WolfNPC", prng);
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
// otherwise wait until death animation
if(stats.isDeathAnimationFinished())
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
}
else if (!stats.getAiSequence().isInCombat())
{
if (stats.getKnockedDown() || MWBase::Environment::get().getMechanicsManager()->isSneaking(actor))
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
// Can't talk to werewolves
if (!getNpcStats(ptr).isWerewolf())
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionTalk(ptr));
return std::unique_ptr<MWWorld::Action>(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<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
return std::unique_ptr<MWWorld::Action>(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<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr));
return std::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction(""));
return std::unique_ptr<MWWorld::Action> (new MWWorld::FailedAction(""));
}
MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr)

@ -83,7 +83,7 @@ namespace MWClass
void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& 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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const override;
///< Generate action for activation

@ -53,7 +53,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Potion::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Potion::use (const MWWorld::Ptr& ptr, bool force) const
{
MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>();
std::shared_ptr<MWWorld::Action> action (
std::unique_ptr<MWWorld::Action> action (
new MWWorld::ActionApply (ptr, ref->mBase->mId));
action->setSound ("Drink");

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -50,7 +50,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr, bool force) const
{
std::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
action->setSound(getUpSoundId(ptr));

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const override;
///< Generate action for activation
@ -49,7 +49,7 @@ namespace MWClass
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override;
std::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -48,7 +48,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Repair::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Repair::use (const MWWorld::Ptr& ptr, bool force) const
{
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionRepair(ptr, force));
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionRepair(ptr, force));
}
bool Repair::canSell (const MWWorld::ConstPtr& item, int npcServices) const

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
///< Generate action for using via inventory menu (default implementation: return a
/// null action).

@ -57,7 +57,7 @@ namespace MWClass
return !name.empty() ? name : ref->mBase->mId;
}
std::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr, bool force) const
std::unique_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr, bool force) const
{
std::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force));
action->setSound(getUpSoundId(ptr));

@ -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<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
std::unique_ptr<MWWorld::Action> 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<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
std::unique_ptr<MWWorld::Action> 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;

@ -561,7 +561,7 @@ namespace MWGui
ptr.getRefData().getLocals().setVarByInt(script, "pcskipequip", 1);
}
std::shared_ptr<MWWorld::Action> action = ptr.getClass().use(ptr, force);
std::unique_ptr<MWWorld::Action> action = ptr.getClass().use(ptr, force);
action->execute(player);
if (isVisible())

@ -256,7 +256,7 @@ namespace MWGui
if ((mFilter & Filter_OnlyUsableItems) && base.getClass().getScript(base).empty())
{
std::shared_ptr<MWWorld::Action> actionOnUse = base.getClass().use(base);
std::unique_ptr<MWWorld::Action> actionOnUse = base.getClass().use(base);
if (!actionOnUse || actionOnUse->isNullAction())
return false;
}

@ -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<MWWorld::Action> action = object.getClass().activate(object, actor);
std::unique_ptr<MWWorld::Action> action = object.getClass().activate(object, actor);
action->execute(actor);
}

@ -185,7 +185,7 @@ namespace MWMechanics
actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true);
float& actionCooldown = storage.mActionCooldown;
std::shared_ptr<Action>& currentAction = storage.mCurrentAction;
std::unique_ptr<Action>& currentAction = storage.mCurrentAction;
if (!forceFlee)
{

@ -36,7 +36,7 @@ namespace MWMechanics
bool mRotateMove;
osg::Vec3f mLastTargetPos;
const MWWorld::CellStore* mCell;
std::shared_ptr<Action> mCurrentAction;
std::unique_ptr<Action> mCurrentAction;
float mActionCooldown;
float mStrength;
bool mForceNoShortcut;

@ -141,14 +141,14 @@ namespace MWMechanics
return mWeapon.get<ESM::Weapon>()->mBase;
}
std::shared_ptr<Action> prepareNextAction(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
std::unique_ptr<Action> 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<Action> bestAction (new ActionWeapon(MWWorld::Ptr()));
std::unique_ptr<Action> bestAction (new ActionWeapon(MWWorld::Ptr()));
if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{
bestAction->prepare(actor);

@ -85,7 +85,7 @@ namespace MWMechanics
const ESM::Weapon* getWeapon() const override;
};
std::shared_ptr<Action> prepareNextAction (const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
std::unique_ptr<Action> 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);

@ -320,7 +320,7 @@ namespace MWScript
MWBase::Environment::get().getWindowManager()->useItem(*it, true);
else
{
std::shared_ptr<MWWorld::Action> action = it->getClass().use(*it, true);
std::unique_ptr<MWWorld::Action> action = it->getClass().use(*it, true);
action->execute(ptr, true);
}
}

@ -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<MWWorld::Action> action = (ptr.getClass().activate(ptr, actor));
std::unique_ptr<MWWorld::Action> action = (ptr.getClass().activate(ptr, actor));
action->execute (actor);
if (action->getTarget() != MWWorld::Ptr() && action->getTarget() != ptr)
{

@ -115,14 +115,14 @@ namespace MWWorld
throw std::runtime_error("class cannot be hit");
}
std::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const
std::unique_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const
{
return std::shared_ptr<Action> (new NullAction);
return std::unique_ptr<Action> (new NullAction);
}
std::shared_ptr<Action> Class::use (const Ptr& ptr, bool force) const
std::unique_ptr<Action> Class::use (const Ptr& ptr, bool force) const
{
return std::shared_ptr<Action> (new NullAction);
return std::unique_ptr<Action> (new NullAction);
}
ContainerStore& Class::getContainerStore (const Ptr& ptr) const
@ -329,10 +329,10 @@ namespace MWWorld
{
}
std::shared_ptr<Action> Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const
std::unique_ptr<Action> Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const
{
if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return std::shared_ptr<Action>(new NullAction());
return std::unique_ptr<Action>(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<ESM::Sound>().searchRandom("WolfItem", prng);
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
if(sound) action->setSound(sound->mId);
return action;
}
std::shared_ptr<MWWorld::Action> action(new ActionTake(ptr));
std::unique_ptr<MWWorld::Action> action(new ActionTake(ptr));
action->setSound(getUpSoundId(ptr));
return action;

@ -62,7 +62,7 @@ namespace MWWorld
explicit Class(unsigned type) : mType(type) {}
std::shared_ptr<Action> defaultItemActivate(const Ptr &ptr, const Ptr &actor) const;
std::unique_ptr<Action> 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<Action> activate (const Ptr& ptr, const Ptr& actor) const;
virtual std::unique_ptr<Action> activate (const Ptr& ptr, const Ptr& actor) const;
///< Generate action for activation (default implementation: return a null action).
virtual std::shared_ptr<Action> use (const Ptr& ptr, bool force=false)
virtual std::unique_ptr<Action> use (const Ptr& ptr, bool force=false)
const;
///< Generate action for using via inventory menu (default implementation: return a
/// null action).

@ -3852,7 +3852,7 @@ namespace MWWorld
if (object.getRefData().activate())
{
MWBase::Environment::get().getLuaManager()->objectActivated(object, actor);
std::shared_ptr<MWWorld::Action> action = object.getClass().activate(object, actor);
std::unique_ptr<MWWorld::Action> action = object.getClass().activate(object, actor);
action->execute (actor);
}
}

@ -97,7 +97,7 @@ namespace MWWorld
std::unique_ptr<MWWorld::Scene> mWorldScene;
std::unique_ptr<MWWorld::WeatherManager> mWeatherManager;
std::unique_ptr<MWWorld::DateTimeManager> mCurrentDate;
std::shared_ptr<ProjectileManager> mProjectileManager;
std::unique_ptr<ProjectileManager> mProjectileManager;
bool mSky;
bool mGodMode;

Loading…
Cancel
Save