Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type

The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID

Slowly going through all the changes to make, still hundreds of errors

a lot of functions/structures use std::string or stringview to designate an ID. So it takes time

Continues slowly replacing ids. There are technically more and more compilation errors

I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type

Continue moving forward, changes to the stores

slowly moving along

Starting to see the fruit of those changes.

still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.

More replacements. Things are starting to get easier

I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.

Still moving forward, and for the first time error count is going down!

Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably

Cells are back to using string for the name, haven't fixed everything yet. Many other changes

Under the bar of 400 compilation errors.

more good progress <100 compile errors!

More progress

Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string

some more progress on other fronts

Mostly game settings clean

one error opened a lot of other errors. Down to 18, but more will prbably appear

only link errors left??

Fixed link errors

OpenMW compiles, and launches, with some issues, but still!
iwyu_full
fteppe 2 years ago committed by florent.teppe
parent 8b0eba8906
commit 125b21de20

@ -163,7 +163,7 @@ void OMW::Engine::executeLocalScripts()
MWWorld::LocalScripts& localScripts = mWorld->getLocalScripts();
localScripts.startIteration();
std::pair<std::string, MWWorld::Ptr> script;
std::pair<ESM::RefId, MWWorld::Ptr> script;
while (localScripts.getNext(script))
{
MWScript::InterpreterContext interpreterContext(&script.second.getRefData().getLocals(), script.second);

@ -17,6 +17,7 @@ namespace ESM
{
class ESMReader;
class ESMWriter;
struct RefId;
}
namespace MWWorld
@ -53,9 +54,9 @@ namespace MWBase
virtual bool startDialogue(const MWWorld::Ptr& actor, ResponseCallback* callback) = 0;
virtual bool inJournal(const std::string& topicId, const std::string& infoId) const = 0;
virtual bool inJournal(const ESM::RefId& topicId, const ESM::RefId& infoId) const = 0;
virtual void addTopic(std::string_view topic) = 0;
virtual void addTopic(const ESM::RefId& topic) = 0;
virtual void addChoice(std::string_view text, int choice) = 0;
virtual const std::vector<std::pair<std::string, int>>& getChoices() const = 0;
@ -64,7 +65,7 @@ namespace MWBase
virtual void goodbye() = 0;
virtual void say(const MWWorld::Ptr& actor, const std::string& topic) = 0;
virtual void say(const MWWorld::Ptr& actor, const ESM::RefId& topic) = 0;
virtual void keywordSelected(const std::string& keyword, ResponseCallback* callback) = 0;
virtual void goodbyeSelected() = 0;
@ -89,7 +90,7 @@ namespace MWBase
};
virtual std::list<std::string> getAvailableTopics() = 0;
virtual int getTopicFlag(const std::string&) const = 0;
virtual int getTopicFlag(const ESM::RefId&) const = 0;
virtual bool checkServiceRefused(ResponseCallback* callback, ServiceType service = ServiceType::Any) = 0;
@ -105,12 +106,12 @@ namespace MWBase
virtual void readRecord(ESM::ESMReader& reader, uint32_t type) = 0;
/// Changes faction1's opinion of faction2 by \a diff.
virtual void modFactionReaction(std::string_view faction1, std::string_view faction2, int diff) = 0;
virtual void modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff) = 0;
virtual void setFactionReaction(std::string_view faction1, std::string_view faction2, int absolute) = 0;
virtual void setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute) = 0;
/// @return faction1's opinion of faction2
virtual int getFactionReaction(std::string_view faction1, std::string_view faction2) const = 0;
virtual int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const = 0;
/// Removes the last added topic response for the given actor from the journal
virtual void clearInfoActor(const MWWorld::Ptr& actor) const = 0;

@ -37,9 +37,9 @@ namespace MWBase
public:
typedef std::deque<MWDialogue::StampedJournalEntry> TEntryContainer;
typedef TEntryContainer::const_iterator TEntryIter;
typedef std::map<std::string, MWDialogue::Quest> TQuestContainer; // topic, quest
typedef std::map<ESM::RefId, MWDialogue::Quest> TQuestContainer; // topic, quest
typedef TQuestContainer::const_iterator TQuestIter;
typedef std::map<std::string, MWDialogue::Topic> TTopicContainer; // topic-id, topic-content
typedef std::map<ESM::RefId, MWDialogue::Topic> TTopicContainer; // topic-id, topic-content
typedef TTopicContainer::const_iterator TTopicIter;
public:
@ -49,20 +49,20 @@ namespace MWBase
virtual ~Journal() {}
virtual void addEntry(const std::string& id, int index, const MWWorld::Ptr& actor) = 0;
virtual void addEntry(const ESM::RefId& id, int index, const MWWorld::Ptr& actor) = 0;
///< Add a journal entry.
/// @param actor Used as context for replacing of escape sequences (%name, etc).
virtual void setJournalIndex(const std::string& id, int index) = 0;
virtual void setJournalIndex(const ESM::RefId& id, int index) = 0;
///< Set the journal index without adding an entry.
virtual int getJournalIndex(const std::string& id) const = 0;
virtual int getJournalIndex(const ESM::RefId& id) const = 0;
///< Get the journal index.
virtual void addTopic(const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor) = 0;
virtual void addTopic(const ESM::RefId& topicId, const ESM::RefId& infoId, const MWWorld::Ptr& actor) = 0;
/// \note topicId must be lowercase
virtual void removeLastAddedTopicResponse(const std::string& topicId, std::string_view actorName) = 0;
virtual void removeLastAddedTopicResponse(const ESM::RefId& topicId, std::string_view actorName) = 0;
///< Removes the last topic response added for the given topicId and actor name.
/// \note topicId must be lowercase

@ -21,7 +21,7 @@ namespace osg
namespace ESM
{
struct Class;
struct RefId;
class ESMReader;
class ESMWriter;
}
@ -69,14 +69,14 @@ namespace MWBase
virtual void setPlayerName(const std::string& name) = 0;
///< Set player name.
virtual void setPlayerRace(const std::string& id, bool male, const std::string& head, const std::string& hair)
virtual void setPlayerRace(const ESM::RefId& id, bool male, const ESM::RefId& head, const ESM::RefId& hair)
= 0;
///< Set player race.
virtual void setPlayerBirthsign(const std::string& id) = 0;
virtual void setPlayerBirthsign(const ESM::RefId& id) = 0;
///< Set player birthsign.
virtual void setPlayerClass(const std::string& id) = 0;
virtual void setPlayerClass(const ESM::RefId& id) = 0;
///< Set player class to stock class.
virtual void setPlayerClass(const ESM::Class& class_) = 0;
@ -98,7 +98,7 @@ namespace MWBase
virtual int getDerivedDisposition(const MWWorld::Ptr& ptr, bool clamp = true) = 0;
///< Calculate the diposition of an NPC toward the player.
virtual int countDeaths(const std::string& id) const = 0;
virtual int countDeaths(const ESM::RefId& id) const = 0;
///< Return the number of deaths for actors with the given ID.
/// Check if \a observer is potentially aware of \a ptr. Does not do a line of sight check!
@ -128,7 +128,7 @@ namespace MWBase
* @return was the crime seen?
*/
virtual bool commitCrime(const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim, OffenseType type,
const std::string& factionId = "", int arg = 0, bool victimAware = false)
const ESM::RefId& factionId = ESM::RefId::sEmpty, int arg = 0, bool victimAware = false)
= 0;
/// @return false if the attack was considered a "friendly hit" and forgiven
virtual bool actorAttacked(const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker) = 0;
@ -236,7 +236,7 @@ namespace MWBase
virtual bool isReadyToBlock(const MWWorld::Ptr& ptr) const = 0;
virtual bool isAttackingOrSpell(const MWWorld::Ptr& ptr) const = 0;
virtual void castSpell(const MWWorld::Ptr& ptr, const std::string& spellId, bool manualSpell) = 0;
virtual void castSpell(const MWWorld::Ptr& ptr, const ESM::RefId& spellId, bool manualSpell) = 0;
virtual void processChangedSettings(const std::set<std::pair<std::string, std::string>>& settings) = 0;
@ -255,10 +255,10 @@ namespace MWBase
/// List the owners that the player has stolen this item from (the owner can be an NPC or a faction).
/// <Owner, item count>
virtual std::vector<std::pair<std::string, int>> getStolenItemOwners(const std::string& itemid) = 0;
virtual std::vector<std::pair<ESM::RefId, int>> getStolenItemOwners(const ESM::RefId& itemid) = 0;
/// Has the player stolen this item from the given owner?
virtual bool isItemStolenFrom(const std::string& itemid, const MWWorld::Ptr& ptr) = 0;
virtual bool isItemStolenFrom(const ESM::RefId& itemid, const MWWorld::Ptr& ptr) = 0;
virtual bool isBoundItem(const MWWorld::Ptr& item) = 0;
virtual bool isAllowedToUse(const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim) = 0;

@ -8,6 +8,11 @@ namespace Interpreter
class Context;
}
namespace ESM
{
struct RefId;
}
namespace Compiler
{
class Extensions;
@ -37,10 +42,10 @@ namespace MWBase
virtual void clear() = 0;
virtual bool run(std::string_view name, Interpreter::Context& interpreterContext) = 0;
virtual bool run(const ESM::RefId& name, Interpreter::Context& interpreterContext) = 0;
///< Run the script with the given name (compile first, if not compiled yet)
virtual bool compile(std::string_view name) = 0;
virtual bool compile(const ESM::RefId& name) = 0;
///< Compile script with the given namen
/// \return Success?
@ -48,7 +53,7 @@ namespace MWBase
///< Compile all scripts
/// \return count, success
virtual const Compiler::Locals& getLocals(std::string_view name) = 0;
virtual const Compiler::Locals& getLocals(const ESM::RefId& name) = 0;
///< Return locals for script \a name.
virtual MWScript::GlobalScripts& getGlobalScripts() = 0;

@ -14,6 +14,11 @@ namespace MWWorld
class CellStore;
}
namespace ESM
{
struct RefId;
}
namespace MWSound
{
// Each entry excepts of MaxCount should be used only in one place
@ -146,20 +151,20 @@ namespace MWBase
/// returned by \ref playTrack). Only intended to be called by the track
/// decoder's read method.
virtual Sound* playSound(std::string_view soundId, float volume, float pitch, Type type = Type::Sfx,
virtual Sound* playSound(const ESM::RefId& soundId, float volume, float pitch, Type type = Type::Sfx,
PlayMode mode = PlayMode::Normal, float offset = 0)
= 0;
///< Play a sound, independently of 3D-position
///< @param offset Number of seconds into the sound to start playback.
virtual Sound* playSound3D(const MWWorld::ConstPtr& reference, std::string_view soundId, float volume,
virtual Sound* playSound3D(const MWWorld::ConstPtr& reference, const ESM::RefId& soundId, float volume,
float pitch, Type type = Type::Sfx, PlayMode mode = PlayMode::Normal, float offset = 0)
= 0;
///< Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless
///< Play_NoTrack is specified.
///< @param offset Number of seconds into the sound to start playback.
virtual Sound* playSound3D(const osg::Vec3f& initialPos, std::string_view soundId, float volume, float pitch,
virtual Sound* playSound3D(const osg::Vec3f& initialPos, const ESM::RefId& soundId, float volume, float pitch,
Type type = Type::Sfx, PlayMode mode = PlayMode::Normal, float offset = 0)
= 0;
///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated using
@ -168,7 +173,7 @@ namespace MWBase
virtual void stopSound(Sound* sound) = 0;
///< Stop the given sound from playing
virtual void stopSound3D(const MWWorld::ConstPtr& reference, std::string_view soundId) = 0;
virtual void stopSound3D(const MWWorld::ConstPtr& reference, const ESM::RefId& soundId) = 0;
///< Stop the given object from playing the given sound,
virtual void stopSound3D(const MWWorld::ConstPtr& reference) = 0;
@ -177,13 +182,13 @@ namespace MWBase
virtual void stopSound(const MWWorld::CellStore* cell) = 0;
///< Stop all sounds for the given cell.
virtual void fadeOutSound3D(const MWWorld::ConstPtr& reference, std::string_view soundId, float duration) = 0;
virtual void fadeOutSound3D(const MWWorld::ConstPtr& reference, const ESM::RefId& soundId, float duration) = 0;
///< Fade out given sound (that is already playing) of given object
///< @param reference Reference to object, whose sound is faded out
///< @param soundId ID of the sound to fade out.
///< @param duration Time until volume reaches 0.
virtual bool getSoundPlaying(const MWWorld::ConstPtr& reference, std::string_view soundId) const = 0;
virtual bool getSoundPlaying(const MWWorld::ConstPtr& reference, const ESM::RefId& soundId) const = 0;
///< Is the given sound currently playing on the given object?
/// If you want to check if sound played with playSound is playing, use empty Ptr

@ -14,6 +14,11 @@
#include <components/sdlutil/events.hpp>
namespace ESM
{
struct RefId;
}
namespace Loading
{
class Listener;
@ -215,8 +220,8 @@ namespace MWBase
/// update activated quick key state (if action executing was delayed for some reason)
virtual void updateActivatedQuickKey() = 0;
virtual const std::string& getSelectedSpell() = 0;
virtual void setSelectedSpell(const std::string& spellId, int successChancePercent) = 0;
virtual const ESM::RefId& getSelectedSpell() = 0;
virtual void setSelectedSpell(const ESM::RefId& spellId, int successChancePercent) = 0;
virtual void setSelectedEnchantItem(const MWWorld::Ptr& item) = 0;
virtual const MWWorld::Ptr& getSelectedEnchantItem() const = 0;
virtual void setSelectedWeapon(const MWWorld::Ptr& item) = 0;
@ -268,7 +273,7 @@ namespace MWBase
* @param id Identifier for the GMST setting, e.g. "aName"
* @param default Default value if the GMST setting cannot be used.
*/
virtual std::string_view getGameSettingString(std::string_view id, std::string_view default_) = 0;
virtual std::string_view getGameSettingString(const std::string_view& id, std::string_view default_) = 0;
virtual void processChangedSettings(const std::set<std::pair<std::string, std::string>>& changed) = 0;
@ -345,7 +350,7 @@ namespace MWBase
/// Cycle to next or previous weapon
virtual void cycleWeapon(bool next) = 0;
virtual void playSound(std::string_view soundId, float volume = 1.f, float pitch = 1.f) = 0;
virtual void playSound(const ESM::RefId& soundId, float volume = 1.f, float pitch = 1.f) = 0;
virtual void addCell(MWWorld::CellStore* cell) = 0;
virtual void removeCell(MWWorld::CellStore* cell) = 0;

@ -56,6 +56,7 @@ namespace ESM
struct CreatureLevList;
struct ItemLevList;
struct TimeStamp;
struct RefId;
}
namespace MWPhysics
@ -176,28 +177,28 @@ namespace MWBase
virtual char getGlobalVariableType(std::string_view name) const = 0;
///< Return ' ', if there is no global variable with this name.
virtual std::string_view getCellName(const MWWorld::CellStore* cell = nullptr) const = 0;
virtual const std::string& 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_view getCellName(const ESM::Cell* cell) const = 0;
virtual const std::string& getCellName(const ESM::Cell* cell) const = 0;
virtual void removeRefScript(MWWorld::RefData* ref) = 0;
//< Remove the script attached to ref from mLocalScripts
virtual MWWorld::Ptr getPtr(std::string_view name, bool activeOnly) = 0;
virtual MWWorld::Ptr getPtr(const ESM::RefId& name, bool activeOnly) = 0;
///< Return a pointer to a liveCellRef with the given name.
/// \param activeOnly do non search inactive cells.
virtual MWWorld::Ptr searchPtr(std::string_view name, bool activeOnly, bool searchInContainers = true) = 0;
virtual MWWorld::Ptr searchPtr(const ESM::RefId& name, bool activeOnly, bool searchInContainers = true) = 0;
///< Return a pointer to a liveCellRef with the given name.
/// \param activeOnly do non search inactive cells.
virtual MWWorld::Ptr searchPtrViaActorId(int actorId) = 0;
///< Search is limited to the active cells.
virtual MWWorld::Ptr searchPtrViaRefNum(const std::string& id, const ESM::RefNum& refNum) = 0;
virtual MWWorld::Ptr searchPtrViaRefNum(const ESM::RefId& id, const ESM::RefNum& refNum) = 0;
virtual MWWorld::Ptr findContainer(const MWWorld::ConstPtr& ptr) = 0;
///< Return a pointer to a liveCellRef which contains \a ptr.
@ -222,7 +223,7 @@ namespace MWBase
virtual bool toggleSky() = 0;
///< \return Resulting mode
virtual void changeWeather(std::string_view region, const unsigned int id) = 0;
virtual void changeWeather(const ESM::RefId& region, const unsigned int id) = 0;
virtual int getCurrentWeather() const = 0;
@ -238,7 +239,7 @@ namespace MWBase
virtual void setMoonColour(bool red) = 0;
virtual void modRegion(std::string_view regionid, const std::vector<char>& chances) = 0;
virtual void modRegion(const ESM::RefId& regionid, const std::vector<char>& chances) = 0;
virtual float getTimeScaleFactor() const = 0;
@ -553,7 +554,7 @@ namespace MWBase
virtual void castSpell(const MWWorld::Ptr& actor, bool manualSpell = false) = 0;
virtual void launchMagicBolt(
const std::string& spellId, const MWWorld::Ptr& caster, const osg::Vec3f& fallbackDirection, int slot)
const ESM::RefId& spellId, const MWWorld::Ptr& caster, const osg::Vec3f& fallbackDirection, int slot)
= 0;
virtual void launchProjectile(MWWorld::Ptr& actor, MWWorld::Ptr& projectile, const osg::Vec3f& worldPos,
const osg::Quat& orient, MWWorld::Ptr& bow, float speed, float attackStrength)
@ -576,7 +577,7 @@ namespace MWBase
/// Teleports \a ptr to the closest reference of \a id (e.g. DivineMarker, PrisonMarker, TempleMarker)
/// @note id must be lower case
virtual void teleportToClosestMarker(const MWWorld::Ptr& ptr, std::string_view id) = 0;
virtual void teleportToClosestMarker(const MWWorld::Ptr& ptr, const ESM::RefId& id) = 0;
enum DetectionType
{
@ -600,7 +601,7 @@ namespace MWBase
virtual void goToJail() = 0;
/// Spawn a random creature from a levelled list next to the player
virtual void spawnRandomCreature(std::string_view creatureList) = 0;
virtual void spawnRandomCreature(const ESM::RefId& creatureList) = 0;
/// Spawn a blood effect for \a ptr at \a worldPosition
virtual void spawnBloodEffect(const MWWorld::Ptr& ptr, const osg::Vec3f& worldPosition) = 0;
@ -675,7 +676,7 @@ namespace MWBase
virtual void reportStats(unsigned int frameNumber, osg::Stats& stats) const = 0;
virtual std::vector<MWWorld::Ptr> getAll(const std::string& id) = 0;
virtual std::vector<MWWorld::Ptr> getAll(const ESM::RefId& id) = 0;
virtual Misc::Rng::Generator& getPrng() = 0;

@ -84,7 +84,7 @@ namespace MWClass
return ref->mBase->mName;
}
std::string_view Activator::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Activator::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Activator>* ref = ptr.get<ESM::Activator>();
@ -109,7 +109,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;
@ -122,7 +122,7 @@ namespace MWClass
{
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfActivator", prng);
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom(ESM::RefId::stringRefId("WolfActivator"), prng);
std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if (sound)
@ -140,12 +140,12 @@ namespace MWClass
return MWWorld::Ptr(cell.insert(ref), &cell);
}
std::string_view Activator::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
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
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::string_view creatureId;
const ESM::RefId* creatureId = nullptr;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
for (const ESM::Creature& iter : store.get<ESM::Creature>())
@ -153,7 +153,7 @@ namespace MWClass
if (!iter.mModel.empty()
&& Misc::StringUtils::ciEqual(model, Misc::ResourceHelpers::correctMeshPath(iter.mModel, vfs)))
{
creatureId = !iter.mOriginal.empty() ? iter.mOriginal : iter.mId;
creatureId = !iter.mOriginal.empty() ? &iter.mOriginal : &iter.mId;
break;
}
}
@ -162,14 +162,14 @@ namespace MWClass
std::vector<const ESM::SoundGenerator*> fallbacksounds;
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
if (!creatureId.empty())
if (creatureId && !creatureId->empty())
{
std::vector<const ESM::SoundGenerator*> sounds;
for (auto sound = store.get<ESM::SoundGenerator>().begin(); sound != store.get<ESM::SoundGenerator>().end();
++sound)
{
if (type == sound->mType && !sound->mCreature.empty()
&& (Misc::StringUtils::ciEqual(creatureId, sound->mCreature)))
&& (ESM::RefId::ciEqual(*creatureId, sound->mCreature)))
sounds.push_back(&*sound);
if (type == sound->mType && sound->mCreature.empty())
fallbacksounds.push_back(&*sound);
@ -192,7 +192,7 @@ namespace MWClass
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size(), prng)]->mSound;
}
return {};
return ESM::RefId::sEmpty;
}
int Activator::getSndGenTypeFromName(std::string_view name)

@ -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.
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
@ -48,7 +48,7 @@ namespace MWClass
bool isActivator() const override;
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
const ESM::RefId& getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
};
}

@ -46,13 +46,13 @@ namespace MWClass
switch (shield->getClass().getEquipmentSkill(*shield))
{
case ESM::Skill::LightArmor:
sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f);
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Light Armor Hit"), 1.0f, 1.0f);
break;
case ESM::Skill::MediumArmor:
sndMgr->playSound3D(ptr, "Medium Armor Hit", 1.0f, 1.0f);
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Medium Armor Hit"), 1.0f, 1.0f);
break;
case ESM::Skill::HeavyArmor:
sndMgr->playSound3D(ptr, "Heavy Armor Hit", 1.0f, 1.0f);
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Heavy Armor Hit"), 1.0f, 1.0f);
break;
default:
return;

@ -45,7 +45,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Apparatus>* ref = ptr.get<ESM::Apparatus>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Apparatus::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -53,7 +53,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
std::string_view Apparatus::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Apparatus::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Apparatus>* ref = ptr.get<ESM::Apparatus>();
@ -67,14 +67,16 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Apparatus::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Apparatus::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Apparatus Up";
static const auto sound = ESM::RefId::stringRefId("Item Apparatus Up");
return sound;
}
std::string_view Apparatus::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Apparatus::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Apparatus Down";
static const auto sound = ESM::RefId::stringRefId("Item Apparatus Down");
return sound;
}
const std::string& Apparatus::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -102,7 +104,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;

@ -26,7 +26,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
///< Generate action for activation
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
@ -35,10 +35,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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;

@ -55,7 +55,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Armor>* ref = ptr.get<ESM::Armor>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Armor::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -75,7 +75,7 @@ namespace MWClass
return ref->mBase->mData.mHealth;
}
std::string_view Armor::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Armor::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Armor>* ref = ptr.get<ESM::Armor>();
@ -176,26 +176,32 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Armor::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Armor::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
int es = getEquipmentSkill(ptr);
std::string soundName;
if (es == ESM::Skill::LightArmor)
return "Item Armor Light Up";
soundName = "Item Armor Light Up";
else if (es == ESM::Skill::MediumArmor)
return "Item Armor Medium Up";
soundName = "Item Armor Medium Up";
else
return "Item Armor Heavy Up";
soundName = "Item Armor Heavy Up";
static const ESM::RefId id = ESM::RefId::stringRefId(soundName);
return id;
}
std::string_view Armor::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Armor::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
int es = getEquipmentSkill(ptr);
std::string soundName;
if (es == ESM::Skill::LightArmor)
return "Item Armor Light Down";
soundName = "Item Armor Light Down";
else if (es == ESM::Skill::MediumArmor)
return "Item Armor Medium Down";
soundName = "Item Armor Medium Down";
else
return "Item Armor Heavy Down";
soundName = "Item Armor Heavy Down";
static const ESM::RefId id = ESM::RefId::stringRefId(soundName);
return id;
}
const std::string& Armor::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -253,7 +259,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.enchant = ref->mBase->mEnchant;
@ -265,15 +271,15 @@ namespace MWClass
return info;
}
std::string_view Armor::getEnchantment(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Armor::getEnchantment(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Armor>* ref = ptr.get<ESM::Armor>();
return ref->mBase->mEnchant;
}
const std::string& Armor::applyEnchantment(
const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
const ESM::RefId& Armor::applyEnchantment(
const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, const std::string& newName) const
{
const MWWorld::LiveCellRef<ESM::Armor>* ref = ptr.get<ESM::Armor>();
@ -317,7 +323,7 @@ namespace MWClass
if (npc.getClass().isNpc())
{
const std::string& npcRace = npc.get<ESM::NPC>()->mBase->mRace;
const ESM::RefId& npcRace = npc.get<ESM::NPC>()->mBase->mRace;
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);

@ -32,7 +32,7 @@ namespace MWClass
int getItemMaxHealth(const MWWorld::ConstPtr& ptr) const override;
///< Return item max health or throw an exception, if class does not have item health
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override;
@ -49,19 +49,19 @@ 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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;
///< Return name of inventory icon.
std::string_view getEnchantment(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const override;
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
const std::string& applyEnchantment(const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge,
const ESM::RefId& applyEnchantment(const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge,
const std::string& newName) const override;
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.

@ -51,7 +51,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Book>* ref = ptr.get<ESM::Book>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Book::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -60,7 +60,7 @@ namespace MWClass
{
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfItem", prng);
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom(ESM::RefId::stringRefId("WolfItem"), prng);
std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if (sound)
@ -72,7 +72,7 @@ namespace MWClass
return std::make_unique<MWWorld::ActionRead>(ptr);
}
std::string_view Book::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Book::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Book>* ref = ptr.get<ESM::Book>();
@ -86,14 +86,16 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Book::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Book::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Book Up";
static auto var = ESM::RefId::stringRefId("Item Book Up");
return var;
}
std::string_view Book::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Book::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Book Down";
static auto var = ESM::RefId::stringRefId("Item Book Down");
return var;
}
const std::string& Book::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -121,7 +123,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.enchant = ref->mBase->mEnchant;
@ -131,15 +133,15 @@ namespace MWClass
return info;
}
std::string_view Book::getEnchantment(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Book::getEnchantment(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Book>* ref = ptr.get<ESM::Book>();
return ref->mBase->mEnchant;
}
const std::string& Book::applyEnchantment(
const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
const ESM::RefId& Book::applyEnchantment(
const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, const std::string& newName) const
{
const MWWorld::LiveCellRef<ESM::Book>* ref = ptr.get<ESM::Book>();

@ -24,7 +24,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
///< Generate action for activation
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
@ -33,19 +33,19 @@ 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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;
///< Return name of inventory icon.
std::string_view getEnchantment(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const override;
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
const std::string& applyEnchantment(const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge,
const ESM::RefId& applyEnchantment(const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge,
const std::string& newName) const override;
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.

@ -50,7 +50,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Clothing::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -58,7 +58,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
std::string_view Clothing::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Clothing::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
@ -118,26 +118,28 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Clothing::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Clothing::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
static ESM::RefId sound;
if (ref->mBase->mData.mType == 8)
{
return "Item Ring Up";
sound = ESM::RefId::stringRefId("Item Ring Up");
}
return "Item Clothes Up";
sound = ESM::RefId::stringRefId("Item Clothes Up");
return sound;
}
std::string_view Clothing::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Clothing::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
static ESM::RefId sound;
if (ref->mBase->mData.mType == 8)
{
return "Item Ring Down";
sound = ESM::RefId::stringRefId("Item Ring Down");
}
return "Item Clothes Down";
sound = ESM::RefId::stringRefId("Item Clothes Down");
return sound;
}
const std::string& Clothing::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -165,7 +167,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.enchant = ref->mBase->mEnchant;
@ -177,15 +179,15 @@ namespace MWClass
return info;
}
std::string_view Clothing::getEnchantment(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Clothing::getEnchantment(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
return ref->mBase->mEnchant;
}
const std::string& Clothing::applyEnchantment(
const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
const ESM::RefId& Clothing::applyEnchantment(
const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, const std::string& newName) const
{
const MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
@ -209,7 +211,7 @@ namespace MWClass
if (npc.getClass().isNpc())
{
const std::string& npcRace = npc.get<ESM::NPC>()->mBase->mRace;
const ESM::RefId& npcRace = npc.get<ESM::NPC>()->mBase->mRace;
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);

@ -24,7 +24,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
///< Generate action for activation
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override;
@ -41,19 +41,19 @@ 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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;
///< Return name of inventory icon.
std::string_view getEnchantment(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const override;
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
const std::string& applyEnchantment(const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge,
const ESM::RefId& applyEnchantment(const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge,
const std::string& newName) const override;
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.

@ -42,7 +42,7 @@ namespace MWClass
unsigned int seed = Misc::Rng::rollDice(std::numeric_limits<int>::max(), prng);
// setting ownership not needed, since taking items from a container inherits the
// container's owner automatically
mStore.fillNonRandom(container.mInventory, "", seed);
mStore.fillNonRandom(container.mInventory, ESM::RefId::sEmpty, seed);
}
ContainerCustomData::ContainerCustomData(const ESM::InventoryState& inventory)
@ -143,7 +143,7 @@ namespace MWClass
{
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfContainer", prng);
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom(ESM::RefId::stringRefId("WolfContainer"), prng);
std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if (sound)
@ -152,8 +152,8 @@ namespace MWClass
return action;
}
const std::string_view lockedSound = "LockedChest";
const std::string_view trapActivationSound = "Disarm Trap Fail";
const ESM::RefId& lockedSound = ESM::RefId::stringRefId("LockedChest");
const ESM::RefId& trapActivationSound = ESM::RefId::stringRefId("Disarm Trap Fail");
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
@ -163,7 +163,7 @@ namespace MWClass
bool hasKey = false;
std::string_view keyName;
const std::string& keyId = ptr.getCellRef().getKey();
const ESM::RefId& keyId = ptr.getCellRef().getKey();
if (!keyId.empty())
{
MWWorld::Ptr keyPtr = invStore.search(keyId);
@ -181,8 +181,8 @@ namespace MWClass
// using a key disarms the trap
if (isTrapped)
{
ptr.getCellRef().setTrap("");
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, "Disarm Trap", 1.0f, 1.0f);
ptr.getCellRef().setTrap(ESM::RefId::sEmpty);
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f);
isTrapped = false;
}
}
@ -220,7 +220,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Container>* ref = ptr.get<ESM::Container>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
MWWorld::ContainerStore& Container::getContainerStore(const MWWorld::Ptr& ptr) const
@ -231,7 +231,7 @@ namespace MWClass
return data.mStore;
}
std::string_view Container::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Container::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Container>* ref = ptr.get<ESM::Container>();
@ -259,14 +259,14 @@ namespace MWClass
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(lockLevel);
else if (lockLevel < 0)
text += "\n#{sUnlocked}";
if (ptr.getCellRef().getTrap() != "")
if (ptr.getCellRef().getTrap() != ESM::RefId::sEmpty)
text += "\n#{sTrapped}";
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
if (Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "stolen_goods"))
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
if (ESM::RefId::ciEqual(ptr.getCellRef().getRefId(), ESM::RefId::stringRefId("stolen_goods")))
text += "\nYou can not use evidence chests";
}
@ -293,7 +293,7 @@ namespace MWClass
return !(ref->mBase->mFlags & ESM::Container::Organic);
}
void Container::modifyBaseInventory(std::string_view containerId, std::string_view itemId, int amount) const
void Container::modifyBaseInventory(const ESM::RefId& containerId, const ESM::RefId& itemId, int amount) const
{
MWMechanics::modifyBaseInventory<ESM::Container>(containerId, itemId, amount);
}

@ -66,7 +66,7 @@ namespace MWClass
MWWorld::ContainerStore& getContainerStore(const MWWorld::Ptr& ptr) const override;
///< Return container store
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
@ -91,7 +91,7 @@ namespace MWClass
bool useAnim() const override;
void modifyBaseInventory(std::string_view containerId, std::string_view itemId, int amount) const override;
void modifyBaseInventory(const ESM::RefId& containerId, const ESM::RefId& itemId, int amount) const override;
};
}

@ -214,7 +214,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Creature>* ref = ptr.get<ESM::Creature>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
MWMechanics::CreatureStats& Creature::getCreatureStats(const MWWorld::Ptr& ptr) const
@ -401,7 +401,7 @@ namespace MWClass
if (setOnPcHitMe && !attacker.isEmpty() && attacker == MWMechanics::getPlayer())
{
const std::string& script = ptr.get<ESM::Creature>()->mBase->mScript;
const ESM::RefId& script = ptr.get<ESM::Creature>()->mBase->mScript;
/* Set the OnPCHitMe script variable. The script is responsible for clearing it. */
if (!script.empty())
ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1);
@ -411,7 +411,7 @@ namespace MWClass
{
// Missed
if (!attacker.isEmpty() && attacker == MWMechanics::getPlayer())
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, "miss", 1.0f, 1.0f);
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("miss"), 1.0f, 1.0f);
return;
}
@ -448,7 +448,7 @@ namespace MWClass
MWBase::Environment::get().getWorld()->spawnBloodEffect(ptr, hitPosition);
}
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, "Health Damage", 1.0f, 1.0f);
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("Health Damage"), 1.0f, 1.0f);
MWMechanics::DynamicStat<float> health(stats.getHealth());
health.setCurrent(health.getCurrent() - damage);
@ -469,7 +469,7 @@ namespace MWClass
{
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfCreature", prng);
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom(ESM::RefId::stringRefId("WolfCreature"), prng);
std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if (sound)
@ -522,7 +522,7 @@ namespace MWClass
return isFlagBitSet(ptr, ESM::Creature::Weapon);
}
std::string_view Creature::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Creature::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Creature>* ref = ptr.get<ESM::Creature>();
@ -601,7 +601,7 @@ namespace MWClass
std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
info.text = text;
return info;
@ -630,18 +630,18 @@ namespace MWClass
return (ref->mBase->mRecordFlags & ESM::FLAG_Persistent) != 0;
}
std::string_view Creature::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
const ESM::RefId& Creature::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
{
int type = getSndGenTypeFromName(ptr, name);
if (type < 0)
return {};
return ESM::RefId::sEmpty;
std::vector<const ESM::SoundGenerator*> sounds;
std::vector<const ESM::SoundGenerator*> fallbacksounds;
MWWorld::LiveCellRef<ESM::Creature>* ref = ptr.get<ESM::Creature>();
const std::string& ourId
const ESM::RefId& ourId
= (ref->mBase->mOriginal.empty()) ? ptr.getCellRef().getRefId() : ref->mBase->mOriginal;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
@ -649,7 +649,7 @@ namespace MWClass
while (sound != store.get<ESM::SoundGenerator>().end())
{
if (type == sound->mType && !sound->mCreature.empty()
&& Misc::StringUtils::ciEqual(ourId, sound->mCreature))
&& ESM::RefId::ciEqual(ourId, sound->mCreature))
sounds.push_back(&*sound);
if (type == sound->mType && sound->mCreature.empty())
fallbacksounds.push_back(&*sound);
@ -668,12 +668,12 @@ namespace MWClass
&& Misc::StringUtils::ciEqual(
model, Misc::ResourceHelpers::correctMeshPath(creature.mModel, vfs)))
{
const std::string& fallbackId = !creature.mOriginal.empty() ? creature.mOriginal : creature.mId;
const ESM::RefId& fallbackId = !creature.mOriginal.empty() ? creature.mOriginal : creature.mId;
sound = store.get<ESM::SoundGenerator>().begin();
while (sound != store.get<ESM::SoundGenerator>().end())
{
if (type == sound->mType && !sound->mCreature.empty()
&& Misc::StringUtils::ciEqual(fallbackId, sound->mCreature))
&& ESM::RefId::ciEqual(fallbackId, sound->mCreature))
sounds.push_back(&*sound);
++sound;
}
@ -689,7 +689,7 @@ namespace MWClass
if (!fallbacksounds.empty())
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size(), prng)]->mSound;
return {};
return ESM::RefId::sEmpty;
}
MWWorld::Ptr Creature::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const
@ -876,7 +876,7 @@ namespace MWClass
if (ptr.getRefData().getCount() == 0)
{
ptr.getRefData().setCount(1);
std::string_view script = getScript(ptr);
const ESM::RefId& script = getScript(ptr);
if (!script.empty())
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr);
}
@ -905,12 +905,12 @@ namespace MWClass
scale *= ref->mBase->mScale;
}
void Creature::setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const
void Creature::setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const
{
MWMechanics::setBaseAISetting<ESM::Creature>(id, setting, value);
}
void Creature::modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const
void Creature::modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const
{
MWMechanics::modifyBaseInventory<ESM::Creature>(actorId, itemId, amount);
}

@ -80,7 +80,7 @@ namespace MWClass
bool hasInventoryStore(const MWWorld::Ptr& ptr) const override;
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
const 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.
@ -135,9 +135,9 @@ namespace MWClass
void adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const override;
/// @param rendering Indicates if the scale to adjust is for the rendering mesh, or for the collision mesh
void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const override;
void setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const override;
void modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const override;
void modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const override;
float getWalkSpeed(const MWWorld::Ptr& ptr) const override;

@ -130,7 +130,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::CreatureLevList>* ref = ptr.get<ESM::CreatureLevList>();
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
std::string_view id = MWMechanics::getLevelledItem(ref->mBase, true, prng);
const ESM::RefId& id = MWMechanics::getLevelledItem(ref->mBase, true, prng);
if (!id.empty())
{

@ -104,17 +104,17 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Door>* ref = ptr.get<ESM::Door>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Door::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
{
MWWorld::LiveCellRef<ESM::Door>* ref = ptr.get<ESM::Door>();
const std::string& openSound = ref->mBase->mOpenSound;
const std::string& closeSound = ref->mBase->mCloseSound;
const std::string_view lockedSound = "LockedDoor";
const std::string_view trapActivationSound = "Disarm Trap Fail";
const ESM::RefId& openSound = ref->mBase->mOpenSound;
const ESM::RefId& closeSound = ref->mBase->mCloseSound;
const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedDoor");
const ESM::RefId trapActivationSound = ESM::RefId::stringRefId("Disarm Trap Fail");
// FIXME: If NPC activate teleporting door, it can lead to crash due to iterator invalidation in the Actors
// update. Make such activation a no-op for now, like how it is in the vanilla game.
@ -148,7 +148,7 @@ namespace MWClass
bool isTrapped = !ptr.getCellRef().getTrap().empty();
bool hasKey = false;
std::string_view keyName;
const std::string& keyId = ptr.getCellRef().getKey();
const ESM::RefId& keyId = ptr.getCellRef().getKey();
if (!keyId.empty())
{
MWWorld::Ptr keyPtr = invStore.search(keyId);
@ -167,8 +167,8 @@ namespace MWClass
// using a key disarms the trap
if (isTrapped)
{
ptr.getCellRef().setTrap("");
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, "Disarm Trap", 1.0f, 1.0f);
ptr.getCellRef().setTrap(ESM::RefId::sEmpty);
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f);
isTrapped = false;
}
}
@ -256,7 +256,7 @@ namespace MWClass
return true;
}
std::string_view Door::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Door::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Door>* ref = ptr.get<ESM::Door>();
@ -290,7 +290,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;

@ -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
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;

@ -48,7 +48,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Ingredient>* ref = ptr.get<ESM::Ingredient>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Ingredient::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -56,7 +56,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
std::string_view Ingredient::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Ingredient::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Ingredient>* ref = ptr.get<ESM::Ingredient>();
@ -74,19 +74,21 @@ namespace MWClass
{
std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionEat>(ptr);
action->setSound("Swallow");
action->setSound(ESM::RefId::stringRefId("Swallow"));
return action;
}
std::string_view Ingredient::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Ingredient::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Ingredient Up";
static auto sound = ESM::RefId::stringRefId("Item Ingredient Up");
return sound;
}
std::string_view Ingredient::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Ingredient::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Ingredient Down";
static auto sound = ESM::RefId::stringRefId("Item Ingredient Down");
return sound;
}
const std::string& Ingredient::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -114,7 +116,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();

@ -27,7 +27,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo(const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
@ -36,10 +36,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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;

@ -83,7 +83,7 @@ namespace MWClass
return {};
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Light::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -98,7 +98,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
std::string_view Light::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Light::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Light>* ref = ptr.get<ESM::Light>();
@ -124,14 +124,16 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Light::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Light::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Misc Up";
static const auto sound = ESM::RefId::stringRefId("Item Misc Up");
return sound;
}
std::string_view Light::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Light::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Misc Down";
static const auto sound = ESM::RefId::stringRefId("Item Misc Down");
return sound;
}
const std::string& Light::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -169,7 +171,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;
@ -237,7 +239,7 @@ namespace MWClass
return { 1, {} };
}
std::string_view Light::getSound(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Light::getSound(const MWWorld::ConstPtr& ptr) const
{
return ptr.get<ESM::Light>()->mBase->mSound;
}

@ -39,7 +39,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
///< Generate action for activation
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override;
@ -49,10 +49,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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;
@ -76,7 +76,7 @@ namespace MWClass
std::pair<int, std::string_view> canBeEquipped(
const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const override;
std::string_view getSound(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getSound(const MWWorld::ConstPtr& ptr) const override;
};
}

@ -48,7 +48,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Lockpick>* ref = ptr.get<ESM::Lockpick>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Lockpick::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -56,7 +56,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
std::string_view Lockpick::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Lockpick::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Lockpick>* ref = ptr.get<ESM::Lockpick>();
@ -79,14 +79,16 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Lockpick::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Lockpick::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Lockpick Up";
static ESM::RefId sound = ESM::RefId::stringRefId("Item Lockpick Up");
return sound;
}
std::string_view Lockpick::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Lockpick::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Lockpick Down";
static ESM::RefId sound = ESM::RefId::stringRefId("Item Lockpick Down");
return sound;
}
const std::string& Lockpick::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -118,7 +120,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;

@ -3,6 +3,11 @@
#include "../mwworld/registeredclass.hpp"
namespace ESM
{
struct RefId;
}
namespace MWClass
{
class Lockpick : public MWWorld::RegisteredClass<Lockpick>
@ -27,7 +32,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo(const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override;
@ -37,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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;

@ -35,11 +35,11 @@ namespace MWClass
bool Miscellaneous::isGold(const MWWorld::ConstPtr& ptr) const
{
return Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_005")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_010")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100");
return ESM::RefId::ciEqual(ptr.getCellRef().getRefId(), ESM::RefId::stringRefId("gold_001"))
|| ESM::RefId::ciEqual(ptr.getCellRef().getRefId(), ESM::RefId::stringRefId("gold_005"))
|| ESM::RefId::ciEqual(ptr.getCellRef().getRefId(), ESM::RefId::stringRefId("gold_010"))
|| ESM::RefId::ciEqual(ptr.getCellRef().getRefId(), ESM::RefId::stringRefId("gold_025"))
|| ESM::RefId::ciEqual(ptr.getCellRef().getRefId(), ESM::RefId::stringRefId("gold_100"));
}
void Miscellaneous::insertObjectRendering(
@ -61,7 +61,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Miscellaneous::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -69,7 +69,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
std::string_view Miscellaneous::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Miscellaneous::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
@ -97,7 +97,7 @@ namespace MWClass
float soulValue = 0.0001 * pow(soul, 3) + 2 * soul;
// for Azura's star add the unfilled value
if (Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "Misc_SoulGem_Azura"))
if (ESM::RefId::ciEqual(ptr.getCellRef().getRefId(), ESM::RefId::stringRefId("Misc_SoulGem_Azura")))
value += soulValue;
else
value = soulValue;
@ -110,18 +110,22 @@ namespace MWClass
return value;
}
std::string_view Miscellaneous::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Miscellaneous::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
static ESM::RefId sound;
if (isGold(ptr))
return "Item Gold Up";
return "Item Misc Up";
sound = ESM::RefId::stringRefId("Item Gold Up");
sound = ESM::RefId::stringRefId("Item Misc Up");
return sound;
}
std::string_view Miscellaneous::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Miscellaneous::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
static ESM::RefId sound;
if (isGold(ptr))
return "Item Gold Down";
return "Item Misc Down";
sound = ESM::RefId::stringRefId("Item Gold Down");
sound = ESM::RefId::stringRefId("Item Misc Down");
return sound;
}
const std::string& Miscellaneous::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -161,7 +165,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;
@ -191,7 +195,7 @@ namespace MWClass
// Really, I have no idea why moving ref out of conditional
// scope causes list::push_back throwing std::bad_alloc
MWWorld::ManualRef newRef(store, base);
MWWorld::ManualRef newRef(store, ESM::RefId::stringRefId(base));
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = newRef.getPtr().get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(cell.insert(ref), &cell);
@ -238,7 +242,7 @@ namespace MWClass
bool Miscellaneous::isSoulGem(const MWWorld::ConstPtr& ptr) const
{
return Misc::StringUtils::ciStartsWith(ptr.getCellRef().getRefId(), "misc_soulgem");
return Misc::StringUtils::ciStartsWith(ptr.getCellRef().getRefId().getRefIdString(), "misc_soulgem");
}
}

@ -27,16 +27,16 @@ 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_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;

@ -247,7 +247,7 @@ namespace
if (!spellsInitialised)
{
std::vector<std::string> spells = MWMechanics::autoCalcNpcSpells(skills, attributes, race);
std::vector<ESM::RefId> spells = MWMechanics::autoCalcNpcSpells(skills, attributes, race);
npcStats.getSpells().addAllToInstance(spells);
}
}
@ -506,11 +506,11 @@ namespace MWClass
for (std::vector<ESM::PartReference>::const_iterator it = parts.begin(); it != parts.end(); ++it)
{
std::string_view partname = female ? it->mFemale : it->mMale;
if (partname.empty())
partname = female ? it->mMale : it->mFemale;
const ESM::RefId* partname = female ? &it->mFemale : &it->mMale;
if (partname->empty())
partname = female ? &it->mMale : &it->mFemale;
const ESM::BodyPart* part
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(partname);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(*partname);
if (part && !part->mModel.empty())
models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs));
}
@ -521,7 +521,7 @@ namespace MWClass
if (race)
{
const std::vector<const ESM::BodyPart*>& parts
= MWRender::NpcAnimation::getBodyParts(Misc::StringUtils::lowerCase(race->mId), female, false, false);
= MWRender::NpcAnimation::getBodyParts(race->mId, female, false, false);
for (std::vector<const ESM::BodyPart*>::const_iterator it = parts.begin(); it != parts.end(); ++it)
{
const ESM::BodyPart* part = *it;
@ -545,7 +545,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
MWMechanics::CreatureStats& Npc::getCreatureStats(const MWWorld::Ptr& ptr) const
@ -687,7 +687,7 @@ namespace MWClass
{
damage *= store.find("fCombatCriticalStrikeMult")->mValue.getFloat();
MWBase::Environment::get().getWindowManager()->messageBox("#{sTargetCriticalStrike}");
MWBase::Environment::get().getSoundManager()->playSound3D(victim, "critical damage", 1.0f, 1.0f);
MWBase::Environment::get().getSoundManager()->playSound3D(victim, ESM::RefId::stringRefId("critical damage"), 1.0f, 1.0f);
}
}
@ -750,7 +750,7 @@ namespace MWClass
if (setOnPcHitMe && !attacker.isEmpty() && attacker == MWMechanics::getPlayer())
{
std::string_view script = getScript(ptr);
const ESM::RefId& script = getScript(ptr);
/* Set the OnPCHitMe script variable. The script is responsible for clearing it. */
if (!script.empty())
ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1);
@ -760,7 +760,7 @@ namespace MWClass
{
// Missed
if (!attacker.isEmpty() && attacker == MWMechanics::getPlayer())
sndMgr->playSound3D(ptr, "miss", 1.0f, 1.0f);
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("miss"), 1.0f, 1.0f);
return;
}
@ -789,7 +789,7 @@ namespace MWClass
int chance = store.get<ESM::GameSetting>().find("iVoiceHitOdds")->mValue.getInteger();
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
if (Misc::Rng::roll0to99(prng) < chance)
MWBase::Environment::get().getDialogueManager()->say(ptr, "hit");
MWBase::Environment::get().getDialogueManager()->say(ptr, ESM::RefId::stringRefId("hit"));
// Check for knockdown
float agilityTerm
@ -870,13 +870,13 @@ namespace MWClass
switch (armor.getClass().getEquipmentSkill(armor))
{
case ESM::Skill::LightArmor:
sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f);
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Light Armor Hit"), 1.0f, 1.0f);
break;
case ESM::Skill::MediumArmor:
sndMgr->playSound3D(ptr, "Medium Armor Hit", 1.0f, 1.0f);
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Medium Armor Hit"), 1.0f, 1.0f);
break;
case ESM::Skill::HeavyArmor:
sndMgr->playSound3D(ptr, "Heavy Armor Hit", 1.0f, 1.0f);
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Heavy Armor Hit"), 1.0f, 1.0f);
break;
}
}
@ -892,7 +892,7 @@ namespace MWClass
if (damage > 0.0f)
{
sndMgr->playSound3D(ptr, "Health Damage", 1.0f, 1.0f);
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Health Damage"), 1.0f, 1.0f);
if (ptr == MWMechanics::getPlayer())
MWBase::Environment::get().getWindowManager()->activateHitOverlay();
if (!attacker.isEmpty())
@ -933,7 +933,7 @@ namespace MWClass
{
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfNPC", prng);
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom(ESM::RefId::stringRefId("WolfNPC"), prng);
std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if (sound)
@ -994,7 +994,7 @@ namespace MWClass
return ptr.getRefData().getCustomData()->asNpcCustomData().mInventoryStore;
}
std::string_view Npc::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Npc::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>();
@ -1141,7 +1141,7 @@ namespace MWClass
}
if (fullHelp)
info.text = MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
info.text = MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
return info;
}
@ -1169,7 +1169,7 @@ namespace MWClass
{
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
MWMechanics::CastSpell cast(actor, actor);
const std::string& recordId = consumable.getCellRef().getRefId();
const ESM::RefId& recordId = consumable.getCellRef().getRefId();
MWBase::Environment::get().getLuaManager()->itemConsumed(consumable, actor);
actor.getClass().getContainerStore(actor).remove(consumable, 1, actor);
return cast.cast(recordId);
@ -1287,18 +1287,19 @@ namespace MWClass
return npc->mAiData.mServices;
}
std::string_view Npc::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
const ESM::RefId& Npc::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
{
std::string sound;
if (name == "left" || name == "right")
{
MWBase::World* world = MWBase::Environment::get().getWorld();
if (world->isFlying(ptr))
return {};
return ESM::RefId::sEmpty;
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
if (world->isSwimming(ptr))
return (name == "left") ? "Swim Left" : "Swim Right";
sound = (name == "left") ? "Swim Left" : "Swim Right";
if (world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr))
return (name == "left") ? "FootWaterLeft" : "FootWaterRight";
sound = (name == "left") ? "FootWaterLeft" : "FootWaterRight";
if (world->isOnGround(ptr))
{
if (getNpcStats(ptr).isWerewolf()
@ -1307,46 +1308,52 @@ namespace MWClass
int weaponType = ESM::Weapon::None;
MWMechanics::getActiveWeapon(ptr, &weaponType);
if (weaponType == ESM::Weapon::None)
return {};
return ESM::RefId::sEmpty;
}
const MWWorld::InventoryStore& inv = Npc::getInventoryStore(ptr);
MWWorld::ConstContainerStoreIterator boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots);
if (boots == inv.end() || boots->getType() != ESM::Armor::sRecordId)
return (name == "left") ? "FootBareLeft" : "FootBareRight";
sound = (name == "left") ? "FootBareLeft" : "FootBareRight";
switch (boots->getClass().getEquipmentSkill(*boots))
{
case ESM::Skill::LightArmor:
return (name == "left") ? "FootLightLeft" : "FootLightRight";
sound = (name == "left") ? "FootLightLeft" : "FootLightRight";
case ESM::Skill::MediumArmor:
return (name == "left") ? "FootMedLeft" : "FootMedRight";
sound = (name == "left") ? "FootMedLeft" : "FootMedRight";
case ESM::Skill::HeavyArmor:
return (name == "left") ? "FootHeavyLeft" : "FootHeavyRight";
sound = (name == "left") ? "FootHeavyLeft" : "FootHeavyRight";
}
}
return {};
return ESM::RefId::sEmpty;
}
// Morrowind ignores land soundgen for NPCs
if (name == "land")
return {};
return ESM::RefId::sEmpty;
if (name == "swimleft")
return "Swim Left";
sound = "Swim Left";
if (name == "swimright")
return "Swim Right";
sound = "Swim Right";
// TODO: I have no idea what these are supposed to do for NPCs since they use
// voiced dialog for various conditions like health loss and combat taunts. Maybe
// only for biped creatures?
if (name == "moan")
return {};
return ESM::RefId::sEmpty;
if (name == "roar")
return {};
return ESM::RefId::sEmpty;
if (name == "scream")
return {};
return ESM::RefId::sEmpty;
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
if(sound.empty())
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
else
{
static auto soundId = ESM::RefId::stringRefId(sound);
return soundId;
}
}
MWWorld::Ptr Npc::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const
@ -1428,7 +1435,7 @@ namespace MWClass
bool Npc::isClass(const MWWorld::ConstPtr& ptr, std::string_view className) const
{
return Misc::StringUtils::ciEqual(ptr.get<ESM::NPC>()->mBase->mClass, className);
return Misc::StringUtils::ciEqual(ptr.get<ESM::NPC>()->mBase->mClass.getRefIdString(), className);
}
bool Npc::canSwim(const MWWorld::ConstPtr& ptr) const
@ -1466,7 +1473,7 @@ namespace MWClass
if (ptr.getRefData().getCount() == 0)
{
ptr.getRefData().setCount(1);
std::string_view script = getScript(ptr);
const ESM::RefId& script = getScript(ptr);
if (!script.empty())
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr);
}
@ -1494,7 +1501,7 @@ namespace MWClass
return true;
}
std::string_view Npc::getPrimaryFaction(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Npc::getPrimaryFaction(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>();
return ref->mBase->mFaction;
@ -1502,7 +1509,7 @@ namespace MWClass
int Npc::getPrimaryFactionRank(const MWWorld::ConstPtr& ptr) const
{
std::string_view factionID = ptr.getClass().getPrimaryFaction(ptr);
const ESM::RefId& factionID = ptr.getClass().getPrimaryFaction(ptr);
if (factionID.empty())
return -1;
@ -1519,12 +1526,12 @@ namespace MWClass
return ref->mBase->getFactionRank();
}
void Npc::setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const
void Npc::setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const
{
MWMechanics::setBaseAISetting<ESM::NPC>(id, setting, value);
}
void Npc::modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const
void Npc::modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const
{
MWMechanics::modifyBaseInventory<ESM::NPC>(actorId, itemId, amount);
}

@ -91,7 +91,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
///< Generate action for activation
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
const ESM::RefId& getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
std::string getModel(const MWWorld::ConstPtr& ptr) const override;
@ -161,12 +161,12 @@ namespace MWClass
int getBaseFightRating(const MWWorld::ConstPtr& ptr) const override;
std::string_view getPrimaryFaction(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getPrimaryFaction(const MWWorld::ConstPtr& ptr) const override;
int getPrimaryFactionRank(const MWWorld::ConstPtr& ptr) const override;
void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const override;
void setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const override;
void modifyBaseInventory(std::string_view actorId, std::string_view itemId, int amount) const override;
void modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const override;
float getWalkSpeed(const MWWorld::Ptr& ptr) const override;

@ -48,7 +48,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Potion>* ref = ptr.get<ESM::Potion>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Potion::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -56,7 +56,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
std::string_view Potion::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Potion::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Potion>* ref = ptr.get<ESM::Potion>();
@ -70,14 +70,16 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Potion::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Potion::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Potion Up";
static const auto sound = ESM::RefId::stringRefId("Item Potion Up");
return sound;
}
std::string_view Potion::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Potion::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Potion Down";
static const auto sound = ESM::RefId::stringRefId("Item Potion Down");
return sound;
}
const std::string& Potion::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -114,7 +116,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;
@ -128,7 +130,7 @@ namespace MWClass
auto action = std::make_unique<MWWorld::ActionApply>(ptr, ref->mBase->mId);
action->setSound("Drink");
action->setSound(ESM::RefId::stringRefId("Drink"));
return action;
}

@ -27,7 +27,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo(const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
@ -36,10 +36,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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;

@ -48,14 +48,14 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Probe>* ref = ptr.get<ESM::Probe>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Probe::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
{
return defaultItemActivate(ptr, actor);
}
std::string_view Probe::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Probe::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Probe>* ref = ptr.get<ESM::Probe>();
@ -78,14 +78,16 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Probe::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Probe::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Probe Up";
static const ESM::RefId sound = ESM::RefId::stringRefId("Item Probe Up");
return sound;
}
std::string_view Probe::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Probe::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Probe Down";
static const ESM::RefId sound = ESM::RefId::stringRefId("Item Probe Down");
return sound;
}
const std::string& Probe::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -117,7 +119,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;

@ -27,7 +27,7 @@ namespace MWClass
MWGui::ToolTipInfo getToolTipInfo(const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override;
@ -37,10 +37,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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;

@ -46,7 +46,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Repair>* ref = ptr.get<ESM::Repair>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Repair::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -54,7 +54,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
std::string_view Repair::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Repair::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Repair>* ref = ptr.get<ESM::Repair>();
@ -68,14 +68,16 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Repair::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Repair::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Repair Up";
static auto val = ESM::RefId::stringRefId("Item Repair Up");
return val;
}
std::string_view Repair::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Repair::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
return "Item Repair Down";
static auto val = ESM::RefId::stringRefId("Item Repair Down");
return val;
}
const std::string& Repair::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
@ -119,7 +121,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;

@ -27,16 +27,16 @@ 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_view getScript(const MWWorld::ConstPtr& ptr) const override;
const 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;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;

@ -54,7 +54,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();
const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId;
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
}
std::unique_ptr<MWWorld::Action> Weapon::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
@ -77,7 +77,7 @@ namespace MWClass
return ref->mBase->mData.mHealth;
}
std::string_view Weapon::getScript(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Weapon::getScript(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();
@ -123,14 +123,14 @@ namespace MWClass
return ref->mBase->mData.mValue;
}
std::string_view Weapon::getUpSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Weapon::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();
int type = ref->mBase->mData.mType;
return MWMechanics::getWeaponType(type)->mSoundIdUp;
}
std::string_view Weapon::getDownSoundId(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Weapon::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();
int type = ref->mBase->mData.mType;
@ -243,7 +243,7 @@ namespace MWClass
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
}
info.text = text;
@ -251,15 +251,15 @@ namespace MWClass
return info;
}
std::string_view Weapon::getEnchantment(const MWWorld::ConstPtr& ptr) const
const ESM::RefId& Weapon::getEnchantment(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();
return ref->mBase->mEnchant;
}
const std::string& Weapon::applyEnchantment(
const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
const ESM::RefId& Weapon::applyEnchantment(
const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge, const std::string& newName) const
{
const MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();

@ -33,7 +33,7 @@ namespace MWClass
int getItemMaxHealth(const MWWorld::ConstPtr& ptr) const override;
///< Return item max health or throw an exception, if class does not have item health
std::string_view getScript(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getScript(const MWWorld::ConstPtr& ptr) const override;
///< Return name of the script attached to ptr
std::pair<std::vector<int>, bool> getEquipmentSlots(const MWWorld::ConstPtr& ptr) const override;
@ -47,19 +47,19 @@ 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_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the pick up sound Id
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
///< Return the put down sound Id
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;
///< Return name of inventory icon.
std::string_view getEnchantment(const MWWorld::ConstPtr& ptr) const override;
const ESM::RefId& getEnchantment(const MWWorld::ConstPtr& ptr) const override;
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
const std::string& applyEnchantment(const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge,
const ESM::RefId& applyEnchantment(const MWWorld::ConstPtr& ptr, const ESM::RefId& enchId, int enchCharge,
const std::string& newName) const override;
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.

@ -74,14 +74,14 @@ namespace MWDialogue
mPermanentDispositionChange = 0;
}
void DialogueManager::addTopic(std::string_view topic)
void DialogueManager::addTopic(const ESM::RefId& topic)
{
mKnownTopics.insert(Misc::StringUtils::lowerCase(topic));
mKnownTopics.insert(topic);
}
std::vector<std::string> DialogueManager::parseTopicIdsFromText(const std::string& text)
std::vector<ESM::RefId> DialogueManager::parseTopicIdsFromText(const std::string& text)
{
std::vector<std::string> topicIdList;
std::vector<ESM::RefId> topicIdList;
std::vector<HyperTextParser::Token> hypertext = HyperTextParser::parseHyperText(text);
@ -99,7 +99,7 @@ namespace MWDialogue
topicId = mTranslationDataStorage.topicStandardForm(topicId);
}
topicIdList.push_back(topicId);
topicIdList.push_back(ESM::RefId::stringRefId(topicId));
}
return topicIdList;
@ -204,7 +204,7 @@ namespace MWDialogue
Compiler::Locals locals;
std::string_view actorScript = actor.getClass().getScript(actor);
const ESM::RefId& actorScript = actor.getClass().getScript(actor);
if (!actorScript.empty())
{
@ -260,7 +260,7 @@ namespace MWDialogue
}
}
bool DialogueManager::inJournal(const std::string& topicId, const std::string& infoId) const
bool DialogueManager::inJournal(const ESM::RefId& topicId, const ESM::RefId& infoId) const
{
const MWDialogue::Topic* topicHistory = nullptr;
MWBase::Journal* journal = MWBase::Environment::get().getJournal();
@ -284,7 +284,7 @@ namespace MWDialogue
return false;
}
void DialogueManager::executeTopic(const std::string& topic, ResponseCallback* callback)
void DialogueManager::executeTopic(const ESM::RefId& topic, ResponseCallback* callback)
{
Filter filter(mActor, mChoice, mTalkedTo);
@ -297,26 +297,26 @@ namespace MWDialogue
if (info)
{
std::string title;
ESM::RefId title;
if (dialogue.mType == ESM::Dialogue::Persuasion)
{
// Determine GMST from dialogue topic. GMSTs are:
// sAdmireSuccess, sAdmireFail, sIntimidateSuccess, sIntimidateFail,
// sTauntSuccess, sTauntFail, sBribeSuccess, sBribeFail
std::string modifiedTopic = "s" + topic;
std::string modifiedTopic = "s" + topic.getRefIdString();
modifiedTopic.erase(std::remove(modifiedTopic.begin(), modifiedTopic.end(), ' '), modifiedTopic.end());
const MWWorld::Store<ESM::GameSetting>& gmsts
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
title = gmsts.find(modifiedTopic)->mValue.getString();
title = ESM::RefId::stringRefId(gmsts.find(modifiedTopic)->mValue.getString());
}
else
title = topic;
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor);
callback->addResponse(title, Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
callback->addResponse(title.getRefIdString(), Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
if (dialogue.mType == ESM::Dialogue::Topic)
{
@ -328,7 +328,7 @@ namespace MWDialogue
if (iter->mId == info->mId)
{
MWBase::Environment::get().getJournal()->addTopic(
Misc::StringUtils::lowerCase(topic), info->mId, mActor);
topic, info->mId, mActor);
break;
}
}
@ -342,7 +342,7 @@ namespace MWDialogue
}
}
const ESM::Dialogue* DialogueManager::searchDialogue(const std::string& id)
const ESM::Dialogue* DialogueManager::searchDialogue(const ESM::RefId& id)
{
return MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().search(id);
}
@ -367,7 +367,7 @@ namespace MWDialogue
if (dialog.mType == ESM::Dialogue::Topic)
{
const auto* answer = filter.search(dialog, true);
auto topicId = Misc::StringUtils::lowerCase(dialog.mId);
auto topicId = dialog.mId;
if (answer != nullptr)
{
@ -375,7 +375,7 @@ namespace MWDialogue
if (!inJournal(topicId, answer->mId))
{
// Does this dialogue contains some actor-specific answer?
if (Misc::StringUtils::ciEqual(answer->mActor, mActor.getCellRef().getRefId()))
if (ESM::RefId::ciEqual(answer->mActor, mActor.getCellRef().getRefId()))
topicFlags |= MWBase::DialogueManager::TopicType::Specific;
}
else
@ -416,7 +416,7 @@ namespace MWDialogue
{
// does the player know the topic?
if (mKnownTopics.count(topic))
keywordList.push_back(topic);
keywordList.push_back(topic.getRefIdString());
}
// sort again, because the previous sort was case-sensitive
@ -424,7 +424,7 @@ namespace MWDialogue
return keywordList;
}
int DialogueManager::getTopicFlag(const std::string& topicId) const
int DialogueManager::getTopicFlag(const ESM::RefId& topicId) const
{
auto known = mActorKnownTopics.find(topicId);
if (known != mActorKnownTopics.end())
@ -436,10 +436,10 @@ namespace MWDialogue
{
if (!mIsInChoice)
{
const ESM::Dialogue* dialogue = searchDialogue(keyword);
const ESM::Dialogue* dialogue = searchDialogue(ESM::RefId::stringRefId(keyword));
if (dialogue && dialogue->mType == ESM::Dialogue::Topic)
{
executeTopic(keyword, callback);
executeTopic(ESM::RefId::stringRefId(keyword), callback);
}
}
}
@ -502,7 +502,7 @@ namespace MWDialogue
if (iter->mId == info->mId)
{
MWBase::Environment::get().getJournal()->addTopic(
Misc::StringUtils::lowerCase(mLastTopic), info->mId, mActor);
mLastTopic, info->mId, mActor);
break;
}
}
@ -590,7 +590,7 @@ namespace MWDialogue
text = "Bribe";
}
executeTopic(text + (success ? " Success" : " Fail"), callback);
executeTopic(ESM::RefId::stringRefId(text + (success ? " Success" : " Fail")), callback);
}
void DialogueManager::applyBarterDispositionChange(int delta)
@ -612,7 +612,7 @@ namespace MWDialogue
const MWWorld::Store<ESM::Dialogue>& dialogues
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
const ESM::Dialogue& dialogue = *dialogues.find("Service Refusal");
const ESM::Dialogue& dialogue = *dialogues.find(ESM::RefId::stringRefId("Service Refusal"));
std::vector<const ESM::DialInfo*> infos = filter.list(dialogue, false, false, true);
if (!infos.empty())
@ -635,7 +635,7 @@ namespace MWDialogue
return false;
}
void DialogueManager::say(const MWWorld::Ptr& actor, const std::string& topic)
void DialogueManager::say(const MWWorld::Ptr& actor, const ESM::RefId& topic)
{
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
if (sndMgr->sayActive(actor))
@ -668,7 +668,7 @@ namespace MWDialogue
if (winMgr->getSubtitlesEnabled())
winMgr->messageBox(info->mResponse);
if (!info->mSound.empty())
sndMgr->say(actor, info->mSound);
sndMgr->say(actor, info->mSound.getRefIdString());
if (!info->mResultScript.empty())
executeScript(info->mResultScript, actor);
}
@ -702,7 +702,7 @@ namespace MWDialogue
ESM::DialogueState state;
state.load(reader);
for (std::vector<std::string>::const_iterator iter(state.mKnownTopics.begin());
for (std::vector<ESM::RefId>::const_iterator iter(state.mKnownTopics.begin());
iter != state.mKnownTopics.end(); ++iter)
if (store.get<ESM::Dialogue>().search(*iter))
mKnownTopics.insert(*iter);
@ -711,49 +711,40 @@ namespace MWDialogue
}
}
void DialogueManager::modFactionReaction(std::string_view faction1, std::string_view faction2, int diff)
void DialogueManager::modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff)
{
std::string fact1 = Misc::StringUtils::lowerCase(faction1);
std::string fact2 = Misc::StringUtils::lowerCase(faction2);
// Make sure the factions exist
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(fact1);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(fact2);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction1);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction2);
int newValue = getFactionReaction(faction1, faction2) + diff;
std::map<std::string, int>& map = mChangedFactionReaction[fact1];
map[fact2] = newValue;
auto& map = mChangedFactionReaction[faction1];
map[faction2] = newValue;
}
void DialogueManager::setFactionReaction(std::string_view faction1, std::string_view faction2, int absolute)
void DialogueManager::setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute)
{
std::string fact1 = Misc::StringUtils::lowerCase(faction1);
std::string fact2 = Misc::StringUtils::lowerCase(faction2);
// Make sure the factions exist
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(fact1);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(fact2);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction1);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction2);
std::map<std::string, int>& map = mChangedFactionReaction[fact1];
map[fact2] = absolute;
auto& map = mChangedFactionReaction[faction1];
map[faction2] = absolute;
}
int DialogueManager::getFactionReaction(std::string_view faction1, std::string_view faction2) const
int DialogueManager::getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const
{
std::string fact1 = Misc::StringUtils::lowerCase(faction1);
std::string fact2 = Misc::StringUtils::lowerCase(faction2);
ModFactionReactionMap::const_iterator map = mChangedFactionReaction.find(fact1);
if (map != mChangedFactionReaction.end() && map->second.find(fact2) != map->second.end())
return map->second.at(fact2);
ModFactionReactionMap::const_iterator map = mChangedFactionReaction.find(faction1);
if (map != mChangedFactionReaction.end() && map->second.find(faction2) != map->second.end())
return map->second.at(faction2);
const ESM::Faction* faction = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(fact1);
const ESM::Faction* faction = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction1);
std::map<std::string, int>::const_iterator it = faction->mReactions.begin();
auto it = faction->mReactions.begin();
for (; it != faction->mReactions.end(); ++it)
{
if (Misc::StringUtils::ciEqual(it->first, fact2))
if (ESM::RefId::ciEqual(it->first, faction2))
return it->second;
}
return 0;
@ -764,7 +755,7 @@ namespace MWDialogue
if (actor == mActor && !mLastTopic.empty())
{
MWBase::Environment::get().getJournal()->removeLastAddedTopicResponse(
Misc::StringUtils::lowerCase(mLastTopic), actor.getClass().getName(actor));
mLastTopic, actor.getClass().getName(actor));
}
}
}

@ -31,13 +31,13 @@ namespace MWDialogue
const ESM::DialInfo* mInfo;
};
std::set<std::string, Misc::StringUtils::CiComp> mKnownTopics; // Those are the topics the player knows.
std::set<ESM::RefId> mKnownTopics; // Those are the topics the player knows.
// Modified faction reactions. <Faction1, <Faction2, Difference> >
typedef std::map<std::string, std::map<std::string, int>> ModFactionReactionMap;
typedef std::map<ESM::RefId, std::map<ESM::RefId, int>> ModFactionReactionMap;
ModFactionReactionMap mChangedFactionReaction;
std::map<std::string, ActorKnownTopicInfo, Misc::StringUtils::CiComp> mActorKnownTopics;
std::map<ESM::RefId, ActorKnownTopicInfo> mActorKnownTopics;
Translation::Storage& mTranslationDataStorage;
MWScript::CompilerContext mCompilerContext;
@ -47,7 +47,7 @@ namespace MWDialogue
bool mTalkedTo;
int mChoice;
std::string mLastTopic; // last topic ID, lowercase
ESM::RefId mLastTopic; // last topic ID, lowercase
bool mIsInChoice;
bool mGoodbye;
@ -57,7 +57,7 @@ namespace MWDialogue
int mCurrentDisposition;
int mPermanentDispositionChange;
std::vector<std::string> parseTopicIdsFromText(const std::string& text);
std::vector<ESM::RefId> parseTopicIdsFromText(const std::string& text);
void addTopicsFromText(const std::string& text);
void updateActorKnownTopics();
@ -66,9 +66,9 @@ namespace MWDialogue
bool compile(const std::string& cmd, std::vector<Interpreter::Type_Code>& code, const MWWorld::Ptr& actor);
void executeScript(const std::string& script, const MWWorld::Ptr& actor);
void executeTopic(const std::string& topic, ResponseCallback* callback);
void executeTopic(const ESM::RefId& topic, ResponseCallback* callback);
const ESM::Dialogue* searchDialogue(const std::string& id);
const ESM::Dialogue* searchDialogue(const ESM::RefId& id);
void updateOriginalDisposition();
@ -82,11 +82,11 @@ namespace MWDialogue
bool startDialogue(const MWWorld::Ptr& actor, ResponseCallback* callback) override;
std::list<std::string> getAvailableTopics() override;
int getTopicFlag(const std::string& topicId) const override;
int getTopicFlag(const ESM::RefId& topicId) const override;
bool inJournal(const std::string& topicId, const std::string& infoId) const override;
bool inJournal(const ESM::RefId& topicId, const ESM::RefId& infoId) const override;
void addTopic(std::string_view topic) override;
void addTopic(const ESM::RefId& topic) override;
void addChoice(std::string_view text, int choice) override;
const std::vector<std::pair<std::string, int>>& getChoices() const override;
@ -97,7 +97,7 @@ namespace MWDialogue
bool checkServiceRefused(ResponseCallback* callback, ServiceType service = ServiceType::Any) override;
void say(const MWWorld::Ptr& actor, const std::string& topic) override;
void say(const MWWorld::Ptr& actor, const ESM::RefId& topic) override;
// calbacks for the GUI
void keywordSelected(const std::string& keyword, ResponseCallback* callback) override;
@ -116,12 +116,12 @@ namespace MWDialogue
void readRecord(ESM::ESMReader& reader, uint32_t type) override;
/// Changes faction1's opinion of faction2 by \a diff.
void modFactionReaction(std::string_view faction1, std::string_view faction2, int diff) override;
void modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff) override;
void setFactionReaction(std::string_view faction1, std::string_view faction2, int absolute) override;
void setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute) override;
/// @return faction1's opinion of faction2
int getFactionReaction(std::string_view faction1, std::string_view faction2) const override;
int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const override;
/// Removes the last added topic response for the given actor from the journal
void clearInfoActor(const MWWorld::Ptr& actor) const override;

@ -4,6 +4,7 @@
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadfact.hpp>
#include <components/esm3/loadmgef.hpp>
#include <components/esm/refid.hpp>
#include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/environment.hpp"
@ -83,7 +84,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const
// actor id
if (!info.mActor.empty())
{
if (!Misc::StringUtils::ciEqual(info.mActor, mActor.getCellRef().getRefId()))
if (!ESM::RefId::ciEqual(info.mActor, mActor.getCellRef().getRefId()))
return false;
}
else if (isCreature)
@ -100,7 +101,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const
MWWorld::LiveCellRef<ESM::NPC>* cellRef = mActor.get<ESM::NPC>();
if (!Misc::StringUtils::ciEqual(info.mRace, cellRef->mBase->mRace))
if (!ESM::RefId::ciEqual(info.mRace, cellRef->mBase->mRace))
return false;
}
@ -112,7 +113,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const
MWWorld::LiveCellRef<ESM::NPC>* cellRef = mActor.get<ESM::NPC>();
if (!Misc::StringUtils::ciEqual(info.mClass, cellRef->mBase->mClass))
if (!ESM::RefId::ciEqual(info.mClass, cellRef->mBase->mClass))
return false;
}
@ -130,7 +131,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const
if (isCreature)
return true;
if (!Misc::StringUtils::ciEqual(mActor.getClass().getPrimaryFaction(mActor), info.mFaction))
if (!ESM::RefId::ciEqual(mActor.getClass().getPrimaryFaction(mActor), info.mFaction))
return false;
// check rank
@ -167,8 +168,8 @@ bool MWDialogue::Filter::testPlayer(const ESM::DialInfo& info) const
// check player faction and rank
if (!info.mPcFaction.empty())
{
std::map<std::string, int>::const_iterator iter
= stats.getFactionRanks().find(Misc::StringUtils::lowerCase(info.mPcFaction));
std::map<ESM::RefId, int>::const_iterator iter
= stats.getFactionRanks().find(info.mPcFaction);
if (iter == stats.getFactionRanks().end())
return false;
@ -180,8 +181,8 @@ bool MWDialogue::Filter::testPlayer(const ESM::DialInfo& info) const
else if (info.mData.mPCrank != -1)
{
// required PC faction is not specified but PC rank is; use speaker's faction
std::map<std::string, int>::const_iterator iter
= stats.getFactionRanks().find(Misc::StringUtils::lowerCase(mActor.getClass().getPrimaryFaction(mActor)));
std::map<ESM::RefId, int>::const_iterator iter
= stats.getFactionRanks().find(mActor.getClass().getPrimaryFaction(mActor));
if (iter == stats.getFactionRanks().end())
return false;
@ -228,7 +229,7 @@ bool MWDialogue::Filter::testDisposition(const ESM::DialInfo& info, bool invert)
bool MWDialogue::Filter::testFunctionLocal(const MWDialogue::SelectWrapper& select) const
{
std::string_view scriptName = mActor.getClass().getScript(mActor);
const ESM::RefId& scriptName = mActor.getClass().getScript(mActor);
if (scriptName.empty())
return false; // no script
@ -354,18 +355,18 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
{
case SelectWrapper::Function_Journal:
return MWBase::Environment::get().getJournal()->getJournalIndex(select.getName());
return MWBase::Environment::get().getJournal()->getJournalIndex(ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_Item:
{
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
return store.count(select.getName());
return store.count(ESM::RefId::stringRefId(select.getName()));
}
case SelectWrapper::Function_Dead:
return MWBase::Environment::get().getMechanicsManager()->countDeaths(select.getName());
return MWBase::Environment::get().getMechanicsManager()->countDeaths(ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_Choice:
@ -424,7 +425,7 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
case SelectWrapper::Function_RankRequirement:
{
std::string_view faction = mActor.getClass().getPrimaryFaction(mActor);
const ESM::RefId& faction = mActor.getClass().getPrimaryFaction(mActor);
if (faction.empty())
return 0;
@ -462,7 +463,7 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
case SelectWrapper::Function_FactionRankDiff:
{
std::string_view faction = mActor.getClass().getPrimaryFaction(mActor);
const ESM::RefId& faction = mActor.getClass().getPrimaryFaction(mActor);
if (faction.empty())
return 0;
@ -481,7 +482,7 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
{
bool low = select.getFunction() == SelectWrapper::Function_RankLow;
std::string_view factionId = mActor.getClass().getPrimaryFaction(mActor);
const ESM::RefId& factionId = mActor.getClass().getPrimaryFaction(mActor);
if (factionId.empty())
return 0;
@ -490,7 +491,7 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats(player);
std::map<std::string, int>::const_iterator playerFactionIt = playerStats.getFactionRanks().begin();
std::map<ESM::RefId, int>::const_iterator playerFactionIt = playerStats.getFactionRanks().begin();
for (; playerFactionIt != playerStats.getFactionRanks().end(); ++playerFactionIt)
{
int reaction = MWBase::Environment::get().getDialogueManager()->getFactionReaction(
@ -535,19 +536,19 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
case SelectWrapper::Function_NotId:
return !Misc::StringUtils::ciEqual(mActor.getCellRef().getRefId(), select.getName());
return !ESM::RefId::ciEqual(mActor.getCellRef().getRefId(), ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_NotFaction:
return !Misc::StringUtils::ciEqual(mActor.getClass().getPrimaryFaction(mActor), select.getName());
return !ESM::RefId::ciEqual(mActor.getClass().getPrimaryFaction(mActor), ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_NotClass:
return !Misc::StringUtils::ciEqual(mActor.get<ESM::NPC>()->mBase->mClass, select.getName());
return !ESM::RefId::ciEqual(mActor.get<ESM::NPC>()->mBase->mClass, ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_NotRace:
return !Misc::StringUtils::ciEqual(mActor.get<ESM::NPC>()->mBase->mRace, select.getName());
return !ESM::RefId::ciEqual(mActor.get<ESM::NPC>()->mBase->mRace, ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_NotCell:
{
@ -561,7 +562,7 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
case SelectWrapper::Function_SameRace:
return Misc::StringUtils::ciEqual(
return ESM::RefId::ciEqual(
mActor.get<ESM::NPC>()->mBase->mRace, player.get<ESM::NPC>()->mBase->mRace);
case SelectWrapper::Function_SameFaction:
@ -587,7 +588,7 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
case SelectWrapper::Function_PcExpelled:
{
std::string_view faction = mActor.getClass().getPrimaryFaction(mActor);
const ESM::RefId& faction = mActor.getClass().getPrimaryFaction(mActor);
if (faction.empty())
return false;
@ -634,14 +635,14 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
}
}
int MWDialogue::Filter::getFactionRank(const MWWorld::Ptr& actor, std::string_view factionId) const
int MWDialogue::Filter::getFactionRank(const MWWorld::Ptr& actor, const ESM::RefId& factionId) const
{
MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor);
return stats.getFactionRank(factionId);
}
bool MWDialogue::Filter::hasFactionRankSkillRequirements(
const MWWorld::Ptr& actor, std::string_view factionId, int rank) const
const MWWorld::Ptr& actor, const ESM::RefId& factionId, int rank) const
{
if (rank < 0 || rank >= 10)
throw std::runtime_error("rank index out of range");
@ -659,7 +660,7 @@ bool MWDialogue::Filter::hasFactionRankSkillRequirements(
}
bool MWDialogue::Filter::hasFactionRankReputationRequirements(
const MWWorld::Ptr& actor, std::string_view factionId, int rank) const
const MWWorld::Ptr& actor, const ESM::RefId& factionId, int rank) const
{
if (rank < 0 || rank >= 10)
throw std::runtime_error("rank index out of range");
@ -726,7 +727,7 @@ std::vector<const ESM::DialInfo*> MWDialogue::Filter::list(
const MWWorld::Store<ESM::Dialogue>& dialogues
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
const ESM::Dialogue& infoRefusalDialogue = *dialogues.find("Info Refusal");
const ESM::Dialogue& infoRefusalDialogue = *dialogues.find(ESM::RefId::stringRefId("Info Refusal"));
for (ESM::Dialogue::InfoContainer::const_iterator iter = infoRefusalDialogue.mInfo.begin();
iter != infoRefusalDialogue.mInfo.end(); ++iter)

@ -9,6 +9,7 @@ namespace ESM
{
struct DialInfo;
struct Dialogue;
struct RefId;
}
namespace MWDialogue
@ -43,12 +44,12 @@ namespace MWDialogue
bool getSelectStructBoolean(const SelectWrapper& select) const;
int getFactionRank(const MWWorld::Ptr& actor, std::string_view factionId) const;
int getFactionRank(const MWWorld::Ptr& actor, const ESM::RefId& factionId) const;
bool hasFactionRankSkillRequirements(const MWWorld::Ptr& actor, std::string_view factionId, int rank) const;
bool hasFactionRankSkillRequirements(const MWWorld::Ptr& actor, const ESM::RefId& factionId, int rank) const;
bool hasFactionRankReputationRequirements(
const MWWorld::Ptr& actor, std::string_view factionId, int rank) const;
const MWWorld::Ptr& actor,const ESM::RefId& factionId, int rank) const;
public:
Filter(const MWWorld::Ptr& actor, int choice, bool talkedToPlayer);

@ -15,7 +15,7 @@
namespace MWDialogue
{
Entry::Entry(std::string_view topic, std::string_view infoId, const MWWorld::Ptr& actor)
Entry::Entry(const ESM::RefId& topic, const ESM::RefId& infoId, const MWWorld::Ptr& actor)
: mInfoId(infoId)
{
const ESM::Dialogue* dialogue
@ -39,7 +39,7 @@ namespace MWDialogue
return;
}
throw std::runtime_error("unknown info ID " + mInfoId + " for topic " + std::string(topic));
throw std::runtime_error("unknown info ID " + mInfoId.getRefIdString() + " for topic " + topic.getRefIdString());
}
Entry::Entry(const ESM::JournalEntry& record)
@ -61,7 +61,7 @@ namespace MWDialogue
entry.mActorName = mActorName;
}
JournalEntry::JournalEntry(std::string_view topic, std::string_view infoId, const MWWorld::Ptr& actor)
JournalEntry::JournalEntry(const ESM::RefId& topic, const ESM::RefId& infoId, const MWWorld::Ptr& actor)
: Entry(topic, infoId, actor)
, mTopic(topic)
{
@ -79,12 +79,12 @@ namespace MWDialogue
entry.mTopic = mTopic;
}
JournalEntry JournalEntry::makeFromQuest(std::string_view topic, int index)
JournalEntry JournalEntry::makeFromQuest(const ESM::RefId& topic, int index)
{
return JournalEntry(topic, idFromIndex(topic, index), MWWorld::Ptr());
}
std::string_view JournalEntry::idFromIndex(std::string_view topic, int index)
const ESM::RefId& JournalEntry::idFromIndex(const ESM::RefId& topic, int index)
{
const ESM::Dialogue* dialogue
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic);
@ -96,7 +96,7 @@ namespace MWDialogue
return iter->mId;
}
throw std::runtime_error("unknown journal index for topic " + std::string(topic));
throw std::runtime_error("unknown journal index for topic " + topic.getRefIdString());
}
StampedJournalEntry::StampedJournalEntry()
@ -107,7 +107,7 @@ namespace MWDialogue
}
StampedJournalEntry::StampedJournalEntry(
std::string_view topic, std::string_view infoId, int day, int month, int dayOfMonth, const MWWorld::Ptr& actor)
const ESM::RefId& topic, const ESM::RefId& infoId, int day, int month, int dayOfMonth, const MWWorld::Ptr& actor)
: JournalEntry(topic, infoId, actor)
, mDay(day)
, mMonth(month)
@ -131,7 +131,7 @@ namespace MWDialogue
entry.mDayOfMonth = mDayOfMonth;
}
StampedJournalEntry StampedJournalEntry::makeFromQuest(std::string_view topic, int index, const MWWorld::Ptr& actor)
StampedJournalEntry StampedJournalEntry::makeFromQuest(const ESM::RefId& topic, int index, const MWWorld::Ptr& actor)
{
int day = MWBase::Environment::get().getWorld()->getGlobalInt("dayspassed");
int month = MWBase::Environment::get().getWorld()->getGlobalInt("month");

@ -3,6 +3,7 @@
#include <string>
#include <string_view>
#include <components/esm/refid.hpp>
namespace ESM
{
@ -19,14 +20,14 @@ namespace MWDialogue
/// \brief Basic quest/dialogue/topic entry
struct Entry
{
std::string mInfoId;
ESM::RefId mInfoId;
std::string mText;
std::string mActorName; // optional
Entry() = default;
/// actor is optional
Entry(std::string_view topic, std::string_view infoId, const MWWorld::Ptr& actor);
Entry(const ESM::RefId& topic, const ESM::RefId& infoId, const MWWorld::Ptr& actor);
Entry(const ESM::JournalEntry& record);
@ -40,19 +41,19 @@ namespace MWDialogue
/// Same as entry, but store TopicID
struct JournalEntry : public Entry
{
std::string mTopic;
ESM::RefId mTopic;
JournalEntry() = default;
JournalEntry(std::string_view topic, std::string_view infoId, const MWWorld::Ptr& actor);
JournalEntry(const ESM::RefId& topic, const ESM::RefId& infoId, const MWWorld::Ptr& actor);
JournalEntry(const ESM::JournalEntry& record);
void write(ESM::JournalEntry& entry) const;
static JournalEntry makeFromQuest(std::string_view topic, int index);
static JournalEntry makeFromQuest(const ESM::RefId& topic, int index);
static std::string_view idFromIndex(std::string_view topic, int index);
static const ESM::RefId& idFromIndex(const ESM::RefId& topic, int index);
};
/// \brief A quest entry with a timestamp.
@ -64,14 +65,14 @@ namespace MWDialogue
StampedJournalEntry();
StampedJournalEntry(std::string_view topic, std::string_view infoId, int day, int month, int dayOfMonth,
StampedJournalEntry(const ESM::RefId& topic, const ESM::RefId& infoId, int day, int month, int dayOfMonth,
const MWWorld::Ptr& actor);
StampedJournalEntry(const ESM::JournalEntry& record);
void write(ESM::JournalEntry& entry) const;
static StampedJournalEntry makeFromQuest(std::string_view topic, int index, const MWWorld::Ptr& actor);
static StampedJournalEntry makeFromQuest(const ESM::RefId& topic, int index, const MWWorld::Ptr& actor);
};
}

@ -18,7 +18,7 @@
namespace MWDialogue
{
Quest& Journal::getQuest(const std::string& id)
Quest& Journal::getQuest(const ESM::RefId& id)
{
TQuestContainer::iterator iter = mQuests.find(id);
@ -32,7 +32,7 @@ namespace MWDialogue
return iter->second;
}
Topic& Journal::getTopic(const std::string& id)
Topic& Journal::getTopic(const ESM::RefId& id)
{
TTopicContainer::iterator iter = mTopics.find(id);
@ -46,7 +46,7 @@ namespace MWDialogue
return iter->second;
}
bool Journal::isThere(const std::string& topicId, const std::string& infoId) const
bool Journal::isThere(const ESM::RefId& topicId, const ESM::RefId& infoId) const
{
if (const ESM::Dialogue* dialogue
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().search(topicId))
@ -72,10 +72,10 @@ namespace MWDialogue
mTopics.clear();
}
void Journal::addEntry(const std::string& id, int index, const MWWorld::Ptr& actor)
void Journal::addEntry(const ESM::RefId& id, int index, const MWWorld::Ptr& actor)
{
// bail out if we already have heard this...
std::string_view infoId = JournalEntry::idFromIndex(id, index);
const ESM::RefId& infoId = JournalEntry::idFromIndex(id, index);
for (TEntryIter i = mJournal.begin(); i != mJournal.end(); ++i)
if (i->mTopic == id && i->mInfoId == infoId)
{
@ -109,14 +109,14 @@ namespace MWDialogue
}
}
void Journal::setJournalIndex(const std::string& id, int index)
void Journal::setJournalIndex(const ESM::RefId& id, int index)
{
Quest& quest = getQuest(id);
quest.setIndex(index);
}
void Journal::addTopic(const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor)
void Journal::addTopic(const ESM::RefId& topicId, const ESM::RefId& infoId, const MWWorld::Ptr& actor)
{
Topic& topic = getTopic(topicId);
@ -125,7 +125,7 @@ namespace MWDialogue
topic.addEntry(entry);
}
void Journal::removeLastAddedTopicResponse(const std::string& topicId, std::string_view actorName)
void Journal::removeLastAddedTopicResponse(const ESM::RefId& topicId, std::string_view actorName)
{
Topic& topic = getTopic(topicId);
@ -135,7 +135,7 @@ namespace MWDialogue
mTopics.erase(mTopics.find(topicId)); // All responses removed -> remove topic
}
int Journal::getJournalIndex(const std::string& id) const
int Journal::getJournalIndex(const ESM::RefId& id) const
{
TQuestContainer::const_iterator iter = mQuests.find(id);

@ -15,31 +15,31 @@ namespace MWDialogue
TTopicContainer mTopics;
private:
Quest& getQuest(const std::string& id);
Quest& getQuest(const ESM::RefId& id);
Topic& getTopic(const std::string& id);
Topic& getTopic(const ESM::RefId& id);
bool isThere(const std::string& topicId, const std::string& infoId = "") const;
bool isThere(const ESM::RefId& topicId, const ESM::RefId& infoId = ESM::RefId::sEmpty) const;
public:
Journal();
void clear() override;
void addEntry(const std::string& id, int index, const MWWorld::Ptr& actor) override;
void addEntry(const ESM::RefId& id, int index, const MWWorld::Ptr& actor) override;
///< Add a journal entry.
/// @param actor Used as context for replacing of escape sequences (%name, etc).
void setJournalIndex(const std::string& id, int index) override;
void setJournalIndex(const ESM::RefId& id, int index) override;
///< Set the journal index without adding an entry.
int getJournalIndex(const std::string& id) const override;
int getJournalIndex(const ESM::RefId& id) const override;
///< Get the journal index.
void addTopic(const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor) override;
void addTopic(const ESM::RefId& topicId, const ESM::RefId& infoId, const MWWorld::Ptr& actor) override;
/// \note topicId must be lowercase
void removeLastAddedTopicResponse(const std::string& topicId, std::string_view actorName) override;
void removeLastAddedTopicResponse(const ESM::RefId& topicId, std::string_view actorName) override;
///< Removes the last topic response added for the given topicId and actor name.
/// \note topicId must be lowercase

@ -18,7 +18,7 @@ namespace MWDialogue
{
}
Quest::Quest(const std::string& topic)
Quest::Quest(const ESM::RefId& topic)
: Topic(topic)
, mIndex(0)
, mFinished(false)
@ -75,7 +75,7 @@ namespace MWDialogue
[&](const auto& info) { return info.mId == entry.mInfoId; });
if (info == dialogue->mInfo.end() || info->mData.mJournalIndex == -1)
throw std::runtime_error("unknown journal entry for topic " + mTopic);
throw std::runtime_error("unknown journal entry for topic " + mTopic.getRefIdString());
if (info->mQuestStatus == ESM::DialInfo::QS_Finished || info->mQuestStatus == ESM::DialInfo::QS_Restart)
mFinished = info->mQuestStatus == ESM::DialInfo::QS_Finished;

@ -19,7 +19,7 @@ namespace MWDialogue
public:
Quest();
Quest(const std::string& topic);
Quest(const ESM::RefId& topic);
Quest(const ESM::QuestState& state);

@ -42,7 +42,7 @@ namespace
Compiler::Locals locals;
std::string_view actorScript = actor.getClass().getScript(actor);
const ESM::RefId& actorScript = actor.getClass().getScript(actor);
if (!actorScript.empty())
{
// grab local variables from actor's script, if available.

@ -9,9 +9,9 @@ namespace MWDialogue
{
Topic::Topic() {}
Topic::Topic(const std::string& topic)
Topic::Topic(const ESM::RefId& topic)
: mTopic(topic)
, mName(MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic)->mId)
, mName(MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic)->mId.getRefIdString())
{
}
@ -20,7 +20,7 @@ namespace MWDialogue
bool Topic::addEntry(const JournalEntry& entry)
{
if (entry.mTopic != mTopic)
throw std::runtime_error("topic does not match: " + mTopic);
throw std::runtime_error("topic does not match: " + mTopic.getRefIdString());
// bail out if we already have heard this
for (Topic::TEntryIter it = mEntries.begin(); it != mEntries.end(); ++it)
@ -38,7 +38,7 @@ namespace MWDialogue
mEntries.push_back(entry);
}
std::string Topic::getTopic() const
ESM::RefId Topic::getTopic() const
{
return mTopic;
}

@ -22,14 +22,14 @@ namespace MWDialogue
typedef TEntryContainer::const_iterator TEntryIter;
protected:
std::string mTopic;
ESM::RefId mTopic;
std::string mName;
TEntryContainer mEntries;
public:
Topic();
Topic(const std::string& topic);
Topic(const ESM::RefId& topic);
virtual ~Topic();
@ -42,7 +42,7 @@ namespace MWDialogue
///< Add entry without checking for redundant entries or modifying the state of the
/// topic otherwise
std::string getTopic() const;
ESM::RefId getTopic() const;
virtual std::string_view getName() const;

@ -126,7 +126,7 @@ namespace MWGui
winMgr->messageBox("#{sNotifyMessage6a}");
break;
case MWMechanics::Alchemy::Result_Success:
winMgr->playSound("potion success");
winMgr->playSound(ESM::RefId::stringRefId("potion success"));
if (count == 1)
winMgr->messageBox("#{sPotionSuccess}");
else
@ -136,7 +136,7 @@ namespace MWGui
case MWMechanics::Alchemy::Result_NoEffects:
case MWMechanics::Alchemy::Result_RandomFailure:
winMgr->messageBox("#{sNotifyMessage8}");
winMgr->playSound("potion fail");
winMgr->playSound(ESM::RefId::stringRefId("potion fail"));
break;
}
@ -301,7 +301,7 @@ namespace MWGui
{
update();
std::string_view sound = item.getClass().getUpSoundId(item);
const ESM::RefId& sound = item.getClass().getUpSoundId(item);
MWBase::Environment::get().getWindowManager()->playSound(sound);
}
}

@ -23,8 +23,8 @@
namespace
{
bool sortBirthSigns(const std::pair<std::string, const ESM::BirthSign*>& left,
const std::pair<std::string, const ESM::BirthSign*>& right)
bool sortBirthSigns(const std::pair<ESM::RefId, const ESM::BirthSign*>& left,
const std::pair<ESM::RefId, const ESM::BirthSign*>& right)
{
return left.second->mName.compare(right.second->mName) < 0;
}
@ -83,20 +83,20 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mBirthList);
// Show the current birthsign by default
const std::string& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
const auto& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
if (!signId.empty())
setBirthId(signId);
}
void BirthDialog::setBirthId(const std::string& birthId)
void BirthDialog::setBirthId(const ESM::RefId& birthId)
{
mCurrentBirthId = birthId;
mBirthList->setIndexSelected(MyGUI::ITEM_NONE);
size_t count = mBirthList->getItemCount();
for (size_t i = 0; i < count; ++i)
{
if (Misc::StringUtils::ciEqual(*mBirthList->getItemDataAt<std::string>(i), birthId))
if (ESM::RefId::ciEqual(ESM::RefId::stringRefId(*mBirthList->getItemDataAt<std::string>(i)), birthId))
{
mBirthList->setIndexSelected(i);
break;
@ -133,11 +133,11 @@ namespace MWGui
if (_index == MyGUI::ITEM_NONE)
return;
const std::string* birthId = mBirthList->getItemDataAt<std::string>(_index);
if (Misc::StringUtils::ciEqual(mCurrentBirthId, *birthId))
const ESM::RefId birthId = ESM::RefId::stringRefId(*mBirthList->getItemDataAt<std::string>(_index));
if (ESM::RefId::ciEqual(mCurrentBirthId, birthId))
return;
mCurrentBirthId = *birthId;
mCurrentBirthId = birthId;
updateSpells();
}
@ -151,7 +151,7 @@ namespace MWGui
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>();
// sort by name
std::vector<std::pair<std::string, const ESM::BirthSign*>> birthSigns;
std::vector<std::pair<ESM::RefId, const ESM::BirthSign*>> birthSigns;
for (const ESM::BirthSign& sign : signs)
{
@ -168,7 +168,7 @@ namespace MWGui
mBirthList->setIndexSelected(index);
mCurrentBirthId = birthsignPair.first;
}
else if (Misc::StringUtils::ciEqual(birthsignPair.first, mCurrentBirthId))
else if (ESM::RefId::ciEqual(birthsignPair.first, mCurrentBirthId))
{
mBirthList->setIndexSelected(index);
}
@ -199,13 +199,13 @@ namespace MWGui
mBirthImage->setImageTexture(Misc::ResourceHelpers::correctTexturePath(
birth->mTexture, MWBase::Environment::get().getResourceSystem()->getVFS()));
std::vector<std::string> abilities, powers, spells;
std::vector<ESM::RefId> abilities, powers, spells;
std::vector<std::string>::const_iterator it = birth->mPowers.mList.begin();
std::vector<std::string>::const_iterator end = birth->mPowers.mList.end();
std::vector<ESM::RefId>::const_iterator it = birth->mPowers.mList.begin();
std::vector<ESM::RefId>::const_iterator end = birth->mPowers.mList.end();
for (; it != end; ++it)
{
const std::string& spellId = *it;
const ESM::RefId& spellId = *it;
const ESM::Spell* spell = store.get<ESM::Spell>().search(spellId);
if (!spell)
continue; // Skip spells which cannot be found
@ -225,7 +225,7 @@ namespace MWGui
struct
{
const std::vector<std::string>& spells;
const std::vector<ESM::RefId>& spells;
const char* label;
} categories[3] = { { abilities, "sBirthsignmenu1" }, { powers, "sPowers" }, { spells, "sBirthsignmenu2" } };
@ -243,7 +243,7 @@ namespace MWGui
end = categories[category].spells.end();
for (it = categories[category].spells.begin(); it != end; ++it)
{
const std::string& spellId = *it;
const ESM::RefId& spellId = *it;
spellWidget = mSpellArea->createWidget<Widgets::MWSpell>("MW_StatName", coord,
MyGUI::Align::Default, std::string("Spell") + MyGUI::utility::toString(i));
spellWidget->setSpellId(spellId);

@ -2,6 +2,7 @@
#define MWGUI_BIRTH_H
#include "windowbase.hpp"
#include <components/esm/refid.hpp>
namespace MWGui
{
@ -16,8 +17,8 @@ namespace MWGui
GM_Female
};
const std::string& getBirthId() const { return mCurrentBirthId; }
void setBirthId(const std::string& raceId);
const ESM::RefId& getBirthId() const { return mCurrentBirthId; }
void setBirthId(const ESM::RefId& raceId);
void setNextButtonShow(bool shown);
void onOpen() override;
@ -53,7 +54,7 @@ namespace MWGui
MyGUI::ImageBox* mBirthImage;
std::vector<MyGUI::Widget*> mSpellItems;
std::string mCurrentBirthId;
ESM::RefId mCurrentBirthId;
};
}
#endif

@ -131,7 +131,7 @@ namespace MWGui
void BookWindow::onTakeButtonClicked(MyGUI::Widget* sender)
{
MWBase::Environment::get().getWindowManager()->playSound("Item Book Up");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Item Book Up"));
MWWorld::ActionTake take(mBook);
take.execute(MWMechanics::getPlayer());
@ -191,7 +191,7 @@ namespace MWGui
{
if ((mCurrentPage + 1) * 2 < mPages.size())
{
MWBase::Environment::get().getWindowManager()->playSound("book page2");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page2"));
++mCurrentPage;
@ -202,7 +202,7 @@ namespace MWGui
{
if (mCurrentPage > 0)
{
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
--mCurrentPage;

@ -101,7 +101,7 @@ namespace MWGui
mPlayerSkillValues.emplace(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue());
}
void CharacterCreation::setValue(const std::string& id, const MWMechanics::AttributeValue& value)
void CharacterCreation::setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value)
{
static const char* ids[] = {
"AttribVal1",
@ -117,7 +117,7 @@ namespace MWGui
for (int i = 0; ids[i]; ++i)
{
if (ids[i] == id)
if (ids[i] == id.getRefIdString())
{
mPlayerAttributes[static_cast<ESM::Attribute::AttributeID>(i)] = value;
if (mReviewDialog)
@ -128,19 +128,19 @@ namespace MWGui
}
}
void CharacterCreation::setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value)
void CharacterCreation::setValue(const ESM::RefId& id, const MWMechanics::DynamicStat<float>& value)
{
if (mReviewDialog)
{
if (id == "HBar")
if (id.getRefIdString() == "HBar")
{
mReviewDialog->setHealth(value);
}
else if (id == "MBar")
else if (id.getRefIdString() == "MBar")
{
mReviewDialog->setMagicka(value);
}
else if (id == "FBar")
else if (id.getRefIdString() == "FBar")
{
mReviewDialog->setFatigue(value);
}
@ -349,7 +349,7 @@ namespace MWGui
{
if (mPickClassDialog)
{
const std::string& classId = mPickClassDialog->getClassId();
const ESM::RefId& classId = mPickClassDialog->getClassId();
if (!classId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
@ -551,96 +551,96 @@ namespace MWGui
unsigned combat = mGenerateClassSpecializations[0];
unsigned magic = mGenerateClassSpecializations[1];
unsigned stealth = mGenerateClassSpecializations[2];
std::string className;
if (combat > 7)
{
mGenerateClass = "Warrior";
className = "Warrior";
}
else if (magic > 7)
{
mGenerateClass = "Mage";
className = "Mage";
}
else if (stealth > 7)
{
mGenerateClass = "Thief";
className = "Thief";
}
else
{
switch (combat)
{
case 4:
mGenerateClass = "Rogue";
className = "Rogue";
break;
case 5:
if (stealth == 3)
mGenerateClass = "Scout";
className = "Scout";
else
mGenerateClass = "Archer";
className = "Archer";
break;
case 6:
if (stealth == 1)
mGenerateClass = "Barbarian";
className = "Barbarian";
else if (stealth == 3)
mGenerateClass = "Crusader";
className = "Crusader";
else
mGenerateClass = "Knight";
className = "Knight";
break;
case 7:
mGenerateClass = "Warrior";
className = "Warrior";
break;
default:
switch (magic)
{
case 4:
mGenerateClass = "Spellsword";
className = "Spellsword";
break;
case 5:
mGenerateClass = "Witchhunter";
className = "Witchhunter";
break;
case 6:
if (combat == 2)
mGenerateClass = "Sorcerer";
className = "Sorcerer";
else if (combat == 3)
mGenerateClass = "Healer";
className = "Healer";
else
mGenerateClass = "Battlemage";
className = "Battlemage";
break;
case 7:
mGenerateClass = "Mage";
className = "Mage";
break;
default:
switch (stealth)
{
case 3:
if (magic == 3)
mGenerateClass = "Bard"; // unreachable
className = "Bard"; // unreachable
else
mGenerateClass = "Warrior";
className = "Warrior";
break;
case 5:
if (magic == 3)
mGenerateClass = "Monk";
className = "Monk";
else
mGenerateClass = "Pilgrim";
className = "Pilgrim";
break;
case 6:
if (magic == 1)
mGenerateClass = "Agent";
className = "Agent";
else if (magic == 3)
mGenerateClass = "Assassin";
className = "Assassin";
else
mGenerateClass = "Acrobat";
className = "Acrobat";
break;
case 7:
mGenerateClass = "Thief";
className = "Thief";
break;
default:
mGenerateClass = "Warrior";
className = "Warrior";
}
}
}
}
mGenerateClass = ESM::RefId::stringRefId(className);
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mGenerateClassResultDialog));
mGenerateClassResultDialog = std::make_unique<GenerateClassResultDialog>();

@ -46,8 +46,8 @@ namespace MWGui
// Show a dialog
void spawnDialog(const char id);
void setValue(const std::string& id, const MWMechanics::AttributeValue& value) override;
void setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value) override;
void setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value) override;
void setValue(const ESM::RefId& id, const MWMechanics::DynamicStat<float>& value) override;
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value) override;
void configureSkills(const SkillList& major, const SkillList& minor) override;
@ -74,8 +74,8 @@ namespace MWGui
// Player data
std::string mPlayerName;
std::string mPlayerRaceId;
std::string mPlayerBirthSignId;
ESM::RefId mPlayerRaceId;
ESM::RefId mPlayerBirthSignId;
ESM::Class mPlayerClass;
// Class generation vars
@ -83,7 +83,7 @@ namespace MWGui
ESM::Class::Specialization mGenerateClassResponses[3];
unsigned mGenerateClassSpecializations[3]; // A counter for each specialization which is increased when an
// answer is chosen
std::string mGenerateClass; // In order: Combat, Magic, Stealth
ESM::RefId mGenerateClass; // In order: Combat, Magic, Stealth
////Dialog events
// Name dialog

@ -24,7 +24,7 @@
namespace
{
bool sortClasses(const std::pair<std::string, std::string>& left, const std::pair<std::string, std::string>& right)
bool sortClasses(const std::pair<ESM::RefId, std::string>& left, const std::pair<ESM::RefId, std::string>& right)
{
return left.second.compare(right.second) < 0;
}
@ -58,7 +58,7 @@ namespace MWGui
center();
}
void GenerateClassResultDialog::setClassId(const std::string& classId)
void GenerateClassResultDialog::setClassId(const ESM::RefId& classId)
{
mCurrentClassId = classId;
@ -144,20 +144,20 @@ namespace MWGui
// Show the current class by default
MWWorld::Ptr player = MWMechanics::getPlayer();
const std::string& classId = player.get<ESM::NPC>()->mBase->mClass;
const ESM::RefId& classId = player.get<ESM::NPC>()->mBase->mClass;
if (!classId.empty())
setClassId(classId);
}
void PickClassDialog::setClassId(const std::string& classId)
void PickClassDialog::setClassId(const ESM::RefId& classId)
{
mCurrentClassId = classId;
mClassList->setIndexSelected(MyGUI::ITEM_NONE);
size_t count = mClassList->getItemCount();
for (size_t i = 0; i < count; ++i)
{
if (Misc::StringUtils::ciEqual(*mClassList->getItemDataAt<std::string>(i), classId))
if (ESM::RefId::ciEqual(*mClassList->getItemDataAt<ESM::RefId>(i), classId))
{
mClassList->setIndexSelected(i);
break;
@ -194,8 +194,8 @@ namespace MWGui
if (_index == MyGUI::ITEM_NONE)
return;
const std::string* classId = mClassList->getItemDataAt<std::string>(_index);
if (Misc::StringUtils::ciEqual(mCurrentClassId, *classId))
const ESM::RefId* classId = mClassList->getItemDataAt<ESM::RefId>(_index);
if (ESM::RefId::ciEqual(mCurrentClassId, *classId))
return;
mCurrentClassId = *classId;
@ -210,7 +210,7 @@ namespace MWGui
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::vector<std::pair<std::string, std::string>> items; // class id, class name
std::vector<std::pair<ESM::RefId, std::string>> items; // class id, class name
for (const ESM::Class& classInfo : store.get<ESM::Class>())
{
bool playable = (classInfo.mData.mIsPlayable != 0);
@ -227,14 +227,14 @@ namespace MWGui
int index = 0;
for (auto& itemPair : items)
{
const std::string& id = itemPair.first;
const ESM::RefId& id = itemPair.first;
mClassList->addItem(itemPair.second, id);
if (mCurrentClassId.empty())
{
mCurrentClassId = id;
mClassList->setIndexSelected(index);
}
else if (Misc::StringUtils::ciEqual(id, mCurrentClassId))
else if (ESM::RefId::ciEqual(id, mCurrentClassId))
{
mClassList->setIndexSelected(index);
}
@ -889,14 +889,14 @@ namespace MWGui
eventDone(this);
}
void setClassImage(MyGUI::ImageBox* imageBox, const std::string& classId)
void setClassImage(MyGUI::ImageBox* imageBox, const ESM::RefId& classId)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
std::string classImage
= Misc::ResourceHelpers::correctTexturePath("textures\\levelup\\" + classId + ".dds", vfs);
= Misc::ResourceHelpers::correctTexturePath("textures\\levelup\\" + classId.getRefIdString() + ".dds", vfs);
if (!vfs->exists(classImage))
{
Log(Debug::Warning) << "No class image for " << classId << ", falling back to default";
Log(Debug::Warning) << "No class image for " << classId.getRefIdString() << ", falling back to default";
classImage = "textures\\levelup\\warrior.dds";
}
imageBox->setImageTexture(classImage);

@ -6,6 +6,7 @@
#include <MyGUI_EditBox.h>
#include <components/esm/attr.hpp>
#include <components/esm/refid.hpp>
#include <components/esm3/loadclas.hpp>
#include "widgets.hpp"
@ -13,7 +14,7 @@
namespace MWGui
{
void setClassImage(MyGUI::ImageBox* imageBox, const std::string& classId);
void setClassImage(MyGUI::ImageBox* imageBox, const ESM::RefId& classId);
class InfoBoxDialog : public WindowModal
{
@ -70,7 +71,7 @@ namespace MWGui
public:
GenerateClassResultDialog();
void setClassId(const std::string& classId);
void setClassId(const ESM::RefId& classId);
bool exit() override { return false; }
@ -95,7 +96,7 @@ namespace MWGui
MyGUI::ImageBox* mClassImage;
MyGUI::TextBox* mClassName;
std::string mCurrentClassId;
ESM::RefId mCurrentClassId;
};
class PickClassDialog : public WindowModal
@ -103,8 +104,8 @@ namespace MWGui
public:
PickClassDialog();
const std::string& getClassId() const { return mCurrentClassId; }
void setClassId(const std::string& classId);
const ESM::RefId& getClassId() const { return mCurrentClassId; }
void setClassId(const ESM::RefId& classId);
void setNextButtonShow(bool shown);
void onOpen() override;
@ -142,7 +143,7 @@ namespace MWGui
Widgets::MWSkillPtr mMajorSkill[5];
Widgets::MWSkillPtr mMinorSkill[5];
std::string mCurrentClassId;
ESM::RefId mCurrentClassId;
};
class SelectSpecializationDialog : public WindowModal

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

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

@ -105,10 +105,15 @@ namespace MWGui
// identifier
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::vector<ESM::RefId> ids;
for (MWWorld::ESMStore::iterator it = store.begin(); it != store.end(); ++it)
{
(*it)->listIdentifier(mNames);
(*it)->listIdentifier(ids);
for (auto id : ids)
{
mNames.push_back(id.getRefIdString());
}
ids.clear();
}
// exterior cell names aren't technically identifiers, but since the COC function accepts them,
@ -190,7 +195,7 @@ namespace MWGui
Compiler::Locals locals;
if (!mPtr.isEmpty())
{
std::string_view script = mPtr.getClass().getScript(mPtr);
const ESM::RefId& script = mPtr.getClass().getScript(mPtr);
if (!script.empty())
locals = MWBase::Environment::get().getScriptManager()->getLocals(script);
}
@ -529,7 +534,7 @@ namespace MWGui
if (!mConsoleMode.empty())
title = mConsoleMode + " " + title;
if (!mPtr.isEmpty())
title.append(" (" + mPtr.getCellRef().getRefId() + ")");
title.append(" (" + mPtr.getCellRef().getRefId().getRefIdString() + ")");
setTitle(title);
}

@ -223,7 +223,7 @@ namespace MWGui
{
// play the sound of the first object
MWWorld::Ptr item = mModel->getItem(i).mBase;
std::string_view sound = item.getClass().getUpSoundId(item);
const ESM::RefId& sound = item.getClass().getUpSoundId(item);
MWBase::Environment::get().getWindowManager()->playSound(sound);
}
@ -261,7 +261,7 @@ namespace MWGui
creatureStats.setDeathAnimationFinished(true);
MWBase::Environment::get().getMechanicsManager()->notifyDied(ptr);
std::string_view script = ptr.getClass().getScript(ptr);
const ESM::RefId& script = ptr.getClass().getScript(ptr);
if (!script.empty() && MWBase::Environment::get().getWorld()->getScriptsEnabled())
{
MWScript::InterpreterContext interpreterContext(&ptr.getRefData().getLocals(), ptr);

@ -278,19 +278,19 @@ namespace MWGui
void Choice::activated()
{
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
eventChoiceActivated(mChoiceId);
}
void Topic::activated()
{
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
eventTopicActivated(mTopicId);
}
void Goodbye::activated()
{
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
eventActivated();
}
@ -791,7 +791,7 @@ namespace MWGui
for (const std::string& keyword : mKeywords)
{
int flag = MWBase::Environment::get().getDialogueManager()->getTopicFlag(keyword);
int flag = MWBase::Environment::get().getDialogueManager()->getTopicFlag(ESM::RefId::stringRefId(keyword));
MyGUI::Button* button = mTopicsList->getItemWidget(keyword);
if (!specialColour.empty() && flag & MWBase::DialogueManager::TopicType::Specific)

@ -63,7 +63,7 @@ namespace MWGui
mSourceSortModel = playerFilterModel;
}
std::string_view sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
const ESM::RefId& sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
MWBase::Environment::get().getWindowManager()->playSound(sound);
if (mSourceSortModel)
@ -95,7 +95,7 @@ namespace MWGui
void DragAndDrop::drop(ItemModel* targetModel, ItemView* targetView)
{
std::string_view sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase);
const ESM::RefId& 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

@ -364,13 +364,13 @@ namespace MWGui
if (result == 1)
{
MWBase::Environment::get().getWindowManager()->playSound("enchant success");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("enchant success"));
MWBase::Environment::get().getWindowManager()->messageBox("#{sEnchantmentMenu12}");
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Enchanting);
}
else
{
MWBase::Environment::get().getWindowManager()->playSound("enchant fail");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("enchant fail"));
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage34}");
if (!mEnchanting.getGem().isEmpty() && !mEnchanting.getGem().getRefData().getCount())
{

@ -54,7 +54,7 @@ namespace MWGui
dropped = world->placeObject(item.mBase, mLeft, mTop, count);
else
dropped = world->dropObjectOnGround(world->getPlayerPtr(), item.mBase, count);
dropped.getCellRef().setOwner("");
dropped.getCellRef().setOwner(ESM::RefId::sEmpty);
return dropped;
}
@ -181,32 +181,32 @@ namespace MWGui
mMainWidget->eventMouseButtonClick.clear();
}
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value)
void HUD::setValue(const ESM::RefId& id, const MWMechanics::DynamicStat<float>& value)
{
int current = static_cast<int>(value.getCurrent());
int modified = static_cast<int>(value.getModified());
const std::string idString = id.getRefIdString();
// Fatigue can be negative
if (id != "FBar")
if (idString != "FBar")
current = std::max(0, current);
MyGUI::Widget* w;
std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified);
if (id == "HBar")
if (idString == "HBar")
{
mHealth->setProgressRange(std::max(0, modified));
mHealth->setProgressPosition(std::max(0, current));
getWidget(w, "HealthFrame");
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
}
else if (id == "MBar")
else if (idString == "MBar")
{
mMagicka->setProgressRange(std::max(0, modified));
mMagicka->setProgressPosition(std::max(0, current));
getWidget(w, "MagickaFrame");
w->setUserString("Caption_HealthDescription", "#{sMagDesc}\n" + valStr);
}
else if (id == "FBar")
else if (idString == "FBar")
{
mStamina->setProgressRange(std::max(0, modified));
mStamina->setProgressPosition(std::max(0, current));
@ -393,7 +393,7 @@ namespace MWGui
}
}
void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent)
void HUD::setSelectedSpell(const ESM::RefId& spellId, int successChancePercent)
{
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
@ -410,7 +410,7 @@ namespace MWGui
mSpellStatus->setProgressPosition(successChancePercent);
mSpellBox->setUserString("ToolTipType", "Spell");
mSpellBox->setUserString("Spell", spellId);
mSpellBox->setUserString("Spell", spellId.getRefIdString());
// use the icon of the first effect
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(

@ -23,7 +23,7 @@ namespace MWGui
public:
HUD(CustomMarkerCollection& customMarkers, DragAndDrop* dragAndDrop, MWRender::LocalMap* localMapRender);
virtual ~HUD();
void setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value) override;
void setValue(const ESM::RefId& id, const MWMechanics::DynamicStat<float>& value) override;
/// Set time left for the player to start drowning
/// @param time time left to start drowning
@ -39,7 +39,7 @@ namespace MWGui
void setEffectVisible(bool visible);
void setMinimapVisible(bool visible);
void setSelectedSpell(const std::string& spellId, int successChancePercent);
void setSelectedSpell(const ESM::RefId& spellId, int successChancePercent);
void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent);
const MWWorld::Ptr& getSelectedEnchantItem();
void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent);

@ -250,7 +250,7 @@ namespace MWGui
}
const ItemStack& item = mTradeModel->getItem(index);
std::string_view sound = item.mBase.getClass().getDownSoundId(item.mBase);
const ESM::RefId& sound = item.mBase.getClass().getDownSoundId(item.mBase);
MWWorld::Ptr object = item.mBase;
int count = item.mCount;
@ -360,7 +360,7 @@ namespace MWGui
{
ensureSelectedItemUnequipped(count);
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
std::string_view sound = item.mBase.getClass().getUpSoundId(item.mBase);
const ESM::RefId& sound = item.mBase.getClass().getUpSoundId(item.mBase);
MWBase::Environment::get().getWindowManager()->playSound(sound);
if (item.mType == ItemStack::Type_Barter)
@ -518,7 +518,7 @@ namespace MWGui
void InventoryWindow::useItem(const MWWorld::Ptr& ptr, bool force)
{
std::string_view script = ptr.getClass().getScript(ptr);
const ESM::RefId& script = ptr.getClass().getScript(ptr);
if (!script.empty())
{
// Don't try to equip the item if PCSkipEquip is set to 1
@ -792,7 +792,7 @@ namespace MWGui
int incr = next ? 1 : -1;
bool found = false;
std::string_view lastId;
ESM::RefId lastId;
if (selected != -1)
lastId = model.getItem(selected).mBase.getCellRef().getRefId();
ItemModel::ModelIndex cycled = selected;
@ -805,7 +805,7 @@ namespace MWGui
// skip different stacks of the same item, or we will get stuck as stacking/unstacking them may change their
// relative ordering
if (Misc::StringUtils::ciEqual(lastId, item.getCellRef().getRefId()))
if (ESM::RefId::ciEqual(lastId, item.getCellRef().getRefId()))
continue;
lastId = item.getCellRef().getRefId();

@ -190,7 +190,7 @@ namespace MWGui
line.mItemPtr.getClass().getItemMaxHealth(line.mItemPtr));
break;
case DisplayMode_EnchantmentCharge:
std::string_view enchId = line.mItemPtr.getClass().getEnchantment(line.mItemPtr);
const ESM::RefId& enchId = line.mItemPtr.getClass().getEnchantment(line.mItemPtr);
if (enchId.empty())
break;
const ESM::Enchantment* ench

@ -58,7 +58,7 @@ namespace MWGui
if (mFadeTimeRemaining <= 0)
{
MWWorld::Ptr player = MWMechanics::getPlayer();
MWBase::Environment::get().getWorld()->teleportToClosestMarker(player, "prisonmarker");
MWBase::Environment::get().getWorld()->teleportToClosestMarker(player, ESM::RefId::stringRefId("prisonmarker"));
MWBase::Environment::get().getWindowManager()->fadeScreenOut(
0.f); // override fade-in caused by cell transition

@ -56,7 +56,7 @@ namespace MWGui
MWBase::Journal* journal = MWBase::Environment::get().getJournal();
for (MWBase::Journal::TTopicIter i = journal->topicBegin(); i != journal->topicEnd(); ++i)
mKeywordSearch.seed(i->first, intptr_t(&i->second));
mKeywordSearch.seed(i->first.getRefIdString(), intptr_t(&i->second));
mKeywordSearchLoaded = true;
}
@ -312,7 +312,7 @@ namespace MWGui
for (MWBase::Journal::TTopicIter i = journal->topicBegin(); i != journal->topicEnd(); ++i)
{
Utf8Stream stream(i->first.c_str());
Utf8Stream stream(i->first.getRefIdString().c_str());
Utf8Stream::UnicodeChar first = Utf8Stream::toLowerUtf8(stream.peek());
if (first != Utf8Stream::toLowerUtf8(character))

@ -119,8 +119,8 @@ namespace
Gui::MWList* list = getWidget<Gui::MWList>(QuestsList);
list->eventItemSelected += MyGUI::newDelegate(this, &JournalWindowImpl::notifyQuestClicked);
Gui::MWList* topicsList = getWidget<Gui::MWList>(TopicsList);
topicsList->eventItemSelected += MyGUI::newDelegate(this, &JournalWindowImpl::notifyTopicSelected);
//Gui::MWList* topicsList = getWidget<Gui::MWList>(TopicsList);
//topicsList->eventItemSelected += MyGUI::newDelegate(this, &JournalWindowImpl::notifyTopicSelected);
{
MWGui::BookPage::ClickCallback callback;
@ -413,16 +413,16 @@ namespace
mOptionsMode = false;
mTopicsMode = false;
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyTopicSelected(const std::string& topic, int id)
void notifyTopicSelected(const ESM::RefId& topic, int id)
{
const MWBase::Journal* journal = MWBase::Environment::get().getJournal();
intptr_t topicId = 0; /// \todo get rid of intptr ids
for (MWBase::Journal::TTopicIter i = journal->topicBegin(); i != journal->topicEnd(); ++i)
{
if (Misc::StringUtils::ciEqual(i->first, topic))
if (ESM::RefId::ciEqual(i->first, topic))
topicId = intptr_t(&i->second);
}
@ -444,7 +444,7 @@ namespace
mOptionsMode = false;
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyOptions(MyGUI::Widget* _sender)
@ -472,7 +472,7 @@ namespace
assert(mStates.size() > 1);
popBook();
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyIndexLinkClicked(MWGui::TypesetBook::InteractiveId index)
@ -493,7 +493,7 @@ namespace
list->adjustSize();
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyTopics(MyGUI::Widget* _sender)
@ -508,7 +508,7 @@ namespace
setVisible(ShowAllBTN, false);
setVisible(ShowActiveBTN, false);
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
struct AddNamesToList
@ -565,7 +565,7 @@ namespace
mModel->visitQuestNames(false, setInactive);
}
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyShowAll(MyGUI::Widget* _sender)
@ -589,14 +589,14 @@ namespace
else
{
setBookMode();
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
}
void notifyClose(MyGUI::Widget* _sender)
{
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
winMgr->playSound("book close");
winMgr->playSound(ESM::RefId::stringRefId("book close"));
winMgr->popGuiMode();
}
@ -619,7 +619,7 @@ namespace
if (page + 2 < book->pageCount())
{
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
page += 2;
updateShowingPages();
@ -637,7 +637,7 @@ namespace
if (page >= 2)
{
MWBase::Environment::get().getWindowManager()->playSound("book page");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
page -= 2;
updateShowingPages();

@ -134,8 +134,8 @@ namespace MWGui
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player);
setClassImage(mClassImage,
getLevelupClassImage(pcStats.getSkillIncreasesForSpecialization(0),
pcStats.getSkillIncreasesForSpecialization(1), pcStats.getSkillIncreasesForSpecialization(2)));
ESM::RefId::stringRefId(getLevelupClassImage(pcStats.getSkillIncreasesForSpecialization(0),
pcStats.getSkillIncreasesForSpecialization(1), pcStats.getSkillIncreasesForSpecialization(2))));
int level = creatureStats.getLevel() + 1;
mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + MyGUI::utility::toString(level));

@ -89,7 +89,7 @@ namespace MWGui
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
const std::string& name = *sender->getUserData<std::string>();
winMgr->playSound("Menu Click");
winMgr->playSound(ESM::RefId::stringRefId("Menu Click"));
if (name == "return")
{
winMgr->removeGuiMode(GM_MainMenu);

@ -134,7 +134,7 @@ namespace MWGui
player.getClass().getContainerStore(player).restack(item);
MWBase::Environment::get().getWindowManager()->playSound("Repair");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Repair"));
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player);

@ -100,7 +100,7 @@ namespace MWGui
if (pickpocket.finish())
{
MWBase::Environment::get().getMechanicsManager()->commitCrime(
player, mActor, MWBase::MechanicsManager::OT_Pickpocket, std::string(), 0, true);
player, mActor, MWBase::MechanicsManager::OT_Pickpocket, ESM::RefId::sEmpty, 0, true);
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Container);
mPickpocketDetected = true;
}
@ -128,7 +128,7 @@ namespace MWGui
if (pickpocket.pick(item, count))
{
MWBase::Environment::get().getMechanicsManager()->commitCrime(
player, mActor, MWBase::MechanicsManager::OT_Pickpocket, std::string(), 0, true);
player, mActor, MWBase::MechanicsManager::OT_Pickpocket, ESM::RefId::sEmpty, 0, true);
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Container);
mPickpocketDetected = true;
return false;

@ -281,7 +281,7 @@ namespace MWGui
mMagicSelectionDialog->setVisible(false);
}
void QuickKeysMenu::onAssignMagic(const std::string& spellId)
void QuickKeysMenu::onAssignMagic(const ESM::RefId& spellId)
{
assert(mSelected);
while (mSelected->button->getChildCount()) // Destroy number label
@ -296,7 +296,7 @@ namespace MWGui
mSelected->button->setItem(MWWorld::Ptr());
mSelected->button->setUserString("ToolTipType", "Spell");
mSelected->button->setUserString("Spell", spellId);
mSelected->button->setUserString("Spell", spellId.getRefIdString());
// use the icon of the first effect
const ESM::MagicEffect* effect = esmStore.get<ESM::MagicEffect>().find(spell->mEffects.mList.front().mEffectID);
@ -425,7 +425,7 @@ namespace MWGui
}
else if (key->type == Type_Magic)
{
const std::string& spellId = key->id;
const ESM::RefId& spellId = key->id;
// Make sure the player still has this spell
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
@ -516,7 +516,7 @@ namespace MWGui
break;
}
case Type_Magic:
key.mId = button->getUserString("Spell");
key.mId = ESM::RefId::stringRefId(button->getUserString("Spell"));
break;
}

@ -30,7 +30,7 @@ namespace MWGui
void onAssignItem(MWWorld::Ptr item);
void onAssignItemCancel();
void onAssignMagicItem(MWWorld::Ptr item);
void onAssignMagic(const std::string& spellId);
void onAssignMagic(const ESM::RefId& spellId);
void onAssignMagicCancel();
void onOpen() override;
void onClose() override;
@ -58,13 +58,13 @@ namespace MWGui
int index;
ItemWidget* button;
QuickKeysMenu::QuickKeyType type;
std::string id;
ESM::RefId id;
std::string name;
keyData()
: index(-1)
, button(nullptr)
, type(Type_Unassigned)
, id("")
, id(ESM::RefId::sEmpty)
, name("")
{
}

@ -34,7 +34,7 @@ namespace
return index;
}
bool sortRaces(const std::pair<std::string, std::string>& left, const std::pair<std::string, std::string>& right)
bool sortRaces(const std::pair<ESM::RefId, std::string>& left, const std::pair<ESM::RefId, std::string>& right)
{
return left.second.compare(right.second) < 0;
}
@ -165,13 +165,13 @@ namespace MWGui
for (unsigned int i = 0; i < mAvailableHeads.size(); ++i)
{
if (Misc::StringUtils::ciEqual(mAvailableHeads[i], proto.mHead))
if (ESM::RefId::ciEqual(mAvailableHeads[i], proto.mHead))
mFaceIndex = i;
}
for (unsigned int i = 0; i < mAvailableHairs.size(); ++i)
{
if (Misc::StringUtils::ciEqual(mAvailableHairs[i], proto.mHair))
if (ESM::RefId::ciEqual(mAvailableHairs[i], proto.mHair))
mHairIndex = i;
}
@ -184,14 +184,14 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mRaceList);
}
void RaceDialog::setRaceId(const std::string& raceId)
void RaceDialog::setRaceId(const ESM::RefId& raceId)
{
mCurrentRaceId = raceId;
mRaceList->setIndexSelected(MyGUI::ITEM_NONE);
size_t count = mRaceList->getItemCount();
for (size_t i = 0; i < count; ++i)
{
if (Misc::StringUtils::ciEqual(*mRaceList->getItemDataAt<std::string>(i), raceId))
if (ESM::RefId::ciEqual(ESM::RefId::stringRefId(*mRaceList->getItemDataAt<std::string>(i)), raceId))
{
mRaceList->setIndexSelected(i);
break;
@ -292,11 +292,11 @@ namespace MWGui
if (_index == MyGUI::ITEM_NONE)
return;
const std::string* raceId = mRaceList->getItemDataAt<std::string>(_index);
if (Misc::StringUtils::ciEqual(mCurrentRaceId, *raceId))
ESM::RefId raceId = ESM::RefId::stringRefId(*mRaceList->getItemDataAt<std::string>(_index));
if (ESM::RefId::ciEqual(mCurrentRaceId, raceId))
return;
mCurrentRaceId = *raceId;
mCurrentRaceId = raceId;
recountParts();
@ -313,7 +313,7 @@ namespace MWGui
eventDone(this);
}
void RaceDialog::getBodyParts(int part, std::vector<std::string>& out)
void RaceDialog::getBodyParts(int part, std::vector<ESM::RefId>& out)
{
out.clear();
const MWWorld::Store<ESM::BodyPart>& store
@ -321,6 +321,7 @@ namespace MWGui
for (const ESM::BodyPart& bodypart : store)
{
const std::string& idString = bodypart.mId.getRefIdString();
if (bodypart.mData.mFlags & ESM::BodyPart::BPF_NotPlayable)
continue;
if (bodypart.mData.mType != ESM::BodyPart::MT_Skin)
@ -329,11 +330,11 @@ namespace MWGui
continue;
if (mGenderIndex != (bodypart.mData.mFlags & ESM::BodyPart::BPF_Female))
continue;
bool firstPerson = (bodypart.mId.size() >= 3) && bodypart.mId[bodypart.mId.size() - 3] == '1'
&& bodypart.mId[bodypart.mId.size() - 2] == 's' && bodypart.mId[bodypart.mId.size() - 1] == 't';
bool firstPerson = (idString.size() >= 3) && idString[idString.size() - 3] == '1'
&& idString[idString.size() - 2] == 's' && idString[idString.size() - 1] == 't';
if (firstPerson)
continue;
if (Misc::StringUtils::ciEqual(bodypart.mRace, mCurrentRaceId))
if (ESM::RefId::ciEqual(bodypart.mRace, mCurrentRaceId))
out.push_back(bodypart.mId);
}
}
@ -377,7 +378,7 @@ namespace MWGui
const MWWorld::Store<ESM::Race>& races = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>();
std::vector<std::pair<std::string, std::string>> items; // ID, name
std::vector<std::pair<ESM::RefId, std::string>> items; // ID, name
for (const ESM::Race& race : races)
{
bool playable = race.mData.mFlags & ESM::Race::Playable;
@ -392,7 +393,7 @@ namespace MWGui
for (auto& item : items)
{
mRaceList->addItem(item.second, item.first);
if (Misc::StringUtils::ciEqual(item.first, mCurrentRaceId))
if (ESM::RefId::ciEqual(item.first, mCurrentRaceId))
mRaceList->setIndexSelected(index);
++index;
}
@ -454,13 +455,13 @@ namespace MWGui
const ESM::Race* race = store.get<ESM::Race>().find(mCurrentRaceId);
int i = 0;
for (const std::string& spellpower : race->mPowers.mList)
for (const auto& spellpower : race->mPowers.mList)
{
Widgets::MWSpellPtr spellPowerWidget = mSpellPowerList->createWidget<Widgets::MWSpell>(
"MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + MyGUI::utility::toString(i));
spellPowerWidget->setSpellId(spellpower);
spellPowerWidget->setUserString("ToolTipType", "Spell");
spellPowerWidget->setUserString("Spell", spellpower);
spellPowerWidget->setUserString("Spell", spellpower.getRefIdString());
mSpellPowerItems.push_back(spellPowerWidget);

@ -2,7 +2,7 @@
#define MWGUI_RACE_H
#include <memory>
#include<components/esm/refid.hpp>
#include "windowbase.hpp"
namespace MWRender
@ -39,10 +39,10 @@ namespace MWGui
};
const ESM::NPC& getResult() const;
const std::string& getRaceId() const { return mCurrentRaceId; }
const ESM::RefId& getRaceId() const { return mCurrentRaceId; }
Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; }
void setRaceId(const std::string& raceId);
void setRaceId(const ESM::RefId& raceId);
void setGender(Gender gender) { mGenderIndex = gender == GM_Male ? 0 : 1; }
void setNextButtonShow(bool shown);
@ -90,13 +90,13 @@ namespace MWGui
void updatePreview();
void recountParts();
void getBodyParts(int part, std::vector<std::string>& out);
void getBodyParts(int part, std::vector<ESM::RefId>& out);
osg::Group* mParent;
Resource::ResourceSystem* mResourceSystem;
std::vector<std::string> mAvailableHeads;
std::vector<std::string> mAvailableHairs;
std::vector<ESM::RefId> mAvailableHeads;
std::vector<ESM::RefId> mAvailableHairs;
MyGUI::ImageBox* mPreviewImage;
MyGUI::ListBox* mRaceList;
@ -110,7 +110,7 @@ namespace MWGui
int mGenderIndex, mFaceIndex, mHairIndex;
std::string mCurrentRaceId;
ESM::RefId mCurrentRaceId;
float mCurrentAngle;

@ -68,7 +68,7 @@ namespace MWGui
{
MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>();
const std::string& soul = gem.getCellRef().getSoul();
const ESM::RefId& soul = gem.getCellRef().getSoul();
const ESM::Creature* creature
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul);

@ -57,7 +57,7 @@ namespace MWGui
void Repair::setPtr(const MWWorld::Ptr& item)
{
MWBase::Environment::get().getWindowManager()->playSound("Item Repair Up");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Item Repair Up"));
mRepair.setTool(item);

@ -124,7 +124,7 @@ namespace MWGui
mNameWidget->setCaption(name);
}
void ReviewDialog::setRace(const std::string& raceId)
void ReviewDialog::setRace(const ESM::RefId& raceId)
{
mRaceId = raceId;
@ -145,7 +145,7 @@ namespace MWGui
ToolTips::createClassToolTip(mClassWidget, mKlass);
}
void ReviewDialog::setBirthSign(const std::string& signId)
void ReviewDialog::setBirthSign(const ESM::RefId& signId)
{
mBirthSignId = signId;
@ -315,7 +315,7 @@ namespace MWGui
"MW_StatName", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default);
widget->setSpellId(spell->mId);
widget->setUserString("ToolTipType", "Spell");
widget->setUserString("Spell", spell->mId);
widget->setUserString("Spell", spell->mId.getRefIdString());
widget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
mSkillWidgets.push_back(widget);
@ -387,7 +387,7 @@ namespace MWGui
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
// starting spells
std::vector<std::string> spells;
std::vector<ESM::RefId> spells;
const ESM::Race* race = nullptr;
if (!mRaceId.empty())
@ -401,21 +401,19 @@ namespace MWGui
for (int i = 0; i < ESM::Attribute::Length; ++i)
attributes[i] = mAttributeWidgets[i]->getAttributeValue().getBase();
std::vector<std::string> selectedSpells = MWMechanics::autoCalcPlayerSpells(skills, attributes, race);
for (std::string& spellId : selectedSpells)
std::vector<ESM::RefId> selectedSpells = MWMechanics::autoCalcPlayerSpells(skills, attributes, race);
for (ESM::RefId& spellId : selectedSpells)
{
std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower);
if (std::find(spells.begin(), spells.end(), spellId) == spells.end())
spells.push_back(spellId);
}
if (race)
{
for (const std::string& spellId : race->mPowers.mList)
for (const ESM::RefId& spellId : race->mPowers.mList)
{
std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower);
if (std::find(spells.begin(), spells.end(), spellId) == spells.end())
spells.push_back(spellId);
}
}
@ -423,11 +421,10 @@ namespace MWGui
{
const ESM::BirthSign* sign
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find(mBirthSignId);
for (const std::string& spellId : sign->mPowers.mList)
for (const auto& spellId : sign->mPowers.mList)
{
std::string lower = Misc::StringUtils::lowerCase(spellId);
if (std::find(spells.begin(), spells.end(), lower) == spells.end())
spells.push_back(lower);
if (std::find(spells.begin(), spells.end(), spellId) == spells.end())
spells.push_back(spellId);
}
}
@ -435,7 +432,7 @@ namespace MWGui
addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeAbility", "Abilities"),
coord1, coord2);
for (std::string& spellId : spells)
for (auto& spellId : spells)
{
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Ability)
@ -445,7 +442,7 @@ namespace MWGui
addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypePower", "Powers"), coord1,
coord2);
for (std::string& spellId : spells)
for (auto& spellId : spells)
{
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Power)
@ -455,7 +452,7 @@ namespace MWGui
addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sTypeSpell", "Spells"), coord1,
coord2);
for (std::string& spellId : spells)
for (auto& spellId : spells)
{
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Spell)

@ -4,6 +4,7 @@
#include "widgets.hpp"
#include "windowbase.hpp"
#include <components/esm/attr.hpp>
#include <components/esm/refid.hpp>
#include <components/esm3/loadclas.hpp>
namespace ESM
@ -30,9 +31,9 @@ namespace MWGui
bool exit() override { return false; }
void setPlayerName(const std::string& name);
void setRace(const std::string& raceId);
void setRace(const ESM::RefId& raceId);
void setClass(const ESM::Class& class_);
void setBirthSign(const std::string& signId);
void setBirthSign(const ESM::RefId& signId);
void setHealth(const MWMechanics::DynamicStat<float>& value);
void setMagicka(const MWMechanics::DynamicStat<float>& value);
@ -95,7 +96,8 @@ namespace MWGui
SkillList mMajorSkills, mMinorSkills, mMiscSkills;
std::map<int, MWMechanics::SkillValue> mSkillValues;
std::map<int, MyGUI::TextBox*> mSkillWidgetMap;
std::string mName, mRaceId, mBirthSignId;
ESM::RefId mRaceId, mBirthSignId;
std::string mName;
ESM::Class mKlass;
std::vector<MyGUI::Widget*> mSkillWidgets; //< Skills and other information

@ -100,7 +100,7 @@ namespace MWGui
void ScrollWindow::onTakeButtonClicked(MyGUI::Widget* _sender)
{
MWBase::Environment::get().getWindowManager()->playSound("Item Book Up");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Item Book Up"));
MWWorld::ActionTake take(mScroll);
take.execute(MWMechanics::getPlayer());

@ -100,13 +100,13 @@ namespace
// 3. item with constant effect comes before items with non-constant effects
int leftChargePercent = -1;
int rightChargePercent = -1;
leftName = left.mBase.getClass().getEnchantment(left.mBase);
rightName = right.mBase.getClass().getEnchantment(right.mBase);
const ESM::RefId& leftNameEnch = left.mBase.getClass().getEnchantment(left.mBase);
const ESM::RefId& rightNameEnch = right.mBase.getClass().getEnchantment(right.mBase);
if (!leftName.empty())
if (!leftNameEnch.empty())
{
const ESM::Enchantment* ench
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(leftName);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(leftNameEnch);
if (ench)
{
if (ench->mData.mType == ESM::Enchantment::ConstantEffect)
@ -117,10 +117,10 @@ namespace
}
}
if (!rightName.empty())
if (!rightNameEnch.empty())
{
const ESM::Enchantment* ench
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(rightName);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(rightNameEnch);
if (ench)
{
if (ench->mData.mType == ESM::Enchantment::ConstantEffect)
@ -161,8 +161,8 @@ namespace
return result > 0;
// compare items by Id
leftName = left.mBase.getCellRef().getRefId();
rightName = right.mBase.getCellRef().getRefId();
leftName = left.mBase.getCellRef().getRefId().getRefIdString();
rightName = right.mBase.getCellRef().getRefId().getRefIdString();
result = leftName.compare(rightName);
return result < 0;
@ -267,7 +267,7 @@ namespace MWGui
if ((mFilter & Filter_OnlyEnchanted) && !(item.mFlags & ItemStack::Flag_Enchanted))
return false;
if ((mFilter & Filter_OnlyChargedSoulstones)
&& (base.getType() != ESM::Miscellaneous::sRecordId || base.getCellRef().getSoul() == ""
&& (base.getType() != ESM::Miscellaneous::sRecordId || base.getCellRef().getSoul() == ESM::RefId::sEmpty
|| !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(
base.getCellRef().getSoul())))
return false;
@ -300,7 +300,7 @@ namespace MWGui
if (!(item.mFlags & ItemStack::Flag_Enchanted))
return false;
std::string_view enchId = base.getClass().getEnchantment(base);
const ESM::RefId& enchId = base.getClass().getEnchantment(base);
const ESM::Enchantment* ench
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(enchId);
if (!ench)

@ -66,7 +66,7 @@ namespace MWGui
toAdd->setSize(mSpellsView->getWidth(), lineHeight);
toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel);
toAdd->setUserString("ToolTipType", "Spell");
toAdd->setUserString("Spell", spell.mId);
toAdd->setUserString("Spell", spell.mId.getRefIdString());
toAdd->setUserString("SpellCost", std::to_string(spell.mData.mCost));
toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onSpellButtonClick);
mSpellsWidgetMap.insert(std::make_pair(toAdd, spell.mId));
@ -135,7 +135,7 @@ namespace MWGui
mSpellsView->setViewOffset(MyGUI::IntPoint(0, startOffset));
}
bool SpellBuyingWindow::playerHasSpell(const std::string& id)
bool SpellBuyingWindow::playerHasSpell(const ESM::RefId& id)
{
MWWorld::Ptr player = MWMechanics::getPlayer();
return player.getClass().getCreatureStats(player).getSpells().hasSpell(id);
@ -160,7 +160,7 @@ namespace MWGui
setPtr(mPtr, mSpellsView->getViewOffset().top);
MWBase::Environment::get().getWindowManager()->playSound("Item Gold Up");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Item Gold Up"));
}
void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender)

@ -3,7 +3,7 @@
#include "referenceinterface.hpp"
#include "windowbase.hpp"
#include <components/esm/refid.hpp>
namespace ESM
{
struct Spell;
@ -36,7 +36,7 @@ namespace MWGui
MyGUI::ScrollView* mSpellsView;
std::map<MyGUI::Widget*, std::string> mSpellsWidgetMap;
std::map<MyGUI::Widget*, ESM::RefId> mSpellsWidgetMap;
void onCancelButtonClicked(MyGUI::Widget* _sender);
void onSpellButtonClick(MyGUI::Widget* _sender);
@ -49,7 +49,7 @@ namespace MWGui
void onReferenceUnavailable() override;
bool playerHasSpell(const std::string& id);
bool playerHasSpell(const ESM::RefId& id);
private:
static bool sortSpells(const ESM::Spell* left, const ESM::Spell* right);

@ -414,7 +414,7 @@ namespace MWGui
MWMechanics::CreatureStats& npcStats = mPtr.getClass().getCreatureStats(mPtr);
npcStats.setGoldPool(npcStats.getGoldPool() + price);
MWBase::Environment::get().getWindowManager()->playSound("Mysticism Hit");
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Mysticism Hit"));
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->createRecord(mSpell);

@ -126,7 +126,7 @@ namespace MWGui
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
{
MWWorld::Ptr item = *it;
const std::string_view enchantId = item.getClass().getEnchantment(item);
const ESM::RefId& enchantId = item.getClass().getEnchantment(item);
if (enchantId.empty())
continue;
const ESM::Enchantment* enchant = esmStore.get<ESM::Enchantment>().search(enchantId);

@ -19,7 +19,7 @@ namespace MWGui
Type mType;
std::string mName;
std::string mCostColumn; // Cost/chance or Cost/charge
std::string mId; // Item ID or spell ID
ESM::RefId mId; // Item ID or spell ID
MWWorld::Ptr mItem; // Only for Type_EnchantedItem
int mCount; // Only for Type_EnchantedItem
bool mSelected; // Is this the currently selected spell/item (only one can be selected at a time)

@ -286,7 +286,7 @@ namespace MWGui
else
{
widget->setUserString("ToolTipType", "Spell");
widget->setUserString("Spell", spell.mId);
widget->setUserString("Spell", spell.mId.getRefIdString());
}
widget->setUserString(sSpellModelIndex, MyGUI::utility::toString(index));

@ -136,17 +136,17 @@ namespace MWGui
updateSpells();
}
void SpellWindow::askDeleteSpell(const std::string& spellId)
void SpellWindow::askDeleteSpell(const ESM::RefId& spellId)
{
// delete spell, if allowed
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
MWWorld::Ptr player = MWMechanics::getPlayer();
const std::string& raceId = player.get<ESM::NPC>()->mBase->mRace;
const ESM::RefId& raceId = player.get<ESM::NPC>()->mBase->mRace;
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceId);
// can't delete racial spells, birthsign spells or powers
bool isInherent = race->mPowers.exists(spell->mId) || spell->mData.mType == ESM::Spell::ST_Power;
const std::string& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
const ESM::RefId& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
if (!isInherent && !signId.empty())
{
const ESM::BirthSign* sign
@ -205,7 +205,7 @@ namespace MWGui
askDeleteSpell(spell.mId);
}
void SpellWindow::onSpellSelected(const std::string& spellId)
void SpellWindow::onSpellSelected(const ESM::RefId& spellId)
{
MWWorld::Ptr player = MWMechanics::getPlayer();
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save