create a specific esm reader function for RefID to avoid allocation for string and then again for RefId

Fixed some types

removed useless header

applied clang format

fixed compile tests

fixed clang tidy, and closer to logic before this MR

Removed hardcoded refids

unless there is a returned value we don't use static RefIds
can use == between RefId and hardcoded string

Fix clang format

Fixed a few instances where std::string was used, when only const std::string& was needed

removed unused variable
iwyu_full
florent.teppe 2 years ago
parent 874ff88288
commit 65cdd489fb

@ -7,7 +7,6 @@
#include <osg/ImageUtils>
#include <osgDB/ReadFile>
#include <components/esm/refidhardcoded.hpp>
#include <components/esm/defs.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm3/esmwriter.hpp>
@ -375,7 +374,7 @@ namespace ESSImport
profile.mInGameTime.mYear = context.mYear;
profile.mTimePlayed = 0;
profile.mPlayerCell = ESM::RefId::stringRefId(header.mGameData.mCurrentCell.toString());
if (context.mPlayerBase.mClass == ESM::RefId::stringRefId("NEWCLASSID_CHARGEN"))
if (context.mPlayerBase.mClass == "NEWCLASSID_CHARGEN")
profile.mPlayerClassName = context.mCustomPlayerClassName;
else
profile.mPlayerClassId = context.mPlayerBase.mClass;
@ -398,7 +397,7 @@ namespace ESSImport
}
writer.startRecord(ESM::REC_NPC_);
context.mPlayerBase.mId = ESM::sPlayerId;
context.mPlayerBase.mId = ESM::RefId::stringRefId("Player");
context.mPlayerBase.save(writer);
writer.endRecord(ESM::REC_NPC_);

@ -229,7 +229,8 @@ namespace NavMeshTool
DetourNavigator::RecastGlobalAllocator::init();
DetourNavigator::Settings navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager();
navigatorSettings.mRecast.mSwimHeightScale
= EsmLoader::getGameSetting(esmData.mGameSettings, ESM::RefId::stringRefId("fSwimHeightScale")).getFloat();
= EsmLoader::getGameSetting(esmData.mGameSettings, ESM::RefId::stringRefId("fSwimHeightScale"))
.getFloat();
WorldspaceData cellsData = gatherWorldspaceData(
navigatorSettings, readers, vfs, bulletShapeManager, esmData, processInteriorCells, writeBinaryLog);

@ -29,6 +29,7 @@
#include <osg/ref_ptr>
#include <algorithm>
#include <components/esm/refid.hpp>
#include <memory>
#include <stdexcept>
#include <string>
@ -36,7 +37,6 @@
#include <tuple>
#include <utility>
#include <vector>
#include <components/esm/refid.hpp>
namespace NavMeshTool
{
namespace

@ -504,7 +504,8 @@ void CSMDoc::Document::startRunning(const std::string& profile, const std::strin
contentFiles.emplace_back(mContentFile.filename());
}
mRunner.configure(getData().getDebugProfiles().getRecord(ESM::RefId::stringRefId(profile)).get(), contentFiles, startupInstruction);
mRunner.configure(getData().getDebugProfiles().getRecord(ESM::RefId::stringRefId(profile)).get(), contentFiles,
startupInstruction);
int state = getState();

@ -178,7 +178,7 @@ void CSMDoc::WriteDialogueCollectionStage::perform(int stage, Messages& messages
if ((*iter)->isModified() || (*iter)->mState == CSMWorld::RecordBase::State_Deleted)
{
ESM::DialInfo info = (*iter)->get();
std::string infoIdString = info.mId.getRefIdString();
std::string_view infoIdString = info.mId.getRefIdString();
info.mId = ESM::RefId::stringRefId(infoIdString.substr(infoIdString.find_last_of('#') + 1));
info.mPrev = ESM::RefId::sEmpty;
@ -269,7 +269,8 @@ void CSMDoc::CollectionReferencesStage::perform(int stage, Messages& messages)
// An empty mOriginalCell is meant to indicate that it is the same as
// the current cell. It is possible that a moved ref is moved again.
if ((record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell) != ESM::RefId::stringRefId(stream.str())
if ((record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell)
!= ESM::RefId::stringRefId(stream.str())
&& !interior && record.mState != CSMWorld::RecordBase::State_ModifiedOnly && !record.get().mNew)
indices.push_back(i);
else
@ -316,8 +317,7 @@ void CSMDoc::WriteCellCollectionStage::writeReferences(
ESM::RefId streamId = ESM::RefId::stringRefId(stream.str());
if (refRecord.mNew || refRecord.mRefNum.mIndex == 0
|| (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly
&& refRecord.mCell != streamId))
|| (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly && refRecord.mCell != streamId))
{
refRecord.mRefNum.mIndex = newRefNum++;
}
@ -390,7 +390,8 @@ void CSMDoc::WriteCellCollectionStage::perform(int stage, Messages& messages)
if (refRecord.mNew
|| (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly &&
/// \todo consider worldspace
ESM::RefId::stringRefId(CSMWorld::CellCoordinates( refRecord.getCellIndex()).getId("")) != refRecord.mCell))
ESM::RefId::stringRefId(CSMWorld::CellCoordinates(refRecord.getCellIndex()).getId(""))
!= refRecord.mCell))
++cellRecord.mRefNumCounter;
if (refRecord.mRefNum.mIndex >= newRefNum)

@ -61,6 +61,7 @@ void CSMTools::BodyPartCheckStage::perform(int stage, CSMDoc::Messages& messages
if (bodyPart.mRace.empty())
messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error);
else if (mRaces.searchId(bodyPart.mRace) == -1)
messages.add(id, "Race '" + bodyPart.mRace.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Race '" + bodyPart.mRace.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
}
}

@ -40,7 +40,7 @@ void CSMTools::GmstCheckStage::perform(int stage, CSMDoc::Messages& messages)
const ESM::GameSetting& gmst = record.get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Gmst, gmst.mId);
std::string gmstIdString = gmst.mId.getRefIdString();
const std::string& gmstIdString = gmst.mId.getRefIdString();
// Test for empty string
if (gmst.mValue.getType() == ESM::VT_String && gmst.mValue.getString().empty())
messages.add(id, gmstIdString + " is an empty string", "", CSMDoc::Message::Severity_Warning);

@ -124,12 +124,15 @@ void CSMTools::MagicEffectCheckStage::perform(int stage, CSMDoc::Messages& messa
}
if (!effect.mCastSound.empty() && mSounds.searchId(effect.mCastSound) == -1)
messages.add(
id, "Casting sound '" + effect.mCastSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Casting sound '" + effect.mCastSound.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
if (!effect.mHitSound.empty() && mSounds.searchId(effect.mHitSound) == -1)
messages.add(id, "Hit sound '" + effect.mHitSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Hit sound '" + effect.mHitSound.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
if (!effect.mAreaSound.empty() && mSounds.searchId(effect.mAreaSound) == -1)
messages.add(id, "Area sound '" + effect.mAreaSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Area sound '" + effect.mAreaSound.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
if (!effect.mBoltSound.empty() && mSounds.searchId(effect.mBoltSound) == -1)
messages.add(id, "Bolt sound '" + effect.mBoltSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Bolt sound '" + effect.mBoltSound.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
}

@ -4,9 +4,9 @@
#include <string>
#include <vector>
#include "../doc/stage.hpp"
#include "../world/universalid.hpp"
#include <components/esm/refid.hpp>
#include "../doc/stage.hpp"
namespace CSMDoc
{

@ -190,7 +190,7 @@ void CSMTools::FixLandsAndLandTexturesMergeStage::perform(int stage, CSMDoc::Mes
CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&>(
*mState.mTarget->getData().getTableModel(CSMWorld::UniversalId::Type_LandTextures));
std::string id = mState.mTarget->getData().getLand().getId(stage).getRefIdString();
const std::string& id = mState.mTarget->getData().getLand().getId(stage).getRefIdString();
CSMWorld::TouchLandCommand cmd(landTable, ltexTable, id);
cmd.redo();

@ -32,7 +32,6 @@
#include <components/esm3/loadweap.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/misc/strings/algorithm.hpp>
#include <components/esm/refidhardcoded.hpp>
#include "../prefs/state.hpp"
@ -520,10 +519,11 @@ void CSMTools::ReferenceableCheckStage::creatureCheck(
{
CSMWorld::RefIdData::LocalIndex index = mReferencables.searchId(creature.mOriginal);
if (index.first == -1)
messages.add(
id, "Parent creature '" + creature.mOriginal.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Parent creature '" + creature.mOriginal.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
else if (index.second != CSMWorld::UniversalId::Type_Creature)
messages.add(id, "'" + creature.mOriginal.getRefIdString() + "' is not a creature", "", CSMDoc::Message::Severity_Error);
messages.add(id, "'" + creature.mOriginal.getRefIdString() + "' is not a creature", "",
CSMDoc::Message::Severity_Error);
}
// Check inventory
@ -682,7 +682,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, npc.mId);
// Detect if player is present
if (npc.mId == ESM::sPlayerId) // Happy now, scrawl?
if (npc.mId == "Player") // Happy now, scrawl?
mPlayerPresent = true;
// Skip "Base" records (setting!)
@ -739,23 +739,27 @@ void CSMTools::ReferenceableCheckStage::npcCheck(
if (npc.mClass.empty())
messages.add(id, "Class is missing", "", CSMDoc::Message::Severity_Error);
else if (mClasses.searchId(npc.mClass.getRefIdString()) == -1)
messages.add(id, "Class '" + npc.mClass.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
else if (mClasses.searchId(npc.mClass) == -1)
messages.add(
id, "Class '" + npc.mClass.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (npc.mRace.empty())
messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error);
else if (mRaces.searchId(npc.mRace.getRefIdString()) == -1)
messages.add(id, "Race '" + npc.mRace.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
else if (mRaces.searchId(npc.mRace) == -1)
messages.add(
id, "Race '" + npc.mRace.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (!npc.mFaction.empty() && mFactions.searchId(npc.mFaction.getRefIdString()) == -1)
messages.add(id, "Faction '" + npc.mFaction.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (!npc.mFaction.empty() && mFactions.searchId(npc.mFaction) == -1)
messages.add(
id, "Faction '" + npc.mFaction.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (npc.mHead.empty())
messages.add(id, "Head is missing", "", CSMDoc::Message::Severity_Error);
else
{
if (mBodyParts.searchId(npc.mHead.getRefIdString()) == -1)
messages.add(id, "Head body part '" + npc.mHead.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (mBodyParts.searchId(npc.mHead) == -1)
messages.add(id, "Head body part '" + npc.mHead.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
/// \todo Check gender, race and other body parts stuff validity for the specific NPC
}
@ -763,8 +767,9 @@ void CSMTools::ReferenceableCheckStage::npcCheck(
messages.add(id, "Hair is missing", "", CSMDoc::Message::Severity_Error);
else
{
if (mBodyParts.searchId(npc.mHair.getRefIdString()) == -1)
messages.add(id, "Hair body part '" + npc.mHair.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (mBodyParts.searchId(npc.mHair) == -1)
messages.add(id, "Hair body part '" + npc.mHair.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
/// \todo Check gender, race and other body part stuff validity for the specific NPC
}
@ -785,22 +790,22 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(
return;
const ESM::Weapon& weapon = (dynamic_cast<const CSMWorld::Record<ESM::Weapon>&>(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Weapon, weapon.mId);
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Weapon, weapon.mId);
// TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present
if ( // THOSE ARE HARDCODED!
!(weapon.mId == ESM::RefId::stringRefId("VFX_Hands") || weapon.mId == ESM::RefId::stringRefId("VFX_Absorb") || weapon.mId == ESM::RefId::stringRefId("VFX_Reflect")
|| weapon.mId == ESM::RefId::stringRefId("VFX_DefaultBolt") ||
!(weapon.mId == "VFX_Hands" || weapon.mId == "VFX_Absorb" || weapon.mId == "VFX_Reflect"
|| weapon.mId == "VFX_DefaultBolt" ||
// TODO I don't know how to get full list of effects :/
// DANGER!, ACHTUNG! FIXME! The following is the list of the magical bolts, valid for Morrowind.esm. However
// those are not hardcoded.
weapon.mId == ESM::RefId::stringRefId("magic_bolt") || weapon.mId == ESM::RefId::stringRefId("shock_bolt") || weapon.mId == ESM::RefId::stringRefId("shield_bolt")
|| weapon.mId == ESM::RefId::stringRefId("VFX_DestructBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_PoisonBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_RestoreBolt")
|| weapon.mId == ESM::RefId::stringRefId("VFX_AlterationBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_ConjureBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_FrostBolt")
|| weapon.mId == ESM::RefId::stringRefId("VFX_MysticismBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_IllusionBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple2")
|| weapon.mId == ESM::RefId::stringRefId("VFX_Multiple3") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple4") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple5")
|| weapon.mId == ESM::RefId::stringRefId("VFX_Multiple6") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple7") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple8")
|| weapon.mId == ESM::RefId::stringRefId("VFX_Multiple9")))
weapon.mId == "magic_bolt" || weapon.mId == "shock_bolt" || weapon.mId == "shield_bolt"
|| weapon.mId == "VFX_DestructBolt" || weapon.mId == "VFX_PoisonBolt" || weapon.mId == "VFX_RestoreBolt"
|| weapon.mId == "VFX_AlterationBolt" || weapon.mId == "VFX_ConjureBolt" || weapon.mId == "VFX_FrostBolt"
|| weapon.mId == "VFX_MysticismBolt" || weapon.mId == "VFX_IllusionBolt" || weapon.mId == "VFX_Multiple2"
|| weapon.mId == "VFX_Multiple3" || weapon.mId == "VFX_Multiple4" || weapon.mId == "VFX_Multiple5"
|| weapon.mId == "VFX_Multiple6" || weapon.mId == "VFX_Multiple7" || weapon.mId == "VFX_Multiple8"
|| weapon.mId == "VFX_Multiple9"))
{
inventoryItemCheck<ESM::Weapon>(weapon, messages, id.toString(), true);
@ -1037,8 +1042,8 @@ void CSMTools::ReferenceableCheckStage::listCheck(
for (unsigned i = 0; i < someList.mList.size(); ++i)
{
if (mReferencables.searchId(someList.mList[i].mId).first == -1)
messages.add(
someID, "Object '" + someList.mList[i].mId.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(someID, "Object '" + someList.mList[i].mId.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
if (someList.mList[i].mLevel < 1)
messages.add(someID, "Level of item '" + someList.mList[i].mId.getRefIdString() + "' is non-positive", "",
@ -1053,7 +1058,7 @@ void CSMTools::ReferenceableCheckStage::scriptCheck(
if (!someTool.mScript.empty())
{
if (mScripts.searchId(someTool.mScript) == -1)
messages.add(
someID, "Script '" + someTool.mScript.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(someID, "Script '" + someTool.mScript.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
}
}

@ -50,8 +50,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message
{
// Check for non existing referenced object
if (mObjects.searchId(cellRef.mRefID) == -1)
messages.add(
id, "Instance of a non-existent object '" + cellRef.mRefID.getRefIdString() + "'", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Instance of a non-existent object '" + cellRef.mRefID.getRefIdString() + "'", "",
CSMDoc::Message::Severity_Error);
else
{
// Check if reference charge is valid for it's proper referenced type
@ -64,13 +64,14 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message
// If object have owner, check if that owner reference is valid
if (!cellRef.mOwner.empty() && mObjects.searchId(cellRef.mOwner) == -1)
messages.add(id, "Owner object '" + cellRef.mOwner.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Owner object '" + cellRef.mOwner.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
// If object have creature soul trapped, check if that creature reference is valid
if (!cellRef.mSoul.empty())
if (mObjects.searchId(cellRef.mSoul) == -1)
messages.add(
id, "Trapped soul object '" + cellRef.mSoul.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Trapped soul object '" + cellRef.mSoul.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
if (cellRef.mFaction.empty())
{
@ -80,7 +81,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message
else
{
if (mFactions.searchId(cellRef.mFaction) == -1)
messages.add(id, "Faction '" + cellRef.mFaction.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Faction '" + cellRef.mFaction.getRefIdString() + "' does not exist", "",
CSMDoc::Message::Severity_Error);
else if (cellRef.mFactionRank < -1)
messages.add(id, "Invalid faction rank", "", CSMDoc::Message::Severity_Error);
}

@ -49,12 +49,13 @@ void CSMTools::SoundGenCheckStage::perform(int stage, CSMDoc::Messages& messages
CSMWorld::RefIdData::LocalIndex creatureIndex = mObjects.getDataSet().searchId(soundGen.mCreature);
if (creatureIndex.first == -1)
{
messages.add(
id, "Creature '" + soundGen.mCreature.getRefIdString() + "' doesn't exist", "", CSMDoc::Message::Severity_Error);
messages.add(id, "Creature '" + soundGen.mCreature.getRefIdString() + "' doesn't exist", "",
CSMDoc::Message::Severity_Error);
}
else if (creatureIndex.second != CSMWorld::UniversalId::Type_Creature)
{
messages.add(id, "'" + soundGen.mCreature.getRefIdString() + "' is not a creature", "", CSMDoc::Message::Severity_Error);
messages.add(id, "'" + soundGen.mCreature.getRefIdString() + "' is not a creature", "",
CSMDoc::Message::Severity_Error);
}
}
@ -64,6 +65,7 @@ void CSMTools::SoundGenCheckStage::perform(int stage, CSMDoc::Messages& messages
}
else if (mSounds.searchId(soundGen.mSound) == -1)
{
messages.add(id, "Sound '" + soundGen.mSound.getRefIdString() + "' doesn't exist", "", CSMDoc::Message::Severity_Error);
messages.add(
id, "Sound '" + soundGen.mSound.getRefIdString() + "' doesn't exist", "", CSMDoc::Message::Severity_Error);
}
}

@ -40,7 +40,8 @@ void CSMTools::StartScriptCheckStage::perform(int stage, CSMDoc::Messages& messa
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_StartScript, scriptId);
if (mScripts.searchId(scriptId) == -1)
messages.add(id, "Start script " + scriptId.getRefIdString() + " does not exist", "", CSMDoc::Message::Severity_Error);
messages.add(
id, "Start script " + scriptId.getRefIdString() + " does not exist", "", CSMDoc::Message::Severity_Error);
}
int CSMTools::StartScriptCheckStage::setup()

@ -183,7 +183,7 @@ void CSMTools::TopicInfoCheckStage::perform(int stage, CSMDoc::Messages& message
bool CSMTools::TopicInfoCheckStage::verifyActor(
const ESM::RefId& actor, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages)
{
std::string actorString = actor.getRefIdString();
const std::string& actorString = actor.getRefIdString();
CSMWorld::RefIdData::LocalIndex index = mReferencables.searchId(actor);
if (index.first == -1)
@ -193,7 +193,8 @@ bool CSMTools::TopicInfoCheckStage::verifyActor(
}
else if (mReferencables.getRecord(index).isDeleted())
{
messages.add(id, "Deleted actor '" + actorString + "' is being referenced", "", CSMDoc::Message::Severity_Error);
messages.add(
id, "Deleted actor '" + actorString + "' is being referenced", "", CSMDoc::Message::Severity_Error);
return false;
}
else if (index.second != CSMWorld::UniversalId::Type_Npc && index.second != CSMWorld::UniversalId::Type_Creature)
@ -212,7 +213,7 @@ bool CSMTools::TopicInfoCheckStage::verifyActor(
bool CSMTools::TopicInfoCheckStage::verifyCell(
const ESM::RefId& cell, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages)
{
std::string cellName = cell.getRefIdString();
const std::string& cellName = cell.getRefIdString();
if (mCellNames.find(cellName) == mCellNames.end())
{
messages.add(id, "Cell '" + cellName + "' does not exist", "", CSMDoc::Message::Severity_Error);
@ -260,7 +261,7 @@ bool CSMTools::TopicInfoCheckStage::verifyFactionRank(
bool CSMTools::TopicInfoCheckStage::verifyItem(
const ESM::RefId& item, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages)
{
std::string idString = item.getRefIdString();
const std::string& idString = item.getRefIdString();
CSMWorld::RefIdData::LocalIndex index = mReferencables.searchId(item);
if (index.first == -1)
@ -440,7 +441,9 @@ bool CSMTools::TopicInfoCheckStage::verifyId(const ESM::RefId& name, const CSMWo
}
else if (collection.getRecord(index).isDeleted())
{
messages.add(id, "Deleted " + std::string(T::getRecordType()) + " record '" + name.getRefIdString() + "' is being referenced",
messages.add(id,
"Deleted " + std::string(T::getRecordType()) + " record '" + name.getRefIdString()
+ "' is being referenced",
"", CSMDoc::Message::Severity_Error);
return false;
}

@ -521,7 +521,8 @@ namespace CSMWorld
}
auto& part = partRecord.get();
if (part.mRace == id && part.mData.mType == ESM::BodyPart::MT_Skin && !is1stPersonPart(part.mId.getRefIdString()))
if (part.mRace == id && part.mData.mType == ESM::BodyPart::MT_Skin
&& !is1stPersonPart(part.mId.getRefIdString()))
{
auto type = (ESM::BodyPart::MeshPart)part.mData.mPart;
bool female = part.mData.mFlags & ESM::BodyPart::BPF_Female;

@ -68,7 +68,7 @@ namespace CSMWorld
template <>
inline const ESM::RefId IdAccessor<Land>::getId(const Land& record) const
{
return ESM::RefId::stringRefId( Land::createUniqueRecordId(record.mX, record.mY));
return ESM::RefId::stringRefId(Land::createUniqueRecordId(record.mX, record.mY));
}
template <>
@ -554,7 +554,7 @@ namespace CSMWorld
throw std::runtime_error("index out of range");
std::unique_ptr<Record<ESXRecordT>> record2(static_cast<Record<ESXRecordT>*>(record.release()));
std::string id =IdAccessorT().getId(record2->get()).getRefIdString();
std::string id = IdAccessorT().getId(record2->get()).getRefIdString();
if (index == size)
mRecords.push_back(std::move(record2));
@ -576,8 +576,7 @@ namespace CSMWorld
template <typename ESXRecordT, typename IdAccessorT>
void Collection<ESXRecordT, IdAccessorT>::setRecord(int index, std::unique_ptr<Record<ESXRecordT>> record)
{
if (IdAccessorT().getId(mRecords.at(index)->get())
!= IdAccessorT().getId(record->get()))
if (IdAccessorT().getId(mRecords.at(index)->get()) != IdAccessorT().getId(record->get()))
throw std::runtime_error("attempt to change the ID of a record");
mRecords.at(index) = std::move(record);

@ -83,8 +83,7 @@ namespace CSMWorld
= 0;
///< If the record type does not match, an exception is thrown.
virtual void cloneRecord(
const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type)
virtual void cloneRecord(const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type)
= 0;
virtual bool touchRecord(const ESM::RefId& id) = 0;

@ -1466,7 +1466,7 @@ namespace CSMWorld
{
ESXRecordT record2 = record.get();
record2.mRace = ESM::RefId::stringRefId( data.toString().toUtf8().constData());
record2.mRace = ESM::RefId::stringRefId(data.toString().toUtf8().constData());
record.setModified(record2);
}

@ -290,8 +290,7 @@ void CSMWorld::CommandDispatcher::executeExtendedDelete()
if (record.mState == RecordBase::State_Deleted)
continue;
if (!std::binary_search(
mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString()))
if (!std::binary_search(mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString()))
continue;
macro.push(new CSMWorld::DeleteCommand(model, record.get().mId.getRefIdString()));
@ -321,8 +320,7 @@ void CSMWorld::CommandDispatcher::executeExtendedRevert()
{
const Record<CellRef>& record = collection.getRecord(i);
if (!std::binary_search(
mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString()))
if (!std::binary_search(mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString()))
continue;
macro.push(new CSMWorld::RevertCommand(model, record.get().mId.getRefIdString()));

@ -1172,7 +1172,8 @@ bool CSMWorld::Data::continueLoading(CSMDoc::Messages& messages)
messages.add(id, "Logic error: cell index out of bounds", "", CSMDoc::Message::Severity_Error);
index = mCells.getSize() - 1;
}
std::string cellId = mCells.getId(index).getRefIdString();;
const std::string& cellId = mCells.getId(index).getRefIdString();
mRefs.load(*mReader, index, mBase, mRefLoadCache[cellId], messages);
break;
}
@ -1241,7 +1242,7 @@ bool CSMWorld::Data::continueLoading(CSMDoc::Messages& messages)
case ESM::REC_DIAL:
{
ESM::Dialogue record;
std::string recordIdString = record.mId.getRefIdString();
const std::string& recordIdString = record.mId.getRefIdString();
bool isDeleted = false;
record.load(*mReader, isDeleted);

@ -370,7 +370,8 @@ CSMWorld::LandTextureIdTable::ImportResults CSMWorld::LandTextureIdTable::import
{
auto& record = static_cast<const Record<LandTexture>&>(idCollection()->getRecord(i));
if (record.isModified())
reverseLookupMap.emplace(Misc::StringUtils::lowerCase(record.get().mTexture), idCollection()->getId(i).getRefIdString());
reverseLookupMap.emplace(
Misc::StringUtils::lowerCase(record.get().mTexture), idCollection()->getId(i).getRefIdString());
}
for (const std::string& id : ids)

@ -342,7 +342,8 @@ void CSMWorld::InfoCollection::appendBlankRecord(const ESM::RefId& id, Universal
record2->get().mId = id;
insertRecord(std::move(record2), getInsertIndex(id.getRefIdString(), type, nullptr), type); // call InfoCollection::insertRecord()
insertRecord(std::move(record2), getInsertIndex(id.getRefIdString(), type, nullptr),
type); // call InfoCollection::insertRecord()
}
int CSMWorld::InfoCollection::searchId(std::string_view id) const
@ -357,7 +358,8 @@ int CSMWorld::InfoCollection::searchId(std::string_view id) const
void CSMWorld::InfoCollection::appendRecord(std::unique_ptr<RecordBase> record, UniversalId::Type type)
{
int index = getInsertIndex(static_cast<Record<Info>*>(record.get())->get().mId.getRefIdString(), type, record.get());
int index
= getInsertIndex(static_cast<Record<Info>*>(record.get())->get().mId.getRefIdString(), type, record.get());
insertRecord(std::move(record), index, type);
}

@ -1,8 +1,8 @@
#ifndef CSM_WOLRD_METADATA_H
#define CSM_WOLRD_METADATA_H
#include <string>
#include <components/esm/refid.hpp>
#include <string>
namespace ESM
{

@ -346,7 +346,8 @@ namespace CSMWorld
case 0:
{
reactions.erase(iter);
reactions.insert(std::make_pair(ESM::RefId::stringRefId(value.toString().toUtf8().constData()), reaction));
reactions.insert(
std::make_pair(ESM::RefId::stringRefId(value.toString().toUtf8().constData()), reaction));
break;
}
case 1:

@ -3,8 +3,8 @@
#include <string>
#include <components/esm3/loadpgrd.hpp>
#include <components/esm/refid.hpp>
#include <components/esm3/loadpgrd.hpp>
namespace ESM
{

@ -87,7 +87,8 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1])
{
ESM::RefId indexCell = ref.mCell;
ref.mCell = ESM::RefId::stringRefId("#" + std::to_string(mref.mTarget[0]) + " " + std::to_string(mref.mTarget[1]));
ref.mCell = ESM::RefId::stringRefId(
"#" + std::to_string(mref.mTarget[0]) + " " + std::to_string(mref.mTarget[1]));
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Cell, mCells.getId(cellIndex));
messages.add(id, "The position of the moved reference " + ref.mRefID.getRefIdString() + " (cell " + indexCell.getRefIdString() + ")"
@ -118,7 +119,8 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
messages.add(id,
"Attempt to move a non-existent reference - RefNum index " + std::to_string(ref.mRefNum.mIndex)
+ ", refID " + ref.mRefID.getRefIdString() + ", content file index " + std::to_string(ref.mRefNum.mContentFile),
+ ", refID " + ref.mRefID.getRefIdString() + ", content file index "
+ std::to_string(ref.mRefNum.mContentFile),
/*hint*/ "", CSMDoc::Message::Severity_Warning);
continue;
}
@ -148,7 +150,8 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
messages.add(id,
"Attempt to delete a non-existent reference - RefNum index " + std::to_string(ref.mRefNum.mIndex)
+ ", refID " + ref.mRefID.getRefIdString() + ", content file index " + std::to_string(ref.mRefNum.mContentFile),
+ ", refID " + ref.mRefID.getRefIdString() + ", content file index "
+ std::to_string(ref.mRefNum.mContentFile),
/*hint*/ "", CSMDoc::Message::Severity_Warning);
continue;
}

@ -67,8 +67,7 @@ namespace CSMWorld
virtual void appendBlankRecord(const std::string& id, UniversalId::Type type = UniversalId::Type_None);
virtual void appendBlankRecord(const ESM::RefId& id, UniversalId::Type type = UniversalId::Type_None);
virtual void cloneRecord(
const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type);
virtual void cloneRecord(const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type);
virtual int searchId(std::string_view id) const;
virtual int searchId(const ESM::RefId& id) const;

@ -1,8 +1,9 @@
#ifndef CSM_WOLRD_REFIDADAPTER_H
#define CSM_WOLRD_REFIDADAPTER_H
#include <string>
#include <components/esm/refid.hpp>
#include <string>
#include <vector>
/*! \brief
* Adapters acts as indirection layer, abstracting details of the record types (in the wrappers) from the higher levels

@ -253,8 +253,7 @@ void CSMWorld::RefIdData::erase(const LocalIndex& index, int count)
for (int i = index.first; i < index.first + count; ++i)
{
auto result
= mIndex.find(iter->second->getId(i));
auto result = mIndex.find(iter->second->getId(i));
if (result != mIndex.end())
mIndex.erase(result);
@ -265,8 +264,7 @@ void CSMWorld::RefIdData::erase(const LocalIndex& index, int count)
int recordCount = iter->second->getSize();
while (recordIndex < recordCount)
{
auto recordIndexFound
= mIndex.find(iter->second->getId(recordIndex));
auto recordIndexFound = mIndex.find(iter->second->getId(recordIndex));
if (recordIndexFound != mIndex.end())
{
recordIndexFound->second.first -= count;

@ -185,8 +185,7 @@ void CSMWorld::RegionMap::updateRegions(const std::vector<ESM::RefId>& regions)
for (std::map<CellCoordinates, CellDescription>::const_iterator iter(mMap.begin()); iter != mMap.end(); ++iter)
{
if (!iter->second.mRegion.empty()
&& std::find(regions2.begin(), regions2.end(),iter->second.mRegion)
!= regions2.end())
&& std::find(regions2.begin(), regions2.end(), iter->second.mRegion) != regions2.end())
{
QModelIndex index = getIndex(iter->first);
@ -333,8 +332,7 @@ QVariant CSMWorld::RegionMap::data(const QModelIndex& index, int role) const
if (cell->second.mDeleted)
return QBrush(Qt::red, Qt::DiagCrossPattern);
auto iter
= mColours.find(cell->second.mRegion);
auto iter = mColours.find(cell->second.mRegion);
if (iter != mColours.end())
return QBrush(QColor(iter->second & 0xff, (iter->second >> 8) & 0xff, (iter->second >> 16) & 0xff));
@ -370,8 +368,7 @@ QVariant CSMWorld::RegionMap::data(const QModelIndex& index, int role) const
{
stream << "<br>";
auto iter
= mColours.find(cell->second.mRegion);
auto iter = mColours.find(cell->second.mRegion);
if (iter != mColours.end())
stream << cell->second.mRegion;

@ -11,6 +11,7 @@
#include <QVariant>
#include "cellcoordinates.hpp"
#include <components/esm/refid.hpp>
class QObject;

@ -108,7 +108,7 @@ bool CSMWorld::ScriptContext::isId(const ESM::RefId& name) const
if (!mIdsUpdated)
{
mIds = mData.getIds();
std::sort(mIds.begin(), mIds.end());
mIdsUpdated = true;

@ -161,7 +161,6 @@ namespace CSMWorld
UniversalId(Type type, const ESM::RefId& id);
UniversalId(Type type, int index);
///< Using a type for a non-index-argument UniversalId will throw an exception.

@ -96,13 +96,12 @@ bool CSVRender::Cell::addObjects(int start, int end)
for (int i = start; i <= end; ++i)
{
auto cellId = collection.getRecord(i).get().mCell;
std::string cell = cellId.getRefIdString();
CSMWorld::RecordBase::State state = collection.getRecord(i).mState;
if (cellId == mId && state != CSMWorld::RecordBase::State_Deleted)
{
std::string id =collection.getRecord(i).get().mId.getRefIdString();
const std::string& id = collection.getRecord(i).get().mId.getRefIdString();
auto object = std::make_unique<Object>(mData, mCellNode, id, false);
@ -269,8 +268,8 @@ bool CSVRender::Cell::referenceDataChanged(const QModelIndex& topLeft, const QMo
for (int i = topLeft.row(); i <= bottomRight.row(); ++i)
{
auto cell =ESM::RefId::stringRefId(
references.data(references.index(i, cellColumn)).toString().toUtf8().constData());
auto cell
= ESM::RefId::stringRefId(references.data(references.index(i, cellColumn)).toString().toUtf8().constData());
if (cell == mId)
{

@ -10,8 +10,8 @@
#include <osg/ref_ptr>
#include "../../model/world/cellcoordinates.hpp"
#include <components/esm/refid.hpp>
#include "instancedragmodes.hpp"
#include <components/esm/refid.hpp>
class QModelIndex;

@ -597,7 +597,7 @@ bool CSVRender::Object::referenceDataChanged(const QModelIndex& topLeft, const Q
const CSMWorld::RefCollection& references = mData.getReferences();
int index = references.searchId(mReferenceId.getRefIdString());
int index = references.searchId(mReferenceId);
if (index != -1 && index >= topLeft.row() && index <= bottomRight.row())
{
@ -607,7 +607,8 @@ bool CSVRender::Object::referenceDataChanged(const QModelIndex& topLeft, const Q
if (columnIndex >= topLeft.column() && columnIndex <= bottomRight.row())
{
mReferenceableId = ESM::RefId::stringRefId(references.getData(index, columnIndex).toString().toUtf8().constData());
mReferenceableId
= ESM::RefId::stringRefId(references.getData(index, columnIndex).toString().toUtf8().constData());
update();
updateMarker();

@ -23,7 +23,6 @@
#include <components/esm3/loadpgrd.hpp>
#include <components/misc/constants.hpp>
#include <components/esm/refid.hpp>
#include <osg/Camera>
#include <osg/Vec3f>

@ -401,7 +401,8 @@ namespace CSVRender
for (std::vector<unsigned short>::iterator row = mSelected.begin(); row != mSelected.end(); ++row)
{
commands.push(new CSMWorld::DeleteNestedCommand(*model, mId.getRefIdString(), static_cast<int>(*row), parentColumn));
commands.push(new CSMWorld::DeleteNestedCommand(
*model, mId.getRefIdString(), static_cast<int>(*row), parentColumn));
}
// Fix/remove edges

@ -11,8 +11,8 @@
#include "../../model/world/cellcoordinates.hpp"
#include "../../model/world/subcellcollection.hpp"
#include <components/esm/refid.hpp>
#include "tagbase.hpp"
#include <components/esm/refid.hpp>
namespace osg
{

@ -338,8 +338,11 @@ int CSVRender::TerrainSelection::calculateLandHeight(int x, int y) // global ver
{
CSMDoc::Document& document = mWorldspaceWidget->getDocument();
std::string cellId = CSMWorld::CellCoordinates::generateId(cellX, cellY);
const ESM::Land::LandData* landData
= document.getData().getLand().getRecord(ESM::RefId::stringRefId(cellId)).get().getLandData(ESM::Land::DATA_VHGT);
const ESM::Land::LandData* landData = document.getData()
.getLand()
.getRecord(ESM::RefId::stringRefId(cellId))
.get()
.getLandData(ESM::Land::DATA_VHGT);
return landData->mHeights[localY * ESM::Land::LAND_SIZE + localX];
}

@ -24,7 +24,11 @@ CSVWorld::PreviewSubView::PreviewSubView(const CSMWorld::UniversalId& id, CSMDoc
if (document.getData().getReferenceables().searchId(id.getId()) == -1)
{
std::string referenceableId = document.getData().getReferences().getRecord(ESM::RefId::stringRefId(id.getId())).get().mRefID.getRefIdString();
std::string referenceableId = document.getData()
.getReferences()
.getRecord(ESM::RefId::stringRefId(id.getId()))
.get()
.mRefID.getRefIdString();
referenceableIdChanged(referenceableId);

@ -3,13 +3,13 @@
#include <sstream>
#include <utility>
#include <apps/opencs/model/prefs/category.hpp>
#include <apps/opencs/model/prefs/setting.hpp>
#include <apps/opencs/model/world/scriptcontext.hpp>
#include <components/compiler/extensions0.hpp>
#include <components/compiler/scanner.hpp>
#include <components/compiler/tokenloc.hpp>
#include <components/esm/refid.hpp>
#include "../../model/prefs/category.hpp"
#include "../../model/prefs/setting.hpp"
class QTextDocument;

@ -69,8 +69,7 @@ namespace MWBase
virtual void setPlayerName(const std::string& name) = 0;
///< Set player name.
virtual void setPlayerRace(const ESM::RefId& id, bool male, const ESM::RefId& head, const ESM::RefId& hair)
= 0;
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 ESM::RefId& id) = 0;

@ -168,8 +168,7 @@ namespace MWClass
for (auto sound = store.get<ESM::SoundGenerator>().begin(); sound != store.get<ESM::SoundGenerator>().end();
++sound)
{
if (type == sound->mType && !sound->mCreature.empty()
&& (*creatureId == sound->mCreature))
if (type == sound->mType && !sound->mCreature.empty() && (*creatureId == sound->mCreature))
sounds.push_back(&*sound);
if (type == sound->mType && sound->mCreature.empty())
fallbacksounds.push_back(&*sound);

@ -152,9 +152,6 @@ namespace MWClass
return action;
}
static const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedChest");
static 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);
@ -182,7 +179,8 @@ namespace MWClass
if (isTrapped)
{
ptr.getCellRef().setTrap(ESM::RefId::sEmpty);
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f);
MWBase::Environment::get().getSoundManager()->playSound3D(
ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f);
isTrapped = false;
}
}
@ -203,14 +201,14 @@ namespace MWClass
// Activate trap
std::unique_ptr<MWWorld::Action> action
= std::make_unique<MWWorld::ActionTrap>(ptr.getCellRef().getTrap(), ptr);
action->setSound(trapActivationSound);
action->setSound(ESM::RefId::stringRefId("Disarm Trap Fail"));
return action;
}
}
else
{
std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>(std::string_view{}, ptr);
action->setSound(lockedSound);
action->setSound(ESM::RefId::stringRefId("LockedChest"));
return action;
}
}
@ -266,7 +264,7 @@ namespace MWClass
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
if (ptr.getCellRef().getRefId() == ESM::RefId::stringRefId("stolen_goods"))
if (ptr.getCellRef().getRefId() == "stolen_goods")
text += "\nYou can not use evidence chests";
}

@ -9,7 +9,6 @@
#include <components/esm3/loadsoun.hpp>
#include <components/misc/rng.hpp>
#include <components/settings/settings.hpp>
#include <components/esm/refidhardcoded.hpp>
#include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/aisetting.hpp"
@ -412,7 +411,8 @@ namespace MWClass
{
// Missed
if (!attacker.isEmpty() && attacker == MWMechanics::getPlayer())
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("miss"), 1.0f, 1.0f);
MWBase::Environment::get().getSoundManager()->playSound3D(
ptr, ESM::RefId::stringRefId("miss"), 1.0f, 1.0f);
return;
}
@ -449,7 +449,8 @@ namespace MWClass
MWBase::Environment::get().getWorld()->spawnBloodEffect(ptr, hitPosition);
}
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::sHealthDamageSoundId, 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);
@ -642,15 +643,13 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature>* ref = ptr.get<ESM::Creature>();
const ESM::RefId& ourId
= (ref->mBase->mOriginal.empty()) ? ptr.getCellRef().getRefId() : ref->mBase->mOriginal;
const ESM::RefId& ourId = (ref->mBase->mOriginal.empty()) ? ptr.getCellRef().getRefId() : ref->mBase->mOriginal;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
auto sound = store.get<ESM::SoundGenerator>().begin();
while (sound != store.get<ESM::SoundGenerator>().end())
{
if (type == sound->mType && !sound->mCreature.empty()
&& ourId == sound->mCreature)
if (type == sound->mType && !sound->mCreature.empty() && ourId == sound->mCreature)
sounds.push_back(&*sound);
if (type == sound->mType && sound->mCreature.empty())
fallbacksounds.push_back(&*sound);
@ -673,8 +672,7 @@ namespace MWClass
sound = store.get<ESM::SoundGenerator>().begin();
while (sound != store.get<ESM::SoundGenerator>().end())
{
if (type == sound->mType && !sound->mCreature.empty()
&& fallbackId == sound->mCreature)
if (type == sound->mType && !sound->mCreature.empty() && fallbackId == sound->mCreature)
sounds.push_back(&*sound);
++sound;
}

@ -113,8 +113,7 @@ namespace MWClass
const ESM::RefId& openSound = ref->mBase->mOpenSound;
const ESM::RefId& closeSound = ref->mBase->mCloseSound;
static const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedDoor");
static const ESM::RefId trapActivationSound = ESM::RefId::stringRefId("Disarm Trap Fail");
const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedDoor");
// 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.
@ -168,7 +167,8 @@ namespace MWClass
if (isTrapped)
{
ptr.getCellRef().setTrap(ESM::RefId::sEmpty);
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f);
MWBase::Environment::get().getSoundManager()->playSound3D(
ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f);
isTrapped = false;
}
}
@ -180,7 +180,7 @@ namespace MWClass
// Trap activation
std::unique_ptr<MWWorld::Action> action
= std::make_unique<MWWorld::ActionTrap>(ptr.getCellRef().getTrap(), ptr);
action->setSound(trapActivationSound);
action->setSound(ESM::RefId::stringRefId("Disarm Trap Fail"));
return action;
}

@ -5,7 +5,6 @@
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadmisc.hpp>
#include <components/esm3/loadnpc.hpp>
#include <components/esm/refidhardcoded.hpp>
#include <components/settings/settings.hpp>
@ -36,11 +35,9 @@ namespace MWClass
bool Miscellaneous::isGold(const MWWorld::ConstPtr& ptr) const
{
return ptr.getCellRef().getRefId() == ESM::sGoldId001
|| ptr.getCellRef().getRefId() == ESM::sGoldId005
|| ptr.getCellRef().getRefId() == ESM::sGoldId010
|| ptr.getCellRef().getRefId() == ESM::sGoldId025
|| ptr.getCellRef().getRefId() == ESM::sGoldId100;
return ptr.getCellRef().getRefId() == "gold_001" || ptr.getCellRef().getRefId() == "gold_005"
|| ptr.getCellRef().getRefId() == "gold_010" || ptr.getCellRef().getRefId() == "gold_025"
|| ptr.getCellRef().getRefId() == "gold_100";
}
void Miscellaneous::insertObjectRendering(
@ -98,7 +95,7 @@ namespace MWClass
float soulValue = 0.0001 * pow(soul, 3) + 2 * soul;
// for Azura's star add the unfilled value
if (ptr.getCellRef().getRefId() == ESM::RefId::stringRefId("Misc_SoulGem_Azura"))
if (ptr.getCellRef().getRefId() == "Misc_SoulGem_Azura")
value += soulValue;
else
value = soulValue;
@ -185,19 +182,19 @@ namespace MWClass
{
int goldAmount = getValue(ptr) * count;
const ESM::RefId* base = &ESM::sGoldId001;
std::string_view base = "gold_001";
if (goldAmount >= 100)
base = &ESM::sGoldId100;
base = "gold_100";
else if (goldAmount >= 25)
base = &ESM::sGoldId025;
base = "gold_025";
else if (goldAmount >= 10)
base = &ESM::sGoldId010;
base = "gold_010";
else if (goldAmount >= 5)
base = &ESM::sGoldId005;
base = "gold_005";
// 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);

@ -9,7 +9,6 @@
#include <components/misc/rng.hpp>
#include <components/debug/debuglog.hpp>
#include <components/esm/refidhardcoded.hpp>
#include <components/esm3/loadbody.hpp>
#include <components/esm3/loadclas.hpp>
#include <components/esm3/loadmgef.hpp>
@ -688,7 +687,8 @@ namespace MWClass
{
damage *= store.find("fCombatCriticalStrikeMult")->mValue.getFloat();
MWBase::Environment::get().getWindowManager()->messageBox("#{sTargetCriticalStrike}");
MWBase::Environment::get().getSoundManager()->playSound3D(victim, ESM::RefId::stringRefId("critical damage"), 1.0f, 1.0f);
MWBase::Environment::get().getSoundManager()->playSound3D(
victim, ESM::RefId::stringRefId("critical damage"), 1.0f, 1.0f);
}
}
@ -893,7 +893,7 @@ namespace MWClass
if (damage > 0.0f)
{
sndMgr->playSound3D(ptr, ESM::sHealthDamageSoundId, 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())
@ -1303,7 +1303,6 @@ namespace MWClass
static const ESM::RefId footHeavyLeft = ESM::RefId::stringRefId("footHeavyLeft");
static const ESM::RefId footHeavyRight = ESM::RefId::stringRefId("footHeavyRight");
const ESM::RefId* sound = nullptr;
if (name == "left" || name == "right")
{
MWBase::World* world = MWBase::Environment::get().getWorld();
@ -1311,9 +1310,9 @@ namespace MWClass
return ESM::RefId::sEmpty;
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
if (world->isSwimming(ptr))
sound = (name == "left") ? &swimLeft : &swimRight;
return (name == "left") ? swimLeft : swimRight;
if (world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr))
sound = (name == "left") ? &footWaterLeft : &footWaterRight;
return (name == "left") ? footWaterLeft : footWaterRight;
if (world->isOnGround(ptr))
{
if (getNpcStats(ptr).isWerewolf()
@ -1328,16 +1327,19 @@ namespace MWClass
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)
sound = (name == "left") ? &footBareLeft : &footBareRight;
return (name == "left") ? footBareLeft : footBareRight;
switch (boots->getClass().getEquipmentSkill(*boots))
{
case ESM::Skill::LightArmor:
sound = (name == "left") ? &footLightLeft : &footLightRight; break;
return (name == "left") ? footLightLeft : footLightRight;
break;
case ESM::Skill::MediumArmor:
sound = (name == "left") ? &footMediumLeft : &footMediumRight; break;
return (name == "left") ? footMediumLeft : footMediumRight;
break;
case ESM::Skill::HeavyArmor:
sound = (name == "left") ? &footHeavyLeft : &footHeavyRight; break;
return (name == "left") ? footHeavyLeft : footHeavyRight;
break;
}
}
return ESM::RefId::sEmpty;
@ -1347,9 +1349,9 @@ namespace MWClass
if (name == "land")
return ESM::RefId::sEmpty;
if (name == "swimleft")
sound = &swimLeft;
return swimLeft;
if (name == "swimright")
sound = &swimRight;
return swimRight;
// 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?
@ -1361,12 +1363,7 @@ namespace MWClass
if (name == "scream")
return ESM::RefId::sEmpty;
if(sound == nullptr)
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
else
{
return *sound;
}
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
}
MWWorld::Ptr Npc::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const

@ -316,7 +316,8 @@ namespace MWDialogue
title = topic;
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor);
callback->addResponse(title.getRefIdString(), Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
callback->addResponse(
title.getRefIdString(), Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
if (dialogue.mType == ESM::Dialogue::Topic)
{
@ -327,8 +328,7 @@ namespace MWDialogue
{
if (iter->mId == info->mId)
{
MWBase::Environment::get().getJournal()->addTopic(
topic, info->mId, mActor);
MWBase::Environment::get().getJournal()->addTopic(topic, info->mId, mActor);
break;
}
}
@ -375,7 +375,7 @@ namespace MWDialogue
if (!inJournal(topicId, answer->mId))
{
// Does this dialogue contains some actor-specific answer?
if (answer->mActor == mActor.getCellRef().getRefId())
if (answer->mActor == mActor.getCellRef().getRefId())
topicFlags |= MWBase::DialogueManager::TopicType::Specific;
}
else
@ -501,8 +501,7 @@ namespace MWDialogue
{
if (iter->mId == info->mId)
{
MWBase::Environment::get().getJournal()->addTopic(
mLastTopic, info->mId, mActor);
MWBase::Environment::get().getJournal()->addTopic(mLastTopic, info->mId, mActor);
break;
}
}
@ -739,12 +738,13 @@ namespace MWDialogue
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(faction1);
const ESM::Faction* faction
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction1);
auto it = faction->mReactions.begin();
for (; it != faction->mReactions.end(); ++it)
{
if (it->first == faction2)
if (it->first == faction2)
return it->second;
}
return 0;

@ -1,10 +1,10 @@
#include "filter.hpp"
#include <components/compiler/locals.hpp>
#include <components/esm/refid.hpp>
#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"
@ -84,7 +84,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const
// actor id
if (!info.mActor.empty())
{
if (info.mActor != mActor.getCellRef().getRefId())
if (info.mActor != mActor.getCellRef().getRefId())
return false;
}
else if (isCreature)
@ -101,7 +101,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const
MWWorld::LiveCellRef<ESM::NPC>* cellRef = mActor.get<ESM::NPC>();
if (!(info.mRace == cellRef->mBase->mRace))
if (!(info.mRace == cellRef->mBase->mRace))
return false;
}
@ -113,7 +113,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const
MWWorld::LiveCellRef<ESM::NPC>* cellRef = mActor.get<ESM::NPC>();
if (!(info.mClass == cellRef->mBase->mClass))
if (!(info.mClass == cellRef->mBase->mClass))
return false;
}
@ -131,7 +131,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const
if (isCreature)
return true;
if (!(mActor.getClass().getPrimaryFaction(mActor) == info.mFaction))
if (!(mActor.getClass().getPrimaryFaction(mActor) == info.mFaction))
return false;
// check rank
@ -168,8 +168,7 @@ bool MWDialogue::Filter::testPlayer(const ESM::DialInfo& info) const
// check player faction and rank
if (!info.mPcFaction.empty())
{
std::map<ESM::RefId, int>::const_iterator iter
= stats.getFactionRanks().find(info.mPcFaction);
std::map<ESM::RefId, int>::const_iterator iter = stats.getFactionRanks().find(info.mPcFaction);
if (iter == stats.getFactionRanks().end())
return false;
@ -366,7 +365,8 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
case SelectWrapper::Function_Dead:
return MWBase::Environment::get().getMechanicsManager()->countDeaths(ESM::RefId::stringRefId(select.getName()));
return MWBase::Environment::get().getMechanicsManager()->countDeaths(
ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_Choice:
@ -536,19 +536,19 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
case SelectWrapper::Function_NotId:
return !(mActor.getCellRef().getRefId() == ESM::RefId::stringRefId(select.getName()));
return !(mActor.getCellRef().getRefId() == ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_NotFaction:
return !(mActor.getClass().getPrimaryFaction(mActor) == ESM::RefId::stringRefId(select.getName()));
return !(mActor.getClass().getPrimaryFaction(mActor) == ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_NotClass:
return !(mActor.get<ESM::NPC>()->mBase->mClass == ESM::RefId::stringRefId(select.getName()));
return !(mActor.get<ESM::NPC>()->mBase->mClass == ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_NotRace:
return !(mActor.get<ESM::NPC>()->mBase->mRace == ESM::RefId::stringRefId(select.getName()));
return !(mActor.get<ESM::NPC>()->mBase->mRace == ESM::RefId::stringRefId(select.getName()));
case SelectWrapper::Function_NotCell:
{

@ -49,7 +49,7 @@ namespace MWDialogue
bool hasFactionRankSkillRequirements(const MWWorld::Ptr& actor, const ESM::RefId& factionId, int rank) const;
bool hasFactionRankReputationRequirements(
const MWWorld::Ptr& actor,const ESM::RefId& 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);

@ -39,7 +39,8 @@ namespace MWDialogue
return;
}
throw std::runtime_error("unknown info ID " + mInfoId.getRefIdString() + " for topic " + topic.getRefIdString());
throw std::runtime_error(
"unknown info ID " + mInfoId.getRefIdString() + " for topic " + topic.getRefIdString());
}
Entry::Entry(const ESM::JournalEntry& record)
@ -106,8 +107,8 @@ namespace MWDialogue
{
}
StampedJournalEntry::StampedJournalEntry(
const ESM::RefId& topic, const ESM::RefId& infoId, int day, int month, int dayOfMonth, const MWWorld::Ptr& actor)
StampedJournalEntry::StampedJournalEntry(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 +132,8 @@ namespace MWDialogue
entry.mDayOfMonth = mDayOfMonth;
}
StampedJournalEntry StampedJournalEntry::makeFromQuest(const ESM::RefId& 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");

@ -1,9 +1,9 @@
#ifndef GAME_MWDIALOGUE_JOURNALENTRY_H
#define GAME_MWDIALOGUE_JOURNALENTRY_H
#include <components/esm/refid.hpp>
#include <string>
#include <string_view>
#include <components/esm/refid.hpp>
namespace ESM
{

@ -11,7 +11,8 @@ namespace MWDialogue
Topic::Topic(const ESM::RefId& topic)
: mTopic(topic)
, mName(MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic)->mId.getRefIdString())
, mName(
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic)->mId.getRefIdString())
{
}

@ -96,7 +96,7 @@ namespace MWGui
size_t count = mBirthList->getItemCount();
for (size_t i = 0; i < count; ++i)
{
if (ESM::RefId::stringRefId(*mBirthList->getItemDataAt<std::string>(i)) == birthId)
if (ESM::RefId::stringRefId(*mBirthList->getItemDataAt<std::string>(i)) == birthId)
{
mBirthList->setIndexSelected(i);
break;
@ -134,7 +134,7 @@ namespace MWGui
return;
const ESM::RefId birthId = ESM::RefId::stringRefId(*mBirthList->getItemDataAt<std::string>(_index));
if (mCurrentBirthId == birthId)
if (mCurrentBirthId == birthId)
return;
mCurrentBirthId = birthId;
@ -168,7 +168,7 @@ namespace MWGui
mBirthList->setIndexSelected(index);
mCurrentBirthId = birthsignPair.first;
}
else if (birthsignPair.first == mCurrentBirthId)
else if (birthsignPair.first == mCurrentBirthId)
{
mBirthList->setIndexSelected(index);
}

@ -4,7 +4,6 @@
#include <MyGUI_TextBox.h>
#include <components/esm3/loadbook.hpp>
#include <components/esm/refidhardcoded.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
@ -203,7 +202,7 @@ namespace MWGui
{
if (mCurrentPage > 0)
{
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
--mCurrentPage;

@ -157,7 +157,7 @@ namespace MWGui
size_t count = mClassList->getItemCount();
for (size_t i = 0; i < count; ++i)
{
if (*mClassList->getItemDataAt<ESM::RefId>(i) == classId)
if (*mClassList->getItemDataAt<ESM::RefId>(i) == classId)
{
mClassList->setIndexSelected(i);
break;
@ -195,7 +195,7 @@ namespace MWGui
return;
const ESM::RefId* classId = mClassList->getItemDataAt<ESM::RefId>(_index);
if (mCurrentClassId == *classId)
if (mCurrentClassId == *classId)
return;
mCurrentClassId = *classId;
@ -234,7 +234,7 @@ namespace MWGui
mCurrentClassId = id;
mClassList->setIndexSelected(index);
}
else if (id == mCurrentClassId)
else if (id == mCurrentClassId)
{
mClassList->setIndexSelected(index);
}

@ -8,7 +8,6 @@
#include <components/debug/debuglog.hpp>
#include <components/esm3/loadcrea.hpp>
#include <components/esm/refidhardcoded.hpp>
#include <components/translation/translation.hpp>
#include <components/widgets/box.hpp>
#include <components/widgets/list.hpp>
@ -279,19 +278,19 @@ namespace MWGui
void Choice::activated()
{
MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
eventChoiceActivated(mChoiceId);
}
void Topic::activated()
{
MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
eventTopicActivated(mTopicId);
}
void Goodbye::activated()
{
MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
eventActivated();
}

@ -409,7 +409,7 @@ namespace MWGui
mSpellStatus->setProgressPosition(successChancePercent);
mSpellBox->setUserString("ToolTipType", "Spell");
mSpellBox->setUserString("Spell", spellId.getRefIdString());
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(

@ -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 (lastId == item.getCellRef().getRefId())
if (lastId == item.getCellRef().getRefId())
continue;
lastId = item.getCellRef().getRefId();

@ -58,7 +58,8 @@ namespace MWGui
if (mFadeTimeRemaining <= 0)
{
MWWorld::Ptr player = MWMechanics::getPlayer();
MWBase::Environment::get().getWorld()->teleportToClosestMarker(player, ESM::RefId::stringRefId("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

@ -10,7 +10,6 @@
#include <MyGUI_TextBox.h>
#include <components/misc/strings/algorithm.hpp>
#include <components/esm/refidhardcoded.hpp>
#include <components/widgets/imagebutton.hpp>
#include <components/widgets/list.hpp>
@ -414,7 +413,7 @@ namespace
mOptionsMode = false;
mTopicsMode = false;
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyTopicSelected(const std::string& topicIdString, int id)
@ -424,7 +423,7 @@ namespace
intptr_t topicId = 0; /// \todo get rid of intptr ids
for (MWBase::Journal::TTopicIter i = journal->topicBegin(); i != journal->topicEnd(); ++i)
{
if (i->first == topic)
if (i->first == topic)
topicId = intptr_t(&i->second);
}
@ -446,7 +445,7 @@ namespace
mOptionsMode = false;
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyOptions(MyGUI::Widget* _sender)
@ -474,7 +473,7 @@ namespace
assert(mStates.size() > 1);
popBook();
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyIndexLinkClicked(MWGui::TypesetBook::InteractiveId index)
@ -495,7 +494,7 @@ namespace
list->adjustSize();
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyTopics(MyGUI::Widget* _sender)
@ -510,7 +509,7 @@ namespace
setVisible(ShowAllBTN, false);
setVisible(ShowActiveBTN, false);
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
struct AddNamesToList
@ -567,7 +566,7 @@ namespace
mModel->visitQuestNames(false, setInactive);
}
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
void notifyShowAll(MyGUI::Widget* _sender)
@ -591,7 +590,7 @@ namespace
else
{
setBookMode();
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
}
}
@ -621,7 +620,7 @@ namespace
if (page + 2 < book->pageCount())
{
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
page += 2;
updateShowingPages();
@ -639,7 +638,7 @@ namespace
if (page >= 2)
{
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
page -= 2;
updateShowingPages();

@ -7,7 +7,6 @@
#include <components/settings/settings.hpp>
#include <components/vfs/manager.hpp>
#include <components/widgets/imagebutton.hpp>
#include <components/esm/refidhardcoded.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/statemanager.hpp"
@ -90,7 +89,7 @@ namespace MWGui
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
const std::string& name = *sender->getUserData<std::string>();
winMgr->playSound(ESM::sMenuClickSoundId);
winMgr->playSound(ESM::RefId::stringRefId("Menu Click"));
if (name == "return")
{
winMgr->removeGuiMode(GM_MainMenu);

@ -165,13 +165,13 @@ namespace MWGui
for (unsigned int i = 0; i < mAvailableHeads.size(); ++i)
{
if (mAvailableHeads[i] == proto.mHead)
if (mAvailableHeads[i] == proto.mHead)
mFaceIndex = i;
}
for (unsigned int i = 0; i < mAvailableHairs.size(); ++i)
{
if (mAvailableHairs[i] == proto.mHair)
if (mAvailableHairs[i] == proto.mHair)
mHairIndex = i;
}
@ -191,7 +191,7 @@ namespace MWGui
size_t count = mRaceList->getItemCount();
for (size_t i = 0; i < count; ++i)
{
if (ESM::RefId::stringRefId(*mRaceList->getItemDataAt<std::string>(i)) == raceId)
if (ESM::RefId::stringRefId(*mRaceList->getItemDataAt<std::string>(i)) == raceId)
{
mRaceList->setIndexSelected(i);
break;
@ -293,7 +293,7 @@ namespace MWGui
return;
ESM::RefId raceId = ESM::RefId::stringRefId(*mRaceList->getItemDataAt<std::string>(_index));
if (mCurrentRaceId == raceId)
if (mCurrentRaceId == raceId)
return;
mCurrentRaceId = raceId;
@ -334,7 +334,7 @@ namespace MWGui
&& idString[idString.size() - 2] == 's' && idString[idString.size() - 1] == 't';
if (firstPerson)
continue;
if (bodypart.mRace == mCurrentRaceId)
if (bodypart.mRace == mCurrentRaceId)
out.push_back(bodypart.mId);
}
}
@ -393,7 +393,7 @@ namespace MWGui
for (auto& item : items)
{
mRaceList->addItem(item.second, item.first);
if (item.first == mCurrentRaceId)
if (item.first == mCurrentRaceId)
mRaceList->setIndexSelected(index);
++index;
}

@ -1,9 +1,9 @@
#ifndef MWGUI_RACE_H
#define MWGUI_RACE_H
#include <memory>
#include<components/esm/refid.hpp>
#include "windowbase.hpp"
#include <components/esm/refid.hpp>
#include <memory>
namespace MWRender
{

@ -1,9 +1,9 @@
#ifndef MWGUI_STATS_WINDOW_H
#define MWGUI_STATS_WINDOW_H
#include <components/esm/refid.hpp>
#include "statswatcher.hpp"
#include "windowpinnablebase.hpp"
#include <components/esm/refid.hpp>
namespace MWGui
{

@ -721,7 +721,8 @@ namespace MWGui
if (owner.second == std::numeric_limits<int>::max())
ret += std::string("\nStolen from ") + owner.first.getRefIdString(); // for legacy (ESS) savegames
else
ret += std::string("\nStolen ") + MyGUI::utility::toString(owner.second) + " from " + owner.first.getRefIdString();
ret += std::string("\nStolen ") + MyGUI::utility::toString(owner.second) + " from "
+ owner.first.getRefIdString();
}
ret += getMiscString(cellref.getGlobalVariable(), "Global");

@ -166,7 +166,7 @@ namespace MWGui
if (!mMerchant.isEmpty())
{
MWWorld::Ptr base = item.mBase;
if (base.getCellRef().getRefId() == MWWorld::ContainerStore::sGoldId)
if (base.getCellRef().getRefId() == MWWorld::ContainerStore::sGoldId)
continue;
if (!base.getClass().showsInInventory(base))

@ -92,7 +92,8 @@ namespace MWGui
const std::string& nameString = name.getRefIdString();
toAdd->setUserString("price", std::to_string(price));
toAdd->setCaptionWithReplacing("#{sCell=" + nameString + "} - " + MyGUI::utility::toString(price) + "#{sgp}");
toAdd->setCaptionWithReplacing(
"#{sCell=" + nameString + "} - " + MyGUI::utility::toString(price) + "#{sgp}");
toAdd->setSize(mDestinationsView->getWidth(), lineHeight);
toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel);
toAdd->setUserString("Destination", nameString);

@ -2,8 +2,8 @@
#define MWGUI_WAIT_DIALOG_H
#include "timeadvancer.hpp"
#include <components/esm/refid.hpp>
#include "windowbase.hpp"
#include <components/esm/refid.hpp>
namespace MWGui
{

@ -7,9 +7,9 @@
#include <MyGUI_TextBox.h>
#include <MyGUI_Widget.h>
#include <components/esm/refid.hpp>
#include <components/esm3/effectlist.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/esm/refid.hpp>
namespace MyGUI
{

@ -933,7 +933,7 @@ namespace MWGui
{
mMap->requestMapRender(cell);
std::string name = MWBase::Environment::get().getWorld()->getCellName(cell) ;
std::string name = MWBase::Environment::get().getWorld()->getCellName(cell);
mMap->setCellName(name);
mHud->setCellName(name);

@ -8,7 +8,6 @@
#include <components/debug/debuglog.hpp>
#include <components/files/conversion.hpp>
#include <components/sdlutil/sdlmappings.hpp>
#include <components/esm/refidhardcoded.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp"
@ -207,7 +206,8 @@ namespace MWInput
MyGUI::Button* b
= MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType<MyGUI::Button>(false);
if (b && b->getEnabled())
MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId);
MWBase::Environment::get().getWindowManager()->playSound(
ESM::RefId::stringRefId("Menu Click"));
}
mBindingsManager->setPlayerControlsEnabled(!mousePressSuccess);

@ -6,7 +6,6 @@
#include <components/sdlutil/sdlinputwrapper.hpp>
#include <components/sdlutil/sdlmappings.hpp>
#include <components/esm/refidhardcoded.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp"
@ -167,7 +166,7 @@ namespace MWInput
= MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType<MyGUI::Button>(false);
if (b && b->getEnabled() && id == SDL_BUTTON_LEFT)
{
MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
}
}
MWBase::Environment::get().getWindowManager()->setCursorActive(true);

@ -146,8 +146,8 @@ namespace MWLua
if (esmCell->isExterior())
ai.stack(MWMechanics::AiEscort(refId, gameHoursDuration, dest.x(), dest.y(), dest.z(), false), ptr);
else
ai.stack(MWMechanics::AiEscort(
refId, ESM::RefId::stringRefId(esmCell->mName), gameHoursDuration, dest.x(), dest.y(), dest.z(), false),
ai.stack(MWMechanics::AiEscort(refId, ESM::RefId::stringRefId(esmCell->mName), gameHoursDuration,
dest.x(), dest.y(), dest.z(), false),
ptr);
};
selfAPI["_startAiWander"] = [](SelfObject& self, int distance, float duration) {

@ -27,16 +27,19 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Activator>();
activator["record"] = sol::overload(
[](const Object& obj) -> const ESM::Activator* { return obj.ptr().get<ESM::Activator>()->mBase; },
[store](const std::string& recordId) -> const ESM::Activator* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Activator* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Activator> record = context.mLua->sol().new_usertype<ESM::Activator>("ESM3_Activator");
record[sol::meta_function::to_string]
= [](const ESM::Activator& rec) { return "ESM3_Activator[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId.getRefIdString(); });
record["id"]
= sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Activator& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"]
= sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Activator& rec) -> std::string { return rec.mScript.getRefIdString(); });
}
}

@ -34,17 +34,20 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Apparatus>();
apparatus["record"] = sol::overload(
[](const Object& obj) -> const ESM::Apparatus* { return obj.ptr().get<ESM::Apparatus>()->mBase; },
[store](const std::string& recordId) -> const ESM::Apparatus* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Apparatus* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Apparatus> record = context.mLua->sol().new_usertype<ESM::Apparatus>("ESM3_Apparatus");
record[sol::meta_function::to_string]
= [](const ESM::Apparatus& rec) { return "ESM3_Apparatus[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId.getRefIdString(); });
record["id"]
= sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"]
= sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Apparatus& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -40,11 +40,14 @@ namespace MWLua
const MWWorld::Store<ESM::Armor>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Armor>();
armor["record"]
= sol::overload([](const Object& obj) -> const ESM::Armor* { return obj.ptr().get<ESM::Armor>()->mBase; },
[store](const std::string& recordId) -> const ESM::Armor* { return store->find(recordId); });
[store](const std::string& recordId) -> const ESM::Armor* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Armor> record = context.mLua->sol().new_usertype<ESM::Armor>("ESM3_Armor");
record[sol::meta_function::to_string]
= [](const ESM::Armor& rec) -> std::string { return "ESM3_Armor[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mId; });
= [](const ESM::Armor& rec) -> std::string { return "ESM3_Armor[" + rec.mId.getRefIdString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
@ -52,8 +55,10 @@ namespace MWLua
record["icon"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["enchant"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mEnchant; });
record["mwscript"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mScript; });
record["enchant"] = sol::readonly_property(
[](const ESM::Armor& rec) -> std::string { return rec.mEnchant.getRefIdString(); });
record["mwscript"]
= sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["weight"] = sol::readonly_property([](const ESM::Armor& rec) -> float { return rec.mData.mWeight; });
record["value"] = sol::readonly_property([](const ESM::Armor& rec) -> int { return rec.mData.mValue; });
record["type"] = sol::readonly_property([](const ESM::Armor& rec) -> int { return rec.mData.mType; });

@ -35,20 +35,26 @@ namespace MWLua
const MWWorld::Store<ESM::Book>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Book>();
book["record"]
= sol::overload([](const Object& obj) -> const ESM::Book* { return obj.ptr().get<ESM::Book>()->mBase; },
[store](const std::string& recordId) -> const ESM::Book* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Book* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Book> record = context.mLua->sol().new_usertype<ESM::Book>("ESM3_Book");
record[sol::meta_function::to_string] = [](const ESM::Book& rec) { return "ESM3_Book[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId.getRefIdString(); });
record[sol::meta_function::to_string]
= [](const ESM::Book& rec) { return "ESM3_Book[" + rec.mId.getRefIdString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"]
= sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["text"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mText; });
record["enchant"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mEnchant.getRefIdString(); });
record["enchant"]
= sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mEnchant.getRefIdString(); });
record["isScroll"] = sol::readonly_property([](const ESM::Book& rec) -> bool { return rec.mData.mIsScroll; });
record["value"] = sol::readonly_property([](const ESM::Book& rec) -> int { return rec.mData.mValue; });
record["weight"] = sol::readonly_property([](const ESM::Book& rec) -> float { return rec.mData.mWeight; });

@ -52,17 +52,21 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Container>();
container["record"] = sol::overload(
[](const Object& obj) -> const ESM::Container* { return obj.ptr().get<ESM::Container>()->mBase; },
[store](const std::string& recordId) -> const ESM::Container* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Container* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Container> record = context.mLua->sol().new_usertype<ESM::Container>("ESM3_Container");
record[sol::meta_function::to_string]
= [](const ESM::Container& rec) -> std::string { return "ESM3_Container[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId.getRefIdString(); });
record[sol::meta_function::to_string] = [](const ESM::Container& rec) -> std::string {
return "ESM3_Container[" + rec.mId.getRefIdString() + "]";
};
record["id"]
= sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Container& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"]
= sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Container& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["weight"] = sol::readonly_property([](const ESM::Container& rec) -> float { return rec.mWeight; });
}
}

@ -27,7 +27,9 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>();
creature["record"] = sol::overload(
[](const Object& obj) -> const ESM::Creature* { return obj.ptr().get<ESM::Creature>()->mBase; },
[store](const std::string& recordId) -> const ESM::Creature* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Creature* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Creature> record = context.mLua->sol().new_usertype<ESM::Creature>("ESM3_Creature");
record[sol::meta_function::to_string]
= [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId.getRefIdString() + "]"; };
@ -35,9 +37,9 @@ namespace MWLua
record["model"] = sol::readonly_property([vfs](const ESM::Creature& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"]
= sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["baseCreature"]
= sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mOriginal.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Creature& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["baseCreature"] = sol::readonly_property(
[](const ESM::Creature& rec) -> std::string { return rec.mOriginal.getRefIdString(); });
}
}

@ -48,20 +48,24 @@ namespace MWLua
const MWWorld::Store<ESM::Door>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Door>();
door["record"]
= sol::overload([](const Object& obj) -> const ESM::Door* { return obj.ptr().get<ESM::Door>()->mBase; },
[store](const std::string& recordId) -> const ESM::Door* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Door* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Door> record = context.mLua->sol().new_usertype<ESM::Door>("ESM3_Door");
record[sol::meta_function::to_string]
= [](const ESM::Door& rec) -> std::string { return "ESM3_Door[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId.getRefIdString(); });
record["id"]
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Door& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["openSound"]
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mOpenSound.getRefIdString(); });
record["closeSound"]
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mCloseSound.getRefIdString(); });
record["mwscript"]
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["openSound"] = sol::readonly_property(
[](const ESM::Door& rec) -> std::string { return rec.mOpenSound.getRefIdString(); });
record["closeSound"] = sol::readonly_property(
[](const ESM::Door& rec) -> std::string { return rec.mCloseSound.getRefIdString(); });
}
}

@ -26,15 +26,18 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>();
ingredient["record"] = sol::overload(
[](const Object& obj) -> const ESM::Ingredient* { return obj.ptr().get<ESM::Ingredient>()->mBase; },
[store](const std::string& recordID) -> const ESM::Ingredient* { return store->find(ESM::RefId::stringRefId(recordID)); });
[store](const std::string& recordID) -> const ESM::Ingredient* {
return store->find(ESM::RefId::stringRefId(recordID));
});
sol::usertype<ESM::Ingredient> record = context.mLua->sol().new_usertype<ESM::Ingredient>(("ESM3_Ingredient"));
record[sol::meta_function::to_string]
= [](const ESM::Potion& rec) { return "ESM3_Ingredient[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mId.getRefIdString(); });
record["id"] = sol::readonly_property(
[](const ESM::Ingredient& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mModel; });
record["mwscript"]
= sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Ingredient& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mIcon; });
record["weight"]
= sol::readonly_property([](const ESM::Ingredient& rec) -> float { return rec.mData.mWeight; });

@ -26,11 +26,14 @@ namespace MWLua
const MWWorld::Store<ESM::Light>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Light>();
light["record"]
= sol::overload([](const Object& obj) -> const ESM::Light* { return obj.ptr().get<ESM::Light>()->mBase; },
[store](const std::string& recordId) -> const ESM::Light* { return store->find(recordId); });
[store](const std::string& recordId) -> const ESM::Light* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Light> record = context.mLua->sol().new_usertype<ESM::Light>("ESM3_Light");
record[sol::meta_function::to_string]
= [](const ESM::Light& rec) -> std::string { return "ESM3_Light[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mId; });
= [](const ESM::Light& rec) -> std::string { return "ESM3_Light[" + rec.mId.getRefIdString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
@ -39,9 +42,10 @@ namespace MWLua
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["sound"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string {
return Misc::ResourceHelpers::correctSoundPath(rec.mSound, vfs);
return Misc::ResourceHelpers::correctSoundPath(rec.mSound.getRefIdString(), vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mScript; });
record["mwscript"]
= sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["weight"] = sol::readonly_property([](const ESM::Light& rec) -> float { return rec.mData.mWeight; });
record["value"] = sol::readonly_property([](const ESM::Light& rec) -> int { return rec.mData.mValue; });
record["duration"] = sol::readonly_property([](const ESM::Light& rec) -> int { return rec.mData.mTime; });

@ -27,17 +27,20 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Lockpick>();
lockpick["record"] = sol::overload(
[](const Object& obj) -> const ESM::Lockpick* { return obj.ptr().get<ESM::Lockpick>()->mBase; },
[store](const std::string& recordId) -> const ESM::Lockpick* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Lockpick* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Lockpick> record = context.mLua->sol().new_usertype<ESM::Lockpick>("ESM3_Lockpick");
record[sol::meta_function::to_string]
= [](const ESM::Lockpick& rec) { return "ESM3_Lockpick[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId.getRefIdString(); });
record["id"]
= sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"]
= sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Lockpick& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -27,18 +27,21 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Miscellaneous>();
miscellaneous["record"] = sol::overload(
[](const Object& obj) -> const ESM::Miscellaneous* { return obj.ptr().get<ESM::Miscellaneous>()->mBase; },
[store](const std::string& recordId) -> const ESM::Miscellaneous* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Miscellaneous* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Miscellaneous> record
= context.mLua->sol().new_usertype<ESM::Miscellaneous>("ESM3_Miscellaneous");
record[sol::meta_function::to_string]
= [](const ESM::Miscellaneous& rec) { return "ESM3_Miscellaneous[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mId.getRefIdString(); });
record["id"] = sol::readonly_property(
[](const ESM::Miscellaneous& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"]
= sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -26,14 +26,22 @@ namespace MWLua
const MWWorld::Store<ESM::NPC>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::NPC>();
npc["record"]
= sol::overload([](const Object& obj) -> const ESM::NPC* { return obj.ptr().get<ESM::NPC>()->mBase; },
[store](const std::string& recordId) -> const ESM::NPC* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::NPC* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::NPC> record = context.mLua->sol().new_usertype<ESM::NPC>("ESM3_NPC");
record[sol::meta_function::to_string] = [](const ESM::NPC& rec) { return "ESM3_NPC[" + rec.mId.getRefIdString() + "]"; };
record[sol::meta_function::to_string]
= [](const ESM::NPC& rec) { return "ESM3_NPC[" + rec.mId.getRefIdString() + "]"; };
record["name"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mName; });
record["race"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mRace.getRefIdString(); });
record["class"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mClass.getRefIdString(); });
record["mwscript"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["hair"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHair.getRefIdString(); });
record["head"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.getRefIdString(); });
record["race"]
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mRace.getRefIdString(); });
record["class"]
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mClass.getRefIdString(); });
record["mwscript"]
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["hair"]
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHair.getRefIdString(); });
record["head"]
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.getRefIdString(); });
}
}

@ -25,12 +25,16 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>();
potion["record"]
= sol::overload([](const Object& obj) -> const ESM::Potion* { return obj.ptr().get<ESM::Potion>()->mBase; },
[store](const std::string& recordId) -> const ESM::Potion* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Potion* {
return store->find(ESM::RefId::stringRefId(recordId));
});
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
sol::usertype<ESM::Potion> record = context.mLua->sol().new_usertype<ESM::Potion>("ESM3_Potion");
record[sol::meta_function::to_string] = [](const ESM::Potion& rec) { return "ESM3_Potion[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId.getRefIdString(); });
record[sol::meta_function::to_string]
= [](const ESM::Potion& rec) { return "ESM3_Potion[" + rec.mId.getRefIdString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
@ -38,7 +42,8 @@ namespace MWLua
record["icon"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Potion& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["weight"] = sol::readonly_property([](const ESM::Potion& rec) -> float { return rec.mData.mWeight; });
record["value"] = sol::readonly_property([](const ESM::Potion& rec) -> int { return rec.mData.mValue; });
}

@ -26,15 +26,20 @@ namespace MWLua
const MWWorld::Store<ESM::Probe>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Probe>();
probe["record"]
= sol::overload([](const Object& obj) -> const ESM::Probe* { return obj.ptr().get<ESM::Probe>()->mBase; },
[store](const std::string& recordId) -> const ESM::Probe* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Probe* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Probe> record = context.mLua->sol().new_usertype<ESM::Probe>("ESM3_Probe");
record[sol::meta_function::to_string] = [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId.getRefIdString(); });
record[sol::meta_function::to_string]
= [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId.getRefIdString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"]
= sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -27,15 +27,20 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Repair>();
repair["record"]
= sol::overload([](const Object& obj) -> const ESM::Repair* { return obj.ptr().get<ESM::Repair>()->mBase; },
[store](const std::string& recordId) -> const ESM::Repair* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Repair* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Repair> record = context.mLua->sol().new_usertype<ESM::Repair>("ESM3_Repair");
record[sol::meta_function::to_string] = [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId.getRefIdString(); });
record[sol::meta_function::to_string]
= [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId.getRefIdString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Repair& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -27,11 +27,14 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>();
stat["record"]
= sol::overload([](const Object& obj) -> const ESM::Static* { return obj.ptr().get<ESM::Static>()->mBase; },
[store](const std::string& recordId) -> const ESM::Static* { return store->find(recordId); });
[store](const std::string& recordId) -> const ESM::Static* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Static> record = context.mLua->sol().new_usertype<ESM::Static>("ESM3_Static");
record[sol::meta_function::to_string]
= [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Static& rec) -> std::string { return rec.mId; });
= [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId.getRefIdString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM::Static& rec) -> std::string { return rec.mId.getRefIdString(); });
record["model"] = sol::readonly_property([vfs](const ESM::Static& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});

@ -2,7 +2,6 @@
#include <components/lua/luastate.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/esm/refidhardcoded.hpp>
namespace MWLua
{
@ -67,7 +66,7 @@ namespace MWLua
if (ref == nullptr)
throw std::runtime_error("Can't get type name from an empty object.");
const ESM::RefId& id = ref->mRef.getRefId();
if (id == ESM::sPlayerId)
if (id == "Player")
return ESM::REC_INTERNAL_PLAYER;
if (Misc::ResourceHelpers::isHiddenMarker(id))
return ESM::REC_INTERNAL_MARKER;

@ -44,11 +44,14 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Weapon>();
weapon["record"]
= sol::overload([](const Object& obj) -> const ESM::Weapon* { return obj.ptr().get<ESM::Weapon>()->mBase; },
[store](const std::string& recordId) -> const ESM::Weapon* { return store->find(ESM::RefId::stringRefId(recordId)); });
[store](const std::string& recordId) -> const ESM::Weapon* {
return store->find(ESM::RefId::stringRefId(recordId));
});
sol::usertype<ESM::Weapon> record = context.mLua->sol().new_usertype<ESM::Weapon>("ESM3_Weapon");
record[sol::meta_function::to_string]
= [](const ESM::Weapon& rec) -> std::string { return "ESM3_Weapon[" + rec.mId.getRefIdString() + "]"; };
record["id"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId.getRefIdString(); });
record["id"]
= sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId.getRefIdString(); });
record["name"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
@ -56,8 +59,10 @@ namespace MWLua
record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["enchant"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mEnchant.getRefIdString(); });
record["mwscript"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["enchant"] = sol::readonly_property(
[](const ESM::Weapon& rec) -> std::string { return rec.mEnchant.getRefIdString(); });
record["mwscript"] = sol::readonly_property(
[](const ESM::Weapon& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["isMagical"] = sol::readonly_property(
[](const ESM::Weapon& rec) -> bool { return rec.mData.mFlags & ESM::Weapon::Magical; });
record["isSilver"] = sol::readonly_property(

@ -325,7 +325,8 @@ namespace MWMechanics
if (reflected)
{
const ESM::Static* reflectStatic
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Reflect"));
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(
ESM::RefId::stringRefId("VFX_Reflect"));
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
if (animation && !reflectStatic->mModel.empty())
{
@ -418,9 +419,8 @@ namespace MWMechanics
bool ActiveSpells::isSpellActive(const ESM::RefId& id) const
{
return std::find_if(mSpells.begin(), mSpells.end(), [&](const auto& spell) {
return spell.mId == id;
}) != mSpells.end();
return std::find_if(mSpells.begin(), mSpells.end(), [&](const auto& spell) { return spell.mId == id; })
!= mSpells.end();
}
void ActiveSpells::addSpell(const ActiveSpellParams& params)

@ -208,7 +208,8 @@ namespace
if (caster == MWMechanics::getPlayer())
MWBase::Environment::get().getWindowManager()->messageBox("#{sSoultrapSuccess}");
const ESM::Static* const fx = world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Soul_Trap"));
const ESM::Static* const fx
= world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Soul_Trap"));
if (fx != nullptr)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
@ -1833,8 +1834,8 @@ namespace MWMechanics
{
MWBase::Environment::get().getWorld()->deleteObject(ptr);
const ESM::Static* fx
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_End"));
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().search(
ESM::RefId::stringRefId("VFX_Summon_End"));
if (fx)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();

@ -44,8 +44,8 @@ namespace MWMechanics
/// Follow Actor for duration or until you arrive at a world position
AiFollow(const ESM::RefId& actorId, float duration, float x, float y, float z, bool repeat);
/// Follow Actor for duration or until you arrive at a position in a cell
AiFollow(
const ESM::RefId& actorId, const ESM::RefId& cellId, float duration, float x, float y, float z, bool repeat);
AiFollow(const ESM::RefId& actorId, const ESM::RefId& cellId, float duration, float x, float y, float z,
bool repeat);
/// Follow Actor indefinitively
AiFollow(const MWWorld::Ptr& actor, bool commanded = false);

@ -455,8 +455,8 @@ namespace MWMechanics
else if (esmPackage.mType == ESM::AI_Escort)
{
ESM::AITarget data = esmPackage.mTarget;
package = std::make_unique<MWMechanics::AiEscort>(
ESM::RefId::stringRefId(data.mId.toStringView()), data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
package = std::make_unique<MWMechanics::AiEscort>(ESM::RefId::stringRefId(data.mId.toStringView()),
data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
}
else if (esmPackage.mType == ESM::AI_Travel)
{
@ -466,13 +466,14 @@ namespace MWMechanics
else if (esmPackage.mType == ESM::AI_Activate)
{
ESM::AIActivate data = esmPackage.mActivate;
package = std::make_unique<MWMechanics::AiActivate>(ESM::RefId::stringRefId(data.mName.toStringView()), data.mShouldRepeat != 0);
package = std::make_unique<MWMechanics::AiActivate>(
ESM::RefId::stringRefId(data.mName.toStringView()), data.mShouldRepeat != 0);
}
else // if (esmPackage.mType == ESM::AI_Follow)
{
ESM::AITarget data = esmPackage.mTarget;
package = std::make_unique<MWMechanics::AiFollow>(
ESM::RefId::stringRefId(data.mId.toStringView()), data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
package = std::make_unique<MWMechanics::AiFollow>(ESM::RefId::stringRefId(data.mId.toStringView()),
data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
}
onPackageAdded(*package);

@ -448,8 +448,7 @@ int MWMechanics::Alchemy::addIngredient(const MWWorld::Ptr& ingredient)
return -1;
for (TIngredientsIterator iter(mIngredients.begin()); iter != mIngredients.end(); ++iter)
if (!iter->isEmpty()
&& ingredient.getCellRef().getRefId() == iter->getCellRef().getRefId())
if (!iter->isEmpty() && ingredient.getCellRef().getRefId() == iter->getCellRef().getRefId())
return -1;
mIngredients[slot] = ingredient;

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

Loading…
Cancel
Save