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

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

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

@ -504,7 +504,8 @@ void CSMDoc::Document::startRunning(const std::string& profile, const std::strin
contentFiles.emplace_back(mContentFile.filename()); 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(); int state = getState();

@ -178,7 +178,7 @@ void CSMDoc::WriteDialogueCollectionStage::perform(int stage, Messages& messages
if ((*iter)->isModified() || (*iter)->mState == CSMWorld::RecordBase::State_Deleted) if ((*iter)->isModified() || (*iter)->mState == CSMWorld::RecordBase::State_Deleted)
{ {
ESM::DialInfo info = (*iter)->get(); 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.mId = ESM::RefId::stringRefId(infoIdString.substr(infoIdString.find_last_of('#') + 1));
info.mPrev = ESM::RefId::sEmpty; 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 // 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. // 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) && !interior && record.mState != CSMWorld::RecordBase::State_ModifiedOnly && !record.get().mNew)
indices.push_back(i); indices.push_back(i);
else else
@ -316,8 +317,7 @@ void CSMDoc::WriteCellCollectionStage::writeReferences(
ESM::RefId streamId = ESM::RefId::stringRefId(stream.str()); ESM::RefId streamId = ESM::RefId::stringRefId(stream.str());
if (refRecord.mNew || refRecord.mRefNum.mIndex == 0 if (refRecord.mNew || refRecord.mRefNum.mIndex == 0
|| (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly || (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly && refRecord.mCell != streamId))
&& refRecord.mCell != streamId))
{ {
refRecord.mRefNum.mIndex = newRefNum++; refRecord.mRefNum.mIndex = newRefNum++;
} }
@ -390,7 +390,8 @@ void CSMDoc::WriteCellCollectionStage::perform(int stage, Messages& messages)
if (refRecord.mNew if (refRecord.mNew
|| (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly && || (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly &&
/// \todo consider worldspace /// \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; ++cellRecord.mRefNumCounter;
if (refRecord.mRefNum.mIndex >= newRefNum) if (refRecord.mRefNum.mIndex >= newRefNum)

@ -61,6 +61,7 @@ void CSMTools::BodyPartCheckStage::perform(int stage, CSMDoc::Messages& messages
if (bodyPart.mRace.empty()) if (bodyPart.mRace.empty())
messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error); messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error);
else if (mRaces.searchId(bodyPart.mRace) == -1) 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(); const ESM::GameSetting& gmst = record.get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Gmst, gmst.mId); 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 // Test for empty string
if (gmst.mValue.getType() == ESM::VT_String && gmst.mValue.getString().empty()) if (gmst.mValue.getType() == ESM::VT_String && gmst.mValue.getString().empty())
messages.add(id, gmstIdString + " is an empty string", "", CSMDoc::Message::Severity_Warning); 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) if (!effect.mCastSound.empty() && mSounds.searchId(effect.mCastSound) == -1)
messages.add( messages.add(id, "Casting sound '" + effect.mCastSound.getRefIdString() + "' does not exist", "",
id, "Casting sound '" + effect.mCastSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); CSMDoc::Message::Severity_Error);
if (!effect.mHitSound.empty() && mSounds.searchId(effect.mHitSound) == -1) 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) 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) 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 <string>
#include <vector> #include <vector>
#include "../doc/stage.hpp"
#include "../world/universalid.hpp" #include "../world/universalid.hpp"
#include <components/esm/refid.hpp> #include <components/esm/refid.hpp>
#include "../doc/stage.hpp"
namespace CSMDoc namespace CSMDoc
{ {

@ -190,7 +190,7 @@ void CSMTools::FixLandsAndLandTexturesMergeStage::perform(int stage, CSMDoc::Mes
CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&>( CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&>(
*mState.mTarget->getData().getTableModel(CSMWorld::UniversalId::Type_LandTextures)); *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); CSMWorld::TouchLandCommand cmd(landTable, ltexTable, id);
cmd.redo(); cmd.redo();

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

@ -50,8 +50,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message
{ {
// Check for non existing referenced object // Check for non existing referenced object
if (mObjects.searchId(cellRef.mRefID) == -1) if (mObjects.searchId(cellRef.mRefID) == -1)
messages.add( messages.add(id, "Instance of a non-existent object '" + cellRef.mRefID.getRefIdString() + "'", "",
id, "Instance of a non-existent object '" + cellRef.mRefID.getRefIdString() + "'", "", CSMDoc::Message::Severity_Error); CSMDoc::Message::Severity_Error);
else else
{ {
// Check if reference charge is valid for it's proper referenced type // 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 object have owner, check if that owner reference is valid
if (!cellRef.mOwner.empty() && mObjects.searchId(cellRef.mOwner) == -1) 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 object have creature soul trapped, check if that creature reference is valid
if (!cellRef.mSoul.empty()) if (!cellRef.mSoul.empty())
if (mObjects.searchId(cellRef.mSoul) == -1) if (mObjects.searchId(cellRef.mSoul) == -1)
messages.add( messages.add(id, "Trapped soul object '" + cellRef.mSoul.getRefIdString() + "' does not exist", "",
id, "Trapped soul object '" + cellRef.mSoul.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); CSMDoc::Message::Severity_Error);
if (cellRef.mFaction.empty()) if (cellRef.mFaction.empty())
{ {
@ -80,7 +81,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message
else else
{ {
if (mFactions.searchId(cellRef.mFaction) == -1) 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) else if (cellRef.mFactionRank < -1)
messages.add(id, "Invalid faction rank", "", CSMDoc::Message::Severity_Error); 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); CSMWorld::RefIdData::LocalIndex creatureIndex = mObjects.getDataSet().searchId(soundGen.mCreature);
if (creatureIndex.first == -1) if (creatureIndex.first == -1)
{ {
messages.add( messages.add(id, "Creature '" + soundGen.mCreature.getRefIdString() + "' doesn't exist", "",
id, "Creature '" + soundGen.mCreature.getRefIdString() + "' doesn't exist", "", CSMDoc::Message::Severity_Error); CSMDoc::Message::Severity_Error);
} }
else if (creatureIndex.second != CSMWorld::UniversalId::Type_Creature) 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) 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); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_StartScript, scriptId);
if (mScripts.searchId(scriptId) == -1) 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() int CSMTools::StartScriptCheckStage::setup()

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

@ -521,7 +521,8 @@ namespace CSMWorld
} }
auto& part = partRecord.get(); 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; auto type = (ESM::BodyPart::MeshPart)part.mData.mPart;
bool female = part.mData.mFlags & ESM::BodyPart::BPF_Female; bool female = part.mData.mFlags & ESM::BodyPart::BPF_Female;

@ -576,8 +576,7 @@ namespace CSMWorld
template <typename ESXRecordT, typename IdAccessorT> template <typename ESXRecordT, typename IdAccessorT>
void Collection<ESXRecordT, IdAccessorT>::setRecord(int index, std::unique_ptr<Record<ESXRecordT>> record) void Collection<ESXRecordT, IdAccessorT>::setRecord(int index, std::unique_ptr<Record<ESXRecordT>> record)
{ {
if (IdAccessorT().getId(mRecords.at(index)->get()) if (IdAccessorT().getId(mRecords.at(index)->get()) != IdAccessorT().getId(record->get()))
!= IdAccessorT().getId(record->get()))
throw std::runtime_error("attempt to change the ID of a record"); throw std::runtime_error("attempt to change the ID of a record");
mRecords.at(index) = std::move(record); mRecords.at(index) = std::move(record);

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

@ -290,8 +290,7 @@ void CSMWorld::CommandDispatcher::executeExtendedDelete()
if (record.mState == RecordBase::State_Deleted) if (record.mState == RecordBase::State_Deleted)
continue; continue;
if (!std::binary_search( if (!std::binary_search(mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString()))
mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString()))
continue; continue;
macro.push(new CSMWorld::DeleteCommand(model, record.get().mId.getRefIdString())); 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); const Record<CellRef>& record = collection.getRecord(i);
if (!std::binary_search( if (!std::binary_search(mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString()))
mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString()))
continue; continue;
macro.push(new CSMWorld::RevertCommand(model, record.get().mId.getRefIdString())); 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); messages.add(id, "Logic error: cell index out of bounds", "", CSMDoc::Message::Severity_Error);
index = mCells.getSize() - 1; 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); mRefs.load(*mReader, index, mBase, mRefLoadCache[cellId], messages);
break; break;
} }
@ -1241,7 +1242,7 @@ bool CSMWorld::Data::continueLoading(CSMDoc::Messages& messages)
case ESM::REC_DIAL: case ESM::REC_DIAL:
{ {
ESM::Dialogue record; ESM::Dialogue record;
std::string recordIdString = record.mId.getRefIdString(); const std::string& recordIdString = record.mId.getRefIdString();
bool isDeleted = false; bool isDeleted = false;
record.load(*mReader, isDeleted); record.load(*mReader, isDeleted);

@ -370,7 +370,8 @@ CSMWorld::LandTextureIdTable::ImportResults CSMWorld::LandTextureIdTable::import
{ {
auto& record = static_cast<const Record<LandTexture>&>(idCollection()->getRecord(i)); auto& record = static_cast<const Record<LandTexture>&>(idCollection()->getRecord(i));
if (record.isModified()) 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) for (const std::string& id : ids)

@ -342,7 +342,8 @@ void CSMWorld::InfoCollection::appendBlankRecord(const ESM::RefId& id, Universal
record2->get().mId = id; 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 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) 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); insertRecord(std::move(record), index, type);
} }

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

@ -346,7 +346,8 @@ namespace CSMWorld
case 0: case 0:
{ {
reactions.erase(iter); 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; break;
} }
case 1: case 1:

@ -3,8 +3,8 @@
#include <string> #include <string>
#include <components/esm3/loadpgrd.hpp>
#include <components/esm/refid.hpp> #include <components/esm/refid.hpp>
#include <components/esm3/loadpgrd.hpp>
namespace ESM 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]) if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1])
{ {
ESM::RefId indexCell = ref.mCell; 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)); 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() + ")" 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, messages.add(id,
"Attempt to move a non-existent reference - RefNum index " + std::to_string(ref.mRefNum.mIndex) "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); /*hint*/ "", CSMDoc::Message::Severity_Warning);
continue; continue;
} }
@ -148,7 +150,8 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
messages.add(id, messages.add(id,
"Attempt to delete a non-existent reference - RefNum index " + std::to_string(ref.mRefNum.mIndex) "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); /*hint*/ "", CSMDoc::Message::Severity_Warning);
continue; continue;
} }

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

@ -1,8 +1,9 @@
#ifndef CSM_WOLRD_REFIDADAPTER_H #ifndef CSM_WOLRD_REFIDADAPTER_H
#define CSM_WOLRD_REFIDADAPTER_H #define CSM_WOLRD_REFIDADAPTER_H
#include <string>
#include <components/esm/refid.hpp> #include <components/esm/refid.hpp>
#include <string>
#include <vector>
/*! \brief /*! \brief
* Adapters acts as indirection layer, abstracting details of the record types (in the wrappers) from the higher levels * 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) for (int i = index.first; i < index.first + count; ++i)
{ {
auto result auto result = mIndex.find(iter->second->getId(i));
= mIndex.find(iter->second->getId(i));
if (result != mIndex.end()) if (result != mIndex.end())
mIndex.erase(result); mIndex.erase(result);
@ -265,8 +264,7 @@ void CSMWorld::RefIdData::erase(const LocalIndex& index, int count)
int recordCount = iter->second->getSize(); int recordCount = iter->second->getSize();
while (recordIndex < recordCount) while (recordIndex < recordCount)
{ {
auto recordIndexFound auto recordIndexFound = mIndex.find(iter->second->getId(recordIndex));
= mIndex.find(iter->second->getId(recordIndex));
if (recordIndexFound != mIndex.end()) if (recordIndexFound != mIndex.end())
{ {
recordIndexFound->second.first -= count; 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) for (std::map<CellCoordinates, CellDescription>::const_iterator iter(mMap.begin()); iter != mMap.end(); ++iter)
{ {
if (!iter->second.mRegion.empty() if (!iter->second.mRegion.empty()
&& std::find(regions2.begin(), regions2.end(),iter->second.mRegion) && std::find(regions2.begin(), regions2.end(), iter->second.mRegion) != regions2.end())
!= regions2.end())
{ {
QModelIndex index = getIndex(iter->first); QModelIndex index = getIndex(iter->first);
@ -333,8 +332,7 @@ QVariant CSMWorld::RegionMap::data(const QModelIndex& index, int role) const
if (cell->second.mDeleted) if (cell->second.mDeleted)
return QBrush(Qt::red, Qt::DiagCrossPattern); return QBrush(Qt::red, Qt::DiagCrossPattern);
auto iter auto iter = mColours.find(cell->second.mRegion);
= mColours.find(cell->second.mRegion);
if (iter != mColours.end()) if (iter != mColours.end())
return QBrush(QColor(iter->second & 0xff, (iter->second >> 8) & 0xff, (iter->second >> 16) & 0xff)); 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>"; stream << "<br>";
auto iter auto iter = mColours.find(cell->second.mRegion);
= mColours.find(cell->second.mRegion);
if (iter != mColours.end()) if (iter != mColours.end())
stream << cell->second.mRegion; stream << cell->second.mRegion;

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

@ -161,7 +161,6 @@ namespace CSMWorld
UniversalId(Type type, const ESM::RefId& id); UniversalId(Type type, const ESM::RefId& id);
UniversalId(Type type, int index); UniversalId(Type type, int index);
///< Using a type for a non-index-argument UniversalId will throw an exception. ///< 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) for (int i = start; i <= end; ++i)
{ {
auto cellId = collection.getRecord(i).get().mCell; auto cellId = collection.getRecord(i).get().mCell;
std::string cell = cellId.getRefIdString();
CSMWorld::RecordBase::State state = collection.getRecord(i).mState; CSMWorld::RecordBase::State state = collection.getRecord(i).mState;
if (cellId == mId && state != CSMWorld::RecordBase::State_Deleted) 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); 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) for (int i = topLeft.row(); i <= bottomRight.row(); ++i)
{ {
auto cell =ESM::RefId::stringRefId( auto cell
references.data(references.index(i, cellColumn)).toString().toUtf8().constData()); = ESM::RefId::stringRefId(references.data(references.index(i, cellColumn)).toString().toUtf8().constData());
if (cell == mId) if (cell == mId)
{ {

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

@ -597,7 +597,7 @@ bool CSVRender::Object::referenceDataChanged(const QModelIndex& topLeft, const Q
const CSMWorld::RefCollection& references = mData.getReferences(); 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()) 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()) 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(); update();
updateMarker(); updateMarker();

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

@ -401,7 +401,8 @@ namespace CSVRender
for (std::vector<unsigned short>::iterator row = mSelected.begin(); row != mSelected.end(); ++row) 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 // Fix/remove edges

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

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

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

@ -69,8 +69,7 @@ namespace MWBase
virtual void setPlayerName(const std::string& name) = 0; virtual void setPlayerName(const std::string& name) = 0;
///< Set player name. ///< Set player name.
virtual void setPlayerRace(const ESM::RefId& id, bool male, const ESM::RefId& head, const ESM::RefId& hair) virtual void setPlayerRace(const ESM::RefId& id, bool male, const ESM::RefId& head, const ESM::RefId& hair) = 0;
= 0;
///< Set player race. ///< Set player race.
virtual void setPlayerBirthsign(const ESM::RefId& id) = 0; 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(); for (auto sound = store.get<ESM::SoundGenerator>().begin(); sound != store.get<ESM::SoundGenerator>().end();
++sound) ++sound)
{ {
if (type == sound->mType && !sound->mCreature.empty() if (type == sound->mType && !sound->mCreature.empty() && (*creatureId == sound->mCreature))
&& (*creatureId == sound->mCreature))
sounds.push_back(&*sound); sounds.push_back(&*sound);
if (type == sound->mType && sound->mCreature.empty()) if (type == sound->mType && sound->mCreature.empty())
fallbacksounds.push_back(&*sound); fallbacksounds.push_back(&*sound);

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

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

@ -113,8 +113,7 @@ namespace MWClass
const ESM::RefId& openSound = ref->mBase->mOpenSound; const ESM::RefId& openSound = ref->mBase->mOpenSound;
const ESM::RefId& closeSound = ref->mBase->mCloseSound; const ESM::RefId& closeSound = ref->mBase->mCloseSound;
static const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedDoor"); const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedDoor");
static const ESM::RefId trapActivationSound = ESM::RefId::stringRefId("Disarm Trap Fail");
// FIXME: If NPC activate teleporting door, it can lead to crash due to iterator invalidation in the Actors // 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. // 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) if (isTrapped)
{ {
ptr.getCellRef().setTrap(ESM::RefId::sEmpty); 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; isTrapped = false;
} }
} }
@ -180,7 +180,7 @@ namespace MWClass
// Trap activation // Trap activation
std::unique_ptr<MWWorld::Action> action std::unique_ptr<MWWorld::Action> action
= std::make_unique<MWWorld::ActionTrap>(ptr.getCellRef().getTrap(), ptr); = std::make_unique<MWWorld::ActionTrap>(ptr.getCellRef().getTrap(), ptr);
action->setSound(trapActivationSound); action->setSound(ESM::RefId::stringRefId("Disarm Trap Fail"));
return action; return action;
} }

@ -5,7 +5,6 @@
#include <components/esm3/loadcrea.hpp> #include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadmisc.hpp> #include <components/esm3/loadmisc.hpp>
#include <components/esm3/loadnpc.hpp> #include <components/esm3/loadnpc.hpp>
#include <components/esm/refidhardcoded.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -36,11 +35,9 @@ namespace MWClass
bool Miscellaneous::isGold(const MWWorld::ConstPtr& ptr) const bool Miscellaneous::isGold(const MWWorld::ConstPtr& ptr) const
{ {
return ptr.getCellRef().getRefId() == ESM::sGoldId001 return ptr.getCellRef().getRefId() == "gold_001" || ptr.getCellRef().getRefId() == "gold_005"
|| ptr.getCellRef().getRefId() == ESM::sGoldId005 || ptr.getCellRef().getRefId() == "gold_010" || ptr.getCellRef().getRefId() == "gold_025"
|| ptr.getCellRef().getRefId() == ESM::sGoldId010 || ptr.getCellRef().getRefId() == "gold_100";
|| ptr.getCellRef().getRefId() == ESM::sGoldId025
|| ptr.getCellRef().getRefId() == ESM::sGoldId100;
} }
void Miscellaneous::insertObjectRendering( void Miscellaneous::insertObjectRendering(
@ -98,7 +95,7 @@ namespace MWClass
float soulValue = 0.0001 * pow(soul, 3) + 2 * soul; float soulValue = 0.0001 * pow(soul, 3) + 2 * soul;
// for Azura's star add the unfilled value // 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; value += soulValue;
else else
value = soulValue; value = soulValue;
@ -185,19 +182,19 @@ namespace MWClass
{ {
int goldAmount = getValue(ptr) * count; int goldAmount = getValue(ptr) * count;
const ESM::RefId* base = &ESM::sGoldId001; std::string_view base = "gold_001";
if (goldAmount >= 100) if (goldAmount >= 100)
base = &ESM::sGoldId100; base = "gold_100";
else if (goldAmount >= 25) else if (goldAmount >= 25)
base = &ESM::sGoldId025; base = "gold_025";
else if (goldAmount >= 10) else if (goldAmount >= 10)
base = &ESM::sGoldId010; base = "gold_010";
else if (goldAmount >= 5) else if (goldAmount >= 5)
base = &ESM::sGoldId005; base = "gold_005";
// Really, I have no idea why moving ref out of conditional // Really, I have no idea why moving ref out of conditional
// scope causes list::push_back throwing std::bad_alloc // 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>(); const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = newRef.getPtr().get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(cell.insert(ref), &cell); newPtr = MWWorld::Ptr(cell.insert(ref), &cell);

@ -9,7 +9,6 @@
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/esm/refidhardcoded.hpp>
#include <components/esm3/loadbody.hpp> #include <components/esm3/loadbody.hpp>
#include <components/esm3/loadclas.hpp> #include <components/esm3/loadclas.hpp>
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
@ -688,7 +687,8 @@ namespace MWClass
{ {
damage *= store.find("fCombatCriticalStrikeMult")->mValue.getFloat(); damage *= store.find("fCombatCriticalStrikeMult")->mValue.getFloat();
MWBase::Environment::get().getWindowManager()->messageBox("#{sTargetCriticalStrike}"); 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) 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()) if (ptr == MWMechanics::getPlayer())
MWBase::Environment::get().getWindowManager()->activateHitOverlay(); MWBase::Environment::get().getWindowManager()->activateHitOverlay();
if (!attacker.isEmpty()) if (!attacker.isEmpty())
@ -1303,7 +1303,6 @@ namespace MWClass
static const ESM::RefId footHeavyLeft = ESM::RefId::stringRefId("footHeavyLeft"); static const ESM::RefId footHeavyLeft = ESM::RefId::stringRefId("footHeavyLeft");
static const ESM::RefId footHeavyRight = ESM::RefId::stringRefId("footHeavyRight"); static const ESM::RefId footHeavyRight = ESM::RefId::stringRefId("footHeavyRight");
const ESM::RefId* sound = nullptr;
if (name == "left" || name == "right") if (name == "left" || name == "right")
{ {
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
@ -1311,9 +1310,9 @@ namespace MWClass
return ESM::RefId::sEmpty; return ESM::RefId::sEmpty;
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3()); osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
if (world->isSwimming(ptr)) if (world->isSwimming(ptr))
sound = (name == "left") ? &swimLeft : &swimRight; return (name == "left") ? swimLeft : swimRight;
if (world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr)) if (world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr))
sound = (name == "left") ? &footWaterLeft : &footWaterRight; return (name == "left") ? footWaterLeft : footWaterRight;
if (world->isOnGround(ptr)) if (world->isOnGround(ptr))
{ {
if (getNpcStats(ptr).isWerewolf() if (getNpcStats(ptr).isWerewolf()
@ -1328,16 +1327,19 @@ namespace MWClass
const MWWorld::InventoryStore& inv = Npc::getInventoryStore(ptr); const MWWorld::InventoryStore& inv = Npc::getInventoryStore(ptr);
MWWorld::ConstContainerStoreIterator boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots); MWWorld::ConstContainerStoreIterator boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots);
if (boots == inv.end() || boots->getType() != ESM::Armor::sRecordId) if (boots == inv.end() || boots->getType() != ESM::Armor::sRecordId)
sound = (name == "left") ? &footBareLeft : &footBareRight; return (name == "left") ? footBareLeft : footBareRight;
switch (boots->getClass().getEquipmentSkill(*boots)) switch (boots->getClass().getEquipmentSkill(*boots))
{ {
case ESM::Skill::LightArmor: case ESM::Skill::LightArmor:
sound = (name == "left") ? &footLightLeft : &footLightRight; break; return (name == "left") ? footLightLeft : footLightRight;
break;
case ESM::Skill::MediumArmor: case ESM::Skill::MediumArmor:
sound = (name == "left") ? &footMediumLeft : &footMediumRight; break; return (name == "left") ? footMediumLeft : footMediumRight;
break;
case ESM::Skill::HeavyArmor: case ESM::Skill::HeavyArmor:
sound = (name == "left") ? &footHeavyLeft : &footHeavyRight; break; return (name == "left") ? footHeavyLeft : footHeavyRight;
break;
} }
} }
return ESM::RefId::sEmpty; return ESM::RefId::sEmpty;
@ -1347,9 +1349,9 @@ namespace MWClass
if (name == "land") if (name == "land")
return ESM::RefId::sEmpty; return ESM::RefId::sEmpty;
if (name == "swimleft") if (name == "swimleft")
sound = &swimLeft; return swimLeft;
if (name == "swimright") if (name == "swimright")
sound = &swimRight; return swimRight;
// TODO: I have no idea what these are supposed to do for NPCs since they use // 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 // voiced dialog for various conditions like health loss and combat taunts. Maybe
// only for biped creatures? // only for biped creatures?
@ -1361,12 +1363,7 @@ namespace MWClass
if (name == "scream") if (name == "scream")
return ESM::RefId::sEmpty; return ESM::RefId::sEmpty;
if(sound == nullptr)
throw std::runtime_error("Unexpected soundgen type: " + std::string(name)); throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
else
{
return *sound;
}
} }
MWWorld::Ptr Npc::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const MWWorld::Ptr Npc::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const

@ -316,7 +316,8 @@ namespace MWDialogue
title = topic; title = topic;
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor); 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) if (dialogue.mType == ESM::Dialogue::Topic)
{ {
@ -327,8 +328,7 @@ namespace MWDialogue
{ {
if (iter->mId == info->mId) if (iter->mId == info->mId)
{ {
MWBase::Environment::get().getJournal()->addTopic( MWBase::Environment::get().getJournal()->addTopic(topic, info->mId, mActor);
topic, info->mId, mActor);
break; break;
} }
} }
@ -501,8 +501,7 @@ namespace MWDialogue
{ {
if (iter->mId == info->mId) if (iter->mId == info->mId)
{ {
MWBase::Environment::get().getJournal()->addTopic( MWBase::Environment::get().getJournal()->addTopic(mLastTopic, info->mId, mActor);
mLastTopic, info->mId, mActor);
break; break;
} }
} }
@ -739,7 +738,8 @@ namespace MWDialogue
if (map != mChangedFactionReaction.end() && map->second.find(faction2) != map->second.end()) if (map != mChangedFactionReaction.end() && map->second.find(faction2) != map->second.end())
return map->second.at(faction2); 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(); auto it = faction->mReactions.begin();
for (; it != faction->mReactions.end(); ++it) for (; it != faction->mReactions.end(); ++it)

@ -1,10 +1,10 @@
#include "filter.hpp" #include "filter.hpp"
#include <components/compiler/locals.hpp> #include <components/compiler/locals.hpp>
#include <components/esm/refid.hpp>
#include <components/esm3/loadcrea.hpp> #include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadfact.hpp> #include <components/esm3/loadfact.hpp>
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
#include <components/esm/refid.hpp>
#include "../mwbase/dialoguemanager.hpp" #include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -168,8 +168,7 @@ bool MWDialogue::Filter::testPlayer(const ESM::DialInfo& info) const
// check player faction and rank // check player faction and rank
if (!info.mPcFaction.empty()) if (!info.mPcFaction.empty())
{ {
std::map<ESM::RefId, int>::const_iterator iter std::map<ESM::RefId, int>::const_iterator iter = stats.getFactionRanks().find(info.mPcFaction);
= stats.getFactionRanks().find(info.mPcFaction);
if (iter == stats.getFactionRanks().end()) if (iter == stats.getFactionRanks().end())
return false; return false;
@ -366,7 +365,8 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
case SelectWrapper::Function_Dead: 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: case SelectWrapper::Function_Choice:

@ -39,7 +39,8 @@ namespace MWDialogue
return; 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) Entry::Entry(const ESM::JournalEntry& record)
@ -106,8 +107,8 @@ namespace MWDialogue
{ {
} }
StampedJournalEntry::StampedJournalEntry( StampedJournalEntry::StampedJournalEntry(const ESM::RefId& topic, const ESM::RefId& infoId, int day, int month,
const ESM::RefId& topic, const ESM::RefId& infoId, int day, int month, int dayOfMonth, const MWWorld::Ptr& actor) int dayOfMonth, const MWWorld::Ptr& actor)
: JournalEntry(topic, infoId, actor) : JournalEntry(topic, infoId, actor)
, mDay(day) , mDay(day)
, mMonth(month) , mMonth(month)
@ -131,7 +132,8 @@ namespace MWDialogue
entry.mDayOfMonth = mDayOfMonth; 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 day = MWBase::Environment::get().getWorld()->getGlobalInt("dayspassed");
int month = MWBase::Environment::get().getWorld()->getGlobalInt("month"); int month = MWBase::Environment::get().getWorld()->getGlobalInt("month");

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

@ -11,7 +11,8 @@ namespace MWDialogue
Topic::Topic(const ESM::RefId& topic) Topic::Topic(const ESM::RefId& topic)
: mTopic(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())
{ {
} }

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

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

@ -58,7 +58,8 @@ namespace MWGui
if (mFadeTimeRemaining <= 0) if (mFadeTimeRemaining <= 0)
{ {
MWWorld::Ptr player = MWMechanics::getPlayer(); 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( MWBase::Environment::get().getWindowManager()->fadeScreenOut(
0.f); // override fade-in caused by cell transition 0.f); // override fade-in caused by cell transition

@ -10,7 +10,6 @@
#include <MyGUI_TextBox.h> #include <MyGUI_TextBox.h>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
#include <components/esm/refidhardcoded.hpp>
#include <components/widgets/imagebutton.hpp> #include <components/widgets/imagebutton.hpp>
#include <components/widgets/list.hpp> #include <components/widgets/list.hpp>
@ -414,7 +413,7 @@ namespace
mOptionsMode = false; mOptionsMode = false;
mTopicsMode = 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) void notifyTopicSelected(const std::string& topicIdString, int id)
@ -446,7 +445,7 @@ namespace
mOptionsMode = false; mOptionsMode = false;
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
} }
void notifyOptions(MyGUI::Widget* _sender) void notifyOptions(MyGUI::Widget* _sender)
@ -474,7 +473,7 @@ namespace
assert(mStates.size() > 1); assert(mStates.size() > 1);
popBook(); popBook();
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
} }
void notifyIndexLinkClicked(MWGui::TypesetBook::InteractiveId index) void notifyIndexLinkClicked(MWGui::TypesetBook::InteractiveId index)
@ -495,7 +494,7 @@ namespace
list->adjustSize(); list->adjustSize();
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
} }
void notifyTopics(MyGUI::Widget* _sender) void notifyTopics(MyGUI::Widget* _sender)
@ -510,7 +509,7 @@ namespace
setVisible(ShowAllBTN, false); setVisible(ShowAllBTN, false);
setVisible(ShowActiveBTN, false); setVisible(ShowActiveBTN, false);
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
} }
struct AddNamesToList struct AddNamesToList
@ -567,7 +566,7 @@ namespace
mModel->visitQuestNames(false, setInactive); 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) void notifyShowAll(MyGUI::Widget* _sender)
@ -591,7 +590,7 @@ namespace
else else
{ {
setBookMode(); 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()) if (page + 2 < book->pageCount())
{ {
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
page += 2; page += 2;
updateShowingPages(); updateShowingPages();
@ -639,7 +638,7 @@ namespace
if (page >= 2) if (page >= 2)
{ {
MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page"));
page -= 2; page -= 2;
updateShowingPages(); updateShowingPages();

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

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

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

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

@ -92,7 +92,8 @@ namespace MWGui
const std::string& nameString = name.getRefIdString(); const std::string& nameString = name.getRefIdString();
toAdd->setUserString("price", std::to_string(price)); 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->setSize(mDestinationsView->getWidth(), lineHeight);
toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel);
toAdd->setUserString("Destination", nameString); toAdd->setUserString("Destination", nameString);

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

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

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

@ -6,7 +6,6 @@
#include <components/sdlutil/sdlinputwrapper.hpp> #include <components/sdlutil/sdlinputwrapper.hpp>
#include <components/sdlutil/sdlmappings.hpp> #include <components/sdlutil/sdlmappings.hpp>
#include <components/esm/refidhardcoded.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
@ -167,7 +166,7 @@ namespace MWInput
= MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType<MyGUI::Button>(false); = MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType<MyGUI::Button>(false);
if (b && b->getEnabled() && id == SDL_BUTTON_LEFT) 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); MWBase::Environment::get().getWindowManager()->setCursorActive(true);

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

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

@ -34,17 +34,20 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Apparatus>(); = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Apparatus>();
apparatus["record"] = sol::overload( apparatus["record"] = sol::overload(
[](const Object& obj) -> const ESM::Apparatus* { return obj.ptr().get<ESM::Apparatus>()->mBase; }, [](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"); sol::usertype<ESM::Apparatus> record = context.mLua->sol().new_usertype<ESM::Apparatus>("ESM3_Apparatus");
record[sol::meta_function::to_string] record[sol::meta_function::to_string]
= [](const ESM::Apparatus& rec) { return "ESM3_Apparatus[" + rec.mId.getRefIdString() + "]"; }; = [](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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
}); });
record["mwscript"] record["mwscript"] = sol::readonly_property(
= sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mScript.getRefIdString(); }); [](const ESM::Apparatus& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); 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>(); const MWWorld::Store<ESM::Armor>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Armor>();
armor["record"] armor["record"]
= sol::overload([](const Object& obj) -> const ESM::Armor* { return obj.ptr().get<ESM::Armor>()->mBase; }, = 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"); sol::usertype<ESM::Armor> record = context.mLua->sol().new_usertype<ESM::Armor>("ESM3_Armor");
record[sol::meta_function::to_string] record[sol::meta_function::to_string]
= [](const ESM::Armor& rec) -> std::string { return "ESM3_Armor[" + 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; }); 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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); 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 { record["icon"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });
record["enchant"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mEnchant; }); record["enchant"] = sol::readonly_property(
record["mwscript"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mScript; }); [](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["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["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; }); 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>(); const MWWorld::Store<ESM::Book>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Book>();
book["record"] book["record"]
= sol::overload([](const Object& obj) -> const ESM::Book* { return obj.ptr().get<ESM::Book>()->mBase; }, = 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"); 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[sol::meta_function::to_string]
record["id"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId.getRefIdString(); }); = [](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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); 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 { record["icon"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });
record["text"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mText; }); 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["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["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; }); 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>(); = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Container>();
container["record"] = sol::overload( container["record"] = sol::overload(
[](const Object& obj) -> const ESM::Container* { return obj.ptr().get<ESM::Container>()->mBase; }, [](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"); sol::usertype<ESM::Container> record = context.mLua->sol().new_usertype<ESM::Container>("ESM3_Container");
record[sol::meta_function::to_string] record[sol::meta_function::to_string] = [](const ESM::Container& rec) -> std::string {
= [](const ESM::Container& rec) -> std::string { return "ESM3_Container[" + rec.mId.getRefIdString() + "]"; }; return "ESM3_Container[" + rec.mId.getRefIdString() + "]";
record["id"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return 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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Container& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
}); });
record["mwscript"] record["mwscript"] = sol::readonly_property(
= sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mScript.getRefIdString(); }); [](const ESM::Container& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["weight"] = sol::readonly_property([](const ESM::Container& rec) -> float { return rec.mWeight; }); 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>(); = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>();
creature["record"] = sol::overload( creature["record"] = sol::overload(
[](const Object& obj) -> const ESM::Creature* { return obj.ptr().get<ESM::Creature>()->mBase; }, [](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"); sol::usertype<ESM::Creature> record = context.mLua->sol().new_usertype<ESM::Creature>("ESM3_Creature");
record[sol::meta_function::to_string] record[sol::meta_function::to_string]
= [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId.getRefIdString() + "]"; }; = [](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 { record["model"] = sol::readonly_property([vfs](const ESM::Creature& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
}); });
record["mwscript"] record["mwscript"] = sol::readonly_property(
= sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mScript.getRefIdString(); }); [](const ESM::Creature& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["baseCreature"] record["baseCreature"] = sol::readonly_property(
= sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mOriginal.getRefIdString(); }); [](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>(); const MWWorld::Store<ESM::Door>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Door>();
door["record"] door["record"]
= sol::overload([](const Object& obj) -> const ESM::Door* { return obj.ptr().get<ESM::Door>()->mBase; }, = 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"); sol::usertype<ESM::Door> record = context.mLua->sol().new_usertype<ESM::Door>("ESM3_Door");
record[sol::meta_function::to_string] record[sol::meta_function::to_string]
= [](const ESM::Door& rec) -> std::string { return "ESM3_Door[" + rec.mId.getRefIdString() + "]"; }; = [](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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Door& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
}); });
record["mwscript"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["mwscript"]
record["openSound"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript.getRefIdString(); });
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mOpenSound.getRefIdString(); }); record["openSound"] = sol::readonly_property(
record["closeSound"] [](const ESM::Door& rec) -> std::string { return rec.mOpenSound.getRefIdString(); });
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mCloseSound.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>(); = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>();
ingredient["record"] = sol::overload( ingredient["record"] = sol::overload(
[](const Object& obj) -> const ESM::Ingredient* { return obj.ptr().get<ESM::Ingredient>()->mBase; }, [](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")); sol::usertype<ESM::Ingredient> record = context.mLua->sol().new_usertype<ESM::Ingredient>(("ESM3_Ingredient"));
record[sol::meta_function::to_string] record[sol::meta_function::to_string]
= [](const ESM::Potion& rec) { return "ESM3_Ingredient[" + rec.mId.getRefIdString() + "]"; }; = [](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["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["model"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mModel; });
record["mwscript"] record["mwscript"] = sol::readonly_property(
= sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mScript.getRefIdString(); }); [](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["icon"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mIcon; });
record["weight"] record["weight"]
= sol::readonly_property([](const ESM::Ingredient& rec) -> float { return rec.mData.mWeight; }); = 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>(); const MWWorld::Store<ESM::Light>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Light>();
light["record"] light["record"]
= sol::overload([](const Object& obj) -> const ESM::Light* { return obj.ptr().get<ESM::Light>()->mBase; }, = 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"); sol::usertype<ESM::Light> record = context.mLua->sol().new_usertype<ESM::Light>("ESM3_Light");
record[sol::meta_function::to_string] record[sol::meta_function::to_string]
= [](const ESM::Light& rec) -> std::string { return "ESM3_Light[" + 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; }); 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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
@ -39,9 +42,10 @@ namespace MWLua
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });
record["sound"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string { 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["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["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; }); 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>(); = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Lockpick>();
lockpick["record"] = sol::overload( lockpick["record"] = sol::overload(
[](const Object& obj) -> const ESM::Lockpick* { return obj.ptr().get<ESM::Lockpick>()->mBase; }, [](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"); sol::usertype<ESM::Lockpick> record = context.mLua->sol().new_usertype<ESM::Lockpick>("ESM3_Lockpick");
record[sol::meta_function::to_string] record[sol::meta_function::to_string]
= [](const ESM::Lockpick& rec) { return "ESM3_Lockpick[" + rec.mId.getRefIdString() + "]"; }; = [](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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
}); });
record["mwscript"] record["mwscript"] = sol::readonly_property(
= sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mScript.getRefIdString(); }); [](const ESM::Lockpick& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });

@ -27,18 +27,21 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Miscellaneous>(); = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Miscellaneous>();
miscellaneous["record"] = sol::overload( miscellaneous["record"] = sol::overload(
[](const Object& obj) -> const ESM::Miscellaneous* { return obj.ptr().get<ESM::Miscellaneous>()->mBase; }, [](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 sol::usertype<ESM::Miscellaneous> record
= context.mLua->sol().new_usertype<ESM::Miscellaneous>("ESM3_Miscellaneous"); = context.mLua->sol().new_usertype<ESM::Miscellaneous>("ESM3_Miscellaneous");
record[sol::meta_function::to_string] record[sol::meta_function::to_string]
= [](const ESM::Miscellaneous& rec) { return "ESM3_Miscellaneous[" + rec.mId.getRefIdString() + "]"; }; = [](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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
}); });
record["mwscript"] record["mwscript"] = sol::readonly_property(
= sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript.getRefIdString(); }); [](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript.getRefIdString(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); 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>(); const MWWorld::Store<ESM::NPC>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::NPC>();
npc["record"] npc["record"]
= sol::overload([](const Object& obj) -> const ESM::NPC* { return obj.ptr().get<ESM::NPC>()->mBase; }, = 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"); 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["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["race"]
record["class"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mClass.getRefIdString(); }); = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mRace.getRefIdString(); });
record["mwscript"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["class"]
record["hair"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHair.getRefIdString(); }); = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mClass.getRefIdString(); });
record["head"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.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>(); = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>();
potion["record"] potion["record"]
= sol::overload([](const Object& obj) -> const ESM::Potion* { return obj.ptr().get<ESM::Potion>()->mBase; }, = 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(); auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
sol::usertype<ESM::Potion> record = context.mLua->sol().new_usertype<ESM::Potion>("ESM3_Potion"); 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[sol::meta_function::to_string]
record["id"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId.getRefIdString(); }); = [](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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); 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 { record["icon"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); 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["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; }); 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>(); const MWWorld::Store<ESM::Probe>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Probe>();
probe["record"] probe["record"]
= sol::overload([](const Object& obj) -> const ESM::Probe* { return obj.ptr().get<ESM::Probe>()->mBase; }, = 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"); 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[sol::meta_function::to_string]
record["id"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId.getRefIdString(); }); = [](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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); 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 { record["icon"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });

@ -27,15 +27,20 @@ namespace MWLua
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Repair>(); = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Repair>();
repair["record"] repair["record"]
= sol::overload([](const Object& obj) -> const ESM::Repair* { return obj.ptr().get<ESM::Repair>()->mBase; }, = 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"); 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[sol::meta_function::to_string]
record["id"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId.getRefIdString(); }); = [](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["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 { record["model"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); 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 { record["icon"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });

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

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

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

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

@ -208,7 +208,8 @@ namespace
if (caster == MWMechanics::getPlayer()) if (caster == MWMechanics::getPlayer())
MWBase::Environment::get().getWindowManager()->messageBox("#{sSoultrapSuccess}"); 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) if (fx != nullptr)
{ {
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
@ -1833,8 +1834,8 @@ namespace MWMechanics
{ {
MWBase::Environment::get().getWorld()->deleteObject(ptr); MWBase::Environment::get().getWorld()->deleteObject(ptr);
const ESM::Static* fx const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().search(
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_End")); ESM::RefId::stringRefId("VFX_Summon_End"));
if (fx) if (fx)
{ {
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); 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 /// 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); 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 /// Follow Actor for duration or until you arrive at a position in a cell
AiFollow( AiFollow(const ESM::RefId& actorId, const ESM::RefId& cellId, float duration, float x, float y, float z,
const ESM::RefId& actorId, const ESM::RefId& cellId, float duration, float x, float y, float z, bool repeat); bool repeat);
/// Follow Actor indefinitively /// Follow Actor indefinitively
AiFollow(const MWWorld::Ptr& actor, bool commanded = false); AiFollow(const MWWorld::Ptr& actor, bool commanded = false);

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

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

@ -100,8 +100,7 @@ namespace MWMechanics
if (cap.mReachedLimit) if (cap.mReachedLimit)
{ {
auto found auto found = std::find(selectedSpells.begin(), selectedSpells.end(), cap.mWeakestSpell);
= std::find(selectedSpells.begin(), selectedSpells.end(), cap.mWeakestSpell);
if (found != selectedSpells.end()) if (found != selectedSpells.end())
selectedSpells.erase(found); selectedSpells.erase(found);
@ -148,7 +147,8 @@ namespace MWMechanics
return selectedSpells; return selectedSpells;
} }
std::vector<ESM::RefId> autoCalcPlayerSpells(const int* actorSkills, const int* actorAttributes, const ESM::Race* race) std::vector<ESM::RefId> autoCalcPlayerSpells(
const int* actorSkills, const int* actorAttributes, const ESM::Race* race)
{ {
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore();

@ -1,9 +1,9 @@
#ifndef OPENMW_AUTOCALCSPELL_H #ifndef OPENMW_AUTOCALCSPELL_H
#define OPENMW_AUTOCALCSPELL_H #define OPENMW_AUTOCALCSPELL_H
#include <components/esm/refid.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
#include <components/esm/refid.hpp>
namespace ESM namespace ESM
{ {
struct Spell; struct Spell;

@ -21,7 +21,6 @@
#include <sstream> #include <sstream>
#include <components/esm/refidhardcoded.hpp>
#include <components/esm/records.hpp> #include <components/esm/records.hpp>
#include <components/misc/mathutil.hpp> #include <components/misc/mathutil.hpp>
#include <components/misc/resourcehelpers.hpp> #include <components/misc/resourcehelpers.hpp>
@ -1443,7 +1442,7 @@ namespace MWMechanics
if (isWerewolf) if (isWerewolf)
{ {
const static ESM::RefId wolfRun = ESM::RefId::stringRefId("WorldRun"); const ESM::RefId wolfRun = ESM::RefId::stringRefId("WorldRun");
if (isRunning() && !world->isSwimming(mPtr) && mWeaponType == ESM::Weapon::None) if (isRunning() && !world->isSwimming(mPtr) && mWeaponType == ESM::Weapon::None)
{ {
if (!sndMgr->getSoundPlaying(mPtr, wolfRun)) if (!sndMgr->getSoundPlaying(mPtr, wolfRun))
@ -1548,7 +1547,8 @@ namespace MWMechanics
const ESM::MagicEffect* effect = store.get<ESM::MagicEffect>().find( const ESM::MagicEffect* effect = store.get<ESM::MagicEffect>().find(
effects->back().mEffectID); // use last effect of list for color of VFX_Hands effects->back().mEffectID); // use last effect of list for color of VFX_Hands
const ESM::Static* castStatic = world->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Hands")); const ESM::Static* castStatic
= world->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Hands"));
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
@ -2137,7 +2137,7 @@ namespace MWMechanics
float realHealthLost = healthLost * (1.0f - 0.25f * fatigueTerm); float realHealthLost = healthLost * (1.0f - 0.25f * fatigueTerm);
health.setCurrent(health.getCurrent() - realHealthLost); health.setCurrent(health.getCurrent() - realHealthLost);
cls.getCreatureStats(mPtr).setHealth(health); cls.getCreatureStats(mPtr).setHealth(health);
sndMgr->playSound3D(mPtr, ESM::sHealthDamageSoundId, 1.0f, 1.0f); sndMgr->playSound3D(mPtr, ESM::RefId::stringRefId("Health Damage"), 1.0f, 1.0f);
if (isPlayer) if (isPlayer)
MWBase::Environment::get().getWindowManager()->activateHitOverlay(); MWBase::Environment::get().getWindowManager()->activateHitOverlay();
} }
@ -2158,19 +2158,17 @@ namespace MWMechanics
if (mPtr.getClass().isNpc()) if (mPtr.getClass().isNpc())
{ {
const ESM::RefId* sound = nullptr; std::string_view sound;
static const ESM::RefId defaultLandWater = ESM::RefId::stringRefId("DefaultLandWater");
static const ESM::RefId defaultLand = ESM::RefId::stringRefId("DefaultLand");
osg::Vec3f pos(mPtr.getRefData().getPosition().asVec3()); osg::Vec3f pos(mPtr.getRefData().getPosition().asVec3());
if (world->isUnderwater(mPtr.getCell(), pos) || world->isWalkingOnWater(mPtr)) if (world->isUnderwater(mPtr.getCell(), pos) || world->isWalkingOnWater(mPtr))
sound = &defaultLandWater; sound = "DefaultLandWater";
else if (onground) else if (onground)
sound = &defaultLand; sound = "DefaultLand";
if (sound && !sound->empty()) if (!sound.empty())
sndMgr->playSound3D( sndMgr->playSound3D(mPtr, ESM::RefId::stringRefId(sound), 1.f, 1.f, MWSound::Type::Foot,
mPtr, *sound, 1.f, 1.f, MWSound::Type::Foot, MWSound::PlayMode::NoPlayerLocal); MWSound::PlayMode::NoPlayerLocal);
} }
} }

@ -9,7 +9,6 @@
#include <components/esm3/loadench.hpp> #include <components/esm3/loadench.hpp>
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
#include <components/esm3/loadsoun.hpp> #include <components/esm3/loadsoun.hpp>
#include <components/esm/refidhardcoded.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
@ -45,7 +44,8 @@ namespace MWMechanics
bool applyOnStrikeEnchantment(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& object, bool applyOnStrikeEnchantment(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& object,
const osg::Vec3f& hitPosition, const bool fromProjectile) const osg::Vec3f& hitPosition, const bool fromProjectile)
{ {
const ESM::RefId& enchantmentName = !object.isEmpty() ? object.getClass().getEnchantment(object) : ESM::RefId::sEmpty; const ESM::RefId& enchantmentName
= !object.isEmpty() ? object.getClass().getEnchantment(object) : ESM::RefId::sEmpty;
if (!enchantmentName.empty()) if (!enchantmentName.empty())
{ {
const ESM::Enchantment* enchantment const ESM::Enchantment* enchantment
@ -269,7 +269,8 @@ namespace MWMechanics
static const float fCombatKODamageMult = gmst.find("fCombatKODamageMult")->mValue.getFloat(); static const float fCombatKODamageMult = gmst.find("fCombatKODamageMult")->mValue.getFloat();
damage *= fCombatKODamageMult; damage *= fCombatKODamageMult;
if (!knockedDown) if (!knockedDown)
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);
} }
} }
@ -383,7 +384,8 @@ namespace MWMechanics
health.setCurrent(health.getCurrent() - x); health.setCurrent(health.getCurrent() - x);
attackerStats.setHealth(health); attackerStats.setHealth(health);
MWBase::Environment::get().getSoundManager()->playSound3D(attacker, ESM::sHealthDamageSoundId, 1.0f, 1.0f); MWBase::Environment::get().getSoundManager()->playSound3D(
attacker, ESM::RefId::stringRefId("Health Damage"), 1.0f, 1.0f);
} }
} }

@ -6,7 +6,6 @@
#include <components/esm/records.hpp> #include <components/esm/records.hpp>
#include <components/esm/refid.hpp> #include <components/esm/refid.hpp>
#include <components/esm/refidhardcoded.hpp>
#include <components/esm3/esmwriter.hpp> #include <components/esm3/esmwriter.hpp>
#include <components/esm3/loadgmst.hpp> #include <components/esm3/loadgmst.hpp>
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
@ -85,7 +84,8 @@ namespace
const MWWorld::CellRef& cellref = target.getCellRef(); const MWWorld::CellRef& cellref = target.getCellRef();
const ESM::RefId& owner = cellref.getOwner(); const ESM::RefId& owner = cellref.getOwner();
bool isOwned = !owner.empty() && owner != ESM::sPlayerId; bool isOwned = !owner.empty() && owner != ESM::RefId::stringRefId("Player");
;
const ESM::RefId& faction = cellref.getFaction(); const ESM::RefId& faction = cellref.getFaction();
bool isFactionOwned = false; bool isFactionOwned = false;
@ -892,7 +892,8 @@ namespace MWMechanics
return true; return true;
// TODO: implement a better check to check if target is owned bed // TODO: implement a better check to check if target is owned bed
if (target.getClass().isActivator() && target.getClass().getScript(target).getRefIdString().compare(0, 3, "Bed") != 0) if (target.getClass().isActivator()
&& target.getClass().getScript(target).getRefIdString().compare(0, 3, "Bed") != 0)
return true; return true;
if (target.getClass().isNpc()) if (target.getClass().isNpc())
@ -914,8 +915,7 @@ namespace MWMechanics
return false; return false;
// A special case for evidence chest - we should not allow to take items even if it is technically permitted // A special case for evidence chest - we should not allow to take items even if it is technically permitted
static const ESM::RefId stolenGoods = ESM::RefId::stringRefId("stolen_goods"); return !(cellref.getRefId() == "stolen_goods");
return !(cellref.getRefId() == stolenGoods);
} }
bool MechanicsManager::sleepInBed(const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed) bool MechanicsManager::sleepInBed(const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed)
@ -989,8 +989,7 @@ namespace MWMechanics
const ESM::RefId& factionid = ptr.getClass().getPrimaryFaction(ptr); const ESM::RefId& factionid = ptr.getClass().getPrimaryFaction(ptr);
if (!factionid.empty()) if (!factionid.empty())
{ {
OwnerMap::const_iterator factionOwnerFound OwnerMap::const_iterator factionOwnerFound = owners.find(std::make_pair(factionid, true));
= owners.find(std::make_pair(factionid, true));
return factionOwnerFound != owners.end(); return factionOwnerFound != owners.end();
} }
@ -1014,8 +1013,7 @@ namespace MWMechanics
owner.second = false; owner.second = false;
const ESM::RefId& victimFaction = victim.getClass().getPrimaryFaction(victim); const ESM::RefId& victimFaction = victim.getClass().getPrimaryFaction(victim);
if (!victimFaction.empty() if (!victimFaction.empty() && item.getCellRef().getFaction() == victimFaction) // Is the item faction-owned?
&& item.getCellRef().getFaction() == victimFaction) // Is the item faction-owned?
{ {
owner.first = victimFaction; owner.first = victimFaction;
owner.second = true; owner.second = true;
@ -1048,8 +1046,7 @@ namespace MWMechanics
MWWorld::ContainerStore& containerStore = targetContainer.getClass().getContainerStore(targetContainer); MWWorld::ContainerStore& containerStore = targetContainer.getClass().getContainerStore(targetContainer);
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{ {
StolenItemsMap::iterator stolenIt StolenItemsMap::iterator stolenIt = mStolenItems.find(it->getCellRef().getRefId());
= mStolenItems.find(it->getCellRef().getRefId());
if (stolenIt == mStolenItems.end()) if (stolenIt == mStolenItems.end())
continue; continue;
OwnerMap& owners = stolenIt->second; OwnerMap& owners = stolenIt->second;
@ -1786,7 +1783,8 @@ namespace MWMechanics
|| (target == getPlayer() && MWBase::Environment::get().getWorld()->getGlobalInt("pcknownwerewolf"))) || (target == getPlayer() && MWBase::Environment::get().getWorld()->getGlobalInt("pcknownwerewolf")))
{ {
const ESM::GameSetting* iWerewolfFightMod const ESM::GameSetting* iWerewolfFightMod
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("iWerewolfFightMod"); = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
"iWerewolfFightMod");
fight += iWerewolfFightMod->mValue.getInteger(); fight += iWerewolfFightMod->mValue.getInteger();
} }
} }
@ -1840,7 +1838,8 @@ namespace MWMechanics
if (werewolf) if (werewolf)
{ {
inv.unequipAll(actor); inv.unequipAll(actor);
inv.equip(MWWorld::InventoryStore::Slot_Robe, inv.ContainerStore::add(ESM::RefId::stringRefId("werewolfrobe"), 1, actor), actor); inv.equip(MWWorld::InventoryStore::Slot_Robe,
inv.ContainerStore::add(ESM::RefId::stringRefId("werewolfrobe"), 1, actor), actor);
} }
else else
{ {

@ -493,8 +493,7 @@ void MWMechanics::NpcStats::writeState(ESM::NpcStats& state) const
for (auto iter(mExpelled.begin()); iter != mExpelled.end(); ++iter) for (auto iter(mExpelled.begin()); iter != mExpelled.end(); ++iter)
state.mFactions[*iter].mExpelled = true; state.mFactions[*iter].mExpelled = true;
for (auto iter(mFactionReputation.begin()); iter != mFactionReputation.end(); for (auto iter(mFactionReputation.begin()); iter != mFactionReputation.end(); ++iter)
++iter)
state.mFactions[iter->first].mReputation = iter->second; state.mFactions[iter->first].mReputation = iter->second;
state.mReputation = mReputation; state.mReputation = mReputation;
@ -520,8 +519,7 @@ void MWMechanics::NpcStats::readState(const ESM::NpcStats& state)
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
for (auto iter(state.mFactions.begin()); for (auto iter(state.mFactions.begin()); iter != state.mFactions.end(); ++iter)
iter != state.mFactions.end(); ++iter)
if (store.get<ESM::Faction>().search(iter->first)) if (store.get<ESM::Faction>().search(iter->first))
{ {
if (iter->second.mExpelled) if (iter->second.mExpelled)

@ -1,12 +1,12 @@
#ifndef GAME_MWMECHANICS_NPCSTATS_H #ifndef GAME_MWMECHANICS_NPCSTATS_H
#define GAME_MWMECHANICS_NPCSTATS_H #define GAME_MWMECHANICS_NPCSTATS_H
#include "creaturestats.hpp"
#include <components/esm/refid.hpp>
#include <map> #include <map>
#include <set> #include <set>
#include <string> #include <string>
#include <vector> #include <vector>
#include <components/esm/refid.hpp>
#include "creaturestats.hpp"
namespace ESM namespace ESM
{ {

@ -97,7 +97,7 @@ namespace MWMechanics
MWBase::Environment::get().getWindowManager()->messageBox(message); MWBase::Environment::get().getWindowManager()->messageBox(message);
static const ESM::RefId soulGemAzura = ESM::RefId::stringRefId("Misc_SoulGem_Azura"); const ESM::RefId soulGemAzura = ESM::RefId::stringRefId("Misc_SoulGem_Azura");
// special case: readd Azura's Star // special case: readd Azura's Star
if (gem.get<ESM::Miscellaneous>()->mBase->mId == soulGemAzura) if (gem.get<ESM::Miscellaneous>()->mBase->mId == soulGemAzura)
player.getClass().getContainerStore(player).add(soulGemAzura, 1, player); player.getClass().getContainerStore(player).add(soulGemAzura, 1, player);

@ -90,7 +90,8 @@ namespace MWMechanics
if (!effect->mAreaSound.empty()) if (!effect->mAreaSound.empty())
sndMgr->playSound3D(mHitPosition, effect->mAreaSound, 1.0f, 1.0f); sndMgr->playSound3D(mHitPosition, effect->mAreaSound, 1.0f, 1.0f);
else else
sndMgr->playSound3D(mHitPosition, ESM::RefId::stringRefId(schools[effect->mData.mSchool] + " area"), 1.0f, 1.0f); sndMgr->playSound3D(
mHitPosition, ESM::RefId::stringRefId(schools[effect->mData.mSchool] + " area"), 1.0f, 1.0f);
} }
// Get the actors in range of the effect // Get the actors in range of the effect
std::vector<MWWorld::Ptr> objects; std::vector<MWWorld::Ptr> objects;
@ -342,7 +343,8 @@ namespace MWMechanics
static const std::string schools[] static const std::string schools[]
= { "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" }; = { "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" };
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
sndMgr->playSound3D(mCaster, ESM::RefId::stringRefId("Spell Failure " + schools[school]), 1.0f, 1.0f); sndMgr->playSound3D(
mCaster, ESM::RefId::stringRefId("Spell Failure " + schools[school]), 1.0f, 1.0f);
} }
return false; return false;
} }
@ -429,7 +431,8 @@ namespace MWMechanics
= { "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" }; = { "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" };
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
sndMgr->playSound3D(mCaster, ESM::RefId::stringRefId("Spell Failure " + schools[school]), 1.0f, 1.0f); sndMgr->playSound3D(
mCaster, ESM::RefId::stringRefId("Spell Failure " + schools[school]), 1.0f, 1.0f);
return false; return false;
} }
} }
@ -600,7 +603,8 @@ namespace MWMechanics
if (!effect->mCastSound.empty()) if (!effect->mCastSound.empty())
sndMgr->playSound3D(mCaster, effect->mCastSound, 1.0f, 1.0f); sndMgr->playSound3D(mCaster, effect->mCastSound, 1.0f, 1.0f);
else else
sndMgr->playSound3D(mCaster, ESM::RefId::stringRefId(schools[effect->mData.mSchool] + " cast"), 1.0f, 1.0f); sndMgr->playSound3D(
mCaster, ESM::RefId::stringRefId(schools[effect->mData.mSchool] + " cast"), 1.0f, 1.0f);
} }
} }
@ -615,7 +619,8 @@ namespace MWMechanics
if (!magicEffect.mHitSound.empty()) if (!magicEffect.mHitSound.empty())
sndMgr->playSound3D(target, magicEffect.mHitSound, 1.0f, 1.0f); sndMgr->playSound3D(target, magicEffect.mHitSound, 1.0f, 1.0f);
else else
sndMgr->playSound3D(target, ESM::RefId::stringRefId(schools[magicEffect.mData.mSchool] + " hit"), 1.0f, 1.0f); sndMgr->playSound3D(
target, ESM::RefId::stringRefId(schools[magicEffect.mData.mSchool] + " hit"), 1.0f, 1.0f);
} }
// Add VFX // Add VFX
@ -623,7 +628,8 @@ namespace MWMechanics
if (!magicEffect.mHit.empty()) if (!magicEffect.mHit.empty())
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(magicEffect.mHit); castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(magicEffect.mHit);
else else
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_DefaultHit")); castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(
ESM::RefId::stringRefId("VFX_DefaultHit"));
bool loop = (magicEffect.mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0; bool loop = (magicEffect.mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(target); MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(target);

@ -206,16 +206,15 @@ namespace
void removeBoundItem(const ESM::RefId& itemId, const MWWorld::Ptr& actor) void removeBoundItem(const ESM::RefId& itemId, const MWWorld::Ptr& actor)
{ {
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor); MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
auto item = std::find_if(store.begin(), store.end(), auto item = std::find_if(
[&](const auto& it) { return it.getCellRef().getRefId() == itemId; }); store.begin(), store.end(), [&](const auto& it) { return it.getCellRef().getRefId() == itemId; });
if (item == store.end()) if (item == store.end())
return; return;
int slot = getBoundItemSlot(*item); int slot = getBoundItemSlot(*item);
auto currentItem = store.getSlot(slot); auto currentItem = store.getSlot(slot);
bool wasEquipped bool wasEquipped = currentItem != store.end() && currentItem->getCellRef().getRefId() == itemId;
= currentItem != store.end() && currentItem->getCellRef().getRefId() == itemId;
if (wasEquipped) if (wasEquipped)
store.remove(*currentItem, 1, actor); store.remove(*currentItem, 1, actor);
@ -457,7 +456,8 @@ namespace MWMechanics
{ {
MWRender::Animation* anim = world->getAnimation(caster); MWRender::Animation* anim = world->getAnimation(caster);
anim->removeEffect(effect.mEffectId); anim->removeEffect(effect.mEffectId);
const ESM::Static* fx = world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_end")); const ESM::Static* fx
= world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_end"));
if (fx) if (fx)
{ {
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
@ -565,8 +565,9 @@ namespace MWMechanics
const auto& magnitudes = target.getClass().getCreatureStats(target).getMagicEffects(); const auto& magnitudes = target.getClass().getCreatureStats(target).getMagicEffects();
float volume = std::clamp( float volume = std::clamp(
(magnitudes.get(effect.mEffectId).getModifier() + effect.mMagnitude) / 100.f, 0.f, 1.f); (magnitudes.get(effect.mEffectId).getModifier() + effect.mMagnitude) / 100.f, 0.f, 1.f);
MWBase::Environment::get().getSoundManager()->playSound3D( MWBase::Environment::get().getSoundManager()->playSound3D(target,
target, ESM::RefId::stringRefId("magic sound"), volume, 1.f, MWSound::Type::Sfx, MWSound::PlayMode::LoopNoEnv); ESM::RefId::stringRefId("magic sound"), volume, 1.f, MWSound::Type::Sfx,
MWSound::PlayMode::LoopNoEnv);
} }
break; break;
case ESM::MagicEffect::SummonScamp: case ESM::MagicEffect::SummonScamp:
@ -602,8 +603,10 @@ namespace MWMechanics
invalid = true; invalid = true;
break; break;
} }
addBoundItem(ESM::RefId::stringRefId( addBoundItem(ESM::RefId::stringRefId(world->getStore()
world->getStore().get<ESM::GameSetting>().find("sMagicBoundRightGauntletID")->mValue.getString()), .get<ESM::GameSetting>()
.find("sMagicBoundRightGauntletID")
->mValue.getString()),
target); target);
// left gauntlet added below // left gauntlet added below
[[fallthrough]]; [[fallthrough]];
@ -622,7 +625,9 @@ namespace MWMechanics
else else
{ {
const std::string& item = sBoundItemsMap.at(effect.mEffectId); const std::string& item = sBoundItemsMap.at(effect.mEffectId);
addBoundItem(ESM::RefId::stringRefId(world->getStore().get<ESM::GameSetting>().find(item)->mValue.getString()), target); addBoundItem(ESM::RefId::stringRefId(
world->getStore().get<ESM::GameSetting>().find(item)->mValue.getString()),
target);
} }
break; break;
case ESM::MagicEffect::FireDamage: case ESM::MagicEffect::FireDamage:
@ -946,7 +951,8 @@ namespace MWMechanics
{ {
if (target.getCellRef().getLockLevel() > 0) if (target.getCellRef().getLockLevel() > 0)
{ {
MWBase::Environment::get().getSoundManager()->playSound3D(target, ESM::RefId::stringRefId("Open Lock"), 1.f, 1.f); MWBase::Environment::get().getSoundManager()->playSound3D(
target, ESM::RefId::stringRefId("Open Lock"), 1.f, 1.f);
if (caster == getPlayer()) if (caster == getPlayer())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}");
@ -955,7 +961,8 @@ namespace MWMechanics
} }
else else
{ {
MWBase::Environment::get().getSoundManager()->playSound3D(target, ESM::RefId::stringRefId("Open Lock Fail"), 1.f, 1.f); MWBase::Environment::get().getSoundManager()->playSound3D(
target, ESM::RefId::stringRefId("Open Lock Fail"), 1.f, 1.f);
} }
} }
else else
@ -1105,7 +1112,8 @@ namespace MWMechanics
break; break;
case ESM::MagicEffect::Sound: case ESM::MagicEffect::Sound:
if (magnitudes.get(effect.mEffectId).getModifier() <= 0.f && target == getPlayer()) if (magnitudes.get(effect.mEffectId).getModifier() <= 0.f && target == getPlayer())
MWBase::Environment::get().getSoundManager()->stopSound3D(target, ESM::RefId::stringRefId("magic sound")); MWBase::Environment::get().getSoundManager()->stopSound3D(
target, ESM::RefId::stringRefId("magic sound"));
break; break;
case ESM::MagicEffect::SummonScamp: case ESM::MagicEffect::SummonScamp:
case ESM::MagicEffect::SummonClannfear: case ESM::MagicEffect::SummonClannfear:
@ -1145,8 +1153,10 @@ namespace MWMechanics
} }
break; break;
case ESM::MagicEffect::BoundGloves: case ESM::MagicEffect::BoundGloves:
removeBoundItem( removeBoundItem(ESM::RefId::stringRefId(world->getStore()
ESM::RefId::stringRefId(world->getStore().get<ESM::GameSetting>().find("sMagicBoundRightGauntletID")->mValue.getString()), .get<ESM::GameSetting>()
.find("sMagicBoundRightGauntletID")
->mValue.getString()),
target); target);
[[fallthrough]]; [[fallthrough]];
case ESM::MagicEffect::BoundDagger: case ESM::MagicEffect::BoundDagger:
@ -1161,7 +1171,9 @@ namespace MWMechanics
case ESM::MagicEffect::BoundShield: case ESM::MagicEffect::BoundShield:
{ {
const std::string& item = sBoundItemsMap.at(effect.mEffectId); const std::string& item = sBoundItemsMap.at(effect.mEffectId);
removeBoundItem(ESM::RefId::stringRefId(world->getStore().get<ESM::GameSetting>().find(item)->mValue.getString()), target); removeBoundItem(
ESM::RefId::stringRefId(world->getStore().get<ESM::GameSetting>().find(item)->mValue.getString()),
target);
} }
break; break;
case ESM::MagicEffect::DrainHealth: case ESM::MagicEffect::DrainHealth:

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

Loading…
Cancel
Save