mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 15:45:35 +00:00
Merge branch 'please_dont_copy_my_nfts' into 'master'
Prevent various values from being copied See merge request OpenMW/openmw!2267
This commit is contained in:
commit
b382e92953
65 changed files with 288 additions and 308 deletions
|
@ -52,7 +52,7 @@ namespace MWBase
|
|||
virtual void toggleControlSwitch(std::string_view sw, bool value) = 0;
|
||||
virtual bool getControlSwitch(std::string_view sw) = 0;
|
||||
|
||||
virtual std::string getActionDescription (int action) const = 0;
|
||||
virtual std::string_view getActionDescription(int action) const = 0;
|
||||
virtual std::string getActionKeyBindingName (int action) const = 0;
|
||||
virtual std::string getActionControllerBindingName (int action) const = 0;
|
||||
virtual bool actionIsActive(int action) const = 0;
|
||||
|
@ -64,9 +64,9 @@ namespace MWBase
|
|||
virtual int getMouseMoveY() const = 0;
|
||||
|
||||
///Actions available for binding to keyboard buttons
|
||||
virtual std::vector<int> getActionKeySorting() = 0;
|
||||
virtual const std::initializer_list<int>& getActionKeySorting() = 0;
|
||||
///Actions available for binding to controller buttons
|
||||
virtual std::vector<int> getActionControllerSorting() = 0;
|
||||
virtual const std::initializer_list<int>& getActionControllerSorting() = 0;
|
||||
virtual int getNumActions() = 0;
|
||||
///If keyboard is true, only pay attention to keyboard events. If false, only pay attention to controller events (excluding esc)
|
||||
virtual void enableDetectingBindingMode (int action, bool keyboard) = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef GAME_MWBASE_SCRIPTMANAGER_H
|
||||
#define GAME_MWBASE_SCRIPTMANAGER_H
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace Interpreter
|
||||
{
|
||||
|
@ -38,10 +38,10 @@ namespace MWBase
|
|||
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual bool run (const std::string& name, Interpreter::Context& interpreterContext) = 0;
|
||||
virtual bool run(std::string_view name, Interpreter::Context& interpreterContext) = 0;
|
||||
///< Run the script with the given name (compile first, if not compiled yet)
|
||||
|
||||
virtual bool compile (const std::string& name) = 0;
|
||||
virtual bool compile(std::string_view name) = 0;
|
||||
///< Compile script with the given namen
|
||||
/// \return Success?
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ namespace MWBase
|
|||
/// Cycle to next or previous weapon
|
||||
virtual void cycleWeapon(bool next) = 0;
|
||||
|
||||
virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) = 0;
|
||||
virtual void playSound(std::string_view soundId, float volume = 1.f, float pitch = 1.f) = 0;
|
||||
|
||||
virtual void addCell(MWWorld::CellStore* cell) = 0;
|
||||
virtual void removeCell(MWWorld::CellStore* cell) = 0;
|
||||
|
|
|
@ -190,12 +190,12 @@ namespace MWBase
|
|||
virtual char getGlobalVariableType(std::string_view name) const = 0;
|
||||
///< Return ' ', if there is no global variable with this name.
|
||||
|
||||
virtual std::string getCellName (const MWWorld::CellStore *cell = nullptr) const = 0;
|
||||
virtual std::string_view getCellName(const MWWorld::CellStore* cell = nullptr) const = 0;
|
||||
///< Return name of the cell.
|
||||
///
|
||||
/// \note If cell==0, the cell the player is currently in will be used instead to
|
||||
/// generate a name.
|
||||
virtual std::string getCellName(const ESM::Cell* cell) const = 0;
|
||||
virtual std::string_view getCellName(const ESM::Cell* cell) const = 0;
|
||||
|
||||
virtual void removeRefScript (MWWorld::RefData *ref) = 0;
|
||||
//< Remove the script attached to ref from mLocalScripts
|
||||
|
|
|
@ -132,11 +132,11 @@ namespace MWClass
|
|||
return MWWorld::Ptr(cell.insert(ref), &cell);
|
||||
}
|
||||
|
||||
std::string Activator::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||
std::string_view 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
|
||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||
std::string creatureId;
|
||||
std::string_view creatureId;
|
||||
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||
|
||||
for (const ESM::Creature &iter : store.get<ESM::Creature>())
|
||||
|
@ -180,10 +180,10 @@ namespace MWClass
|
|||
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size(), prng)]->mSound;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
int Activator::getSndGenTypeFromName(const std::string &name)
|
||||
int Activator::getSndGenTypeFromName(std::string_view name)
|
||||
{
|
||||
if (name == "left")
|
||||
return ESM::SoundGenerator::LeftFoot;
|
||||
|
@ -202,6 +202,6 @@ namespace MWClass
|
|||
if (name == "land")
|
||||
return ESM::SoundGenerator::Land;
|
||||
|
||||
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
||||
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace MWClass
|
|||
|
||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||
|
||||
static int getSndGenTypeFromName(const std::string &name);
|
||||
static int getSndGenTypeFromName(std::string_view name);
|
||||
|
||||
public:
|
||||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
|
@ -45,7 +45,7 @@ namespace MWClass
|
|||
|
||||
bool isActivator() const override;
|
||||
|
||||
std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const override;
|
||||
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -67,14 +67,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Apparatus::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Apparatus::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Apparatus Up");
|
||||
return "Item Apparatus Up";
|
||||
}
|
||||
|
||||
std::string Apparatus::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Apparatus::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Apparatus Down");
|
||||
return "Item Apparatus Down";
|
||||
}
|
||||
|
||||
std::string Apparatus::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -36,10 +36,10 @@ 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 getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -161,26 +161,26 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Armor::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Armor::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
int es = getEquipmentSkill(ptr);
|
||||
if (es == ESM::Skill::LightArmor)
|
||||
return std::string("Item Armor Light Up");
|
||||
return "Item Armor Light Up";
|
||||
else if (es == ESM::Skill::MediumArmor)
|
||||
return std::string("Item Armor Medium Up");
|
||||
return "Item Armor Medium Up";
|
||||
else
|
||||
return std::string("Item Armor Heavy Up");
|
||||
return "Item Armor Heavy Up";
|
||||
}
|
||||
|
||||
std::string Armor::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Armor::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
int es = getEquipmentSkill(ptr);
|
||||
if (es == ESM::Skill::LightArmor)
|
||||
return std::string("Item Armor Light Down");
|
||||
return "Item Armor Light Down";
|
||||
else if (es == ESM::Skill::MediumArmor)
|
||||
return std::string("Item Armor Medium Down");
|
||||
return "Item Armor Medium Down";
|
||||
else
|
||||
return std::string("Item Armor Heavy Down");
|
||||
return "Item Armor Heavy Down";
|
||||
}
|
||||
|
||||
std::string Armor::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -50,10 +50,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -84,14 +84,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Book::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Book::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Book Up");
|
||||
return "Item Book Up";
|
||||
}
|
||||
|
||||
std::string Book::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Book::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Book Down");
|
||||
return "Item Book Down";
|
||||
}
|
||||
|
||||
std::string Book::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -34,10 +34,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -119,26 +119,26 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Clothing::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Clothing::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
|
||||
|
||||
if (ref->mBase->mData.mType == 8)
|
||||
{
|
||||
return std::string("Item Ring Up");
|
||||
return "Item Ring Up";
|
||||
}
|
||||
return std::string("Item Clothes Up");
|
||||
return "Item Clothes Up";
|
||||
}
|
||||
|
||||
std::string Clothing::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Clothing::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
|
||||
|
||||
if (ref->mBase->mData.mType == 8)
|
||||
{
|
||||
return std::string("Item Ring Down");
|
||||
return "Item Ring Down";
|
||||
}
|
||||
return std::string("Item Clothes Down");
|
||||
return "Item Clothes Down";
|
||||
}
|
||||
|
||||
std::string Clothing::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -42,10 +42,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -622,11 +622,11 @@ namespace MWClass
|
|||
return (ref->mBase->mRecordFlags & ESM::FLAG_Persistent) != 0;
|
||||
}
|
||||
|
||||
std::string Creature::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||
std::string_view Creature::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
|
||||
{
|
||||
int type = getSndGenTypeFromName(ptr, name);
|
||||
if (type < 0)
|
||||
return std::string();
|
||||
return {};
|
||||
|
||||
std::vector<const ESM::SoundGenerator*> sounds;
|
||||
std::vector<const ESM::SoundGenerator*> fallbacksounds;
|
||||
|
@ -679,7 +679,7 @@ namespace MWClass
|
|||
if (!fallbacksounds.empty())
|
||||
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size(), prng)]->mSound;
|
||||
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
MWWorld::Ptr Creature::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||
|
@ -709,7 +709,7 @@ namespace MWClass
|
|||
return isFlagBitSet(ptr, static_cast<ESM::Creature::Flags>(ESM::Creature::Walks | ESM::Creature::Bipedal));
|
||||
}
|
||||
|
||||
int Creature::getSndGenTypeFromName(const MWWorld::Ptr &ptr, const std::string &name)
|
||||
int Creature::getSndGenTypeFromName(const MWWorld::Ptr& ptr, std::string_view name)
|
||||
{
|
||||
if(name == "left")
|
||||
{
|
||||
|
@ -748,7 +748,7 @@ namespace MWClass
|
|||
if(name == "land")
|
||||
return ESM::SoundGenerator::Land;
|
||||
|
||||
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
||||
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
|
||||
}
|
||||
|
||||
float Creature::getSkill(const MWWorld::Ptr &ptr, int skill) const
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
|
||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||
|
||||
static int getSndGenTypeFromName(const MWWorld::Ptr &ptr, const std::string &name);
|
||||
static int getSndGenTypeFromName(const MWWorld::Ptr& ptr, std::string_view name);
|
||||
|
||||
// cached GMSTs
|
||||
struct GMST
|
||||
|
@ -99,7 +99,7 @@ namespace MWClass
|
|||
|
||||
bool isPersistent (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
||||
std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const override;
|
||||
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
|
||||
|
||||
MWMechanics::Movement& getMovementSettings (const MWWorld::Ptr& ptr) const override;
|
||||
///< Return desired movement.
|
||||
|
|
|
@ -79,14 +79,14 @@ namespace MWClass
|
|||
return action;
|
||||
}
|
||||
|
||||
std::string Ingredient::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Ingredient::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Ingredient Up");
|
||||
return "Item Ingredient Up";
|
||||
}
|
||||
|
||||
std::string Ingredient::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Ingredient::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Ingredient Down");
|
||||
return "Item Ingredient Down";
|
||||
}
|
||||
|
||||
std::string Ingredient::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -37,10 +37,10 @@ namespace MWClass
|
|||
std::unique_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
||||
///< Generate action for using via inventory menu
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -122,14 +122,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Light::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Light::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Misc Up");
|
||||
return "Item Misc Up";
|
||||
}
|
||||
|
||||
std::string Light::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Light::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Misc Down");
|
||||
return "Item Misc Down";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -78,14 +78,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Lockpick::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Lockpick::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Lockpick Up");
|
||||
return "Item Lockpick Up";
|
||||
}
|
||||
|
||||
std::string Lockpick::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Lockpick::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Lockpick Down");
|
||||
return "Item Lockpick Down";
|
||||
}
|
||||
|
||||
std::string Lockpick::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -38,10 +38,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -105,18 +105,18 @@ namespace MWClass
|
|||
return value;
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Miscellaneous::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
if (isGold(ptr))
|
||||
return std::string("Item Gold Up");
|
||||
return std::string("Item Misc Up");
|
||||
return "Item Gold Up";
|
||||
return "Item Misc Up";
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Miscellaneous::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
if (isGold(ptr))
|
||||
return std::string("Item Gold Down");
|
||||
return std::string("Item Misc Down");
|
||||
return "Item Gold Down";
|
||||
return "Item Misc Down";
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -34,10 +34,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -1260,13 +1260,13 @@ namespace MWClass
|
|||
}
|
||||
|
||||
|
||||
std::string Npc::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||
std::string_view Npc::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
|
||||
{
|
||||
if(name == "left" || name == "right")
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
if(world->isFlying(ptr))
|
||||
return std::string();
|
||||
return {};
|
||||
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
|
||||
if(world->isSwimming(ptr))
|
||||
return (name == "left") ? "Swim Left" : "Swim Right";
|
||||
|
@ -1280,7 +1280,7 @@ namespace MWClass
|
|||
int weaponType = ESM::Weapon::None;
|
||||
MWMechanics::getActiveWeapon(ptr, &weaponType);
|
||||
if (weaponType == ESM::Weapon::None)
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
const MWWorld::InventoryStore &inv = Npc::getInventoryStore(ptr);
|
||||
|
@ -1298,12 +1298,12 @@ namespace MWClass
|
|||
return (name == "left") ? "FootHeavyLeft" : "FootHeavyRight";
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Morrowind ignores land soundgen for NPCs
|
||||
if(name == "land")
|
||||
return std::string();
|
||||
return {};
|
||||
if(name == "swimleft")
|
||||
return "Swim Left";
|
||||
if(name == "swimright")
|
||||
|
@ -1313,13 +1313,13 @@ namespace MWClass
|
|||
// only for biped creatures?
|
||||
|
||||
if(name == "moan")
|
||||
return std::string();
|
||||
return {};
|
||||
if(name == "roar")
|
||||
return std::string();
|
||||
return {};
|
||||
if(name == "scream")
|
||||
return std::string();
|
||||
return {};
|
||||
|
||||
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
||||
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
|
||||
}
|
||||
|
||||
MWWorld::Ptr Npc::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace MWClass
|
|||
|
||||
bool isPersistent (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
||||
std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const override;
|
||||
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
|
||||
|
||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||
|
||||
|
|
|
@ -72,14 +72,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Potion::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Potion::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Potion Up");
|
||||
return "Item Potion Up";
|
||||
}
|
||||
|
||||
std::string Potion::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Potion::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Potion Down");
|
||||
return "Item Potion Down";
|
||||
}
|
||||
|
||||
std::string Potion::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -37,10 +37,10 @@ namespace MWClass
|
|||
std::unique_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
||||
///< Generate action for using via inventory menu
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -78,14 +78,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Probe::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Probe::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Probe Up");
|
||||
return "Item Probe Up";
|
||||
}
|
||||
|
||||
std::string Probe::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Probe::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Probe Down");
|
||||
return "Item Probe Down";
|
||||
}
|
||||
|
||||
std::string Probe::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -38,10 +38,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -67,14 +67,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Repair::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Repair::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Repair Up");
|
||||
return "Item Repair Up";
|
||||
}
|
||||
|
||||
std::string Repair::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Repair::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Repair Down");
|
||||
return "Item Repair Down";
|
||||
}
|
||||
|
||||
std::string Repair::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -34,10 +34,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -123,20 +123,18 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Weapon::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Weapon::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
|
||||
int type = ref->mBase->mData.mType;
|
||||
std::string soundId = MWMechanics::getWeaponType(type)->mSoundId;
|
||||
return soundId + " Up";
|
||||
return MWMechanics::getWeaponType(type)->mSoundIdUp;
|
||||
}
|
||||
|
||||
std::string Weapon::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Weapon::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
|
||||
int type = ref->mBase->mData.mType;
|
||||
std::string soundId = MWMechanics::getWeaponType(type)->mSoundId;
|
||||
return soundId + " Down";
|
||||
return MWMechanics::getWeaponType(type)->mSoundIdDown;
|
||||
}
|
||||
|
||||
std::string Weapon::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -48,10 +48,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -138,7 +138,7 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const
|
|||
if (!info.mCell.empty())
|
||||
{
|
||||
// supports partial matches, just like getPcCell
|
||||
const std::string& playerCell = MWBase::Environment::get().getWorld()->getCellName(player.getCell());
|
||||
std::string_view playerCell = MWBase::Environment::get().getWorld()->getCellName(player.getCell());
|
||||
bool match = playerCell.length()>=info.mCell.length() &&
|
||||
Misc::StringUtils::ciEqual(playerCell.substr (0, info.mCell.length()), info.mCell);
|
||||
if (!match)
|
||||
|
@ -485,7 +485,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
|||
|
||||
case SelectWrapper::Function_NotCell:
|
||||
{
|
||||
const std::string& actorCell = MWBase::Environment::get().getWorld()->getCellName(mActor.getCell());
|
||||
std::string_view actorCell = MWBase::Environment::get().getWorld()->getCellName(mActor.getCell());
|
||||
return !(actorCell.length() >= select.getName().length()
|
||||
&& Misc::StringUtils::ciEqual(actorCell.substr(0, select.getName().length()), select.getName()));
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ namespace MWGui
|
|||
{
|
||||
update();
|
||||
|
||||
std::string sound = item.getClass().getUpSoundId(item);
|
||||
std::string_view sound = item.getClass().getUpSoundId(item);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace MWGui
|
|||
{
|
||||
// play the sound of the first object
|
||||
MWWorld::Ptr item = mModel->getItem(i).mBase;
|
||||
std::string sound = item.getClass().getUpSoundId(item);
|
||||
std::string_view sound = item.getClass().getUpSoundId(item);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ namespace MWGui
|
|||
if (!script.empty() && MWBase::Environment::get().getWorld()->getScriptsEnabled())
|
||||
{
|
||||
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
|
||||
MWBase::Environment::get().getScriptManager()->run(std::string{script}, interpreterContext);
|
||||
MWBase::Environment::get().getScriptManager()->run(script, interpreterContext);
|
||||
}
|
||||
|
||||
// Clean up summoned creatures as well
|
||||
|
|
|
@ -62,7 +62,7 @@ void DragAndDrop::startDrag (int index, SortFilterItemModel* sortModel, ItemMode
|
|||
mSourceSortModel = playerFilterModel;
|
||||
}
|
||||
|
||||
std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
|
||||
std::string_view sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
|
||||
MWBase::Environment::get().getWindowManager()->playSound (sound);
|
||||
|
||||
if (mSourceSortModel)
|
||||
|
@ -92,7 +92,7 @@ void DragAndDrop::startDrag (int index, SortFilterItemModel* sortModel, ItemMode
|
|||
|
||||
void DragAndDrop::drop(ItemModel *targetModel, ItemView *targetView)
|
||||
{
|
||||
std::string sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase);
|
||||
std::string_view sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
|
||||
// We can't drop a conjured item to the ground; the target container should always be the source container
|
||||
|
|
|
@ -246,7 +246,7 @@ namespace MWGui
|
|||
}
|
||||
|
||||
const ItemStack& item = mTradeModel->getItem(index);
|
||||
std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);
|
||||
std::string_view sound = item.mBase.getClass().getDownSoundId(item.mBase);
|
||||
|
||||
MWWorld::Ptr object = item.mBase;
|
||||
int count = item.mCount;
|
||||
|
@ -356,7 +356,7 @@ namespace MWGui
|
|||
{
|
||||
ensureSelectedItemUnequipped(count);
|
||||
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
|
||||
std::string sound = item.mBase.getClass().getUpSoundId(item.mBase);
|
||||
std::string_view sound = item.mBase.getClass().getUpSoundId(item.mBase);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
|
||||
if (item.mType == ItemStack::Type_Barter)
|
||||
|
|
|
@ -700,23 +700,20 @@ namespace MWGui
|
|||
MyGUI::Gui::getInstance().destroyWidget(mControlsBox->getChildAt(0));
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeStaticMessageBox();
|
||||
std::vector<int> actions;
|
||||
if(mKeyboardMode)
|
||||
actions = MWBase::Environment::get().getInputManager()->getActionKeySorting();
|
||||
else
|
||||
actions = MWBase::Environment::get().getInputManager()->getActionControllerSorting();
|
||||
const auto inputManager = MWBase::Environment::get().getInputManager();
|
||||
const auto& actions = mKeyboardMode ? inputManager->getActionKeySorting() : inputManager->getActionControllerSorting();
|
||||
|
||||
for (const int& action : actions)
|
||||
{
|
||||
std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (action);
|
||||
if (desc == "")
|
||||
std::string desc{inputManager->getActionDescription(action)};
|
||||
if (desc.empty())
|
||||
continue;
|
||||
|
||||
std::string binding;
|
||||
if(mKeyboardMode)
|
||||
binding = MWBase::Environment::get().getInputManager()->getActionKeyBindingName(action);
|
||||
binding = inputManager->getActionKeyBindingName(action);
|
||||
else
|
||||
binding = MWBase::Environment::get().getInputManager()->getActionControllerBindingName(action);
|
||||
binding = inputManager->getActionControllerBindingName(action);
|
||||
|
||||
Gui::SharedStateButton* leftText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default);
|
||||
leftText->setCaptionWithReplacing(desc);
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace MWGui
|
|||
void TradeWindow::sellItem(MyGUI::Widget* sender, int count)
|
||||
{
|
||||
const ItemStack& item = mTradeModel->getItem(mItemToSell);
|
||||
std::string sound = item.mBase.getClass().getUpSoundId(item.mBase);
|
||||
std::string_view sound = item.mBase.getClass().getUpSoundId(item.mBase);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
|
||||
TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
|
||||
|
|
|
@ -917,7 +917,7 @@ namespace MWGui
|
|||
{
|
||||
mMap->requestMapRender(cell);
|
||||
|
||||
std::string name = MWBase::Environment::get().getWorld()->getCellName (cell);
|
||||
std::string name{MWBase::Environment::get().getWorld()->getCellName(cell)};
|
||||
|
||||
mMap->setCellName( name );
|
||||
mHud->setCellName( name );
|
||||
|
@ -2105,7 +2105,7 @@ namespace MWGui
|
|||
mInventoryWindow->cycle(next);
|
||||
}
|
||||
|
||||
void WindowManager::playSound(const std::string& soundId, float volume, float pitch)
|
||||
void WindowManager::playSound(std::string_view soundId, float volume, float pitch)
|
||||
{
|
||||
if (soundId.empty())
|
||||
return;
|
||||
|
|
|
@ -374,7 +374,7 @@ namespace MWGui
|
|||
/// Cycle to next or previous weapon
|
||||
void cycleWeapon(bool next) override;
|
||||
|
||||
void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) override;
|
||||
void playSound(std::string_view soundId, float volume = 1.f, float pitch = 1.f) override;
|
||||
|
||||
void addCell(MWWorld::CellStore* cell) override;
|
||||
void removeCell(MWWorld::CellStore* cell) override;
|
||||
|
|
|
@ -421,7 +421,7 @@ namespace MWInput
|
|||
}
|
||||
}
|
||||
|
||||
std::string BindingsManager::getActionDescription(int action)
|
||||
std::string_view BindingsManager::getActionDescription(int action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -506,7 +506,7 @@ namespace MWInput
|
|||
case A_TogglePostProcessorHUD:
|
||||
return "#{SettingsMenu:TogglePostProcessorHUD}";
|
||||
default:
|
||||
return std::string(); // not configurable
|
||||
return {}; // not configurable
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -557,9 +557,9 @@ namespace MWInput
|
|||
return "#{sNone}";
|
||||
}
|
||||
|
||||
std::vector<int> BindingsManager::getActionKeySorting()
|
||||
const std::initializer_list<int>& BindingsManager::getActionKeySorting()
|
||||
{
|
||||
static const std::vector<int> actions
|
||||
static const std::initializer_list<int> actions
|
||||
{
|
||||
A_MoveForward, A_MoveBackward, A_MoveLeft, A_MoveRight, A_TogglePOV, A_ZoomIn, A_ZoomOut,
|
||||
A_Run, A_AlwaysRun, A_Sneak, A_Activate, A_Use, A_ToggleWeapon, A_ToggleSpell,
|
||||
|
@ -572,9 +572,9 @@ namespace MWInput
|
|||
|
||||
return actions;
|
||||
}
|
||||
std::vector<int> BindingsManager::getActionControllerSorting()
|
||||
const std::initializer_list<int>& BindingsManager::getActionControllerSorting()
|
||||
{
|
||||
static const std::vector<int> actions
|
||||
static const std::initializer_list<int> actions
|
||||
{
|
||||
A_TogglePOV, A_ZoomIn, A_ZoomOut, A_Sneak, A_Activate, A_Use, A_ToggleWeapon, A_ToggleSpell,
|
||||
A_AutoMove, A_Jump, A_Inventory, A_Journal, A_Rest, A_QuickSave, A_QuickLoad, A_ToggleHUD,
|
||||
|
|
|
@ -19,11 +19,11 @@ namespace MWInput
|
|||
|
||||
virtual ~BindingsManager();
|
||||
|
||||
std::string getActionDescription (int action);
|
||||
std::string_view getActionDescription(int action);
|
||||
std::string getActionKeyBindingName (int action);
|
||||
std::string getActionControllerBindingName (int action);
|
||||
std::vector<int> getActionKeySorting();
|
||||
std::vector<int> getActionControllerSorting();
|
||||
const std::initializer_list<int>& getActionKeySorting();
|
||||
const std::initializer_list<int>& getActionControllerSorting();
|
||||
|
||||
void enableDetectingBindingMode (int action, bool keyboard);
|
||||
bool isDetectingBindingState() const;
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace MWInput
|
|||
return mActionManager->getIdleTime() > 0.5;
|
||||
}
|
||||
|
||||
std::string InputManager::getActionDescription(int action) const
|
||||
std::string_view InputManager::getActionDescription(int action) const
|
||||
{
|
||||
return mBindingsManager->getActionDescription(action);
|
||||
}
|
||||
|
@ -191,12 +191,12 @@ namespace MWInput
|
|||
return mMouseManager->getMouseMoveY();
|
||||
}
|
||||
|
||||
std::vector<int> InputManager::getActionKeySorting()
|
||||
const std::initializer_list<int>& InputManager::getActionKeySorting()
|
||||
{
|
||||
return mBindingsManager->getActionKeySorting();
|
||||
}
|
||||
|
||||
std::vector<int> InputManager::getActionControllerSorting()
|
||||
const std::initializer_list<int>& InputManager::getActionControllerSorting()
|
||||
{
|
||||
return mBindingsManager->getActionControllerSorting();
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace MWInput
|
|||
void toggleControlSwitch(std::string_view sw, bool value) override;
|
||||
bool getControlSwitch(std::string_view sw) override;
|
||||
|
||||
std::string getActionDescription (int action) const override;
|
||||
std::string_view getActionDescription(int action) const override;
|
||||
std::string getActionKeyBindingName (int action) const override;
|
||||
std::string getActionControllerBindingName (int action) const override;
|
||||
bool actionIsActive(int action) const override;
|
||||
|
@ -88,8 +88,8 @@ namespace MWInput
|
|||
int getMouseMoveY() const override;
|
||||
|
||||
int getNumActions() override { return A_Last; }
|
||||
std::vector<int> getActionKeySorting() override;
|
||||
std::vector<int> getActionControllerSorting() override;
|
||||
const std::initializer_list<int>& getActionKeySorting() override;
|
||||
const std::initializer_list<int>& getActionControllerSorting() override;
|
||||
void enableDetectingBindingMode (int action, bool keyboard) override;
|
||||
void resetToDefaultKeyBindings() override;
|
||||
void resetToDefaultControllerBindings() override;
|
||||
|
|
|
@ -926,13 +926,13 @@ void CharacterController::handleTextKey(std::string_view groupname, SceneUtil::T
|
|||
auto& charClass = mPtr.getClass();
|
||||
if (evt.substr(0, 10) == "soundgen: ")
|
||||
{
|
||||
std::string soundgen = std::string(evt.substr(10));
|
||||
std::string_view soundgen = evt.substr(10);
|
||||
|
||||
// The event can optionally contain volume and pitch modifiers
|
||||
float volume=1.f, pitch=1.f;
|
||||
if (soundgen.find(' ') != std::string::npos)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
std::vector<std::string_view> tokens;
|
||||
Misc::StringUtils::split(soundgen, tokens);
|
||||
soundgen = tokens[0];
|
||||
if (tokens.size() >= 2)
|
||||
|
@ -949,7 +949,7 @@ void CharacterController::handleTextKey(std::string_view groupname, SceneUtil::T
|
|||
}
|
||||
}
|
||||
|
||||
std::string sound = charClass.getSoundIdFromSndGen(mPtr, soundgen);
|
||||
std::string_view sound = charClass.getSoundIdFromSndGen(mPtr, soundgen);
|
||||
if(!sound.empty())
|
||||
{
|
||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
|
@ -1132,7 +1132,7 @@ bool CharacterController::updateWeaponState()
|
|||
|
||||
const bool isWerewolf = cls.isNpc() && cls.getNpcStats(mPtr).isWerewolf();
|
||||
|
||||
std::string downSoundId;
|
||||
std::string_view downSoundId;
|
||||
bool weaponChanged = false;
|
||||
bool ammunition = true;
|
||||
float weapSpeed = 1.f;
|
||||
|
@ -1307,7 +1307,7 @@ bool CharacterController::updateWeaponState()
|
|||
|
||||
if (!mWeapon.isEmpty() && mWeaponType != ESM::Weapon::HandToHand && isRealWeapon(weaptype))
|
||||
{
|
||||
std::string upSoundId = mWeapon.getClass().getUpSoundId(mWeapon);
|
||||
std::string_view upSoundId = mWeapon.getClass().getUpSoundId(mWeapon);
|
||||
if (!upSoundId.empty())
|
||||
sndMgr->playSound3D(mPtr, upSoundId, 1.0f, 1.0f);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ void WeaponAnimation::attachArrow(const MWWorld::Ptr& actor)
|
|||
ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(type)->mWeaponClass;
|
||||
if (weapclass == ESM::WeaponType::Thrown)
|
||||
{
|
||||
std::string soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot);
|
||||
std::string_view soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot);
|
||||
if(!soundid.empty())
|
||||
{
|
||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
|
|
|
@ -170,11 +170,8 @@ namespace MWScript
|
|||
}
|
||||
const MWWorld::CellStore *cell = MWMechanics::getPlayer().getCell();
|
||||
|
||||
std::string current = MWBase::Environment::get().getWorld()->getCellName(cell);
|
||||
Misc::StringUtils::lowerCaseInPlace(current);
|
||||
|
||||
bool match = current.length()>=name.length() &&
|
||||
current.substr (0, name.length())==name;
|
||||
std::string_view current = MWBase::Environment::get().getWorld()->getCellName(cell);
|
||||
bool match = Misc::StringUtils::ciCompareLen(name, current, name.length()) == 0;
|
||||
|
||||
runtime.push (match ? 1 : 0);
|
||||
}
|
||||
|
|
|
@ -95,14 +95,14 @@ namespace
|
|||
|
||||
struct IdGettingVisitor
|
||||
{
|
||||
std::string operator()(const MWWorld::Ptr& ptr) const
|
||||
std::string_view operator()(const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
if(ptr.isEmpty())
|
||||
return {};
|
||||
return ptr.mRef->mRef.getRefId();
|
||||
}
|
||||
|
||||
std::string operator()(const std::pair<ESM::RefNum, std::string>& pair) const
|
||||
std::string_view operator()(const std::pair<ESM::RefNum, std::string>& pair) const
|
||||
{
|
||||
return pair.second;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ namespace MWScript
|
|||
return ptr;
|
||||
}
|
||||
|
||||
std::string GlobalScriptDesc::getId() const
|
||||
std::string_view GlobalScriptDesc::getId() const
|
||||
{
|
||||
return std::visit(IdGettingVisitor {}, mTarget);
|
||||
}
|
||||
|
@ -309,17 +309,16 @@ namespace MWScript
|
|||
|
||||
Locals& GlobalScripts::getLocals(std::string_view name)
|
||||
{
|
||||
std::string name2 = ::Misc::StringUtils::lowerCase (name);
|
||||
auto iter = mScripts.find (name2);
|
||||
auto iter = mScripts.find(name);
|
||||
|
||||
if (iter==mScripts.end())
|
||||
{
|
||||
const ESM::Script *script = mStore.get<ESM::Script>().find(name2);
|
||||
const ESM::Script *script = mStore.get<ESM::Script>().find(name);
|
||||
|
||||
auto desc = std::make_shared<GlobalScriptDesc>();
|
||||
desc->mLocals.configure (*script);
|
||||
|
||||
iter = mScripts.insert (std::make_pair (name2, desc)).first;
|
||||
iter = mScripts.emplace(name, desc).first;
|
||||
}
|
||||
|
||||
return iter->second->mLocals;
|
||||
|
@ -327,8 +326,7 @@ namespace MWScript
|
|||
|
||||
const Locals* GlobalScripts::getLocalsIfPresent(std::string_view name) const
|
||||
{
|
||||
std::string name2 = ::Misc::StringUtils::lowerCase (name);
|
||||
auto iter = mScripts.find (name2);
|
||||
auto iter = mScripts.find(name);
|
||||
if (iter==mScripts.end())
|
||||
return nullptr;
|
||||
return &iter->second->mLocals;
|
||||
|
|
|
@ -2,13 +2,16 @@
|
|||
#define GAME_SCRIPT_GLOBALSCRIPTS_H
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <components/misc/algorithm.hpp>
|
||||
|
||||
#include "locals.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
@ -44,13 +47,13 @@ namespace MWScript
|
|||
|
||||
MWWorld::Ptr getPtr(); // Resolves mTarget to a Ptr and caches the (potentially empty) result
|
||||
|
||||
std::string getId() const; // Returns the target's ID -- if any
|
||||
std::string_view getId() const; // Returns the target's ID -- if any
|
||||
};
|
||||
|
||||
class GlobalScripts
|
||||
{
|
||||
const MWWorld::ESMStore& mStore;
|
||||
std::map<std::string, std::shared_ptr<GlobalScriptDesc> > mScripts;
|
||||
std::unordered_map<std::string, std::shared_ptr<GlobalScriptDesc>, ::Misc::StringUtils::CiHash, ::Misc::StringUtils::CiEqual> mScripts;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
namespace MWScript
|
||||
{
|
||||
const MWWorld::Ptr InterpreterContext::getReferenceImp (
|
||||
const std::string& id, bool activeOnly, bool doThrow) const
|
||||
const MWWorld::Ptr InterpreterContext::getReferenceImp(std::string_view id, bool activeOnly, bool doThrow) const
|
||||
{
|
||||
if (!id.empty())
|
||||
{
|
||||
|
@ -45,7 +44,7 @@ namespace MWScript
|
|||
}
|
||||
}
|
||||
|
||||
const Locals& InterpreterContext::getMemberLocals (std::string& id, bool global)
|
||||
const Locals& InterpreterContext::getMemberLocals(std::string_view& id, bool global)
|
||||
const
|
||||
{
|
||||
if (global)
|
||||
|
@ -66,7 +65,7 @@ namespace MWScript
|
|||
}
|
||||
}
|
||||
|
||||
Locals& InterpreterContext::getMemberLocals (std::string& id, bool global)
|
||||
Locals& InterpreterContext::getMemberLocals(std::string_view& id, bool global)
|
||||
{
|
||||
if (global)
|
||||
{
|
||||
|
@ -88,8 +87,7 @@ namespace MWScript
|
|||
|
||||
MissingImplicitRefError::MissingImplicitRefError() : std::runtime_error("no implicit reference") {}
|
||||
|
||||
int InterpreterContext::findLocalVariableIndex (const std::string& scriptId,
|
||||
std::string_view name, char type) const
|
||||
int InterpreterContext::findLocalVariableIndex(std::string_view scriptId, std::string_view name, char type) const
|
||||
{
|
||||
int index = MWBase::Environment::get().getScriptManager()->getLocals (scriptId).
|
||||
searchIndex (type, name);
|
||||
|
@ -130,7 +128,7 @@ namespace MWScript
|
|||
mGlobalScriptDesc = globalScriptDesc;
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getTarget() const
|
||||
std::string_view InterpreterContext::getTarget() const
|
||||
{
|
||||
if(!mReference.isEmpty())
|
||||
return mReference.mRef->mRef.getRefId();
|
||||
|
@ -237,7 +235,7 @@ namespace MWScript
|
|||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Global>();
|
||||
|
||||
std::vector<std::string> ids;
|
||||
for (auto& globalVariable : globals)
|
||||
for (const auto& globalVariable : globals)
|
||||
{
|
||||
ids.emplace_back(globalVariable.mId);
|
||||
}
|
||||
|
@ -254,11 +252,11 @@ namespace MWScript
|
|||
std::string InterpreterContext::getActionBinding(std::string_view targetAction) const
|
||||
{
|
||||
MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
|
||||
std::vector<int> actions = input->getActionKeySorting ();
|
||||
const auto& actions = input->getActionKeySorting();
|
||||
for (const int action : actions)
|
||||
{
|
||||
std::string desc = input->getActionDescription (action);
|
||||
if(desc == "")
|
||||
std::string_view desc = input->getActionDescription(action);
|
||||
if(desc.empty())
|
||||
continue;
|
||||
|
||||
if(desc == targetAction)
|
||||
|
@ -273,7 +271,7 @@ namespace MWScript
|
|||
return "None";
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getActorName() const
|
||||
std::string_view InterpreterContext::getActorName() const
|
||||
{
|
||||
const MWWorld::Ptr& ptr = getReferenceImp();
|
||||
if (ptr.getClass().isNpc())
|
||||
|
@ -286,28 +284,28 @@ namespace MWScript
|
|||
return creature->mName;
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getNPCRace() const
|
||||
std::string_view InterpreterContext::getNPCRace() const
|
||||
{
|
||||
ESM::NPC npc = *getReferenceImp().get<ESM::NPC>()->mBase;
|
||||
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npc.mRace);
|
||||
const ESM::NPC* npc = getReferenceImp().get<ESM::NPC>()->mBase;
|
||||
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npc->mRace);
|
||||
return race->mName;
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getNPCClass() const
|
||||
std::string_view InterpreterContext::getNPCClass() const
|
||||
{
|
||||
ESM::NPC npc = *getReferenceImp().get<ESM::NPC>()->mBase;
|
||||
const ESM::Class* class_ = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(npc.mClass);
|
||||
const ESM::NPC* npc = getReferenceImp().get<ESM::NPC>()->mBase;
|
||||
const ESM::Class* class_ = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(npc->mClass);
|
||||
return class_->mName;
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getNPCFaction() const
|
||||
std::string_view InterpreterContext::getNPCFaction() const
|
||||
{
|
||||
ESM::NPC npc = *getReferenceImp().get<ESM::NPC>()->mBase;
|
||||
const ESM::Faction* faction = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(npc.mFaction);
|
||||
const ESM::NPC* npc = getReferenceImp().get<ESM::NPC>()->mBase;
|
||||
const ESM::Faction* faction = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(npc->mFaction);
|
||||
return faction->mName;
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getNPCRank() const
|
||||
std::string_view InterpreterContext::getNPCRank() const
|
||||
{
|
||||
const MWWorld::Ptr& ptr = getReferenceImp();
|
||||
std::string_view faction = ptr.getClass().getPrimaryFaction(ptr);
|
||||
|
@ -324,28 +322,27 @@ namespace MWScript
|
|||
return fact->mRanks[rank];
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getPCName() const
|
||||
std::string_view InterpreterContext::getPCName() const
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
ESM::NPC player = *world->getPlayerPtr().get<ESM::NPC>()->mBase;
|
||||
return player.mName;
|
||||
return world->getPlayerPtr().get<ESM::NPC>()->mBase->mName;
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getPCRace() const
|
||||
std::string_view InterpreterContext::getPCRace() const
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
std::string race = world->getPlayerPtr().get<ESM::NPC>()->mBase->mRace;
|
||||
const std::string& race = world->getPlayerPtr().get<ESM::NPC>()->mBase->mRace;
|
||||
return world->getStore().get<ESM::Race>().find(race)->mName;
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getPCClass() const
|
||||
std::string_view InterpreterContext::getPCClass() const
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
std::string class_ = world->getPlayerPtr().get<ESM::NPC>()->mBase->mClass;
|
||||
const std::string& class_ = world->getPlayerPtr().get<ESM::NPC>()->mBase->mClass;
|
||||
return world->getStore().get<ESM::Class>().find(class_)->mName;
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getPCRank() const
|
||||
std::string_view InterpreterContext::getPCRank() const
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
|
@ -369,12 +366,12 @@ namespace MWScript
|
|||
const ESM::Faction *faction = store.get<ESM::Faction>().find(factionId);
|
||||
|
||||
if(rank < 0 || rank > 9) // there are only 10 ranks
|
||||
return "";
|
||||
return {};
|
||||
|
||||
return faction->mRanks[rank];
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getPCNextRank() const
|
||||
std::string_view InterpreterContext::getPCNextRank() const
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
|
@ -399,7 +396,7 @@ namespace MWScript
|
|||
const ESM::Faction *faction = store.get<ESM::Faction>().find(factionId);
|
||||
|
||||
if(rank < 0)
|
||||
return "";
|
||||
return {};
|
||||
|
||||
return faction->mRanks[rank];
|
||||
}
|
||||
|
@ -411,9 +408,9 @@ namespace MWScript
|
|||
return player.getClass().getNpcStats (player).getBounty();
|
||||
}
|
||||
|
||||
std::string InterpreterContext::getCurrentCellName() const
|
||||
std::string_view InterpreterContext::getCurrentCellName() const
|
||||
{
|
||||
return MWBase::Environment::get().getWorld()->getCellName();
|
||||
return MWBase::Environment::get().getWorld()->getCellName();
|
||||
}
|
||||
|
||||
void InterpreterContext::executeActivation(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor)
|
||||
|
@ -430,64 +427,52 @@ namespace MWScript
|
|||
int InterpreterContext::getMemberShort(std::string_view id, std::string_view name,
|
||||
bool global) const
|
||||
{
|
||||
std::string scriptId (id);
|
||||
const Locals& locals = getMemberLocals(id, global);
|
||||
|
||||
const Locals& locals = getMemberLocals (scriptId, global);
|
||||
|
||||
return locals.mShorts[findLocalVariableIndex (scriptId, name, 's')];
|
||||
return locals.mShorts[findLocalVariableIndex(id, name, 's')];
|
||||
}
|
||||
|
||||
int InterpreterContext::getMemberLong(std::string_view id, std::string_view name,
|
||||
bool global) const
|
||||
{
|
||||
std::string scriptId (id);
|
||||
const Locals& locals = getMemberLocals(id, global);
|
||||
|
||||
const Locals& locals = getMemberLocals (scriptId, global);
|
||||
|
||||
return locals.mLongs[findLocalVariableIndex (scriptId, name, 'l')];
|
||||
return locals.mLongs[findLocalVariableIndex(id, name, 'l')];
|
||||
}
|
||||
|
||||
float InterpreterContext::getMemberFloat(std::string_view id, std::string_view name,
|
||||
bool global) const
|
||||
{
|
||||
std::string scriptId (id);
|
||||
const Locals& locals = getMemberLocals(id, global);
|
||||
|
||||
const Locals& locals = getMemberLocals (scriptId, global);
|
||||
|
||||
return locals.mFloats[findLocalVariableIndex (scriptId, name, 'f')];
|
||||
return locals.mFloats[findLocalVariableIndex(id, name, 'f')];
|
||||
}
|
||||
|
||||
void InterpreterContext::setMemberShort(std::string_view id, std::string_view name,
|
||||
int value, bool global)
|
||||
{
|
||||
std::string scriptId (id);
|
||||
Locals& locals = getMemberLocals(id, global);
|
||||
|
||||
Locals& locals = getMemberLocals (scriptId, global);
|
||||
|
||||
locals.mShorts[findLocalVariableIndex (scriptId, name, 's')] = value;
|
||||
locals.mShorts[findLocalVariableIndex(id, name, 's')] = value;
|
||||
}
|
||||
|
||||
void InterpreterContext::setMemberLong(std::string_view id, std::string_view name, int value, bool global)
|
||||
{
|
||||
std::string scriptId (id);
|
||||
Locals& locals = getMemberLocals(id, global);
|
||||
|
||||
Locals& locals = getMemberLocals (scriptId, global);
|
||||
|
||||
locals.mLongs[findLocalVariableIndex (scriptId, name, 'l')] = value;
|
||||
locals.mLongs[findLocalVariableIndex(id, name, 'l')] = value;
|
||||
}
|
||||
|
||||
void InterpreterContext::setMemberFloat(std::string_view id, std::string_view name, float value, bool global)
|
||||
{
|
||||
std::string scriptId (id);
|
||||
Locals& locals = getMemberLocals(id, global);
|
||||
|
||||
Locals& locals = getMemberLocals (scriptId, global);
|
||||
|
||||
locals.mFloats[findLocalVariableIndex (scriptId, name, 'f')] = value;
|
||||
locals.mFloats[findLocalVariableIndex(id, name, 'f')] = value;
|
||||
}
|
||||
|
||||
MWWorld::Ptr InterpreterContext::getReference(bool required) const
|
||||
{
|
||||
return getReferenceImp ("", true, required);
|
||||
return getReferenceImp({}, true, required);
|
||||
}
|
||||
|
||||
void InterpreterContext::updatePtr(const MWWorld::Ptr& base, const MWWorld::Ptr& updated)
|
||||
|
|
|
@ -28,18 +28,16 @@ namespace MWScript
|
|||
|
||||
/// If \a id is empty, a reference the script is run from is returned or in case
|
||||
/// of a non-local script the reference derived from the target ID.
|
||||
const MWWorld::Ptr getReferenceImp (const std::string& id = "",
|
||||
bool activeOnly = false, bool doThrow=true) const;
|
||||
const MWWorld::Ptr getReferenceImp(std::string_view id = {}, bool activeOnly = false, bool doThrow = true) const;
|
||||
|
||||
const Locals& getMemberLocals (std::string& id, bool global) const;
|
||||
const Locals& getMemberLocals(std::string_view& id, bool global) const;
|
||||
///< \a id is changed to the respective script ID, if \a id wasn't a script ID before
|
||||
|
||||
Locals& getMemberLocals (std::string& id, bool global);
|
||||
Locals& getMemberLocals(std::string_view& id, bool global);
|
||||
///< \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.
|
||||
int findLocalVariableIndex (const std::string& scriptId, std::string_view name,
|
||||
char type) const;
|
||||
int findLocalVariableIndex(std::string_view scriptId, std::string_view name, char type) const;
|
||||
|
||||
public:
|
||||
InterpreterContext (std::shared_ptr<GlobalScriptDesc> globalScriptDesc);
|
||||
|
@ -47,7 +45,7 @@ namespace MWScript
|
|||
InterpreterContext (MWScript::Locals *locals, const MWWorld::Ptr& reference);
|
||||
///< The ownership of \a locals is not transferred. 0-pointer allowed.
|
||||
|
||||
std::string getTarget() const override;
|
||||
std::string_view getTarget() const override;
|
||||
|
||||
int getLocalShort (int index) const override;
|
||||
|
||||
|
@ -87,29 +85,29 @@ namespace MWScript
|
|||
|
||||
std::string getActionBinding(std::string_view action) const override;
|
||||
|
||||
std::string getActorName() const override;
|
||||
std::string_view getActorName() const override;
|
||||
|
||||
std::string getNPCRace() const override;
|
||||
std::string_view getNPCRace() const override;
|
||||
|
||||
std::string getNPCClass() const override;
|
||||
std::string_view getNPCClass() const override;
|
||||
|
||||
std::string getNPCFaction() const override;
|
||||
std::string_view getNPCFaction() const override;
|
||||
|
||||
std::string getNPCRank() const override;
|
||||
std::string_view getNPCRank() const override;
|
||||
|
||||
std::string getPCName() const override;
|
||||
std::string_view getPCName() const override;
|
||||
|
||||
std::string getPCRace() const override;
|
||||
std::string_view getPCRace() const override;
|
||||
|
||||
std::string getPCClass() const override;
|
||||
std::string_view getPCClass() const override;
|
||||
|
||||
std::string getPCRank() const override;
|
||||
std::string_view getPCRank() const override;
|
||||
|
||||
std::string getPCNextRank() const override;
|
||||
std::string_view getPCNextRank() const override;
|
||||
|
||||
int getPCBounty() const override;
|
||||
|
||||
std::string getCurrentCellName() const override;
|
||||
std::string_view getCurrentCellName() const override;
|
||||
|
||||
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.
|
||||
|
|
|
@ -39,14 +39,14 @@ namespace MWScript
|
|||
std::sort (mScriptBlacklist.begin(), mScriptBlacklist.end());
|
||||
}
|
||||
|
||||
bool ScriptManager::compile (const std::string& name)
|
||||
bool ScriptManager::compile(std::string_view name)
|
||||
{
|
||||
mParser.reset();
|
||||
mErrorHandler.reset();
|
||||
|
||||
if (const ESM::Script *script = mStore.get<ESM::Script>().find (name))
|
||||
{
|
||||
mErrorHandler.setContext(name);
|
||||
mErrorHandler.setContext(script->mId);
|
||||
|
||||
bool Success = true;
|
||||
try
|
||||
|
@ -89,10 +89,10 @@ namespace MWScript
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext)
|
||||
bool ScriptManager::run(std::string_view name, Interpreter::Context& interpreterContext)
|
||||
{
|
||||
// compile script
|
||||
ScriptCollection::iterator iter = mScripts.find (name);
|
||||
auto iter = mScripts.find(name);
|
||||
|
||||
if (iter==mScripts.end())
|
||||
{
|
||||
|
@ -167,27 +167,25 @@ namespace MWScript
|
|||
|
||||
const Compiler::Locals& ScriptManager::getLocals(std::string_view name)
|
||||
{
|
||||
std::string name2 = Misc::StringUtils::lowerCase (name);
|
||||
|
||||
{
|
||||
auto iter = mScripts.find (name2);
|
||||
auto iter = mScripts.find(name);
|
||||
|
||||
if (iter!=mScripts.end())
|
||||
return iter->second.mLocals;
|
||||
}
|
||||
|
||||
{
|
||||
auto iter = mOtherLocals.find (name2);
|
||||
auto iter = mOtherLocals.find(name);
|
||||
|
||||
if (iter!=mOtherLocals.end())
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
if (const ESM::Script *script = mStore.get<ESM::Script>().search (name2))
|
||||
if (const ESM::Script* script = mStore.get<ESM::Script>().search(name))
|
||||
{
|
||||
Compiler::Locals locals;
|
||||
|
||||
const Compiler::ContextOverride override(mErrorHandler, name2 + "[local variables]");
|
||||
const Compiler::ContextOverride override(mErrorHandler, std::string{name} + "[local variables]");
|
||||
|
||||
std::istringstream stream (script->mScriptText);
|
||||
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
|
||||
|
@ -207,12 +205,12 @@ namespace MWScript
|
|||
locals.clear();
|
||||
}
|
||||
|
||||
auto iter = mOtherLocals.emplace(name2, locals).first;
|
||||
auto iter = mOtherLocals.emplace(name, locals).first;
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
throw std::logic_error("script " + name2 + " does not exist");
|
||||
throw std::logic_error("script " + std::string{name} + " does not exist");
|
||||
}
|
||||
|
||||
GlobalScripts& ScriptManager::getGlobalScripts()
|
||||
|
|
|
@ -53,11 +53,9 @@ namespace MWScript
|
|||
{}
|
||||
};
|
||||
|
||||
typedef std::map<std::string, CompiledScript> ScriptCollection;
|
||||
|
||||
ScriptCollection mScripts;
|
||||
std::unordered_map<std::string, CompiledScript, ::Misc::StringUtils::CiHash, ::Misc::StringUtils::CiEqual> mScripts;
|
||||
GlobalScripts mGlobalScripts;
|
||||
std::map<std::string, Compiler::Locals> mOtherLocals;
|
||||
std::unordered_map<std::string, Compiler::Locals, ::Misc::StringUtils::CiHash, ::Misc::StringUtils::CiEqual> mOtherLocals;
|
||||
std::vector<std::string> mScriptBlacklist;
|
||||
|
||||
public:
|
||||
|
@ -68,10 +66,10 @@ namespace MWScript
|
|||
|
||||
void clear() override;
|
||||
|
||||
bool run (const std::string& name, Interpreter::Context& interpreterContext) override;
|
||||
bool run(std::string_view name, Interpreter::Context& interpreterContext) override;
|
||||
///< Run the script with the given name (compile first, if not compiled yet)
|
||||
|
||||
bool compile (const std::string& name) override;
|
||||
bool compile(std::string_view name) override;
|
||||
///< Compile script with the given namen
|
||||
/// \return Success?
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void MWWorld::Action::execute (const Ptr& actor, bool noSound)
|
|||
executeImp (actor);
|
||||
}
|
||||
|
||||
void MWWorld::Action::setSound (const std::string& id)
|
||||
void MWWorld::Action::setSound(std::string_view id)
|
||||
{
|
||||
mSoundId = id;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWWORLD_ACTION_H
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ptr.hpp"
|
||||
|
||||
|
@ -39,7 +40,7 @@ namespace MWWorld
|
|||
|
||||
void execute (const Ptr& actor, bool noSound = false);
|
||||
|
||||
void setSound (const std::string& id);
|
||||
void setSound(std::string_view id);
|
||||
void setSoundOffset(float offset);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -256,17 +256,17 @@ namespace MWWorld
|
|||
getClasses().emplace(instance.getType(), &instance);
|
||||
}
|
||||
|
||||
std::string Class::getUpSoundId (const ConstPtr& ptr) const
|
||||
std::string_view Class::getUpSoundId (const ConstPtr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have an up sound");
|
||||
}
|
||||
|
||||
std::string Class::getDownSoundId (const ConstPtr& ptr) const
|
||||
std::string_view Class::getDownSoundId (const ConstPtr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have an down sound");
|
||||
}
|
||||
|
||||
std::string Class::getSoundIdFromSndGen(const Ptr &ptr, const std::string &type) const
|
||||
std::string_view Class::getSoundIdFromSndGen(const Ptr& ptr, std::string_view type) const
|
||||
{
|
||||
throw std::runtime_error("class does not support soundgen look up");
|
||||
}
|
||||
|
|
|
@ -238,15 +238,15 @@ namespace MWWorld
|
|||
///
|
||||
/// (default implementation: return false)
|
||||
|
||||
virtual std::string getUpSoundId (const ConstPtr& ptr) const;
|
||||
virtual std::string_view getUpSoundId(const ConstPtr& ptr) const;
|
||||
///< Return the up sound ID of \a ptr or throw an exception, if class does not support ID retrieval
|
||||
/// (default implementation: throw an exception)
|
||||
|
||||
virtual std::string getDownSoundId (const ConstPtr& ptr) const;
|
||||
virtual std::string_view getDownSoundId(const ConstPtr& ptr) const;
|
||||
///< 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 std::string getSoundIdFromSndGen(const Ptr &ptr, const std::string &type) const;
|
||||
virtual std::string_view 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;
|
||||
|
|
|
@ -671,14 +671,14 @@ namespace MWWorld
|
|||
return mCurrentDate->getMonthName(month);
|
||||
}
|
||||
|
||||
std::string World::getCellName (const MWWorld::CellStore *cell) const
|
||||
std::string_view World::getCellName(const MWWorld::CellStore* cell) const
|
||||
{
|
||||
if (!cell)
|
||||
cell = mWorldScene->getCurrentCell();
|
||||
return getCellName(cell->getCell());
|
||||
}
|
||||
|
||||
std::string World::getCellName(const ESM::Cell* cell) const
|
||||
std::string_view World::getCellName(const ESM::Cell* cell) const
|
||||
{
|
||||
if (cell)
|
||||
{
|
||||
|
|
|
@ -280,12 +280,12 @@ namespace MWWorld
|
|||
char getGlobalVariableType(std::string_view name) const override;
|
||||
///< Return ' ', if there is no global variable with this name.
|
||||
|
||||
std::string getCellName (const MWWorld::CellStore *cell = nullptr) const override;
|
||||
std::string_view getCellName(const MWWorld::CellStore* cell = nullptr) const override;
|
||||
///< Return name of the cell.
|
||||
///
|
||||
/// \note If cell==0, the cell the player is currently in will be used instead to
|
||||
/// generate a name.
|
||||
std::string getCellName(const ESM::Cell* cell) const override;
|
||||
std::string_view getCellName(const ESM::Cell* cell) const override;
|
||||
|
||||
void removeRefScript (MWWorld::RefData *ref) override;
|
||||
//< Remove the script attached to ref from mLocalScripts
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace
|
|||
LocalVariables mLocals;
|
||||
std::map<std::string, GlobalVariables, std::less<>> mMembers;
|
||||
public:
|
||||
std::string getTarget() const override { return {}; };
|
||||
std::string_view getTarget() const override { return {}; };
|
||||
|
||||
int getLocalShort(int index) const override { return mLocals.getShort(index); };
|
||||
|
||||
|
@ -176,29 +176,29 @@ namespace
|
|||
|
||||
std::string getActionBinding(std::string_view action) const override { return {}; };
|
||||
|
||||
std::string getActorName() const override { return {}; };
|
||||
std::string_view getActorName() const override { return {}; };
|
||||
|
||||
std::string getNPCRace() const override { return {}; };
|
||||
std::string_view getNPCRace() const override { return {}; };
|
||||
|
||||
std::string getNPCClass() const override { return {}; };
|
||||
std::string_view getNPCClass() const override { return {}; };
|
||||
|
||||
std::string getNPCFaction() const override { return {}; };
|
||||
std::string_view getNPCFaction() const override { return {}; };
|
||||
|
||||
std::string getNPCRank() const override { return {}; };
|
||||
std::string_view getNPCRank() const override { return {}; };
|
||||
|
||||
std::string getPCName() const override { return {}; };
|
||||
std::string_view getPCName() const override { return {}; };
|
||||
|
||||
std::string getPCRace() const override { return {}; };
|
||||
std::string_view getPCRace() const override { return {}; };
|
||||
|
||||
std::string getPCClass() const override { return {}; };
|
||||
std::string_view getPCClass() const override { return {}; };
|
||||
|
||||
std::string getPCRank() const override { return {}; };
|
||||
std::string_view getPCRank() const override { return {}; };
|
||||
|
||||
std::string getPCNextRank() const override { return {}; };
|
||||
std::string_view getPCNextRank() const override { return {}; };
|
||||
|
||||
int getPCBounty() const override { return {}; };
|
||||
|
||||
std::string getCurrentCellName() const override { return {}; };
|
||||
std::string_view getCurrentCellName() const override { return {}; };
|
||||
|
||||
int getMemberShort(std::string_view id, std::string_view name, bool global) const override
|
||||
{
|
||||
|
|
|
@ -103,13 +103,20 @@ struct WeaponType
|
|||
//std::string mDisplayName; // TODO: will be needed later for editor
|
||||
std::string mShortGroup;
|
||||
std::string mLongGroup;
|
||||
std::string mSoundId;
|
||||
std::string mSoundIdDown;
|
||||
std::string mSoundIdUp;
|
||||
std::string mAttachBone;
|
||||
std::string mSheathingBone;
|
||||
Skill::SkillEnum mSkill;
|
||||
Class mWeaponClass;
|
||||
int mAmmoType;
|
||||
int mFlags;
|
||||
|
||||
WeaponType(std::string shortGroup, std::string longGroup, const std::string& soundId, std::string attachBone,
|
||||
std::string sheathingBone, Skill::SkillEnum skill, Class weaponClass, int ammoType, int flags) :
|
||||
mShortGroup(std::move(shortGroup)), mLongGroup(std::move(longGroup)), mSoundIdDown(soundId + " Down"),
|
||||
mSoundIdUp(soundId + " Up"), mAttachBone(std::move(attachBone)), mSheathingBone(std::move(sheathingBone)),
|
||||
mSkill(skill), mWeaponClass(weaponClass), mAmmoType(ammoType), mFlags(flags) {};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Interpreter
|
|||
|
||||
virtual ~Context() {}
|
||||
|
||||
virtual std::string getTarget() const = 0;
|
||||
virtual std::string_view getTarget() const = 0;
|
||||
|
||||
virtual int getLocalShort (int index) const = 0;
|
||||
|
||||
|
@ -56,29 +56,29 @@ namespace Interpreter
|
|||
|
||||
virtual std::string getActionBinding(std::string_view action) const = 0;
|
||||
|
||||
virtual std::string getActorName() const = 0;
|
||||
virtual std::string_view getActorName() const = 0;
|
||||
|
||||
virtual std::string getNPCRace() const = 0;
|
||||
virtual std::string_view getNPCRace() const = 0;
|
||||
|
||||
virtual std::string getNPCClass() const = 0;
|
||||
virtual std::string_view getNPCClass() const = 0;
|
||||
|
||||
virtual std::string getNPCFaction() const = 0;
|
||||
virtual std::string_view getNPCFaction() const = 0;
|
||||
|
||||
virtual std::string getNPCRank() const = 0;
|
||||
virtual std::string_view getNPCRank() const = 0;
|
||||
|
||||
virtual std::string getPCName() const = 0;
|
||||
virtual std::string_view getPCName() const = 0;
|
||||
|
||||
virtual std::string getPCRace() const = 0;
|
||||
virtual std::string_view getPCRace() const = 0;
|
||||
|
||||
virtual std::string getPCClass() const = 0;
|
||||
virtual std::string_view getPCClass() const = 0;
|
||||
|
||||
virtual std::string getPCRank() const = 0;
|
||||
virtual std::string_view getPCRank() const = 0;
|
||||
|
||||
virtual std::string getPCNextRank() const = 0;
|
||||
virtual std::string_view getPCNextRank() const = 0;
|
||||
|
||||
virtual int getPCBounty() const = 0;
|
||||
|
||||
virtual std::string getCurrentCellName() const = 0;
|
||||
virtual std::string_view getCurrentCellName() const = 0;
|
||||
|
||||
virtual int getMemberShort(std::string_view id, std::string_view name, bool global) const = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue