mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 00:26:39 +00:00 
			
		
		
		
	Make getScript return string_view
This commit is contained in:
		
							parent
							
								
									e733dca907
								
							
						
					
					
						commit
						685906afdf
					
				
					 63 changed files with 104 additions and 105 deletions
				
			
		| 
						 | 
				
			
			@ -49,7 +49,7 @@ namespace MWBase
 | 
			
		|||
            ///< Compile all scripts
 | 
			
		||||
            /// \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.
 | 
			
		||||
 | 
			
		||||
            virtual MWScript::GlobalScripts& getGlobalScripts() = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ namespace MWClass
 | 
			
		|||
        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 =
 | 
			
		||||
            ptr.get<ESM::Activator>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ namespace MWClass
 | 
			
		|||
            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.
 | 
			
		||||
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
            std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,7 +53,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ namespace MWClass
 | 
			
		|||
                const MWWorld::Ptr& actor) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            int getValue (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,7 +73,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ namespace MWClass
 | 
			
		|||
            int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,7 +70,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ namespace MWClass
 | 
			
		|||
                const MWWorld::Ptr& actor) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ namespace MWClass
 | 
			
		|||
                const MWWorld::Ptr& actor) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -226,7 +226,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ namespace MWClass
 | 
			
		|||
            MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            float getCapacity (const MWWorld::Ptr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -488,7 +488,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -836,7 +836,7 @@ namespace MWClass
 | 
			
		|||
                if (ptr.getRefData().getCount() == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    ptr.getRefData().setCount(1);
 | 
			
		||||
                    const std::string& script = getScript(ptr);
 | 
			
		||||
                    std::string_view script = getScript(ptr);
 | 
			
		||||
                    if(!script.empty())
 | 
			
		||||
                        MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr);
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ namespace MWClass
 | 
			
		|||
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
            float getCapacity (const MWWorld::Ptr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -255,7 +255,7 @@ namespace MWClass
 | 
			
		|||
            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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ namespace MWClass
 | 
			
		|||
            bool allowTelekinesis(const MWWorld::ConstPtr &ptr) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            std::string getModel(const MWWorld::ConstPtr &ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ namespace MWClass
 | 
			
		|||
            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.
 | 
			
		||||
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
            int getValue (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ namespace MWClass
 | 
			
		|||
                const MWWorld::Ptr& actor) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ namespace MWClass
 | 
			
		|||
            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.
 | 
			
		||||
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
            std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,7 +65,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ namespace MWClass
 | 
			
		|||
            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.
 | 
			
		||||
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
            int getValue (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -707,7 +707,7 @@ namespace MWClass
 | 
			
		|||
 | 
			
		||||
        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. */
 | 
			
		||||
            if(!script.empty())
 | 
			
		||||
                ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1);
 | 
			
		||||
| 
						 | 
				
			
			@ -951,7 +951,7 @@ namespace MWClass
 | 
			
		|||
        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>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1406,7 +1406,7 @@ namespace MWClass
 | 
			
		|||
                if (ptr.getRefData().getCount() == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    ptr.getRefData().setCount(1);
 | 
			
		||||
                    const std::string& script = getScript(ptr);
 | 
			
		||||
                    std::string_view script = getScript(ptr);
 | 
			
		||||
                    if (!script.empty())
 | 
			
		||||
                        MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr);
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -87,7 +87,7 @@ namespace MWClass
 | 
			
		|||
                const MWWorld::Ptr& actor) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            float getMaxSpeed (const MWWorld::Ptr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ namespace MWClass
 | 
			
		|||
        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 =
 | 
			
		||||
            ptr.get<ESM::Potion>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ namespace MWClass
 | 
			
		|||
            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.
 | 
			
		||||
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
            int getValue (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ namespace MWClass
 | 
			
		|||
        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 =
 | 
			
		||||
            ptr.get<ESM::Probe>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ namespace MWClass
 | 
			
		|||
            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.
 | 
			
		||||
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
            std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ namespace MWClass
 | 
			
		|||
        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 =
 | 
			
		||||
            ptr.get<ESM::Repair>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ namespace MWClass
 | 
			
		|||
            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.
 | 
			
		||||
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
            int getValue (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ namespace MWClass
 | 
			
		|||
        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 =
 | 
			
		||||
            ptr.get<ESM::Weapon>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,7 +34,7 @@ namespace MWClass
 | 
			
		|||
            int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
            ///< 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
 | 
			
		||||
 | 
			
		||||
            std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -201,7 +201,7 @@ namespace MWDialogue
 | 
			
		|||
 | 
			
		||||
            Compiler::Locals locals;
 | 
			
		||||
 | 
			
		||||
            std::string actorScript = actor.getClass().getScript (actor);
 | 
			
		||||
            std::string_view actorScript = actor.getClass().getScript(actor);
 | 
			
		||||
 | 
			
		||||
            if (!actorScript.empty())
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -173,7 +173,7 @@ bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info, bool invert
 | 
			
		|||
 | 
			
		||||
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())
 | 
			
		||||
        return false; // no script
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ void test(const MWWorld::Ptr& actor, int &compiled, int &total, const Compiler::
 | 
			
		|||
 | 
			
		||||
                    Compiler::Locals locals;
 | 
			
		||||
 | 
			
		||||
                    std::string actorScript = actor.getClass().getScript(actor);
 | 
			
		||||
                    std::string_view actorScript = actor.getClass().getScript(actor);
 | 
			
		||||
 | 
			
		||||
                    if (!actorScript.empty())
 | 
			
		||||
                    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ namespace
 | 
			
		|||
 | 
			
		||||
    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())
 | 
			
		||||
        {
 | 
			
		||||
            int profit = actor.getRefData().getLocals().getIntVar(script, "minimumprofit");
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ namespace MWGui
 | 
			
		|||
 | 
			
		||||
    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())
 | 
			
		||||
            return false;
 | 
			
		||||
        return actor.getRefData().getLocals().hasVar(script, "minimumprofit");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ namespace
 | 
			
		|||
 | 
			
		||||
    int getProfit(const MWWorld::Ptr& actor)
 | 
			
		||||
    {
 | 
			
		||||
        std::string script = actor.getClass().getScript(actor);
 | 
			
		||||
        std::string_view script = actor.getClass().getScript(actor);
 | 
			
		||||
        if (!script.empty())
 | 
			
		||||
        {
 | 
			
		||||
            return actor.getRefData().getLocals().getIntVar(script, "minimumprofit");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -194,7 +194,7 @@ namespace MWGui
 | 
			
		|||
        Compiler::Locals locals;
 | 
			
		||||
        if (!mPtr.isEmpty())
 | 
			
		||||
        {
 | 
			
		||||
            std::string script = mPtr.getClass().getScript(mPtr);
 | 
			
		||||
            std::string_view script = mPtr.getClass().getScript(mPtr);
 | 
			
		||||
            if (!script.empty())
 | 
			
		||||
                locals = MWBase::Environment::get().getScriptManager()->getLocals(script);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -257,11 +257,11 @@ namespace MWGui
 | 
			
		|||
                    creatureStats.setDeathAnimationFinished(true);
 | 
			
		||||
                    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())
 | 
			
		||||
                    {
 | 
			
		||||
                        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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -512,7 +512,7 @@ namespace MWGui
 | 
			
		|||
 | 
			
		||||
    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())
 | 
			
		||||
        {
 | 
			
		||||
            // Don't try to equip the item if PCSkipEquip is set to 1
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1447,7 +1447,7 @@ namespace MWMechanics
 | 
			
		|||
                // 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)
 | 
			
		||||
                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)
 | 
			
		||||
                {
 | 
			
		||||
                    const int fight = target.getClass().getCreatureStats(target).getAiSetting(AiSetting::Fight).getModified();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,8 +61,8 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
 | 
			
		|||
        MWWorld::ContainerStoreIterator stacked = player.getClass().getContainerStore(player).restack(itemToRepair);
 | 
			
		||||
 | 
			
		||||
        // set the OnPCRepair variable on the item's script
 | 
			
		||||
        std::string script = stacked->getClass().getScript(itemToRepair);
 | 
			
		||||
        if(script != "")
 | 
			
		||||
        std::string_view script = stacked->getClass().getScript(itemToRepair);
 | 
			
		||||
        if(!script.empty())
 | 
			
		||||
            stacked->getRefData().getLocals().setVarByInt(script, "onpcrepair", 1);
 | 
			
		||||
 | 
			
		||||
        // increase skill
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -125,7 +125,7 @@ namespace MWMechanics
 | 
			
		|||
        // Don't make use of racial bonus spells, like MW. Can be made optional later
 | 
			
		||||
        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);
 | 
			
		||||
            if (race->mPowers.exists(spell->mId))
 | 
			
		||||
                return 0.f;
 | 
			
		||||
| 
						 | 
				
			
			@ -367,7 +367,7 @@ namespace MWMechanics
 | 
			
		|||
            if (actor.getClass().isNpc())
 | 
			
		||||
            {
 | 
			
		||||
                // 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);
 | 
			
		||||
                if (race->mData.mFlags & ESM::Race::Beast)
 | 
			
		||||
                    return 0.f;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ namespace MWScript
 | 
			
		|||
    std::pair<char, bool> CompilerContext::getMemberType (const std::string& name,
 | 
			
		||||
        const std::string& id) const
 | 
			
		||||
    {
 | 
			
		||||
        std::string script;
 | 
			
		||||
        std::string_view script;
 | 
			
		||||
        bool reference = false;
 | 
			
		||||
 | 
			
		||||
        if (const ESM::Script *scriptRecord =
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@
 | 
			
		|||
 | 
			
		||||
namespace MWScript
 | 
			
		||||
{
 | 
			
		||||
    void Locals::ensure (const std::string& scriptName)
 | 
			
		||||
    void Locals::ensure(std::string_view scriptName)
 | 
			
		||||
    {
 | 
			
		||||
        if (!mInitialised)
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			@ -62,7 +62,7 @@ namespace MWScript
 | 
			
		|||
        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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ namespace MWScript
 | 
			
		|||
        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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -98,7 +98,7 @@ namespace MWScript
 | 
			
		|||
        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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +124,7 @@ namespace MWScript
 | 
			
		|||
        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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -149,7 +149,7 @@ namespace MWScript
 | 
			
		|||
        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)
 | 
			
		||||
            return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -188,7 +188,7 @@ namespace MWScript
 | 
			
		|||
        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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ namespace MWScript
 | 
			
		|||
    {
 | 
			
		||||
            bool mInitialised;
 | 
			
		||||
 | 
			
		||||
            void ensure (const std::string& scriptName);
 | 
			
		||||
            void ensure(std::string_view scriptName);
 | 
			
		||||
 | 
			
		||||
        public:
 | 
			
		||||
            std::vector<Interpreter::Type_Short> mShorts;
 | 
			
		||||
| 
						 | 
				
			
			@ -39,33 +39,33 @@ namespace MWScript
 | 
			
		|||
            /// @note var needs to be in lowercase
 | 
			
		||||
            ///
 | 
			
		||||
            /// \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 If it can not be determined if the variable exists, the error will be
 | 
			
		||||
            // 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
 | 
			
		||||
            /// @note var needs to be in lowercase
 | 
			
		||||
            ///
 | 
			
		||||
            /// \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
 | 
			
		||||
            /// @note var needs to be in lowercase
 | 
			
		||||
            ///
 | 
			
		||||
            /// \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.
 | 
			
		||||
            ///
 | 
			
		||||
            /// \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
 | 
			
		||||
            void read (const ESM::Locals& locals, const std::string& script);
 | 
			
		||||
            void read(const ESM::Locals& locals, std::string_view script);
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1045,7 +1045,7 @@ namespace MWScript
 | 
			
		|||
 | 
			
		||||
                if (!ptr.isEmpty())
 | 
			
		||||
                {
 | 
			
		||||
                    const std::string& script = ptr.getClass().getScript(ptr);
 | 
			
		||||
                    std::string_view script = ptr.getClass().getScript(ptr);
 | 
			
		||||
                    if (!script.empty())
 | 
			
		||||
                    {
 | 
			
		||||
                        const Compiler::Locals& locals =
 | 
			
		||||
| 
						 | 
				
			
			@ -1097,7 +1097,7 @@ namespace MWScript
 | 
			
		|||
            {
 | 
			
		||||
                std::stringstream str;
 | 
			
		||||
 | 
			
		||||
                const std::string script = ptr.getClass().getScript(ptr);
 | 
			
		||||
                std::string_view script = ptr.getClass().getScript(ptr);
 | 
			
		||||
                if(script.empty())
 | 
			
		||||
                    str<< ptr.getCellRef().getRefId()<<" does not have a script.";
 | 
			
		||||
                else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -165,7 +165,7 @@ namespace MWScript
 | 
			
		|||
        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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -212,7 +212,7 @@ namespace MWScript
 | 
			
		|||
            return iter->second;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw std::logic_error ("script " + name + " does not exist");
 | 
			
		||||
        throw std::logic_error("script " + name2 + " does not exist");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    GlobalScripts& ScriptManager::getGlobalScripts()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ namespace MWScript
 | 
			
		|||
            ///< Compile all scripts
 | 
			
		||||
            /// \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.
 | 
			
		||||
 | 
			
		||||
            GlobalScripts& getGlobalScripts() override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,7 +71,7 @@ namespace MWWorld
 | 
			
		|||
        {
 | 
			
		||||
            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))
 | 
			
		||||
                continue;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -155,9 +155,9 @@ namespace MWWorld
 | 
			
		|||
        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
 | 
			
		||||
| 
						 | 
				
			
			@ -291,7 +291,7 @@ namespace MWWorld
 | 
			
		|||
 | 
			
		||||
    std::string Class::getEnchantment (const ConstPtr& ptr) const
 | 
			
		||||
    {
 | 
			
		||||
        return "";
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
    {
 | 
			
		||||
        return "";
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool Class::useAnim() const
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -170,7 +170,7 @@ namespace MWWorld
 | 
			
		|||
            ///< Returns the remaining duration of the object, such as an equippable light
 | 
			
		||||
            /// 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
 | 
			
		||||
            /// string).
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ namespace
 | 
			
		|||
        auto& scripts = MWBase::Environment::get().getWorld()->getLocalScripts();
 | 
			
		||||
        for(const auto&& ptr : store)
 | 
			
		||||
        {
 | 
			
		||||
            const std::string& script = ptr.getClass().getScript(ptr);
 | 
			
		||||
            std::string_view script = ptr.getClass().getScript(ptr);
 | 
			
		||||
            if(!script.empty())
 | 
			
		||||
            {
 | 
			
		||||
                MWWorld::Ptr item = ptr;
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +208,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::unstack(const Ptr &ptr,
 | 
			
		|||
    if (ptr.getRefData().getCount() <= count)
 | 
			
		||||
        return end();
 | 
			
		||||
    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())
 | 
			
		||||
        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?
 | 
			
		||||
    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 (actorPtr == player)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -655,8 +655,8 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, c
 | 
			
		|||
            if (actor == MWMechanics::getPlayer())
 | 
			
		||||
            {
 | 
			
		||||
                // Unset OnPCEquip Variable on item's script, if it has a script with that variable declared
 | 
			
		||||
                const std::string& script = it->getClass().getScript(*it);
 | 
			
		||||
                if (script != "")
 | 
			
		||||
                std::string_view script = it->getClass().getScript(*it);
 | 
			
		||||
                if (!script.empty())
 | 
			
		||||
                    (*it).getRefData().getLocals().setVarByInt(script, "onpcequip", 0);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
 | 
			
		|||
 | 
			
		||||
    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.
 | 
			
		||||
        if (!scriptId.empty())
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ namespace
 | 
			
		|||
            if (ptr.getRefData().isDeleted())
 | 
			
		||||
                return true;
 | 
			
		||||
 | 
			
		||||
            std::string script = ptr.getClass().getScript(ptr);
 | 
			
		||||
            std::string_view script = ptr.getClass().getScript(ptr);
 | 
			
		||||
 | 
			
		||||
            if (!script.empty())
 | 
			
		||||
                mScripts.add(script, ptr);
 | 
			
		||||
| 
						 | 
				
			
			@ -48,12 +48,12 @@ namespace
 | 
			
		|||
                return true;
 | 
			
		||||
 | 
			
		||||
            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);
 | 
			
		||||
                if(script != "")
 | 
			
		||||
                std::string_view script = ptr.getClass().getScript(ptr);
 | 
			
		||||
                if(!script.empty())
 | 
			
		||||
                {
 | 
			
		||||
                    MWWorld::Ptr item = *it;
 | 
			
		||||
                    MWWorld::Ptr item = ptr;
 | 
			
		||||
                    item.mCell = containerPtr.getCell();
 | 
			
		||||
                    mScripts.add (script, item);
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +85,7 @@ bool MWWorld::LocalScripts::getNext(std::pair<std::string, Ptr>& script)
 | 
			
		|||
    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))
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ namespace MWWorld
 | 
			
		|||
            ///< Get next local 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.
 | 
			
		||||
 | 
			
		||||
            void addCell (CellStore *cell);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,7 +82,7 @@ namespace MWWorld
 | 
			
		|||
 | 
			
		||||
            ~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
 | 
			
		||||
            /// perform this operations).
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -816,8 +816,8 @@ namespace MWWorld
 | 
			
		|||
            MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference);
 | 
			
		||||
            for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it)
 | 
			
		||||
            {
 | 
			
		||||
                std::string script = it->getClass().getScript(*it);
 | 
			
		||||
                if(script != "")
 | 
			
		||||
                std::string_view script = it->getClass().getScript(*it);
 | 
			
		||||
                if(!script.empty())
 | 
			
		||||
                {
 | 
			
		||||
                    MWWorld::Ptr item = *it;
 | 
			
		||||
                    item.mCell = cell;
 | 
			
		||||
| 
						 | 
				
			
			@ -859,8 +859,8 @@ namespace MWWorld
 | 
			
		|||
            MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference);
 | 
			
		||||
            for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it)
 | 
			
		||||
            {
 | 
			
		||||
                std::string script = it->getClass().getScript(*it);
 | 
			
		||||
                if(script != "")
 | 
			
		||||
                std::string_view script = it->getClass().getScript(*it);
 | 
			
		||||
                if(!script.empty())
 | 
			
		||||
                {
 | 
			
		||||
                    MWWorld::Ptr item = *it;
 | 
			
		||||
                    mLocalScripts.remove (item);
 | 
			
		||||
| 
						 | 
				
			
			@ -1140,7 +1140,7 @@ namespace MWWorld
 | 
			
		|||
                    && ptr.getRefData().isEnabled())
 | 
			
		||||
            {
 | 
			
		||||
                mWorldScene->addObjectToScene(ptr);
 | 
			
		||||
                std::string script = ptr.getClass().getScript(ptr);
 | 
			
		||||
                std::string_view script = ptr.getClass().getScript(ptr);
 | 
			
		||||
                if (!script.empty())
 | 
			
		||||
                    mLocalScripts.add(script, ptr);
 | 
			
		||||
                addContainerScripts(ptr, ptr.getCell());
 | 
			
		||||
| 
						 | 
				
			
			@ -1196,7 +1196,7 @@ namespace MWWorld
 | 
			
		|||
                    if(newPtr.getRefData().isEnabled())
 | 
			
		||||
                        mWorldScene->addObjectToScene(newPtr);
 | 
			
		||||
 | 
			
		||||
                    std::string script = newPtr.getClass().getScript(newPtr);
 | 
			
		||||
                    std::string_view script = newPtr.getClass().getScript(newPtr);
 | 
			
		||||
                    if (!script.empty())
 | 
			
		||||
                    {
 | 
			
		||||
                        mLocalScripts.add(script, newPtr);
 | 
			
		||||
| 
						 | 
				
			
			@ -1226,8 +1226,7 @@ namespace MWWorld
 | 
			
		|||
                    MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager();
 | 
			
		||||
                    mechMgr->updateCell(ptr, newPtr);
 | 
			
		||||
 | 
			
		||||
                    std::string script =
 | 
			
		||||
                        ptr.getClass().getScript(ptr);
 | 
			
		||||
                    std::string_view script = ptr.getClass().getScript(ptr);
 | 
			
		||||
                    if (!script.empty())
 | 
			
		||||
                    {
 | 
			
		||||
                        mLocalScripts.remove(ptr);
 | 
			
		||||
| 
						 | 
				
			
			@ -2135,10 +2134,10 @@ namespace MWWorld
 | 
			
		|||
 | 
			
		||||
    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
 | 
			
		||||
        if(script != "")
 | 
			
		||||
        if(!script.empty())
 | 
			
		||||
            item.getRefData().getLocals().setVarByInt(script, "onpcdrop", 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2209,7 +2208,7 @@ namespace MWWorld
 | 
			
		|||
            if (dropped.getRefData().isEnabled()) {
 | 
			
		||||
                mWorldScene->addObjectToScene(dropped);
 | 
			
		||||
            }
 | 
			
		||||
            std::string script = dropped.getClass().getScript(dropped);
 | 
			
		||||
            std::string_view script = dropped.getClass().getScript(dropped);
 | 
			
		||||
            if (!script.empty()) {
 | 
			
		||||
                mLocalScripts.add(script, dropped);
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue