diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 09578b8345..9e99b4cacb 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -84,7 +84,7 @@ namespace MWClass return ref->mBase->mName; } - const ESM::RefId& Activator::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Activator::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); @@ -140,7 +140,7 @@ namespace MWClass return MWWorld::Ptr(cell.insert(ref), &cell); } - const ESM::RefId& Activator::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const + ESM::RefId Activator::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const { const std::string model = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise @@ -191,7 +191,7 @@ namespace MWClass return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size(), prng)]->mSound; } - return ESM::RefId::sEmpty; + return ESM::RefId(); } int Activator::getSndGenTypeFromName(std::string_view name) diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index 7f5f9db5c2..309e163abe 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -35,7 +35,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. - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr std::unique_ptr activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; @@ -48,7 +48,7 @@ namespace MWClass bool isActivator() const override; - const ESM::RefId& getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override; + ESM::RefId getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override; }; } diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 23791f2102..2fbe2f9f87 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -53,7 +53,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Apparatus::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Apparatus::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 70599a897b..ce0916c079 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -28,7 +28,7 @@ namespace MWClass std::unique_ptr activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr int getValue(const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 12954e29d7..416a55336a 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -75,7 +75,7 @@ namespace MWClass return ref->mBase->mData.mHealth; } - const ESM::RefId& Armor::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Armor::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); @@ -272,7 +272,7 @@ namespace MWClass return info; } - const ESM::RefId& Armor::getEnchantment(const MWWorld::ConstPtr& ptr) const + ESM::RefId Armor::getEnchantment(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index eccf4e6161..0b01b643ba 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -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 - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr std::pair, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override; @@ -60,7 +60,7 @@ namespace MWClass const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override; ///< Return name of inventory icon. - const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getEnchantment(const MWWorld::ConstPtr& ptr) const override; ///< @return the enchantment ID if the object is enchanted, otherwise an empty string const ESM::RefId& applyEnchantment(const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 0a32d3acbf..b2b65e01b2 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -72,7 +72,7 @@ namespace MWClass return std::make_unique(ptr); } - const ESM::RefId& Book::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Book::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); @@ -133,7 +133,7 @@ namespace MWClass return info; } - const ESM::RefId& Book::getEnchantment(const MWWorld::ConstPtr& ptr) const + ESM::RefId Book::getEnchantment(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index a60a2f3e46..a30e85c107 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -26,7 +26,7 @@ namespace MWClass std::unique_ptr activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId 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; @@ -44,7 +44,7 @@ namespace MWClass const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override; ///< Return name of inventory icon. - const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getEnchantment(const MWWorld::ConstPtr& ptr) const override; ///< @return the enchantment ID if the object is enchanted, otherwise an empty string const ESM::RefId& applyEnchantment(const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index b3c58443f0..06935ad2bd 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -58,7 +58,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Clothing::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Clothing::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); @@ -179,7 +179,7 @@ namespace MWClass return info; } - const ESM::RefId& Clothing::getEnchantment(const MWWorld::ConstPtr& ptr) const + ESM::RefId Clothing::getEnchantment(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index 916f4befd2..1c758ac68b 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -26,7 +26,7 @@ namespace MWClass std::unique_ptr activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr std::pair, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override; @@ -52,7 +52,7 @@ namespace MWClass const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override; ///< Return name of inventory icon. - const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getEnchantment(const MWWorld::ConstPtr& ptr) const override; ///< @return the enchantment ID if the object is enchanted, otherwise an empty string const ESM::RefId& applyEnchantment(const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 13a7406c21..bc55f091d4 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -229,7 +229,7 @@ namespace MWClass return data.mStore; } - const ESM::RefId& Container::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Container::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index c3b55f7f6f..a2eb5d65f6 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -66,7 +66,7 @@ namespace MWClass MWWorld::ContainerStore& getContainerStore(const MWWorld::Ptr& ptr) const override; ///< Return container store - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr float getCapacity(const MWWorld::Ptr& ptr) const override; diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index e1cff1b201..7ea0c7c111 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -526,7 +526,7 @@ namespace MWClass return isFlagBitSet(ptr, ESM::Creature::Weapon); } - const ESM::RefId& Creature::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Creature::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); @@ -634,11 +634,11 @@ namespace MWClass return (ref->mBase->mRecordFlags & ESM::FLAG_Persistent) != 0; } - const ESM::RefId& Creature::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const + ESM::RefId Creature::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const { int type = getSndGenTypeFromName(ptr, name); if (type < 0) - return ESM::RefId::sEmpty; + return ESM::RefId(); std::vector sounds; std::vector fallbacksounds; @@ -690,7 +690,7 @@ namespace MWClass if (!fallbacksounds.empty()) return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size(), prng)]->mSound; - return ESM::RefId::sEmpty; + return ESM::RefId(); } MWWorld::Ptr Creature::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 320370db93..465c28aaaf 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -80,7 +80,7 @@ namespace MWClass bool hasInventoryStore(const MWWorld::Ptr& ptr) const override; - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr float getCapacity(const MWWorld::Ptr& ptr) const override; @@ -97,7 +97,7 @@ namespace MWClass bool isPersistent(const MWWorld::ConstPtr& ptr) const override; - const ESM::RefId& getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override; + ESM::RefId getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override; MWMechanics::Movement& getMovementSettings(const MWWorld::Ptr& ptr) const override; ///< Return desired movement. diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index f848b2c311..3b9aae37d4 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -256,7 +256,7 @@ namespace MWClass return true; } - const ESM::RefId& Door::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Door::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index 4226f56b85..17ada40c6f 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -48,7 +48,7 @@ namespace MWClass bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const override; ///< Return whether this class of object can be activated with telekinesis - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr std::string getModel(const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 81f26430ef..88446e2d4f 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -57,7 +57,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Ingredient::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Ingredient::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 5a181424f3..b7a36d300f 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -29,7 +29,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. - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr int getValue(const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index b553b85399..d00da800d1 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -103,7 +103,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Light::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Light::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); @@ -244,7 +244,7 @@ namespace MWClass return { 1, {} }; } - const ESM::RefId& Light::getSound(const MWWorld::ConstPtr& ptr) const + ESM::RefId Light::getSound(const MWWorld::ConstPtr& ptr) const { return ptr.get()->mBase->mSound; } diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index f2855445d7..70d6852ff8 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -41,7 +41,7 @@ namespace MWClass std::unique_ptr activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr std::pair, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override; @@ -78,7 +78,7 @@ namespace MWClass std::pair canBeEquipped( const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const override; - const ESM::RefId& getSound(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getSound(const MWWorld::ConstPtr& ptr) const override; }; } diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index e44135d720..1fc65c8f79 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -56,7 +56,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Lockpick::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Lockpick::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 0d285011e4..fc65a038a6 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -34,7 +34,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. - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr std::pair, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 83a903387e..eca29f74ce 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -68,7 +68,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Miscellaneous::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Miscellaneous::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 96332ea32e..7f43ab2861 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -29,7 +29,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. - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr int getValue(const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 55739256dd..d734a3868c 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -989,7 +989,7 @@ namespace MWClass return store; } - const ESM::RefId& Npc::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Npc::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); @@ -1278,7 +1278,7 @@ namespace MWClass return npc->mAiData.mServices; } - const ESM::RefId& Npc::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const + ESM::RefId Npc::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const { static const ESM::RefId swimLeft = ESM::RefId::stringRefId("Swim Left"); static const ESM::RefId swimRight = ESM::RefId::stringRefId("Swim Right"); @@ -1297,7 +1297,7 @@ namespace MWClass { MWBase::World* world = MWBase::Environment::get().getWorld(); if (world->isFlying(ptr)) - return ESM::RefId::sEmpty; + return ESM::RefId(); osg::Vec3f pos(ptr.getRefData().getPosition().asVec3()); if (world->isSwimming(ptr)) return (name == "left") ? swimLeft : swimRight; @@ -1311,7 +1311,7 @@ namespace MWClass int weaponType = ESM::Weapon::None; MWMechanics::getActiveWeapon(ptr, &weaponType); if (weaponType == ESM::Weapon::None) - return ESM::RefId::sEmpty; + return ESM::RefId(); } const MWWorld::InventoryStore& inv = Npc::getInventoryStore(ptr); @@ -1332,12 +1332,12 @@ namespace MWClass break; } } - return ESM::RefId::sEmpty; + return ESM::RefId(); } // Morrowind ignores land soundgen for NPCs if (name == "land") - return ESM::RefId::sEmpty; + return ESM::RefId(); if (name == "swimleft") return swimLeft; if (name == "swimright") @@ -1347,11 +1347,11 @@ namespace MWClass // only for biped creatures? if (name == "moan") - return ESM::RefId::sEmpty; + return ESM::RefId(); if (name == "roar") - return ESM::RefId::sEmpty; + return ESM::RefId(); if (name == "scream") - return ESM::RefId::sEmpty; + return ESM::RefId(); throw std::runtime_error("Unexpected soundgen type: " + std::string(name)); } @@ -1501,7 +1501,7 @@ namespace MWClass return true; } - const ESM::RefId& Npc::getPrimaryFaction(const MWWorld::ConstPtr& ptr) const + ESM::RefId Npc::getPrimaryFaction(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); return ref->mBase->mFaction; diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 6ae3cc6704..9b8e229890 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -91,7 +91,7 @@ namespace MWClass std::unique_ptr activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override; ///< Generate action for activation - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr float getMaxSpeed(const MWWorld::Ptr& ptr) const override; @@ -130,7 +130,7 @@ namespace MWClass bool isPersistent(const MWWorld::ConstPtr& ptr) const override; - const ESM::RefId& getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override; + ESM::RefId getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override; std::string getModel(const MWWorld::ConstPtr& ptr) const override; @@ -161,7 +161,8 @@ namespace MWClass int getBaseFightRating(const MWWorld::ConstPtr& ptr) const override; - const ESM::RefId& getPrimaryFaction(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getPrimaryFaction(const MWWorld::ConstPtr& ptr) const override; + int getPrimaryFactionRank(const MWWorld::ConstPtr& ptr) const override; void setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const override; diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index dedf72d2db..2e6fbddf49 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -56,7 +56,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Potion::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Potion::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 2e3d5efa71..66b11b8ef4 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -29,7 +29,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. - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr int getValue(const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index f0348deebf..e020c89443 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -55,7 +55,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Probe::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Probe::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 85659470d5..9a66d7a4bf 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -29,7 +29,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. - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr std::pair, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 3756084963..68fc2f60da 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -54,7 +54,7 @@ namespace MWClass return defaultItemActivate(ptr, actor); } - const ESM::RefId& Repair::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Repair::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index 8bf0539102..ee96c83eeb 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -29,7 +29,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. - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr int getValue(const MWWorld::ConstPtr& ptr) const override; diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 320d979fc7..d271eba9c2 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -77,7 +77,7 @@ namespace MWClass return ref->mBase->mData.mHealth; } - const ESM::RefId& Weapon::getScript(const MWWorld::ConstPtr& ptr) const + ESM::RefId Weapon::getScript(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); @@ -251,7 +251,7 @@ namespace MWClass return info; } - const ESM::RefId& Weapon::getEnchantment(const MWWorld::ConstPtr& ptr) const + ESM::RefId Weapon::getEnchantment(const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef* ref = ptr.get(); diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index e66d58cf1c..336c1a89eb 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -35,7 +35,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 - const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getScript(const MWWorld::ConstPtr& ptr) const override; ///< Return name of the script attached to ptr std::pair, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override; @@ -58,7 +58,7 @@ namespace MWClass const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override; ///< Return name of inventory icon. - const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const override; + ESM::RefId getEnchantment(const MWWorld::ConstPtr& ptr) const override; ///< @return the enchantment ID if the object is enchanted, otherwise an empty string const ESM::RefId& applyEnchantment(const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index f6ae36c224..e3f209fa2e 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -775,9 +775,9 @@ namespace MWGui int incr = next ? 1 : -1; bool found = false; - const ESM::RefId* lastId = &ESM::RefId::sEmpty; + ESM::RefId lastId; if (selected != -1) - lastId = &model.getItem(selected).mBase.getCellRef().getRefId(); + lastId = model.getItem(selected).mBase.getCellRef().getRefId(); ItemModel::ModelIndex cycled = selected; for (unsigned int i = 0; i < model.getItemCount(); ++i) { @@ -788,10 +788,10 @@ namespace MWGui // skip different stacks of the same item, or we will get stuck as stacking/unstacking them may change their // relative ordering - if (*lastId == item.getCellRef().getRefId()) + if (lastId == item.getCellRef().getRefId()) continue; - lastId = &item.getCellRef().getRefId(); + lastId = item.getCellRef().getRefId(); if (item.getClass().getType() == ESM::Weapon::sRecordId && isRightHandWeapon(item) && item.getClass().canBeEquipped(item, player).first) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index b0d5a108bb..1208c2a2c3 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1025,7 +1025,7 @@ namespace MWMechanics } } - const auto& sound = charClass.getSoundIdFromSndGen(mPtr, soundgen); + const ESM::RefId sound = charClass.getSoundIdFromSndGen(mPtr, soundgen); if (!sound.empty()) { MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager(); @@ -1485,7 +1485,7 @@ namespace MWMechanics = MWBase::Environment::get().getWindowManager()->getSelectedSpell(); stats.getSpells().setSelectedSpell(selectedSpell); } - const ESM::RefId* spellid = &stats.getSpells().getSelectedSpell(); + ESM::RefId spellid = stats.getSpells().getSelectedSpell(); bool isMagicItem = false; // Play hand VFX and allow castSpell use (assuming an animation is going to be played) if @@ -1495,13 +1495,13 @@ namespace MWMechanics spellCastResult = world->startSpellCast(mPtr); mCanCast = spellCastResult == MWWorld::SpellCastState::Success; - if (spellid->empty() && cls.hasInventoryStore(mPtr)) + if (spellid.empty() && cls.hasInventoryStore(mPtr)) { MWWorld::InventoryStore& inv = cls.getInventoryStore(mPtr); if (inv.getSelectedEnchantItem() != inv.end()) { const MWWorld::Ptr& enchantItem = *inv.getSelectedEnchantItem(); - spellid = &enchantItem.getClass().getEnchantment(enchantItem); + spellid = enchantItem.getClass().getEnchantment(enchantItem); isMagicItem = true; } } @@ -1520,7 +1520,7 @@ namespace MWMechanics } // Play the spellcasting animation/VFX if the spellcasting was successful or failed due to // insufficient magicka. Used up powers are exempt from this from some reason. - else if (!spellid->empty() && spellCastResult != MWWorld::SpellCastState::PowerAlreadyUsed) + else if (!spellid.empty() && spellCastResult != MWWorld::SpellCastState::PowerAlreadyUsed) { world->breakInvisibility(mPtr); MWMechanics::CastSpell cast(mPtr, {}, false, mCastingManualSpell); @@ -1529,13 +1529,13 @@ namespace MWMechanics const MWWorld::ESMStore& store = world->getStore(); if (isMagicItem) { - const ESM::Enchantment* enchantment = store.get().find(*spellid); + const ESM::Enchantment* enchantment = store.get().find(spellid); effects = &enchantment->mEffects.mList; cast.playSpellCastingEffects(enchantment); } else { - const ESM::Spell* spell = store.get().find(*spellid); + const ESM::Spell* spell = store.get().find(spellid); effects = &spell->mEffects.mList; cast.playSpellCastingEffects(spell); } diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index bc7ada178d..f835652561 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -45,8 +45,7 @@ namespace MWMechanics bool applyOnStrikeEnchantment(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& object, const osg::Vec3f& hitPosition, const bool fromProjectile) { - const ESM::RefId& enchantmentName - = !object.isEmpty() ? object.getClass().getEnchantment(object) : ESM::RefId::sEmpty; + const ESM::RefId enchantmentName = !object.isEmpty() ? object.getClass().getEnchantment(object) : ESM::RefId(); if (!enchantmentName.empty()) { const ESM::Enchantment* enchantment diff --git a/apps/openmw/mwmechanics/levelledlist.cpp b/apps/openmw/mwmechanics/levelledlist.cpp index 83e964f2d0..795c641391 100644 --- a/apps/openmw/mwmechanics/levelledlist.cpp +++ b/apps/openmw/mwmechanics/levelledlist.cpp @@ -7,7 +7,6 @@ #include "../mwworld/ptr.hpp" #include "../mwbase/environment.hpp" -#include "../mwbase/world.hpp" #include "actorutil.hpp" #include "creaturestats.hpp" @@ -16,7 +15,7 @@ namespace MWMechanics { - const ESM::RefId& getLevelledItem(const ESM::LevelledListBase* levItem, bool creature, Misc::Rng::Generator& prng) + ESM::RefId getLevelledItem(const ESM::LevelledListBase* levItem, bool creature, Misc::Rng::Generator& prng) { const std::vector& items = levItem->mList; @@ -24,7 +23,7 @@ namespace MWMechanics int playerLevel = player.getClass().getCreatureStats(player).getLevel(); if (Misc::Rng::roll0to99(prng) < levItem->mChanceNone) - return ESM::RefId::sEmpty; + return ESM::RefId(); std::vector candidates; int highestLevel = 0; @@ -45,7 +44,7 @@ namespace MWMechanics candidates.push_back(&levelledItem.mId); } if (candidates.empty()) - return ESM::RefId::sEmpty; + return ESM::RefId(); const ESM::RefId& item = *candidates[Misc::Rng::rollDice(candidates.size(), prng)]; // Vanilla doesn't fail on nonexistent items in levelled lists @@ -53,7 +52,7 @@ namespace MWMechanics { Log(Debug::Warning) << "Warning: ignoring nonexistent item " << item << " in levelled list " << levItem->mId; - return ESM::RefId::sEmpty; + return ESM::RefId(); } // Is this another levelled item or a real item? diff --git a/apps/openmw/mwmechanics/levelledlist.hpp b/apps/openmw/mwmechanics/levelledlist.hpp index 08d9457bca..3348118366 100644 --- a/apps/openmw/mwmechanics/levelledlist.hpp +++ b/apps/openmw/mwmechanics/levelledlist.hpp @@ -13,7 +13,7 @@ namespace MWMechanics { /// @return ID of resulting item, or empty if none - const ESM::RefId& getLevelledItem(const ESM::LevelledListBase* levItem, bool creature, Misc::Rng::Generator& prng); + ESM::RefId getLevelledItem(const ESM::LevelledListBase* levItem, bool creature, Misc::Rng::Generator& prng); } diff --git a/apps/openmw/mwmechanics/summoning.cpp b/apps/openmw/mwmechanics/summoning.cpp index 16316989f7..ceac555802 100644 --- a/apps/openmw/mwmechanics/summoning.cpp +++ b/apps/openmw/mwmechanics/summoning.cpp @@ -69,7 +69,7 @@ namespace MWMechanics return summonMap; } - const ESM::RefId& getSummonedCreature(int effectId) + ESM::RefId getSummonedCreature(int effectId) { const auto& summonMap = getSummonMap(); auto it = summonMap.find(effectId); @@ -77,7 +77,7 @@ namespace MWMechanics { return it->second; } - return ESM::RefId::sEmpty; + return ESM::RefId(); } int summonCreature(int effectId, const MWWorld::Ptr& summoner) diff --git a/apps/openmw/mwmechanics/summoning.hpp b/apps/openmw/mwmechanics/summoning.hpp index c322589876..a341ee6e93 100644 --- a/apps/openmw/mwmechanics/summoning.hpp +++ b/apps/openmw/mwmechanics/summoning.hpp @@ -16,7 +16,7 @@ namespace MWMechanics { bool isSummoningEffect(int effectId); - const ESM::RefId& getSummonedCreature(int effectId); + ESM::RefId getSummonedCreature(int effectId); void purgeSummonEffect(const MWWorld::Ptr& summoner, const std::pair& summon); diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index b1ec747f3d..eb39f57628 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -52,25 +52,25 @@ namespace MWScript std::pair CompilerContext::getMemberType(const std::string& name, const ESM::RefId& id) const { - const ESM::RefId* script = nullptr; + ESM::RefId script; bool reference = false; if (const ESM::Script* scriptRecord = MWBase::Environment::get().getESMStore()->get().search(id)) { - script = &scriptRecord->mId; + script = scriptRecord->mId; } else { MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), id); - script = &ref.getPtr().getClass().getScript(ref.getPtr()); + script = ref.getPtr().getClass().getScript(ref.getPtr()); reference = true; } char type = ' '; - if (script && !script->empty()) - type = MWBase::Environment::get().getScriptManager()->getLocals(*script).getType( + if (!script.empty()) + type = MWBase::Environment::get().getScriptManager()->getLocals(script).getType( Misc::StringUtils::lowerCase(name)); return std::make_pair(type, reference); diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index f35f74a063..60bf58953a 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -85,14 +85,14 @@ namespace struct IdGettingVisitor { - const ESM::RefId& operator()(const MWWorld::Ptr& ptr) const + ESM::RefId operator()(const MWWorld::Ptr& ptr) const { if (ptr.isEmpty()) - return ESM::RefId::sEmpty; + return ESM::RefId(); return ptr.mRef->mRef.getRefId(); } - const ESM::RefId& operator()(const std::pair& pair) const { return pair.second; } + ESM::RefId operator()(const std::pair& pair) const { return pair.second; } }; } @@ -115,7 +115,7 @@ namespace MWScript return ptr; } - const ESM::RefId& GlobalScriptDesc::getId() const + ESM::RefId GlobalScriptDesc::getId() const { return std::visit(IdGettingVisitor{}, mTarget); } diff --git a/apps/openmw/mwscript/globalscripts.hpp b/apps/openmw/mwscript/globalscripts.hpp index 74d8c94f98..69d58597e4 100644 --- a/apps/openmw/mwscript/globalscripts.hpp +++ b/apps/openmw/mwscript/globalscripts.hpp @@ -49,7 +49,7 @@ namespace MWScript MWWorld::Ptr getPtr(); // Resolves mTarget to a Ptr and caches the (potentially empty) result - const ESM::RefId& getId() const; // Returns the target's ID -- if any + ESM::RefId getId() const; // Returns the target's ID -- if any }; class GlobalScripts diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 0f296b2ca9..f9d777aaff 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -44,7 +44,7 @@ namespace MWScript } } - const Locals& InterpreterContext::getMemberLocals(std::reference_wrapper& id, bool global) const + const Locals& InterpreterContext::getMemberLocals(bool global, ESM::RefId& id) const { if (global) { @@ -54,7 +54,7 @@ namespace MWScript { const MWWorld::Ptr ptr = getReferenceImp(id, false); - id = std::ref(ptr.getClass().getScript(ptr)); + id = ptr.getClass().getScript(ptr); ptr.getRefData().setLocals(*MWBase::Environment::get().getESMStore()->get().find(id)); @@ -62,7 +62,7 @@ namespace MWScript } } - Locals& InterpreterContext::getMemberLocals(std::reference_wrapper& id, bool global) + Locals& InterpreterContext::getMemberLocals(bool global, ESM::RefId& id) { if (global) { @@ -72,7 +72,7 @@ namespace MWScript { const MWWorld::Ptr ptr = getReferenceImp(id, false); - id = std::ref(ptr.getClass().getScript(ptr)); + id = ptr.getClass().getScript(ptr); ptr.getRefData().setLocals(*MWBase::Environment::get().getESMStore()->get().find(id)); @@ -133,13 +133,13 @@ namespace MWScript mGlobalScriptDesc = globalScriptDesc; } - const ESM::RefId& InterpreterContext::getTarget() const + ESM::RefId InterpreterContext::getTarget() const { if (!mReference.isEmpty()) return mReference.mRef->mRef.getRefId(); else if (mGlobalScriptDesc) return mGlobalScriptDesc->getId(); - return ESM::RefId::sEmpty; + return ESM::RefId(); } int InterpreterContext::getLocalShort(int index) const @@ -435,52 +435,46 @@ namespace MWScript #endif } - int InterpreterContext::getMemberShort(const ESM::RefId& id, std::string_view name, bool global) const + int InterpreterContext::getMemberShort(ESM::RefId id, std::string_view name, bool global) const { - auto idRefWrapper = std::ref(id); - const Locals& locals = getMemberLocals(idRefWrapper, global); + const Locals& locals = getMemberLocals(global, id); - return locals.mShorts[findLocalVariableIndex(idRefWrapper, name, 's')]; + return locals.mShorts[findLocalVariableIndex(id, name, 's')]; } - int InterpreterContext::getMemberLong(const ESM::RefId& id, std::string_view name, bool global) const + int InterpreterContext::getMemberLong(ESM::RefId id, std::string_view name, bool global) const { - auto idRefWrapper = std::ref(id); - const Locals& locals = getMemberLocals(idRefWrapper, global); + const Locals& locals = getMemberLocals(global, id); - return locals.mLongs[findLocalVariableIndex(idRefWrapper, name, 'l')]; + return locals.mLongs[findLocalVariableIndex(id, name, 'l')]; } - float InterpreterContext::getMemberFloat(const ESM::RefId& id, std::string_view name, bool global) const + float InterpreterContext::getMemberFloat(ESM::RefId id, std::string_view name, bool global) const { - auto idRefWrapper = std::ref(id); - const Locals& locals = getMemberLocals(idRefWrapper, global); + const Locals& locals = getMemberLocals(global, id); - return locals.mFloats[findLocalVariableIndex(idRefWrapper, name, 'f')]; + return locals.mFloats[findLocalVariableIndex(id, name, 'f')]; } - void InterpreterContext::setMemberShort(const ESM::RefId& id, std::string_view name, int value, bool global) + void InterpreterContext::setMemberShort(ESM::RefId id, std::string_view name, int value, bool global) { - auto idRefWrapper = std::ref(id); - Locals& locals = getMemberLocals(idRefWrapper, global); + Locals& locals = getMemberLocals(global, id); - locals.mShorts[findLocalVariableIndex(idRefWrapper, name, 's')] = value; + locals.mShorts[findLocalVariableIndex(id, name, 's')] = value; } - void InterpreterContext::setMemberLong(const ESM::RefId& id, std::string_view name, int value, bool global) + void InterpreterContext::setMemberLong(ESM::RefId id, std::string_view name, int value, bool global) { - auto idRefWrapper = std::ref(id); - Locals& locals = getMemberLocals(idRefWrapper, global); + Locals& locals = getMemberLocals(global, id); - locals.mLongs[findLocalVariableIndex(idRefWrapper, name, 'l')] = value; + locals.mLongs[findLocalVariableIndex(id, name, 'l')] = value; } - void InterpreterContext::setMemberFloat(const ESM::RefId& id, std::string_view name, float value, bool global) + void InterpreterContext::setMemberFloat(ESM::RefId id, std::string_view name, float value, bool global) { - auto idRefWrapper = std::ref(id); - Locals& locals = getMemberLocals(idRefWrapper, global); + Locals& locals = getMemberLocals(global, id); - locals.mFloats[findLocalVariableIndex(idRefWrapper, name, 'f')] = value; + locals.mFloats[findLocalVariableIndex(id, name, 'f')] = value; } MWWorld::Ptr InterpreterContext::getReference(bool required) const diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index f8d0cbca62..bdae56cb3a 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -32,10 +32,10 @@ namespace MWScript const MWWorld::Ptr getReferenceImp( const ESM::RefId& id = ESM::RefId(), bool activeOnly = false, bool doThrow = true) const; - const Locals& getMemberLocals(std::reference_wrapper& id, bool global) const; + const Locals& getMemberLocals(bool global, ESM::RefId& id) const; ///< \a id is changed to the respective script ID, if \a id wasn't a script ID before - Locals& getMemberLocals(std::reference_wrapper& id, bool global); + Locals& getMemberLocals(bool global, ESM::RefId& id); ///< \a id is changed to the respective script ID, if \a id wasn't a script ID before /// Throws an exception if local variable can't be found. @@ -47,7 +47,7 @@ namespace MWScript InterpreterContext(MWScript::Locals* locals, const MWWorld::Ptr& reference); ///< The ownership of \a locals is not transferred. 0-pointer allowed. - const ESM::RefId& getTarget() const override; + ESM::RefId getTarget() const override; int getLocalShort(int index) const override; @@ -113,17 +113,17 @@ namespace MWScript void executeActivation(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor); ///< Execute the activation action for this ptr. If ptr is mActivated, mark activation as handled. - int getMemberShort(const ESM::RefId& id, std::string_view name, bool global) const override; + int getMemberShort(ESM::RefId id, std::string_view name, bool global) const override; - int getMemberLong(const ESM::RefId& id, std::string_view name, bool global) const override; + int getMemberLong(ESM::RefId id, std::string_view name, bool global) const override; - float getMemberFloat(const ESM::RefId& id, std::string_view name, bool global) const override; + float getMemberFloat(ESM::RefId id, std::string_view name, bool global) const override; - void setMemberShort(const ESM::RefId& id, std::string_view name, int value, bool global) override; + void setMemberShort(ESM::RefId id, std::string_view name, int value, bool global) override; - void setMemberLong(const ESM::RefId& id, std::string_view name, int value, bool global) override; + void setMemberLong(ESM::RefId id, std::string_view name, int value, bool global) override; - void setMemberFloat(const ESM::RefId& id, std::string_view name, float value, bool global) override; + void setMemberFloat(ESM::RefId id, std::string_view name, float value, bool global) override; MWWorld::Ptr getReference(bool required = true) const; ///< Reference, that the script is running from (can be empty) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index d88b277af6..1b2fe0275f 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -33,9 +33,9 @@ namespace { - const ESM::RefId& getDialogueActorFaction(const MWWorld::ConstPtr& actor) + ESM::RefId getDialogueActorFaction(const MWWorld::ConstPtr& actor) { - const ESM::RefId& factionId = actor.getClass().getPrimaryFaction(actor); + ESM::RefId factionId = actor.getClass().getPrimaryFaction(actor); if (factionId.empty()) throw std::runtime_error("failed to determine dialogue actors faction (because actor is factionless)"); diff --git a/apps/openmw/mwworld/cellref.cpp b/apps/openmw/mwworld/cellref.cpp index e5ed333098..4a2ba37609 100644 --- a/apps/openmw/mwworld/cellref.cpp +++ b/apps/openmw/mwworld/cellref.cpp @@ -97,12 +97,12 @@ namespace MWWorld }; auto esm4Visit = [&](const ESM4::Reference& ref) -> ESM::RefId { if (ref.mDoor.destDoor.isZeroOrUnset()) - return ESM::RefId::sEmpty; + return ESM::RefId(); const ESM4::Reference* refDest = MWBase::Environment::get().getESMStore()->get().searchStatic(ref.mDoor.destDoor); if (refDest) return refDest->mParent; - return ESM::RefId::sEmpty; + return ESM::RefId(); }; return std::visit(ESM::VisitOverload{ esm3Visit, esm4Visit }, mCellRef.mVariant); diff --git a/apps/openmw/mwworld/cellref.hpp b/apps/openmw/mwworld/cellref.hpp index 8e386b718f..0d13abb12e 100644 --- a/apps/openmw/mwworld/cellref.hpp +++ b/apps/openmw/mwworld/cellref.hpp @@ -38,12 +38,12 @@ namespace MWWorld bool hasContentFile() const { return getRefNum().hasContentFile(); } // Id of object being referenced - const ESM::RefId& getRefId() const + ESM::RefId getRefId() const { struct Visitor { - const ESM::RefId& operator()(const ESM::CellRef& ref) { return ref.mRefID; } - const ESM::RefId& operator()(const ESM4::Reference& ref) { return ref.mBaseObj; } + ESM::RefId operator()(const ESM::CellRef& ref) { return ref.mRefID; } + ESM::RefId operator()(const ESM4::Reference& ref) { return ref.mBaseObj; } }; return std::visit(Visitor(), mCellRef.mVariant); } @@ -115,12 +115,12 @@ namespace MWWorld void applyChargeRemainderToBeSubtracted(float chargeRemainder); // Stores remainders and applies if > 1 // The NPC that owns this object (and will get angry if you steal it) - const ESM::RefId& getOwner() const + ESM::RefId getOwner() const { struct Visitor { - const ESM::RefId& operator()(const ESM::CellRef& ref) { return ref.mOwner; } - const ESM::RefId& operator()(const ESM4::Reference& /*ref*/) { return ESM::RefId::sEmpty; } + ESM::RefId operator()(const ESM::CellRef& ref) { return ref.mOwner; } + ESM::RefId operator()(const ESM4::Reference& /*ref*/) { return ESM::RefId(); } }; return std::visit(Visitor(), mCellRef.mVariant); } @@ -134,12 +134,12 @@ namespace MWWorld void resetGlobalVariable(); // ID of creature trapped in this soul gem - const ESM::RefId& getSoul() const + ESM::RefId getSoul() const { struct Visitor { - const ESM::RefId& operator()(const ESM::CellRef& ref) { return ref.mSoul; } - const ESM::RefId& operator()(const ESM4::Reference& /*ref*/) { return ESM::RefId::sEmpty; } + ESM::RefId operator()(const ESM::CellRef& ref) { return ref.mSoul; } + ESM::RefId operator()(const ESM4::Reference& /*ref*/) { return ESM::RefId(); } }; return std::visit(Visitor(), mCellRef.mVariant); } @@ -147,12 +147,12 @@ namespace MWWorld // The faction that owns this object (and will get angry if // you take it and are not a faction member) - const ESM::RefId& getFaction() const + ESM::RefId getFaction() const { struct Visitor { - const ESM::RefId& operator()(const ESM::CellRef& ref) { return ref.mFaction; } - const ESM::RefId& operator()(const ESM4::Reference& /*ref*/) { return ESM::RefId::sEmpty; } + ESM::RefId operator()(const ESM::CellRef& ref) { return ref.mFaction; } + ESM::RefId operator()(const ESM4::Reference& /*ref*/) { return ESM::RefId(); } }; return std::visit(Visitor(), mCellRef.mVariant); } @@ -176,16 +176,17 @@ namespace MWWorld void lock(int lockLevel); void unlock(); // Key and trap ID names, if any - const ESM::RefId& getKey() const + ESM::RefId getKey() const { return std::visit([](auto&& ref) -> const ESM::RefId& { return ref.mKey; }, mCellRef.mVariant); } - const ESM::RefId& getTrap() const + + ESM::RefId getTrap() const { struct Visitor { - const ESM::RefId& operator()(const ESM::CellRef& ref) { return ref.mTrap; } - const ESM::RefId& operator()(const ESM4::Reference& /*ref*/) { return ESM::RefId::sEmpty; } + ESM::RefId operator()(const ESM::CellRef& ref) { return ref.mTrap; } + ESM::RefId operator()(const ESM4::Reference& /*ref*/) { return ESM::RefId(); } }; return std::visit(Visitor(), mCellRef.mVariant); } diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 92439c1550..209789778b 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -169,9 +169,9 @@ namespace MWWorld return -1; } - const ESM::RefId& Class::getScript(const ConstPtr& ptr) const + ESM::RefId Class::getScript(const ConstPtr& ptr) const { - return ESM::RefId::sEmpty; + return ESM::RefId(); } float Class::getMaxSpeed(const Ptr& ptr) const @@ -275,7 +275,7 @@ namespace MWWorld throw std::runtime_error("class does not have an down sound"); } - const ESM::RefId& Class::getSoundIdFromSndGen(const Ptr& ptr, std::string_view type) const + ESM::RefId Class::getSoundIdFromSndGen(const Ptr& ptr, std::string_view type) const { throw std::runtime_error("class does not support soundgen look up"); } @@ -303,9 +303,9 @@ namespace MWWorld return true; } - const ESM::RefId& Class::getEnchantment(const ConstPtr& ptr) const + ESM::RefId Class::getEnchantment(const ConstPtr& ptr) const { - return ESM::RefId::sEmpty; + return ESM::RefId(); } void Class::adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const {} @@ -476,9 +476,9 @@ namespace MWWorld return encumbrance / capacity; } - const ESM::RefId& Class::getSound(const MWWorld::ConstPtr&) const + ESM::RefId Class::getSound(const MWWorld::ConstPtr&) const { - return ESM::RefId::sEmpty; + return ESM::RefId(); } int Class::getBaseFightRating(const ConstPtr& ptr) const @@ -486,9 +486,9 @@ namespace MWWorld throw std::runtime_error("class does not support fight rating"); } - const ESM::RefId& Class::getPrimaryFaction(const MWWorld::ConstPtr& ptr) const + ESM::RefId Class::getPrimaryFaction(const MWWorld::ConstPtr& ptr) const { - return ESM::RefId::sEmpty; + return ESM::RefId(); } int Class::getPrimaryFactionRank(const MWWorld::ConstPtr& ptr) const { diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 506b20793c..6feb79f7cd 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -179,7 +179,7 @@ namespace MWWorld ///< Returns the remaining duration of the object, such as an equippable light /// source. (default implementation: -1, i.e. infinite) - virtual const ESM::RefId& getScript(const ConstPtr& ptr) const; + virtual ESM::RefId getScript(const ConstPtr& ptr) const; ///< Return name of the script attached to ptr (default implementation: return an empty /// string). @@ -252,7 +252,7 @@ namespace MWWorld ///< Return the down sound ID of \a ptr or throw an exception, if class does not support ID retrieval /// (default implementation: throw an exception) - virtual const ESM::RefId& getSoundIdFromSndGen(const Ptr& ptr, std::string_view type) const; + virtual ESM::RefId getSoundIdFromSndGen(const Ptr& ptr, std::string_view type) const; ///< Returns the sound ID for \a ptr of the given soundgen \a type. virtual float getArmorRating(const MWWorld::Ptr& ptr) const; @@ -261,7 +261,7 @@ namespace MWWorld virtual const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const; ///< Return name of inventory icon. - virtual const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const; + virtual ESM::RefId getEnchantment(const MWWorld::ConstPtr& ptr) const; ///< @return the enchantment ID if the object is enchanted, otherwise an empty string /// (default implementation: return empty string) @@ -359,11 +359,11 @@ namespace MWWorld virtual void respawn(const MWWorld::Ptr& ptr) const {} /// Returns sound id - virtual const ESM::RefId& getSound(const MWWorld::ConstPtr& ptr) const; + virtual ESM::RefId getSound(const MWWorld::ConstPtr& ptr) const; virtual int getBaseFightRating(const MWWorld::ConstPtr& ptr) const; - virtual const ESM::RefId& getPrimaryFaction(const MWWorld::ConstPtr& ptr) const; + virtual ESM::RefId getPrimaryFaction(const MWWorld::ConstPtr& ptr) const; virtual int getPrimaryFactionRank(const MWWorld::ConstPtr& ptr) const; /// Get the effective armor rating, factoring in the actor's skills, for the given armor. diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 43297c0eaf..21ed7a6ee4 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2738,7 +2738,7 @@ namespace MWWorld return cellId; } - return ESM::RefId::sEmpty; + return ESM::RefId(); } ESM::RefId World::findExteriorPosition(std::string_view nameId, ESM::Position& pos) @@ -2785,7 +2785,7 @@ namespace MWWorld return ext->getId(); } - return ESM::RefId::sEmpty; + return ESM::RefId(); } void World::enableTeleporting(bool enable) diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index 9b644de987..58f47eb8aa 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -155,8 +155,8 @@ void MWWorld::WorldModel::writeCell(ESM::ESMWriter& writer, CellStore& cell) con MWWorld::WorldModel::WorldModel(const MWWorld::ESMStore& store, ESM::ReadersCache& readers) : mStore(store) , mReaders(readers) - , mIdCache(std::clamp(Settings::Manager::getInt("pointers cache size", "Cells"), 40, 1000), - { ESM::RefId::sEmpty, nullptr }) + , mIdCache( + std::clamp(Settings::Manager::getInt("pointers cache size", "Cells"), 40, 1000), { ESM::RefId(), nullptr }) { } diff --git a/apps/openmw_test_suite/mwscript/test_utils.hpp b/apps/openmw_test_suite/mwscript/test_utils.hpp index 2680bfbb66..ba22156f56 100644 --- a/apps/openmw_test_suite/mwscript/test_utils.hpp +++ b/apps/openmw_test_suite/mwscript/test_utils.hpp @@ -147,7 +147,7 @@ namespace std::map mMembers; public: - const ESM::RefId& getTarget() const override { return ESM::RefId::sEmpty; } + ESM::RefId getTarget() const override { return ESM::RefId(); } int getLocalShort(int index) const override { return mLocals.getShort(index); } @@ -207,7 +207,7 @@ namespace std::string_view getCurrentCellName() const override { return {}; } - int getMemberShort(const ESM::RefId& id, std::string_view name, bool global) const override + int getMemberShort(ESM::RefId id, std::string_view name, bool global) const override { auto it = mMembers.find(id); if (it != mMembers.end()) @@ -215,7 +215,7 @@ namespace return {}; } - int getMemberLong(const ESM::RefId& id, std::string_view name, bool global) const override + int getMemberLong(ESM::RefId id, std::string_view name, bool global) const override { auto it = mMembers.find(id); if (it != mMembers.end()) @@ -223,7 +223,7 @@ namespace return {}; } - float getMemberFloat(const ESM::RefId& id, std::string_view name, bool global) const override + float getMemberFloat(ESM::RefId id, std::string_view name, bool global) const override { auto it = mMembers.find(id); if (it != mMembers.end()) @@ -231,17 +231,17 @@ namespace return {}; } - void setMemberShort(const ESM::RefId& id, std::string_view name, int value, bool global) override + void setMemberShort(ESM::RefId id, std::string_view name, int value, bool global) override { mMembers[id].setShort(name, value); } - void setMemberLong(const ESM::RefId& id, std::string_view name, int value, bool global) override + void setMemberLong(ESM::RefId id, std::string_view name, int value, bool global) override { mMembers[id].setLong(name, value); } - void setMemberFloat(const ESM::RefId& id, std::string_view name, float value, bool global) override + void setMemberFloat(ESM::RefId id, std::string_view name, float value, bool global) override { mMembers[id].setFloat(name, value); } diff --git a/components/esm/refid.cpp b/components/esm/refid.cpp index 4011fca8ec..3d489b9b97 100644 --- a/components/esm/refid.cpp +++ b/components/esm/refid.cpp @@ -124,8 +124,6 @@ namespace ESM }; } - const RefId RefId::sEmpty = {}; - std::string EmptyRefId::toString() const { return std::string(); diff --git a/components/esm/refid.hpp b/components/esm/refid.hpp index d1cd5901bf..8eb7b78be1 100644 --- a/components/esm/refid.hpp +++ b/components/esm/refid.hpp @@ -48,8 +48,6 @@ namespace ESM class RefId { public: - const static RefId sEmpty; - using Value = std::variant; diff --git a/components/esm3/esmreader.cpp b/components/esm3/esmreader.cpp index 1cafac7e78..ef8230ca2b 100644 --- a/components/esm3/esmreader.cpp +++ b/components/esm3/esmreader.cpp @@ -149,7 +149,7 @@ namespace ESM { if (isNextSub(name)) return getRefId(); - return ESM::RefId::sEmpty; + return ESM::RefId(); } void ESMReader::skipHNORefId(NAME name) diff --git a/components/interpreter/context.hpp b/components/interpreter/context.hpp index d4656eaa85..1de56ab2a8 100644 --- a/components/interpreter/context.hpp +++ b/components/interpreter/context.hpp @@ -13,7 +13,7 @@ namespace Interpreter public: virtual ~Context() {} - virtual const ESM::RefId& getTarget() const = 0; + virtual ESM::RefId getTarget() const = 0; virtual int getLocalShort(int index) const = 0; @@ -79,17 +79,17 @@ namespace Interpreter virtual std::string_view getCurrentCellName() const = 0; - virtual int getMemberShort(const ESM::RefId& id, std::string_view name, bool global) const = 0; + virtual int getMemberShort(ESM::RefId id, std::string_view name, bool global) const = 0; - virtual int getMemberLong(const ESM::RefId& id, std::string_view name, bool global) const = 0; + virtual int getMemberLong(ESM::RefId id, std::string_view name, bool global) const = 0; - virtual float getMemberFloat(const ESM::RefId& id, std::string_view name, bool global) const = 0; + virtual float getMemberFloat(ESM::RefId id, std::string_view name, bool global) const = 0; - virtual void setMemberShort(const ESM::RefId& id, std::string_view name, int value, bool global) = 0; + virtual void setMemberShort(ESM::RefId id, std::string_view name, int value, bool global) = 0; - virtual void setMemberLong(const ESM::RefId& id, std::string_view name, int value, bool global) = 0; + virtual void setMemberLong(ESM::RefId id, std::string_view name, int value, bool global) = 0; - virtual void setMemberFloat(const ESM::RefId& id, std::string_view name, float value, bool global) = 0; + virtual void setMemberFloat(ESM::RefId id, std::string_view name, float value, bool global) = 0; }; }