1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-20 12:11:32 +00:00

Make getScript return string_view

This commit is contained in:
Evil Eye 2022-08-11 22:51:55 +02:00
parent e733dca907
commit 685906afdf
63 changed files with 104 additions and 105 deletions

View file

@ -49,7 +49,7 @@ namespace MWBase
///< Compile all scripts ///< Compile all scripts
/// \return count, success /// \return count, success
virtual const Compiler::Locals& getLocals (const std::string& name) = 0; virtual const Compiler::Locals& getLocals(std::string_view name) = 0;
///< Return locals for script \a name. ///< Return locals for script \a name.
virtual MWScript::GlobalScripts& getGlobalScripts() = 0; virtual MWScript::GlobalScripts& getGlobalScripts() = 0;

View file

@ -77,7 +77,7 @@ namespace MWClass
return ref->mBase->mName; return ref->mBase->mName;
} }
std::string Activator::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Activator::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Activator> *ref = const MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>(); ptr.get<ESM::Activator>();

View file

@ -32,7 +32,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override; MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
std::unique_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;

View file

@ -53,7 +53,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Apparatus::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Apparatus::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>();

View file

@ -27,7 +27,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const override; const MWWorld::Ptr& actor) const override;
///< Generate action for activation ///< Generate action for activation
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
int getValue (const MWWorld::ConstPtr& ptr) const override; int getValue (const MWWorld::ConstPtr& ptr) const override;

View file

@ -73,7 +73,7 @@ namespace MWClass
return ref->mBase->mData.mHealth; return ref->mBase->mData.mHealth;
} }
std::string Armor::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Armor::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();

View file

@ -33,7 +33,7 @@ namespace MWClass
int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const override; int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const override;
///< Return item max health or throw an exception, if class does not have item health ///< Return item max health or throw an exception, if class does not have item health
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override; std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;

View file

@ -70,7 +70,7 @@ namespace MWClass
return std::make_unique<MWWorld::ActionRead>(ptr); return std::make_unique<MWWorld::ActionRead>(ptr);
} }
std::string Book::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Book::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>();

View file

@ -25,7 +25,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const override; const MWWorld::Ptr& actor) const override;
///< Generate action for activation ///< Generate action for activation
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override; MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;

View file

@ -56,7 +56,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Clothing::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Clothing::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();

View file

@ -25,7 +25,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const override; const MWWorld::Ptr& actor) const override;
///< Generate action for activation ///< Generate action for activation
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override; std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;

View file

@ -226,7 +226,7 @@ namespace MWClass
return data.mStore; return data.mStore;
} }
std::string Container::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Container::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();

View file

@ -63,7 +63,7 @@ namespace MWClass
MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const override; MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const override;
///< Return container store ///< Return container store
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
float getCapacity (const MWWorld::Ptr& ptr) const override; float getCapacity (const MWWorld::Ptr& ptr) const override;

View file

@ -488,7 +488,7 @@ namespace MWClass
return isFlagBitSet(ptr, ESM::Creature::Weapon); return isFlagBitSet(ptr, ESM::Creature::Weapon);
} }
std::string Creature::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Creature::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
@ -836,7 +836,7 @@ namespace MWClass
if (ptr.getRefData().getCount() == 0) if (ptr.getRefData().getCount() == 0)
{ {
ptr.getRefData().setCount(1); ptr.getRefData().setCount(1);
const std::string& script = getScript(ptr); std::string_view script = getScript(ptr);
if(!script.empty()) if(!script.empty())
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr); MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr);
} }

View file

@ -80,7 +80,7 @@ namespace MWClass
bool hasInventoryStore (const MWWorld::Ptr &ptr) const override; bool hasInventoryStore (const MWWorld::Ptr &ptr) const override;
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
float getCapacity (const MWWorld::Ptr& ptr) const override; float getCapacity (const MWWorld::Ptr& ptr) const override;

View file

@ -255,7 +255,7 @@ namespace MWClass
return true; return true;
} }
std::string Door::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Door::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();

View file

@ -47,7 +47,7 @@ namespace MWClass
bool allowTelekinesis(const MWWorld::ConstPtr &ptr) const override; bool allowTelekinesis(const MWWorld::ConstPtr &ptr) const override;
///< Return whether this class of object can be activated with telekinesis ///< Return whether this class of object can be activated with telekinesis
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
std::string getModel(const MWWorld::ConstPtr &ptr) const override; std::string getModel(const MWWorld::ConstPtr &ptr) const override;

View file

@ -55,7 +55,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Ingredient::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Ingredient::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>();

View file

@ -28,7 +28,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override; MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
int getValue (const MWWorld::ConstPtr& ptr) const override; int getValue (const MWWorld::ConstPtr& ptr) const override;

View file

@ -96,7 +96,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Light::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Light::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();

View file

@ -38,7 +38,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const override; const MWWorld::Ptr& actor) const override;
///< Generate action for activation ///< Generate action for activation
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override; std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;

View file

@ -55,7 +55,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Lockpick::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Lockpick::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>(); const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>();

View file

@ -28,7 +28,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override; MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override; std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;

View file

@ -65,7 +65,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Miscellaneous::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Miscellaneous::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>();

View file

@ -28,7 +28,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override; MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
int getValue (const MWWorld::ConstPtr& ptr) const override; int getValue (const MWWorld::ConstPtr& ptr) const override;

View file

@ -707,7 +707,7 @@ namespace MWClass
if (setOnPcHitMe && !attacker.isEmpty() && attacker == MWMechanics::getPlayer()) if (setOnPcHitMe && !attacker.isEmpty() && attacker == MWMechanics::getPlayer())
{ {
const std::string &script = getScript(ptr); std::string_view script = getScript(ptr);
/* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */
if(!script.empty()) if(!script.empty())
ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1);
@ -951,7 +951,7 @@ namespace MWClass
return ptr.getRefData().getCustomData()->asNpcCustomData().mInventoryStore; return ptr.getRefData().getCustomData()->asNpcCustomData().mInventoryStore;
} }
std::string Npc::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Npc::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); const MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
@ -1406,7 +1406,7 @@ namespace MWClass
if (ptr.getRefData().getCount() == 0) if (ptr.getRefData().getCount() == 0)
{ {
ptr.getRefData().setCount(1); ptr.getRefData().setCount(1);
const std::string& script = getScript(ptr); std::string_view script = getScript(ptr);
if (!script.empty()) if (!script.empty())
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr); MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr);
} }

View file

@ -87,7 +87,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const override; const MWWorld::Ptr& actor) const override;
///< Generate action for activation ///< Generate action for activation
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
float getMaxSpeed (const MWWorld::Ptr& ptr) const override; float getMaxSpeed (const MWWorld::Ptr& ptr) const override;

View file

@ -57,7 +57,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Potion::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Potion::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Potion> *ref = const MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); ptr.get<ESM::Potion>();

View file

@ -28,7 +28,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override; MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
int getValue (const MWWorld::ConstPtr& ptr) const override; int getValue (const MWWorld::ConstPtr& ptr) const override;

View file

@ -54,7 +54,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Probe::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Probe::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Probe> *ref = const MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); ptr.get<ESM::Probe>();

View file

@ -28,7 +28,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override; MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override; std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;

View file

@ -52,7 +52,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
std::string Repair::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Repair::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Repair> *ref = const MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); ptr.get<ESM::Repair>();

View file

@ -28,7 +28,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override; MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
int getValue (const MWWorld::ConstPtr& ptr) const override; int getValue (const MWWorld::ConstPtr& ptr) const override;

View file

@ -76,7 +76,7 @@ namespace MWClass
return ref->mBase->mData.mHealth; return ref->mBase->mData.mHealth;
} }
std::string Weapon::getScript (const MWWorld::ConstPtr& ptr) const std::string_view Weapon::getScript(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Weapon> *ref = const MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();

View file

@ -34,7 +34,7 @@ namespace MWClass
int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const override; int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const override;
///< Return item max health or throw an exception, if class does not have item health ///< Return item max health or throw an exception, if class does not have item health
std::string getScript (const MWWorld::ConstPtr& ptr) const override; std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override; std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;

View file

@ -201,7 +201,7 @@ namespace MWDialogue
Compiler::Locals locals; Compiler::Locals locals;
std::string actorScript = actor.getClass().getScript (actor); std::string_view actorScript = actor.getClass().getScript(actor);
if (!actorScript.empty()) if (!actorScript.empty())
{ {

View file

@ -173,7 +173,7 @@ bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info, bool invert
bool MWDialogue::Filter::testFunctionLocal(const MWDialogue::SelectWrapper& select) const bool MWDialogue::Filter::testFunctionLocal(const MWDialogue::SelectWrapper& select) const
{ {
std::string scriptName = mActor.getClass().getScript (mActor); std::string_view scriptName = mActor.getClass().getScript(mActor);
if (scriptName.empty()) if (scriptName.empty())
return false; // no script return false; // no script

View file

@ -55,7 +55,7 @@ void test(const MWWorld::Ptr& actor, int &compiled, int &total, const Compiler::
Compiler::Locals locals; Compiler::Locals locals;
std::string actorScript = actor.getClass().getScript(actor); std::string_view actorScript = actor.getClass().getScript(actor);
if (!actorScript.empty()) if (!actorScript.empty())
{ {

View file

@ -7,7 +7,7 @@ namespace
void modifyProfit(const MWWorld::Ptr& actor, int diff) void modifyProfit(const MWWorld::Ptr& actor, int diff)
{ {
std::string script = actor.getClass().getScript(actor); std::string_view script = actor.getClass().getScript(actor);
if (!script.empty()) if (!script.empty())
{ {
int profit = actor.getRefData().getLocals().getIntVar(script, "minimumprofit"); int profit = actor.getRefData().getLocals().getIntVar(script, "minimumprofit");
@ -43,7 +43,7 @@ namespace MWGui
bool CompanionItemModel::hasProfit(const MWWorld::Ptr &actor) bool CompanionItemModel::hasProfit(const MWWorld::Ptr &actor)
{ {
std::string script = actor.getClass().getScript(actor); std::string_view script = actor.getClass().getScript(actor);
if (script.empty()) if (script.empty())
return false; return false;
return actor.getRefData().getLocals().hasVar(script, "minimumprofit"); return actor.getRefData().getLocals().hasVar(script, "minimumprofit");

View file

@ -25,7 +25,7 @@ namespace
int getProfit(const MWWorld::Ptr& actor) int getProfit(const MWWorld::Ptr& actor)
{ {
std::string script = actor.getClass().getScript(actor); std::string_view script = actor.getClass().getScript(actor);
if (!script.empty()) if (!script.empty())
{ {
return actor.getRefData().getLocals().getIntVar(script, "minimumprofit"); return actor.getRefData().getLocals().getIntVar(script, "minimumprofit");

View file

@ -194,7 +194,7 @@ namespace MWGui
Compiler::Locals locals; Compiler::Locals locals;
if (!mPtr.isEmpty()) if (!mPtr.isEmpty())
{ {
std::string script = mPtr.getClass().getScript(mPtr); std::string_view script = mPtr.getClass().getScript(mPtr);
if (!script.empty()) if (!script.empty())
locals = MWBase::Environment::get().getScriptManager()->getLocals(script); locals = MWBase::Environment::get().getScriptManager()->getLocals(script);
} }

View file

@ -257,11 +257,11 @@ namespace MWGui
creatureStats.setDeathAnimationFinished(true); creatureStats.setDeathAnimationFinished(true);
MWBase::Environment::get().getMechanicsManager()->notifyDied(ptr); MWBase::Environment::get().getMechanicsManager()->notifyDied(ptr);
const std::string script = ptr.getClass().getScript(ptr); std::string_view script = ptr.getClass().getScript(ptr);
if (!script.empty() && MWBase::Environment::get().getWorld()->getScriptsEnabled()) if (!script.empty() && MWBase::Environment::get().getWorld()->getScriptsEnabled())
{ {
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr); MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
MWBase::Environment::get().getScriptManager()->run (script, interpreterContext); MWBase::Environment::get().getScriptManager()->run(std::string{script}, interpreterContext);
} }
// Clean up summoned creatures as well // Clean up summoned creatures as well

View file

@ -512,7 +512,7 @@ namespace MWGui
void InventoryWindow::useItem(const MWWorld::Ptr &ptr, bool force) void InventoryWindow::useItem(const MWWorld::Ptr &ptr, bool force)
{ {
const std::string& script = ptr.getClass().getScript(ptr); std::string_view script = ptr.getClass().getScript(ptr);
if (!script.empty()) if (!script.empty())
{ {
// Don't try to equip the item if PCSkipEquip is set to 1 // Don't try to equip the item if PCSkipEquip is set to 1

View file

@ -1447,7 +1447,7 @@ namespace MWMechanics
// If an actor has OnPCHitMe declared in his script, his Fight = 0 and the attacker is player, // If an actor has OnPCHitMe declared in his script, his Fight = 0 and the attacker is player,
// he will attack the player only if we will force him (e.g. via StartCombat console command) // he will attack the player only if we will force him (e.g. via StartCombat console command)
bool peaceful = false; bool peaceful = false;
std::string script = target.getClass().getScript(target); std::string_view script = target.getClass().getScript(target);
if (!script.empty() && target.getRefData().getLocals().hasVar(script, "onpchitme") && attacker == player) if (!script.empty() && target.getRefData().getLocals().hasVar(script, "onpchitme") && attacker == player)
{ {
const int fight = target.getClass().getCreatureStats(target).getAiSetting(AiSetting::Fight).getModified(); const int fight = target.getClass().getCreatureStats(target).getAiSetting(AiSetting::Fight).getModified();

View file

@ -61,8 +61,8 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
MWWorld::ContainerStoreIterator stacked = player.getClass().getContainerStore(player).restack(itemToRepair); MWWorld::ContainerStoreIterator stacked = player.getClass().getContainerStore(player).restack(itemToRepair);
// set the OnPCRepair variable on the item's script // set the OnPCRepair variable on the item's script
std::string script = stacked->getClass().getScript(itemToRepair); std::string_view script = stacked->getClass().getScript(itemToRepair);
if(script != "") if(!script.empty())
stacked->getRefData().getLocals().setVarByInt(script, "onpcrepair", 1); stacked->getRefData().getLocals().setVarByInt(script, "onpcrepair", 1);
// increase skill // increase skill

View file

@ -125,7 +125,7 @@ namespace MWMechanics
// Don't make use of racial bonus spells, like MW. Can be made optional later // Don't make use of racial bonus spells, like MW. Can be made optional later
if (actor.getClass().isNpc()) if (actor.getClass().isNpc())
{ {
std::string raceid = actor.get<ESM::NPC>()->mBase->mRace; const std::string& raceid = actor.get<ESM::NPC>()->mBase->mRace;
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceid); const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceid);
if (race->mPowers.exists(spell->mId)) if (race->mPowers.exists(spell->mId))
return 0.f; return 0.f;
@ -367,7 +367,7 @@ namespace MWMechanics
if (actor.getClass().isNpc()) if (actor.getClass().isNpc())
{ {
// Beast races can't wear helmets or boots // Beast races can't wear helmets or boots
std::string raceid = actor.get<ESM::NPC>()->mBase->mRace; const std::string& raceid = actor.get<ESM::NPC>()->mBase->mRace;
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceid); const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceid);
if (race->mData.mFlags & ESM::Race::Beast) if (race->mData.mFlags & ESM::Race::Beast)
return 0.f; return 0.f;

View file

@ -33,7 +33,7 @@ namespace MWScript
std::pair<char, bool> CompilerContext::getMemberType (const std::string& name, std::pair<char, bool> CompilerContext::getMemberType (const std::string& name,
const std::string& id) const const std::string& id) const
{ {
std::string script; std::string_view script;
bool reference = false; bool reference = false;
if (const ESM::Script *scriptRecord = if (const ESM::Script *scriptRecord =

View file

@ -15,7 +15,7 @@
namespace MWScript namespace MWScript
{ {
void Locals::ensure (const std::string& scriptName) void Locals::ensure(std::string_view scriptName)
{ {
if (!mInitialised) if (!mInitialised)
{ {
@ -62,7 +62,7 @@ namespace MWScript
return (mShorts.empty() && mLongs.empty() && mFloats.empty()); return (mShorts.empty() && mLongs.empty() && mFloats.empty());
} }
bool Locals::hasVar(const std::string &script, std::string_view var) bool Locals::hasVar(std::string_view script, std::string_view var)
{ {
ensure (script); ensure (script);
@ -72,7 +72,7 @@ namespace MWScript
return (index != -1); return (index != -1);
} }
int Locals::getIntVar(const std::string &script, std::string_view var) int Locals::getIntVar(std::string_view script, std::string_view var)
{ {
ensure (script); ensure (script);
@ -98,7 +98,7 @@ namespace MWScript
return 0; return 0;
} }
float Locals::getFloatVar(const std::string &script, std::string_view var) float Locals::getFloatVar(std::string_view script, std::string_view var)
{ {
ensure (script); ensure (script);
@ -124,7 +124,7 @@ namespace MWScript
return 0; return 0;
} }
bool Locals::setVarByInt(const std::string& script, std::string_view var, int val) bool Locals::setVarByInt(std::string_view script, std::string_view var, int val)
{ {
ensure (script); ensure (script);
@ -149,7 +149,7 @@ namespace MWScript
return false; return false;
} }
bool Locals::write (ESM::Locals& locals, const std::string& script) const bool Locals::write(ESM::Locals& locals, std::string_view script) const
{ {
if (!mInitialised) if (!mInitialised)
return false; return false;
@ -188,7 +188,7 @@ namespace MWScript
return true; return true;
} }
void Locals::read (const ESM::Locals& locals, const std::string& script) void Locals::read(const ESM::Locals& locals, std::string_view script)
{ {
ensure (script); ensure (script);

View file

@ -19,7 +19,7 @@ namespace MWScript
{ {
bool mInitialised; bool mInitialised;
void ensure (const std::string& scriptName); void ensure(std::string_view scriptName);
public: public:
std::vector<Interpreter::Type_Short> mShorts; std::vector<Interpreter::Type_Short> mShorts;
@ -39,33 +39,33 @@ namespace MWScript
/// @note var needs to be in lowercase /// @note var needs to be in lowercase
/// ///
/// \note Locals will be automatically configured first, if necessary /// \note Locals will be automatically configured first, if necessary
bool setVarByInt(const std::string& script, std::string_view var, int val); bool setVarByInt(std::string_view script, std::string_view var, int val);
/// \note Locals will be automatically configured first, if necessary /// \note Locals will be automatically configured first, if necessary
// //
// \note If it can not be determined if the variable exists, the error will be // \note If it can not be determined if the variable exists, the error will be
// ignored and false will be returned. // ignored and false will be returned.
bool hasVar(const std::string& script, std::string_view var); bool hasVar(std::string_view script, std::string_view var);
/// if var does not exist, returns 0 /// if var does not exist, returns 0
/// @note var needs to be in lowercase /// @note var needs to be in lowercase
/// ///
/// \note Locals will be automatically configured first, if necessary /// \note Locals will be automatically configured first, if necessary
int getIntVar (const std::string& script, std::string_view var); int getIntVar(std::string_view script, std::string_view var);
/// if var does not exist, returns 0 /// if var does not exist, returns 0
/// @note var needs to be in lowercase /// @note var needs to be in lowercase
/// ///
/// \note Locals will be automatically configured first, if necessary /// \note Locals will be automatically configured first, if necessary
float getFloatVar (const std::string& script, std::string_view var); float getFloatVar(std::string_view script, std::string_view var);
/// \note If locals have not been configured yet, no data is written. /// \note If locals have not been configured yet, no data is written.
/// ///
/// \return Locals written? /// \return Locals written?
bool write (ESM::Locals& locals, const std::string& script) const; bool write(ESM::Locals& locals, std::string_view script) const;
/// \note Locals will be automatically configured first, if necessary /// \note Locals will be automatically configured first, if necessary
void read (const ESM::Locals& locals, const std::string& script); void read(const ESM::Locals& locals, std::string_view script);
}; };
} }

View file

@ -1045,7 +1045,7 @@ namespace MWScript
if (!ptr.isEmpty()) if (!ptr.isEmpty())
{ {
const std::string& script = ptr.getClass().getScript(ptr); std::string_view script = ptr.getClass().getScript(ptr);
if (!script.empty()) if (!script.empty())
{ {
const Compiler::Locals& locals = const Compiler::Locals& locals =
@ -1097,7 +1097,7 @@ namespace MWScript
{ {
std::stringstream str; std::stringstream str;
const std::string script = ptr.getClass().getScript(ptr); std::string_view script = ptr.getClass().getScript(ptr);
if(script.empty()) if(script.empty())
str<< ptr.getCellRef().getRefId()<<" does not have a script."; str<< ptr.getCellRef().getRefId()<<" does not have a script.";
else else

View file

@ -165,7 +165,7 @@ namespace MWScript
return std::make_pair (count, success); return std::make_pair (count, success);
} }
const Compiler::Locals& ScriptManager::getLocals (const std::string& name) const Compiler::Locals& ScriptManager::getLocals(std::string_view name)
{ {
std::string name2 = Misc::StringUtils::lowerCase (name); std::string name2 = Misc::StringUtils::lowerCase (name);
@ -212,7 +212,7 @@ namespace MWScript
return iter->second; return iter->second;
} }
throw std::logic_error ("script " + name + " does not exist"); throw std::logic_error("script " + name2 + " does not exist");
} }
GlobalScripts& ScriptManager::getGlobalScripts() GlobalScripts& ScriptManager::getGlobalScripts()

View file

@ -79,7 +79,7 @@ namespace MWScript
///< Compile all scripts ///< Compile all scripts
/// \return count, success /// \return count, success
const Compiler::Locals& getLocals (const std::string& name) override; const Compiler::Locals& getLocals(std::string_view name) override;
///< Return locals for script \a name. ///< Return locals for script \a name.
GlobalScripts& getGlobalScripts() override; GlobalScripts& getGlobalScripts() override;

View file

@ -71,7 +71,7 @@ namespace MWWorld
{ {
MWWorld::Ptr follower = *it; MWWorld::Ptr follower = *it;
std::string script = follower.getClass().getScript(follower); std::string_view script = follower.getClass().getScript(follower);
if (!includeHostiles && follower.getClass().getCreatureStats(follower).getAiSequence().isInCombat(actor)) if (!includeHostiles && follower.getClass().getCreatureStats(follower).getAiSequence().isInCombat(actor))
continue; continue;

View file

@ -155,9 +155,9 @@ namespace MWWorld
return -1; return -1;
} }
std::string Class::getScript (const ConstPtr& ptr) const std::string_view Class::getScript(const ConstPtr& ptr) const
{ {
return ""; return {};
} }
float Class::getMaxSpeed (const Ptr& ptr) const float Class::getMaxSpeed (const Ptr& ptr) const
@ -291,7 +291,7 @@ namespace MWWorld
std::string Class::getEnchantment (const ConstPtr& ptr) const std::string Class::getEnchantment (const ConstPtr& ptr) const
{ {
return ""; return {};
} }
void Class::adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const void Class::adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const
@ -300,7 +300,7 @@ namespace MWWorld
std::string Class::getModel(const MWWorld::ConstPtr &ptr) const std::string Class::getModel(const MWWorld::ConstPtr &ptr) const
{ {
return ""; return {};
} }
bool Class::useAnim() const bool Class::useAnim() const

View file

@ -170,7 +170,7 @@ namespace MWWorld
///< Returns the remaining duration of the object, such as an equippable light ///< Returns the remaining duration of the object, such as an equippable light
/// source. (default implementation: -1, i.e. infinite) /// source. (default implementation: -1, i.e. infinite)
virtual std::string getScript (const ConstPtr& ptr) const; virtual std::string_view getScript(const ConstPtr& ptr) const;
///< Return name of the script attached to ptr (default implementation: return an empty ///< Return name of the script attached to ptr (default implementation: return an empty
/// string). /// string).

View file

@ -30,7 +30,7 @@ namespace
auto& scripts = MWBase::Environment::get().getWorld()->getLocalScripts(); auto& scripts = MWBase::Environment::get().getWorld()->getLocalScripts();
for(const auto&& ptr : store) for(const auto&& ptr : store)
{ {
const std::string& script = ptr.getClass().getScript(ptr); std::string_view script = ptr.getClass().getScript(ptr);
if(!script.empty()) if(!script.empty())
{ {
MWWorld::Ptr item = ptr; MWWorld::Ptr item = ptr;
@ -208,7 +208,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::unstack(const Ptr &ptr,
if (ptr.getRefData().getCount() <= count) if (ptr.getRefData().getCount() <= count)
return end(); return end();
MWWorld::ContainerStoreIterator it = addNewStack(ptr, subtractItems(ptr.getRefData().getCount(false), count)); MWWorld::ContainerStoreIterator it = addNewStack(ptr, subtractItems(ptr.getRefData().getCount(false), count));
const std::string script = it->getClass().getScript(*it); std::string_view script = it->getClass().getScript(*it);
if (!script.empty()) if (!script.empty())
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, *it); MWBase::Environment::get().getWorld()->getLocalScripts().add(script, *it);
@ -317,7 +317,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
// maybe we should do this in the copy constructor instead? // maybe we should do this in the copy constructor instead?
item.getCellRef().unsetRefNum(); // destroy link to content file item.getCellRef().unsetRefNum(); // destroy link to content file
std::string script = item.getClass().getScript(item); std::string_view script = item.getClass().getScript(item);
if (!script.empty()) if (!script.empty())
{ {
if (actorPtr == player) if (actorPtr == player)

View file

@ -655,8 +655,8 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, c
if (actor == MWMechanics::getPlayer()) if (actor == MWMechanics::getPlayer())
{ {
// Unset OnPCEquip Variable on item's script, if it has a script with that variable declared // Unset OnPCEquip Variable on item's script, if it has a script with that variable declared
const std::string& script = it->getClass().getScript(*it); std::string_view script = it->getClass().getScript(*it);
if (script != "") if (!script.empty())
(*it).getRefData().getLocals().setVarByInt(script, "onpcequip", 0); (*it).getRefData().getLocals().setVarByInt(script, "onpcequip", 0);
} }

View file

@ -27,7 +27,7 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
if (state.mHasLocals) if (state.mHasLocals)
{ {
std::string scriptId = mClass->getScript (ptr); std::string_view scriptId = mClass->getScript(ptr);
// Make sure we still have a script. It could have been coming from a content file that is no longer active. // Make sure we still have a script. It could have been coming from a content file that is no longer active.
if (!scriptId.empty()) if (!scriptId.empty())
{ {

View file

@ -23,7 +23,7 @@ namespace
if (ptr.getRefData().isDeleted()) if (ptr.getRefData().isDeleted())
return true; return true;
std::string script = ptr.getClass().getScript(ptr); std::string_view script = ptr.getClass().getScript(ptr);
if (!script.empty()) if (!script.empty())
mScripts.add(script, ptr); mScripts.add(script, ptr);
@ -48,12 +48,12 @@ namespace
return true; return true;
MWWorld::ContainerStore& container = containerPtr.getClass().getContainerStore(containerPtr); MWWorld::ContainerStore& container = containerPtr.getClass().getContainerStore(containerPtr);
for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it) for(const auto& ptr : container)
{ {
std::string script = it->getClass().getScript(*it); std::string_view script = ptr.getClass().getScript(ptr);
if(script != "") if(!script.empty())
{ {
MWWorld::Ptr item = *it; MWWorld::Ptr item = ptr;
item.mCell = containerPtr.getCell(); item.mCell = containerPtr.getCell();
mScripts.add (script, item); mScripts.add (script, item);
} }
@ -85,7 +85,7 @@ bool MWWorld::LocalScripts::getNext(std::pair<std::string, Ptr>& script)
return false; return false;
} }
void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) void MWWorld::LocalScripts::add(std::string_view scriptName, const Ptr& ptr)
{ {
if (const ESM::Script *script = mStore.get<ESM::Script>().search (scriptName)) if (const ESM::Script *script = mStore.get<ESM::Script>().search (scriptName))
{ {

View file

@ -30,7 +30,7 @@ namespace MWWorld
///< Get next local script ///< Get next local script
/// @return Did we get a script? /// @return Did we get a script?
void add (const std::string& scriptName, const Ptr& ptr); void add(std::string_view scriptName, const Ptr& ptr);
///< Add script to collection of active local scripts. ///< Add script to collection of active local scripts.
void addCell (CellStore *cell); void addCell (CellStore *cell);

View file

@ -102,7 +102,7 @@ namespace MWWorld
} }
} }
void RefData::write (ESM::ObjectState& objectState, const std::string& scriptId) const void RefData::write(ESM::ObjectState& objectState, std::string_view scriptId) const
{ {
objectState.mHasLocals = mLocals.write (objectState.mLocals, scriptId); objectState.mHasLocals = mLocals.write (objectState.mLocals, scriptId);

View file

@ -82,7 +82,7 @@ namespace MWWorld
~RefData(); ~RefData();
void write (ESM::ObjectState& objectState, const std::string& scriptId = "") const; void write(ESM::ObjectState& objectState, std::string_view scriptId = {}) const;
///< Ignores custom data (not enough context available here to ///< Ignores custom data (not enough context available here to
/// perform this operations). /// perform this operations).

View file

@ -816,8 +816,8 @@ namespace MWWorld
MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference); MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference);
for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it) for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it)
{ {
std::string script = it->getClass().getScript(*it); std::string_view script = it->getClass().getScript(*it);
if(script != "") if(!script.empty())
{ {
MWWorld::Ptr item = *it; MWWorld::Ptr item = *it;
item.mCell = cell; item.mCell = cell;
@ -859,8 +859,8 @@ namespace MWWorld
MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference); MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference);
for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it) for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it)
{ {
std::string script = it->getClass().getScript(*it); std::string_view script = it->getClass().getScript(*it);
if(script != "") if(!script.empty())
{ {
MWWorld::Ptr item = *it; MWWorld::Ptr item = *it;
mLocalScripts.remove (item); mLocalScripts.remove (item);
@ -1140,7 +1140,7 @@ namespace MWWorld
&& ptr.getRefData().isEnabled()) && ptr.getRefData().isEnabled())
{ {
mWorldScene->addObjectToScene(ptr); mWorldScene->addObjectToScene(ptr);
std::string script = ptr.getClass().getScript(ptr); std::string_view script = ptr.getClass().getScript(ptr);
if (!script.empty()) if (!script.empty())
mLocalScripts.add(script, ptr); mLocalScripts.add(script, ptr);
addContainerScripts(ptr, ptr.getCell()); addContainerScripts(ptr, ptr.getCell());
@ -1196,7 +1196,7 @@ namespace MWWorld
if(newPtr.getRefData().isEnabled()) if(newPtr.getRefData().isEnabled())
mWorldScene->addObjectToScene(newPtr); mWorldScene->addObjectToScene(newPtr);
std::string script = newPtr.getClass().getScript(newPtr); std::string_view script = newPtr.getClass().getScript(newPtr);
if (!script.empty()) if (!script.empty())
{ {
mLocalScripts.add(script, newPtr); mLocalScripts.add(script, newPtr);
@ -1226,8 +1226,7 @@ namespace MWWorld
MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager(); MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager();
mechMgr->updateCell(ptr, newPtr); mechMgr->updateCell(ptr, newPtr);
std::string script = std::string_view script = ptr.getClass().getScript(ptr);
ptr.getClass().getScript(ptr);
if (!script.empty()) if (!script.empty())
{ {
mLocalScripts.remove(ptr); mLocalScripts.remove(ptr);
@ -2135,10 +2134,10 @@ namespace MWWorld
void World::PCDropped (const Ptr& item) void World::PCDropped (const Ptr& item)
{ {
std::string script = item.getClass().getScript(item); std::string_view script = item.getClass().getScript(item);
// Set OnPCDrop Variable on item's script, if it has a script with that variable declared // Set OnPCDrop Variable on item's script, if it has a script with that variable declared
if(script != "") if(!script.empty())
item.getRefData().getLocals().setVarByInt(script, "onpcdrop", 1); item.getRefData().getLocals().setVarByInt(script, "onpcdrop", 1);
} }
@ -2209,7 +2208,7 @@ namespace MWWorld
if (dropped.getRefData().isEnabled()) { if (dropped.getRefData().isEnabled()) {
mWorldScene->addObjectToScene(dropped); mWorldScene->addObjectToScene(dropped);
} }
std::string script = dropped.getClass().getScript(dropped); std::string_view script = dropped.getClass().getScript(dropped);
if (!script.empty()) { if (!script.empty()) {
mLocalScripts.add(script, dropped); mLocalScripts.add(script, dropped);
} }