diff --git a/apps/essimporter/importer.cpp b/apps/essimporter/importer.cpp index ef96d8ad11..3799e6981a 100644 --- a/apps/essimporter/importer.cpp +++ b/apps/essimporter/importer.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -375,7 +374,7 @@ namespace ESSImport profile.mInGameTime.mYear = context.mYear; profile.mTimePlayed = 0; profile.mPlayerCell = ESM::RefId::stringRefId(header.mGameData.mCurrentCell.toString()); - if (context.mPlayerBase.mClass == ESM::RefId::stringRefId("NEWCLASSID_CHARGEN")) + if (context.mPlayerBase.mClass == "NEWCLASSID_CHARGEN") profile.mPlayerClassName = context.mCustomPlayerClassName; else profile.mPlayerClassId = context.mPlayerBase.mClass; @@ -398,7 +397,7 @@ namespace ESSImport } writer.startRecord(ESM::REC_NPC_); - context.mPlayerBase.mId = ESM::sPlayerId; + context.mPlayerBase.mId = ESM::RefId::stringRefId("Player"); context.mPlayerBase.save(writer); writer.endRecord(ESM::REC_NPC_); diff --git a/apps/navmeshtool/main.cpp b/apps/navmeshtool/main.cpp index 8eb4b3e92f..808f393b49 100644 --- a/apps/navmeshtool/main.cpp +++ b/apps/navmeshtool/main.cpp @@ -229,7 +229,8 @@ namespace NavMeshTool DetourNavigator::RecastGlobalAllocator::init(); DetourNavigator::Settings navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager(); navigatorSettings.mRecast.mSwimHeightScale - = EsmLoader::getGameSetting(esmData.mGameSettings, ESM::RefId::stringRefId("fSwimHeightScale")).getFloat(); + = EsmLoader::getGameSetting(esmData.mGameSettings, ESM::RefId::stringRefId("fSwimHeightScale")) + .getFloat(); WorldspaceData cellsData = gatherWorldspaceData( navigatorSettings, readers, vfs, bulletShapeManager, esmData, processInteriorCells, writeBinaryLog); diff --git a/apps/navmeshtool/worldspacedata.cpp b/apps/navmeshtool/worldspacedata.cpp index 8ac6090cac..5e1c94f9cb 100644 --- a/apps/navmeshtool/worldspacedata.cpp +++ b/apps/navmeshtool/worldspacedata.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -36,7 +37,6 @@ #include #include #include -#include namespace NavMeshTool { namespace diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index eab9dce8cd..ae43953652 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -504,7 +504,8 @@ void CSMDoc::Document::startRunning(const std::string& profile, const std::strin contentFiles.emplace_back(mContentFile.filename()); } - mRunner.configure(getData().getDebugProfiles().getRecord(ESM::RefId::stringRefId(profile)).get(), contentFiles, startupInstruction); + mRunner.configure(getData().getDebugProfiles().getRecord(ESM::RefId::stringRefId(profile)).get(), contentFiles, + startupInstruction); int state = getState(); diff --git a/apps/opencs/model/doc/savingstages.cpp b/apps/opencs/model/doc/savingstages.cpp index 2d2f066906..7e75dffffc 100644 --- a/apps/opencs/model/doc/savingstages.cpp +++ b/apps/opencs/model/doc/savingstages.cpp @@ -178,7 +178,7 @@ void CSMDoc::WriteDialogueCollectionStage::perform(int stage, Messages& messages if ((*iter)->isModified() || (*iter)->mState == CSMWorld::RecordBase::State_Deleted) { ESM::DialInfo info = (*iter)->get(); - std::string infoIdString = info.mId.getRefIdString(); + std::string_view infoIdString = info.mId.getRefIdString(); info.mId = ESM::RefId::stringRefId(infoIdString.substr(infoIdString.find_last_of('#') + 1)); info.mPrev = ESM::RefId::sEmpty; @@ -269,7 +269,8 @@ void CSMDoc::CollectionReferencesStage::perform(int stage, Messages& messages) // An empty mOriginalCell is meant to indicate that it is the same as // the current cell. It is possible that a moved ref is moved again. - if ((record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell) != ESM::RefId::stringRefId(stream.str()) + if ((record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell) + != ESM::RefId::stringRefId(stream.str()) && !interior && record.mState != CSMWorld::RecordBase::State_ModifiedOnly && !record.get().mNew) indices.push_back(i); else @@ -316,8 +317,7 @@ void CSMDoc::WriteCellCollectionStage::writeReferences( ESM::RefId streamId = ESM::RefId::stringRefId(stream.str()); if (refRecord.mNew || refRecord.mRefNum.mIndex == 0 - || (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly - && refRecord.mCell != streamId)) + || (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly && refRecord.mCell != streamId)) { refRecord.mRefNum.mIndex = newRefNum++; } @@ -390,7 +390,8 @@ void CSMDoc::WriteCellCollectionStage::perform(int stage, Messages& messages) if (refRecord.mNew || (!interior && ref.mState == CSMWorld::RecordBase::State_ModifiedOnly && /// \todo consider worldspace - ESM::RefId::stringRefId(CSMWorld::CellCoordinates( refRecord.getCellIndex()).getId("")) != refRecord.mCell)) + ESM::RefId::stringRefId(CSMWorld::CellCoordinates(refRecord.getCellIndex()).getId("")) + != refRecord.mCell)) ++cellRecord.mRefNumCounter; if (refRecord.mRefNum.mIndex >= newRefNum) diff --git a/apps/opencs/model/tools/bodypartcheck.cpp b/apps/opencs/model/tools/bodypartcheck.cpp index a301aff248..4fc9f5cf83 100644 --- a/apps/opencs/model/tools/bodypartcheck.cpp +++ b/apps/opencs/model/tools/bodypartcheck.cpp @@ -61,6 +61,7 @@ void CSMTools::BodyPartCheckStage::perform(int stage, CSMDoc::Messages& messages if (bodyPart.mRace.empty()) messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error); else if (mRaces.searchId(bodyPart.mRace) == -1) - messages.add(id, "Race '" + bodyPart.mRace.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Race '" + bodyPart.mRace.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); } } diff --git a/apps/opencs/model/tools/gmstcheck.cpp b/apps/opencs/model/tools/gmstcheck.cpp index 3433bbbbf3..8b7390387e 100644 --- a/apps/opencs/model/tools/gmstcheck.cpp +++ b/apps/opencs/model/tools/gmstcheck.cpp @@ -40,7 +40,7 @@ void CSMTools::GmstCheckStage::perform(int stage, CSMDoc::Messages& messages) const ESM::GameSetting& gmst = record.get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Gmst, gmst.mId); - std::string gmstIdString = gmst.mId.getRefIdString(); + const std::string& gmstIdString = gmst.mId.getRefIdString(); // Test for empty string if (gmst.mValue.getType() == ESM::VT_String && gmst.mValue.getString().empty()) messages.add(id, gmstIdString + " is an empty string", "", CSMDoc::Message::Severity_Warning); diff --git a/apps/opencs/model/tools/magiceffectcheck.cpp b/apps/opencs/model/tools/magiceffectcheck.cpp index 1770cb694e..a9ad4023fc 100644 --- a/apps/opencs/model/tools/magiceffectcheck.cpp +++ b/apps/opencs/model/tools/magiceffectcheck.cpp @@ -124,12 +124,15 @@ void CSMTools::MagicEffectCheckStage::perform(int stage, CSMDoc::Messages& messa } if (!effect.mCastSound.empty() && mSounds.searchId(effect.mCastSound) == -1) - messages.add( - id, "Casting sound '" + effect.mCastSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Casting sound '" + effect.mCastSound.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); if (!effect.mHitSound.empty() && mSounds.searchId(effect.mHitSound) == -1) - messages.add(id, "Hit sound '" + effect.mHitSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Hit sound '" + effect.mHitSound.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); if (!effect.mAreaSound.empty() && mSounds.searchId(effect.mAreaSound) == -1) - messages.add(id, "Area sound '" + effect.mAreaSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Area sound '" + effect.mAreaSound.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); if (!effect.mBoltSound.empty() && mSounds.searchId(effect.mBoltSound) == -1) - messages.add(id, "Bolt sound '" + effect.mBoltSound.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Bolt sound '" + effect.mBoltSound.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); } diff --git a/apps/opencs/model/tools/mandatoryid.hpp b/apps/opencs/model/tools/mandatoryid.hpp index 3c62b8a2c2..24e295539b 100644 --- a/apps/opencs/model/tools/mandatoryid.hpp +++ b/apps/opencs/model/tools/mandatoryid.hpp @@ -4,9 +4,9 @@ #include #include +#include "../doc/stage.hpp" #include "../world/universalid.hpp" #include -#include "../doc/stage.hpp" namespace CSMDoc { diff --git a/apps/opencs/model/tools/mergestages.cpp b/apps/opencs/model/tools/mergestages.cpp index 5f8ef6788c..3f9cff4d96 100644 --- a/apps/opencs/model/tools/mergestages.cpp +++ b/apps/opencs/model/tools/mergestages.cpp @@ -190,7 +190,7 @@ void CSMTools::FixLandsAndLandTexturesMergeStage::perform(int stage, CSMDoc::Mes CSMWorld::IdTable& ltexTable = dynamic_cast( *mState.mTarget->getData().getTableModel(CSMWorld::UniversalId::Type_LandTextures)); - std::string id = mState.mTarget->getData().getLand().getId(stage).getRefIdString(); + const std::string& id = mState.mTarget->getData().getLand().getId(stage).getRefIdString(); CSMWorld::TouchLandCommand cmd(landTable, ltexTable, id); cmd.redo(); diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 5eda9fb82d..3eeefd5348 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include "../prefs/state.hpp" @@ -520,10 +519,11 @@ void CSMTools::ReferenceableCheckStage::creatureCheck( { CSMWorld::RefIdData::LocalIndex index = mReferencables.searchId(creature.mOriginal); if (index.first == -1) - messages.add( - id, "Parent creature '" + creature.mOriginal.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Parent creature '" + creature.mOriginal.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); else if (index.second != CSMWorld::UniversalId::Type_Creature) - messages.add(id, "'" + creature.mOriginal.getRefIdString() + "' is not a creature", "", CSMDoc::Message::Severity_Error); + messages.add(id, "'" + creature.mOriginal.getRefIdString() + "' is not a creature", "", + CSMDoc::Message::Severity_Error); } // Check inventory @@ -682,7 +682,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, npc.mId); // Detect if player is present - if (npc.mId == ESM::sPlayerId) // Happy now, scrawl? + if (npc.mId == "Player") // Happy now, scrawl? mPlayerPresent = true; // Skip "Base" records (setting!) @@ -739,23 +739,27 @@ void CSMTools::ReferenceableCheckStage::npcCheck( if (npc.mClass.empty()) messages.add(id, "Class is missing", "", CSMDoc::Message::Severity_Error); - else if (mClasses.searchId(npc.mClass.getRefIdString()) == -1) - messages.add(id, "Class '" + npc.mClass.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + else if (mClasses.searchId(npc.mClass) == -1) + messages.add( + id, "Class '" + npc.mClass.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); if (npc.mRace.empty()) messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error); - else if (mRaces.searchId(npc.mRace.getRefIdString()) == -1) - messages.add(id, "Race '" + npc.mRace.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + else if (mRaces.searchId(npc.mRace) == -1) + messages.add( + id, "Race '" + npc.mRace.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); - if (!npc.mFaction.empty() && mFactions.searchId(npc.mFaction.getRefIdString()) == -1) - messages.add(id, "Faction '" + npc.mFaction.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + if (!npc.mFaction.empty() && mFactions.searchId(npc.mFaction) == -1) + messages.add( + id, "Faction '" + npc.mFaction.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); if (npc.mHead.empty()) messages.add(id, "Head is missing", "", CSMDoc::Message::Severity_Error); else { - if (mBodyParts.searchId(npc.mHead.getRefIdString()) == -1) - messages.add(id, "Head body part '" + npc.mHead.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + if (mBodyParts.searchId(npc.mHead) == -1) + messages.add(id, "Head body part '" + npc.mHead.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); /// \todo Check gender, race and other body parts stuff validity for the specific NPC } @@ -763,8 +767,9 @@ void CSMTools::ReferenceableCheckStage::npcCheck( messages.add(id, "Hair is missing", "", CSMDoc::Message::Severity_Error); else { - if (mBodyParts.searchId(npc.mHair.getRefIdString()) == -1) - messages.add(id, "Hair body part '" + npc.mHair.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + if (mBodyParts.searchId(npc.mHair) == -1) + messages.add(id, "Hair body part '" + npc.mHair.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); /// \todo Check gender, race and other body part stuff validity for the specific NPC } @@ -785,22 +790,22 @@ void CSMTools::ReferenceableCheckStage::weaponCheck( return; const ESM::Weapon& weapon = (dynamic_cast&>(baseRecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Weapon, weapon.mId); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Weapon, weapon.mId); // TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present if ( // THOSE ARE HARDCODED! - !(weapon.mId == ESM::RefId::stringRefId("VFX_Hands") || weapon.mId == ESM::RefId::stringRefId("VFX_Absorb") || weapon.mId == ESM::RefId::stringRefId("VFX_Reflect") - || weapon.mId == ESM::RefId::stringRefId("VFX_DefaultBolt") || + !(weapon.mId == "VFX_Hands" || weapon.mId == "VFX_Absorb" || weapon.mId == "VFX_Reflect" + || weapon.mId == "VFX_DefaultBolt" || // TODO I don't know how to get full list of effects :/ // DANGER!, ACHTUNG! FIXME! The following is the list of the magical bolts, valid for Morrowind.esm. However // those are not hardcoded. - weapon.mId == ESM::RefId::stringRefId("magic_bolt") || weapon.mId == ESM::RefId::stringRefId("shock_bolt") || weapon.mId == ESM::RefId::stringRefId("shield_bolt") - || weapon.mId == ESM::RefId::stringRefId("VFX_DestructBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_PoisonBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_RestoreBolt") - || weapon.mId == ESM::RefId::stringRefId("VFX_AlterationBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_ConjureBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_FrostBolt") - || weapon.mId == ESM::RefId::stringRefId("VFX_MysticismBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_IllusionBolt") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple2") - || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple3") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple4") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple5") - || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple6") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple7") || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple8") - || weapon.mId == ESM::RefId::stringRefId("VFX_Multiple9"))) + weapon.mId == "magic_bolt" || weapon.mId == "shock_bolt" || weapon.mId == "shield_bolt" + || weapon.mId == "VFX_DestructBolt" || weapon.mId == "VFX_PoisonBolt" || weapon.mId == "VFX_RestoreBolt" + || weapon.mId == "VFX_AlterationBolt" || weapon.mId == "VFX_ConjureBolt" || weapon.mId == "VFX_FrostBolt" + || weapon.mId == "VFX_MysticismBolt" || weapon.mId == "VFX_IllusionBolt" || weapon.mId == "VFX_Multiple2" + || weapon.mId == "VFX_Multiple3" || weapon.mId == "VFX_Multiple4" || weapon.mId == "VFX_Multiple5" + || weapon.mId == "VFX_Multiple6" || weapon.mId == "VFX_Multiple7" || weapon.mId == "VFX_Multiple8" + || weapon.mId == "VFX_Multiple9")) { inventoryItemCheck(weapon, messages, id.toString(), true); @@ -1037,8 +1042,8 @@ void CSMTools::ReferenceableCheckStage::listCheck( for (unsigned i = 0; i < someList.mList.size(); ++i) { if (mReferencables.searchId(someList.mList[i].mId).first == -1) - messages.add( - someID, "Object '" + someList.mList[i].mId.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(someID, "Object '" + someList.mList[i].mId.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); if (someList.mList[i].mLevel < 1) messages.add(someID, "Level of item '" + someList.mList[i].mId.getRefIdString() + "' is non-positive", "", @@ -1053,7 +1058,7 @@ void CSMTools::ReferenceableCheckStage::scriptCheck( if (!someTool.mScript.empty()) { if (mScripts.searchId(someTool.mScript) == -1) - messages.add( - someID, "Script '" + someTool.mScript.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(someID, "Script '" + someTool.mScript.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); } } diff --git a/apps/opencs/model/tools/referencecheck.cpp b/apps/opencs/model/tools/referencecheck.cpp index c6924cfc73..cf6d0b3a4d 100644 --- a/apps/opencs/model/tools/referencecheck.cpp +++ b/apps/opencs/model/tools/referencecheck.cpp @@ -50,8 +50,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message { // Check for non existing referenced object if (mObjects.searchId(cellRef.mRefID) == -1) - messages.add( - id, "Instance of a non-existent object '" + cellRef.mRefID.getRefIdString() + "'", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Instance of a non-existent object '" + cellRef.mRefID.getRefIdString() + "'", "", + CSMDoc::Message::Severity_Error); else { // Check if reference charge is valid for it's proper referenced type @@ -64,13 +64,14 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message // If object have owner, check if that owner reference is valid if (!cellRef.mOwner.empty() && mObjects.searchId(cellRef.mOwner) == -1) - messages.add(id, "Owner object '" + cellRef.mOwner.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Owner object '" + cellRef.mOwner.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); // If object have creature soul trapped, check if that creature reference is valid if (!cellRef.mSoul.empty()) if (mObjects.searchId(cellRef.mSoul) == -1) - messages.add( - id, "Trapped soul object '" + cellRef.mSoul.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Trapped soul object '" + cellRef.mSoul.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); if (cellRef.mFaction.empty()) { @@ -80,7 +81,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message else { if (mFactions.searchId(cellRef.mFaction) == -1) - messages.add(id, "Faction '" + cellRef.mFaction.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Faction '" + cellRef.mFaction.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); else if (cellRef.mFactionRank < -1) messages.add(id, "Invalid faction rank", "", CSMDoc::Message::Severity_Error); } diff --git a/apps/opencs/model/tools/soundgencheck.cpp b/apps/opencs/model/tools/soundgencheck.cpp index 64c1bacc32..9caf007a47 100644 --- a/apps/opencs/model/tools/soundgencheck.cpp +++ b/apps/opencs/model/tools/soundgencheck.cpp @@ -49,12 +49,13 @@ void CSMTools::SoundGenCheckStage::perform(int stage, CSMDoc::Messages& messages CSMWorld::RefIdData::LocalIndex creatureIndex = mObjects.getDataSet().searchId(soundGen.mCreature); if (creatureIndex.first == -1) { - messages.add( - id, "Creature '" + soundGen.mCreature.getRefIdString() + "' doesn't exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Creature '" + soundGen.mCreature.getRefIdString() + "' doesn't exist", "", + CSMDoc::Message::Severity_Error); } else if (creatureIndex.second != CSMWorld::UniversalId::Type_Creature) { - messages.add(id, "'" + soundGen.mCreature.getRefIdString() + "' is not a creature", "", CSMDoc::Message::Severity_Error); + messages.add(id, "'" + soundGen.mCreature.getRefIdString() + "' is not a creature", "", + CSMDoc::Message::Severity_Error); } } @@ -64,6 +65,7 @@ void CSMTools::SoundGenCheckStage::perform(int stage, CSMDoc::Messages& messages } else if (mSounds.searchId(soundGen.mSound) == -1) { - messages.add(id, "Sound '" + soundGen.mSound.getRefIdString() + "' doesn't exist", "", CSMDoc::Message::Severity_Error); + messages.add( + id, "Sound '" + soundGen.mSound.getRefIdString() + "' doesn't exist", "", CSMDoc::Message::Severity_Error); } } diff --git a/apps/opencs/model/tools/startscriptcheck.cpp b/apps/opencs/model/tools/startscriptcheck.cpp index ba468ddb51..1e81967832 100644 --- a/apps/opencs/model/tools/startscriptcheck.cpp +++ b/apps/opencs/model/tools/startscriptcheck.cpp @@ -40,7 +40,8 @@ void CSMTools::StartScriptCheckStage::perform(int stage, CSMDoc::Messages& messa CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_StartScript, scriptId); if (mScripts.searchId(scriptId) == -1) - messages.add(id, "Start script " + scriptId.getRefIdString() + " does not exist", "", CSMDoc::Message::Severity_Error); + messages.add( + id, "Start script " + scriptId.getRefIdString() + " does not exist", "", CSMDoc::Message::Severity_Error); } int CSMTools::StartScriptCheckStage::setup() diff --git a/apps/opencs/model/tools/topicinfocheck.cpp b/apps/opencs/model/tools/topicinfocheck.cpp index eb1fe2be5b..b8a04cc5a6 100644 --- a/apps/opencs/model/tools/topicinfocheck.cpp +++ b/apps/opencs/model/tools/topicinfocheck.cpp @@ -183,7 +183,7 @@ void CSMTools::TopicInfoCheckStage::perform(int stage, CSMDoc::Messages& message bool CSMTools::TopicInfoCheckStage::verifyActor( const ESM::RefId& actor, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages) { - std::string actorString = actor.getRefIdString(); + const std::string& actorString = actor.getRefIdString(); CSMWorld::RefIdData::LocalIndex index = mReferencables.searchId(actor); if (index.first == -1) @@ -193,7 +193,8 @@ bool CSMTools::TopicInfoCheckStage::verifyActor( } else if (mReferencables.getRecord(index).isDeleted()) { - messages.add(id, "Deleted actor '" + actorString + "' is being referenced", "", CSMDoc::Message::Severity_Error); + messages.add( + id, "Deleted actor '" + actorString + "' is being referenced", "", CSMDoc::Message::Severity_Error); return false; } else if (index.second != CSMWorld::UniversalId::Type_Npc && index.second != CSMWorld::UniversalId::Type_Creature) @@ -212,7 +213,7 @@ bool CSMTools::TopicInfoCheckStage::verifyActor( bool CSMTools::TopicInfoCheckStage::verifyCell( const ESM::RefId& cell, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages) { - std::string cellName = cell.getRefIdString(); + const std::string& cellName = cell.getRefIdString(); if (mCellNames.find(cellName) == mCellNames.end()) { messages.add(id, "Cell '" + cellName + "' does not exist", "", CSMDoc::Message::Severity_Error); @@ -260,7 +261,7 @@ bool CSMTools::TopicInfoCheckStage::verifyFactionRank( bool CSMTools::TopicInfoCheckStage::verifyItem( const ESM::RefId& item, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages) { - std::string idString = item.getRefIdString(); + const std::string& idString = item.getRefIdString(); CSMWorld::RefIdData::LocalIndex index = mReferencables.searchId(item); if (index.first == -1) @@ -440,7 +441,9 @@ bool CSMTools::TopicInfoCheckStage::verifyId(const ESM::RefId& name, const CSMWo } else if (collection.getRecord(index).isDeleted()) { - messages.add(id, "Deleted " + std::string(T::getRecordType()) + " record '" + name.getRefIdString() + "' is being referenced", + messages.add(id, + "Deleted " + std::string(T::getRecordType()) + " record '" + name.getRefIdString() + + "' is being referenced", "", CSMDoc::Message::Severity_Error); return false; } diff --git a/apps/opencs/model/world/actoradapter.cpp b/apps/opencs/model/world/actoradapter.cpp index 9374e16414..a47b216236 100644 --- a/apps/opencs/model/world/actoradapter.cpp +++ b/apps/opencs/model/world/actoradapter.cpp @@ -521,7 +521,8 @@ namespace CSMWorld } auto& part = partRecord.get(); - if (part.mRace == id && part.mData.mType == ESM::BodyPart::MT_Skin && !is1stPersonPart(part.mId.getRefIdString())) + if (part.mRace == id && part.mData.mType == ESM::BodyPart::MT_Skin + && !is1stPersonPart(part.mId.getRefIdString())) { auto type = (ESM::BodyPart::MeshPart)part.mData.mPart; bool female = part.mData.mFlags & ESM::BodyPart::BPF_Female; diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index d04c983eab..db64988179 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -68,7 +68,7 @@ namespace CSMWorld template <> inline const ESM::RefId IdAccessor::getId(const Land& record) const { - return ESM::RefId::stringRefId( Land::createUniqueRecordId(record.mX, record.mY)); + return ESM::RefId::stringRefId(Land::createUniqueRecordId(record.mX, record.mY)); } template <> @@ -554,7 +554,7 @@ namespace CSMWorld throw std::runtime_error("index out of range"); std::unique_ptr> record2(static_cast*>(record.release())); - std::string id =IdAccessorT().getId(record2->get()).getRefIdString(); + std::string id = IdAccessorT().getId(record2->get()).getRefIdString(); if (index == size) mRecords.push_back(std::move(record2)); @@ -576,8 +576,7 @@ namespace CSMWorld template void Collection::setRecord(int index, std::unique_ptr> record) { - if (IdAccessorT().getId(mRecords.at(index)->get()) - != IdAccessorT().getId(record->get())) + if (IdAccessorT().getId(mRecords.at(index)->get()) != IdAccessorT().getId(record->get())) throw std::runtime_error("attempt to change the ID of a record"); mRecords.at(index) = std::move(record); diff --git a/apps/opencs/model/world/collectionbase.hpp b/apps/opencs/model/world/collectionbase.hpp index a22e9ce7a6..7d829e8342 100644 --- a/apps/opencs/model/world/collectionbase.hpp +++ b/apps/opencs/model/world/collectionbase.hpp @@ -83,8 +83,7 @@ namespace CSMWorld = 0; ///< If the record type does not match, an exception is thrown. - virtual void cloneRecord( - const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type) + virtual void cloneRecord(const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type) = 0; virtual bool touchRecord(const ESM::RefId& id) = 0; diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 264e81fe03..2d6cbeca0b 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -1466,7 +1466,7 @@ namespace CSMWorld { ESXRecordT record2 = record.get(); - record2.mRace = ESM::RefId::stringRefId( data.toString().toUtf8().constData()); + record2.mRace = ESM::RefId::stringRefId(data.toString().toUtf8().constData()); record.setModified(record2); } diff --git a/apps/opencs/model/world/commanddispatcher.cpp b/apps/opencs/model/world/commanddispatcher.cpp index 7b6929b88a..19d57a3ce9 100644 --- a/apps/opencs/model/world/commanddispatcher.cpp +++ b/apps/opencs/model/world/commanddispatcher.cpp @@ -290,8 +290,7 @@ void CSMWorld::CommandDispatcher::executeExtendedDelete() if (record.mState == RecordBase::State_Deleted) continue; - if (!std::binary_search( - mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString())) + if (!std::binary_search(mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString())) continue; macro.push(new CSMWorld::DeleteCommand(model, record.get().mId.getRefIdString())); @@ -321,8 +320,7 @@ void CSMWorld::CommandDispatcher::executeExtendedRevert() { const Record& record = collection.getRecord(i); - if (!std::binary_search( - mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString())) + if (!std::binary_search(mSelection.begin(), mSelection.end(), record.get().mCell.getRefIdString())) continue; macro.push(new CSMWorld::RevertCommand(model, record.get().mId.getRefIdString())); diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 36804d8cb0..450613ce5a 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -1172,7 +1172,8 @@ bool CSMWorld::Data::continueLoading(CSMDoc::Messages& messages) messages.add(id, "Logic error: cell index out of bounds", "", CSMDoc::Message::Severity_Error); index = mCells.getSize() - 1; } - std::string cellId = mCells.getId(index).getRefIdString();; + const std::string& cellId = mCells.getId(index).getRefIdString(); + mRefs.load(*mReader, index, mBase, mRefLoadCache[cellId], messages); break; } @@ -1241,7 +1242,7 @@ bool CSMWorld::Data::continueLoading(CSMDoc::Messages& messages) case ESM::REC_DIAL: { ESM::Dialogue record; - std::string recordIdString = record.mId.getRefIdString(); + const std::string& recordIdString = record.mId.getRefIdString(); bool isDeleted = false; record.load(*mReader, isDeleted); diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index 4820f4e2a8..c0da8e7fac 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -370,7 +370,8 @@ CSMWorld::LandTextureIdTable::ImportResults CSMWorld::LandTextureIdTable::import { auto& record = static_cast&>(idCollection()->getRecord(i)); if (record.isModified()) - reverseLookupMap.emplace(Misc::StringUtils::lowerCase(record.get().mTexture), idCollection()->getId(i).getRefIdString()); + reverseLookupMap.emplace( + Misc::StringUtils::lowerCase(record.get().mTexture), idCollection()->getId(i).getRefIdString()); } for (const std::string& id : ids) diff --git a/apps/opencs/model/world/infocollection.cpp b/apps/opencs/model/world/infocollection.cpp index d812ba4275..756009bf2a 100644 --- a/apps/opencs/model/world/infocollection.cpp +++ b/apps/opencs/model/world/infocollection.cpp @@ -342,7 +342,8 @@ void CSMWorld::InfoCollection::appendBlankRecord(const ESM::RefId& id, Universal record2->get().mId = id; - insertRecord(std::move(record2), getInsertIndex(id.getRefIdString(), type, nullptr), type); // call InfoCollection::insertRecord() + insertRecord(std::move(record2), getInsertIndex(id.getRefIdString(), type, nullptr), + type); // call InfoCollection::insertRecord() } int CSMWorld::InfoCollection::searchId(std::string_view id) const @@ -357,7 +358,8 @@ int CSMWorld::InfoCollection::searchId(std::string_view id) const void CSMWorld::InfoCollection::appendRecord(std::unique_ptr record, UniversalId::Type type) { - int index = getInsertIndex(static_cast*>(record.get())->get().mId.getRefIdString(), type, record.get()); + int index + = getInsertIndex(static_cast*>(record.get())->get().mId.getRefIdString(), type, record.get()); insertRecord(std::move(record), index, type); } diff --git a/apps/opencs/model/world/metadata.hpp b/apps/opencs/model/world/metadata.hpp index edc1785eaa..13721253d5 100644 --- a/apps/opencs/model/world/metadata.hpp +++ b/apps/opencs/model/world/metadata.hpp @@ -1,8 +1,8 @@ #ifndef CSM_WOLRD_METADATA_H #define CSM_WOLRD_METADATA_H -#include #include +#include namespace ESM { diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 4a12ee0268..146354e854 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -346,7 +346,8 @@ namespace CSMWorld case 0: { reactions.erase(iter); - reactions.insert(std::make_pair(ESM::RefId::stringRefId(value.toString().toUtf8().constData()), reaction)); + reactions.insert( + std::make_pair(ESM::RefId::stringRefId(value.toString().toUtf8().constData()), reaction)); break; } case 1: diff --git a/apps/opencs/model/world/pathgrid.hpp b/apps/opencs/model/world/pathgrid.hpp index 853a4c0997..02ddeca97c 100644 --- a/apps/opencs/model/world/pathgrid.hpp +++ b/apps/opencs/model/world/pathgrid.hpp @@ -3,8 +3,8 @@ #include -#include #include +#include namespace ESM { diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp index 37428a147a..1317dcc65f 100644 --- a/apps/opencs/model/world/refcollection.cpp +++ b/apps/opencs/model/world/refcollection.cpp @@ -87,7 +87,8 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1]) { ESM::RefId indexCell = ref.mCell; - ref.mCell = ESM::RefId::stringRefId("#" + std::to_string(mref.mTarget[0]) + " " + std::to_string(mref.mTarget[1])); + ref.mCell = ESM::RefId::stringRefId( + "#" + std::to_string(mref.mTarget[0]) + " " + std::to_string(mref.mTarget[1])); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Cell, mCells.getId(cellIndex)); messages.add(id, "The position of the moved reference " + ref.mRefID.getRefIdString() + " (cell " + indexCell.getRefIdString() + ")" @@ -118,7 +119,8 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b messages.add(id, "Attempt to move a non-existent reference - RefNum index " + std::to_string(ref.mRefNum.mIndex) - + ", refID " + ref.mRefID.getRefIdString() + ", content file index " + std::to_string(ref.mRefNum.mContentFile), + + ", refID " + ref.mRefID.getRefIdString() + ", content file index " + + std::to_string(ref.mRefNum.mContentFile), /*hint*/ "", CSMDoc::Message::Severity_Warning); continue; } @@ -148,7 +150,8 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b messages.add(id, "Attempt to delete a non-existent reference - RefNum index " + std::to_string(ref.mRefNum.mIndex) - + ", refID " + ref.mRefID.getRefIdString() + ", content file index " + std::to_string(ref.mRefNum.mContentFile), + + ", refID " + ref.mRefID.getRefIdString() + ", content file index " + + std::to_string(ref.mRefNum.mContentFile), /*hint*/ "", CSMDoc::Message::Severity_Warning); continue; } diff --git a/apps/opencs/model/world/refcollection.hpp b/apps/opencs/model/world/refcollection.hpp index fe844cb0ed..1140e50255 100644 --- a/apps/opencs/model/world/refcollection.hpp +++ b/apps/opencs/model/world/refcollection.hpp @@ -67,8 +67,7 @@ namespace CSMWorld virtual void appendBlankRecord(const std::string& id, UniversalId::Type type = UniversalId::Type_None); virtual void appendBlankRecord(const ESM::RefId& id, UniversalId::Type type = UniversalId::Type_None); - virtual void cloneRecord( - const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type); + virtual void cloneRecord(const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type); virtual int searchId(std::string_view id) const; virtual int searchId(const ESM::RefId& id) const; diff --git a/apps/opencs/model/world/refidadapter.hpp b/apps/opencs/model/world/refidadapter.hpp index d18b790a70..b49692c4c4 100644 --- a/apps/opencs/model/world/refidadapter.hpp +++ b/apps/opencs/model/world/refidadapter.hpp @@ -1,8 +1,9 @@ #ifndef CSM_WOLRD_REFIDADAPTER_H #define CSM_WOLRD_REFIDADAPTER_H -#include #include +#include +#include /*! \brief * Adapters acts as indirection layer, abstracting details of the record types (in the wrappers) from the higher levels diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 1d13e42866..ba23e67ca9 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -253,8 +253,7 @@ void CSMWorld::RefIdData::erase(const LocalIndex& index, int count) for (int i = index.first; i < index.first + count; ++i) { - auto result - = mIndex.find(iter->second->getId(i)); + auto result = mIndex.find(iter->second->getId(i)); if (result != mIndex.end()) mIndex.erase(result); @@ -265,8 +264,7 @@ void CSMWorld::RefIdData::erase(const LocalIndex& index, int count) int recordCount = iter->second->getSize(); while (recordIndex < recordCount) { - auto recordIndexFound - = mIndex.find(iter->second->getId(recordIndex)); + auto recordIndexFound = mIndex.find(iter->second->getId(recordIndex)); if (recordIndexFound != mIndex.end()) { recordIndexFound->second.first -= count; diff --git a/apps/opencs/model/world/regionmap.cpp b/apps/opencs/model/world/regionmap.cpp index ed233946a7..5c22aedf4d 100644 --- a/apps/opencs/model/world/regionmap.cpp +++ b/apps/opencs/model/world/regionmap.cpp @@ -185,8 +185,7 @@ void CSMWorld::RegionMap::updateRegions(const std::vector& regions) for (std::map::const_iterator iter(mMap.begin()); iter != mMap.end(); ++iter) { if (!iter->second.mRegion.empty() - && std::find(regions2.begin(), regions2.end(),iter->second.mRegion) - != regions2.end()) + && std::find(regions2.begin(), regions2.end(), iter->second.mRegion) != regions2.end()) { QModelIndex index = getIndex(iter->first); @@ -333,8 +332,7 @@ QVariant CSMWorld::RegionMap::data(const QModelIndex& index, int role) const if (cell->second.mDeleted) return QBrush(Qt::red, Qt::DiagCrossPattern); - auto iter - = mColours.find(cell->second.mRegion); + auto iter = mColours.find(cell->second.mRegion); if (iter != mColours.end()) return QBrush(QColor(iter->second & 0xff, (iter->second >> 8) & 0xff, (iter->second >> 16) & 0xff)); @@ -370,8 +368,7 @@ QVariant CSMWorld::RegionMap::data(const QModelIndex& index, int role) const { stream << "
"; - auto iter - = mColours.find(cell->second.mRegion); + auto iter = mColours.find(cell->second.mRegion); if (iter != mColours.end()) stream << cell->second.mRegion; diff --git a/apps/opencs/model/world/regionmap.hpp b/apps/opencs/model/world/regionmap.hpp index f93c45274f..3f62c7b61d 100644 --- a/apps/opencs/model/world/regionmap.hpp +++ b/apps/opencs/model/world/regionmap.hpp @@ -11,6 +11,7 @@ #include #include "cellcoordinates.hpp" +#include class QObject; diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index e002baea47..e26bfa9c33 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -108,7 +108,7 @@ bool CSMWorld::ScriptContext::isId(const ESM::RefId& name) const if (!mIdsUpdated) { mIds = mData.getIds(); - + std::sort(mIds.begin(), mIds.end()); mIdsUpdated = true; diff --git a/apps/opencs/model/world/universalid.hpp b/apps/opencs/model/world/universalid.hpp index dedf732478..c8c3aed587 100644 --- a/apps/opencs/model/world/universalid.hpp +++ b/apps/opencs/model/world/universalid.hpp @@ -161,7 +161,6 @@ namespace CSMWorld UniversalId(Type type, const ESM::RefId& id); - UniversalId(Type type, int index); ///< Using a type for a non-index-argument UniversalId will throw an exception. diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 83c6a7c9ae..11647c6ccd 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -96,13 +96,12 @@ bool CSVRender::Cell::addObjects(int start, int end) for (int i = start; i <= end; ++i) { auto cellId = collection.getRecord(i).get().mCell; - std::string cell = cellId.getRefIdString(); CSMWorld::RecordBase::State state = collection.getRecord(i).mState; if (cellId == mId && state != CSMWorld::RecordBase::State_Deleted) { - std::string id =collection.getRecord(i).get().mId.getRefIdString(); + const std::string& id = collection.getRecord(i).get().mId.getRefIdString(); auto object = std::make_unique(mData, mCellNode, id, false); @@ -269,8 +268,8 @@ bool CSVRender::Cell::referenceDataChanged(const QModelIndex& topLeft, const QMo for (int i = topLeft.row(); i <= bottomRight.row(); ++i) { - auto cell =ESM::RefId::stringRefId( - references.data(references.index(i, cellColumn)).toString().toUtf8().constData()); + auto cell + = ESM::RefId::stringRefId(references.data(references.index(i, cellColumn)).toString().toUtf8().constData()); if (cell == mId) { diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 8458dbf7d8..2754c4671f 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -10,8 +10,8 @@ #include #include "../../model/world/cellcoordinates.hpp" -#include #include "instancedragmodes.hpp" +#include class QModelIndex; diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index f41bcb2a20..833c1533e0 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -597,7 +597,7 @@ bool CSVRender::Object::referenceDataChanged(const QModelIndex& topLeft, const Q const CSMWorld::RefCollection& references = mData.getReferences(); - int index = references.searchId(mReferenceId.getRefIdString()); + int index = references.searchId(mReferenceId); if (index != -1 && index >= topLeft.row() && index <= bottomRight.row()) { @@ -607,7 +607,8 @@ bool CSVRender::Object::referenceDataChanged(const QModelIndex& topLeft, const Q if (columnIndex >= topLeft.column() && columnIndex <= bottomRight.row()) { - mReferenceableId = ESM::RefId::stringRefId(references.getData(index, columnIndex).toString().toUtf8().constData()); + mReferenceableId + = ESM::RefId::stringRefId(references.getData(index, columnIndex).toString().toUtf8().constData()); update(); updateMarker(); diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 8b96a9b376..7a209a1ed5 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include diff --git a/apps/opencs/view/render/pathgrid.cpp b/apps/opencs/view/render/pathgrid.cpp index c2321d10f7..987d880965 100644 --- a/apps/opencs/view/render/pathgrid.cpp +++ b/apps/opencs/view/render/pathgrid.cpp @@ -401,7 +401,8 @@ namespace CSVRender for (std::vector::iterator row = mSelected.begin(); row != mSelected.end(); ++row) { - commands.push(new CSMWorld::DeleteNestedCommand(*model, mId.getRefIdString(), static_cast(*row), parentColumn)); + commands.push(new CSMWorld::DeleteNestedCommand( + *model, mId.getRefIdString(), static_cast(*row), parentColumn)); } // Fix/remove edges diff --git a/apps/opencs/view/render/pathgrid.hpp b/apps/opencs/view/render/pathgrid.hpp index bcf1faef8e..4c37a7fa7e 100644 --- a/apps/opencs/view/render/pathgrid.hpp +++ b/apps/opencs/view/render/pathgrid.hpp @@ -11,8 +11,8 @@ #include "../../model/world/cellcoordinates.hpp" #include "../../model/world/subcellcollection.hpp" -#include #include "tagbase.hpp" +#include namespace osg { diff --git a/apps/opencs/view/render/terrainselection.cpp b/apps/opencs/view/render/terrainselection.cpp index b37ecd3ac3..030d441c9b 100644 --- a/apps/opencs/view/render/terrainselection.cpp +++ b/apps/opencs/view/render/terrainselection.cpp @@ -338,8 +338,11 @@ int CSVRender::TerrainSelection::calculateLandHeight(int x, int y) // global ver { CSMDoc::Document& document = mWorldspaceWidget->getDocument(); std::string cellId = CSMWorld::CellCoordinates::generateId(cellX, cellY); - const ESM::Land::LandData* landData - = document.getData().getLand().getRecord(ESM::RefId::stringRefId(cellId)).get().getLandData(ESM::Land::DATA_VHGT); + const ESM::Land::LandData* landData = document.getData() + .getLand() + .getRecord(ESM::RefId::stringRefId(cellId)) + .get() + .getLandData(ESM::Land::DATA_VHGT); return landData->mHeights[localY * ESM::Land::LAND_SIZE + localX]; } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 38d071d06a..b2148d5ee0 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -24,7 +24,11 @@ CSVWorld::PreviewSubView::PreviewSubView(const CSMWorld::UniversalId& id, CSMDoc if (document.getData().getReferenceables().searchId(id.getId()) == -1) { - std::string referenceableId = document.getData().getReferences().getRecord(ESM::RefId::stringRefId(id.getId())).get().mRefID.getRefIdString(); + std::string referenceableId = document.getData() + .getReferences() + .getRecord(ESM::RefId::stringRefId(id.getId())) + .get() + .mRefID.getRefIdString(); referenceableIdChanged(referenceableId); diff --git a/apps/opencs/view/world/scripthighlighter.cpp b/apps/opencs/view/world/scripthighlighter.cpp index 5f92eee82e..4615412951 100644 --- a/apps/opencs/view/world/scripthighlighter.cpp +++ b/apps/opencs/view/world/scripthighlighter.cpp @@ -3,13 +3,13 @@ #include #include +#include +#include #include #include #include #include #include -#include "../../model/prefs/category.hpp" -#include "../../model/prefs/setting.hpp" class QTextDocument; diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 8c4ae278bb..cabd4d2a86 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -69,8 +69,7 @@ namespace MWBase virtual void setPlayerName(const std::string& name) = 0; ///< Set player name. - virtual void setPlayerRace(const ESM::RefId& id, bool male, const ESM::RefId& head, const ESM::RefId& hair) - = 0; + virtual void setPlayerRace(const ESM::RefId& id, bool male, const ESM::RefId& head, const ESM::RefId& hair) = 0; ///< Set player race. virtual void setPlayerBirthsign(const ESM::RefId& id) = 0; diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index a9fe07df53..679dd0b505 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -168,8 +168,7 @@ namespace MWClass for (auto sound = store.get().begin(); sound != store.get().end(); ++sound) { - if (type == sound->mType && !sound->mCreature.empty() - && (*creatureId == sound->mCreature)) + if (type == sound->mType && !sound->mCreature.empty() && (*creatureId == sound->mCreature)) sounds.push_back(&*sound); if (type == sound->mType && sound->mCreature.empty()) fallbacksounds.push_back(&*sound); diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index e9a39cceff..f656965ca5 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -152,9 +152,6 @@ namespace MWClass return action; } - static const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedChest"); - static const ESM::RefId trapActivationSound = ESM::RefId::stringRefId("Disarm Trap Fail"); - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player); @@ -182,7 +179,8 @@ namespace MWClass if (isTrapped) { ptr.getCellRef().setTrap(ESM::RefId::sEmpty); - MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f); + MWBase::Environment::get().getSoundManager()->playSound3D( + ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f); isTrapped = false; } } @@ -203,14 +201,14 @@ namespace MWClass // Activate trap std::unique_ptr action = std::make_unique(ptr.getCellRef().getTrap(), ptr); - action->setSound(trapActivationSound); + action->setSound(ESM::RefId::stringRefId("Disarm Trap Fail")); return action; } } else { std::unique_ptr action = std::make_unique(std::string_view{}, ptr); - action->setSound(lockedSound); + action->setSound(ESM::RefId::stringRefId("LockedChest")); return action; } } @@ -266,7 +264,7 @@ namespace MWClass { text += MWGui::ToolTips::getCellRefString(ptr.getCellRef()); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script"); - if (ptr.getCellRef().getRefId() == ESM::RefId::stringRefId("stolen_goods")) + if (ptr.getCellRef().getRefId() == "stolen_goods") text += "\nYou can not use evidence chests"; } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 11e7ff2af7..42d672f13a 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/aisetting.hpp" @@ -412,7 +411,8 @@ namespace MWClass { // Missed if (!attacker.isEmpty() && attacker == MWMechanics::getPlayer()) - MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("miss"), 1.0f, 1.0f); + MWBase::Environment::get().getSoundManager()->playSound3D( + ptr, ESM::RefId::stringRefId("miss"), 1.0f, 1.0f); return; } @@ -449,7 +449,8 @@ namespace MWClass MWBase::Environment::get().getWorld()->spawnBloodEffect(ptr, hitPosition); } - MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::sHealthDamageSoundId, 1.0f, 1.0f); + MWBase::Environment::get().getSoundManager()->playSound3D( + ptr, ESM::RefId::stringRefId("Health Damage"), 1.0f, 1.0f); MWMechanics::DynamicStat health(stats.getHealth()); health.setCurrent(health.getCurrent() - damage); @@ -642,15 +643,13 @@ namespace MWClass MWWorld::LiveCellRef* ref = ptr.get(); - const ESM::RefId& ourId - = (ref->mBase->mOriginal.empty()) ? ptr.getCellRef().getRefId() : ref->mBase->mOriginal; + const ESM::RefId& ourId = (ref->mBase->mOriginal.empty()) ? ptr.getCellRef().getRefId() : ref->mBase->mOriginal; const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); auto sound = store.get().begin(); while (sound != store.get().end()) { - if (type == sound->mType && !sound->mCreature.empty() - && ourId == sound->mCreature) + if (type == sound->mType && !sound->mCreature.empty() && ourId == sound->mCreature) sounds.push_back(&*sound); if (type == sound->mType && sound->mCreature.empty()) fallbacksounds.push_back(&*sound); @@ -673,8 +672,7 @@ namespace MWClass sound = store.get().begin(); while (sound != store.get().end()) { - if (type == sound->mType && !sound->mCreature.empty() - && fallbackId == sound->mCreature) + if (type == sound->mType && !sound->mCreature.empty() && fallbackId == sound->mCreature) sounds.push_back(&*sound); ++sound; } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index e0c9a32f30..f5f808514b 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -113,8 +113,7 @@ namespace MWClass const ESM::RefId& openSound = ref->mBase->mOpenSound; const ESM::RefId& closeSound = ref->mBase->mCloseSound; - static const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedDoor"); - static const ESM::RefId trapActivationSound = ESM::RefId::stringRefId("Disarm Trap Fail"); + const ESM::RefId lockedSound = ESM::RefId::stringRefId("LockedDoor"); // FIXME: If NPC activate teleporting door, it can lead to crash due to iterator invalidation in the Actors // update. Make such activation a no-op for now, like how it is in the vanilla game. @@ -168,7 +167,8 @@ namespace MWClass if (isTrapped) { ptr.getCellRef().setTrap(ESM::RefId::sEmpty); - MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f); + MWBase::Environment::get().getSoundManager()->playSound3D( + ptr, ESM::RefId::stringRefId("Disarm Trap"), 1.0f, 1.0f); isTrapped = false; } } @@ -180,7 +180,7 @@ namespace MWClass // Trap activation std::unique_ptr action = std::make_unique(ptr.getCellRef().getTrap(), ptr); - action->setSound(trapActivationSound); + action->setSound(ESM::RefId::stringRefId("Disarm Trap Fail")); return action; } diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 7b530d379a..3b4c71fb42 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -36,11 +35,9 @@ namespace MWClass bool Miscellaneous::isGold(const MWWorld::ConstPtr& ptr) const { - return ptr.getCellRef().getRefId() == ESM::sGoldId001 - || ptr.getCellRef().getRefId() == ESM::sGoldId005 - || ptr.getCellRef().getRefId() == ESM::sGoldId010 - || ptr.getCellRef().getRefId() == ESM::sGoldId025 - || ptr.getCellRef().getRefId() == ESM::sGoldId100; + return ptr.getCellRef().getRefId() == "gold_001" || ptr.getCellRef().getRefId() == "gold_005" + || ptr.getCellRef().getRefId() == "gold_010" || ptr.getCellRef().getRefId() == "gold_025" + || ptr.getCellRef().getRefId() == "gold_100"; } void Miscellaneous::insertObjectRendering( @@ -98,7 +95,7 @@ namespace MWClass float soulValue = 0.0001 * pow(soul, 3) + 2 * soul; // for Azura's star add the unfilled value - if (ptr.getCellRef().getRefId() == ESM::RefId::stringRefId("Misc_SoulGem_Azura")) + if (ptr.getCellRef().getRefId() == "Misc_SoulGem_Azura") value += soulValue; else value = soulValue; @@ -185,19 +182,19 @@ namespace MWClass { int goldAmount = getValue(ptr) * count; - const ESM::RefId* base = &ESM::sGoldId001; + std::string_view base = "gold_001"; if (goldAmount >= 100) - base = &ESM::sGoldId100; + base = "gold_100"; else if (goldAmount >= 25) - base = &ESM::sGoldId025; + base = "gold_025"; else if (goldAmount >= 10) - base = &ESM::sGoldId010; + base = "gold_010"; else if (goldAmount >= 5) - base = &ESM::sGoldId005; + base = "gold_005"; // Really, I have no idea why moving ref out of conditional // scope causes list::push_back throwing std::bad_alloc - MWWorld::ManualRef newRef(store, *base); + MWWorld::ManualRef newRef(store, ESM::RefId::stringRefId(base)); const MWWorld::LiveCellRef* ref = newRef.getPtr().get(); newPtr = MWWorld::Ptr(cell.insert(ref), &cell); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index a2e750f4e2..f551ad3078 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -688,7 +687,8 @@ namespace MWClass { damage *= store.find("fCombatCriticalStrikeMult")->mValue.getFloat(); MWBase::Environment::get().getWindowManager()->messageBox("#{sTargetCriticalStrike}"); - MWBase::Environment::get().getSoundManager()->playSound3D(victim, ESM::RefId::stringRefId("critical damage"), 1.0f, 1.0f); + MWBase::Environment::get().getSoundManager()->playSound3D( + victim, ESM::RefId::stringRefId("critical damage"), 1.0f, 1.0f); } } @@ -893,7 +893,7 @@ namespace MWClass if (damage > 0.0f) { - sndMgr->playSound3D(ptr, ESM::sHealthDamageSoundId, 1.0f, 1.0f); + sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Health Damage"), 1.0f, 1.0f); if (ptr == MWMechanics::getPlayer()) MWBase::Environment::get().getWindowManager()->activateHitOverlay(); if (!attacker.isEmpty()) @@ -1303,7 +1303,6 @@ namespace MWClass static const ESM::RefId footHeavyLeft = ESM::RefId::stringRefId("footHeavyLeft"); static const ESM::RefId footHeavyRight = ESM::RefId::stringRefId("footHeavyRight"); - const ESM::RefId* sound = nullptr; if (name == "left" || name == "right") { MWBase::World* world = MWBase::Environment::get().getWorld(); @@ -1311,9 +1310,9 @@ namespace MWClass return ESM::RefId::sEmpty; osg::Vec3f pos(ptr.getRefData().getPosition().asVec3()); if (world->isSwimming(ptr)) - sound = (name == "left") ? &swimLeft : &swimRight; + return (name == "left") ? swimLeft : swimRight; if (world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr)) - sound = (name == "left") ? &footWaterLeft : &footWaterRight; + return (name == "left") ? footWaterLeft : footWaterRight; if (world->isOnGround(ptr)) { if (getNpcStats(ptr).isWerewolf() @@ -1328,16 +1327,19 @@ namespace MWClass const MWWorld::InventoryStore& inv = Npc::getInventoryStore(ptr); MWWorld::ConstContainerStoreIterator boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots); if (boots == inv.end() || boots->getType() != ESM::Armor::sRecordId) - sound = (name == "left") ? &footBareLeft : &footBareRight; + return (name == "left") ? footBareLeft : footBareRight; switch (boots->getClass().getEquipmentSkill(*boots)) { case ESM::Skill::LightArmor: - sound = (name == "left") ? &footLightLeft : &footLightRight; break; + return (name == "left") ? footLightLeft : footLightRight; + break; case ESM::Skill::MediumArmor: - sound = (name == "left") ? &footMediumLeft : &footMediumRight; break; + return (name == "left") ? footMediumLeft : footMediumRight; + break; case ESM::Skill::HeavyArmor: - sound = (name == "left") ? &footHeavyLeft : &footHeavyRight; break; + return (name == "left") ? footHeavyLeft : footHeavyRight; + break; } } return ESM::RefId::sEmpty; @@ -1347,9 +1349,9 @@ namespace MWClass if (name == "land") return ESM::RefId::sEmpty; if (name == "swimleft") - sound = &swimLeft; + return swimLeft; if (name == "swimright") - sound = &swimRight; + return swimRight; // TODO: I have no idea what these are supposed to do for NPCs since they use // voiced dialog for various conditions like health loss and combat taunts. Maybe // only for biped creatures? @@ -1361,12 +1363,7 @@ namespace MWClass if (name == "scream") return ESM::RefId::sEmpty; - if(sound == nullptr) - throw std::runtime_error("Unexpected soundgen type: " + std::string(name)); - else - { - return *sound; - } + throw std::runtime_error("Unexpected soundgen type: " + std::string(name)); } MWWorld::Ptr Npc::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index ad11a6c861..9c52aa347e 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -316,7 +316,8 @@ namespace MWDialogue title = topic; MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor); - callback->addResponse(title.getRefIdString(), Interpreter::fixDefinesDialog(info->mResponse, interpreterContext)); + callback->addResponse( + title.getRefIdString(), Interpreter::fixDefinesDialog(info->mResponse, interpreterContext)); if (dialogue.mType == ESM::Dialogue::Topic) { @@ -327,8 +328,7 @@ namespace MWDialogue { if (iter->mId == info->mId) { - MWBase::Environment::get().getJournal()->addTopic( - topic, info->mId, mActor); + MWBase::Environment::get().getJournal()->addTopic(topic, info->mId, mActor); break; } } @@ -375,7 +375,7 @@ namespace MWDialogue if (!inJournal(topicId, answer->mId)) { // Does this dialogue contains some actor-specific answer? - if (answer->mActor == mActor.getCellRef().getRefId()) + if (answer->mActor == mActor.getCellRef().getRefId()) topicFlags |= MWBase::DialogueManager::TopicType::Specific; } else @@ -501,8 +501,7 @@ namespace MWDialogue { if (iter->mId == info->mId) { - MWBase::Environment::get().getJournal()->addTopic( - mLastTopic, info->mId, mActor); + MWBase::Environment::get().getJournal()->addTopic(mLastTopic, info->mId, mActor); break; } } @@ -739,12 +738,13 @@ namespace MWDialogue if (map != mChangedFactionReaction.end() && map->second.find(faction2) != map->second.end()) return map->second.at(faction2); - const ESM::Faction* faction = MWBase::Environment::get().getWorld()->getStore().get().find(faction1); + const ESM::Faction* faction + = MWBase::Environment::get().getWorld()->getStore().get().find(faction1); auto it = faction->mReactions.begin(); for (; it != faction->mReactions.end(); ++it) { - if (it->first == faction2) + if (it->first == faction2) return it->second; } return 0; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index efe92d13fa..39bb19471c 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -1,10 +1,10 @@ #include "filter.hpp" #include +#include #include #include #include -#include #include "../mwbase/dialoguemanager.hpp" #include "../mwbase/environment.hpp" @@ -84,7 +84,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const // actor id if (!info.mActor.empty()) { - if (info.mActor != mActor.getCellRef().getRefId()) + if (info.mActor != mActor.getCellRef().getRefId()) return false; } else if (isCreature) @@ -101,7 +101,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const MWWorld::LiveCellRef* cellRef = mActor.get(); - if (!(info.mRace == cellRef->mBase->mRace)) + if (!(info.mRace == cellRef->mBase->mRace)) return false; } @@ -113,7 +113,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const MWWorld::LiveCellRef* cellRef = mActor.get(); - if (!(info.mClass == cellRef->mBase->mClass)) + if (!(info.mClass == cellRef->mBase->mClass)) return false; } @@ -131,7 +131,7 @@ bool MWDialogue::Filter::testActor(const ESM::DialInfo& info) const if (isCreature) return true; - if (!(mActor.getClass().getPrimaryFaction(mActor) == info.mFaction)) + if (!(mActor.getClass().getPrimaryFaction(mActor) == info.mFaction)) return false; // check rank @@ -168,8 +168,7 @@ bool MWDialogue::Filter::testPlayer(const ESM::DialInfo& info) const // check player faction and rank if (!info.mPcFaction.empty()) { - std::map::const_iterator iter - = stats.getFactionRanks().find(info.mPcFaction); + std::map::const_iterator iter = stats.getFactionRanks().find(info.mPcFaction); if (iter == stats.getFactionRanks().end()) return false; @@ -366,7 +365,8 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons case SelectWrapper::Function_Dead: - return MWBase::Environment::get().getMechanicsManager()->countDeaths(ESM::RefId::stringRefId(select.getName())); + return MWBase::Environment::get().getMechanicsManager()->countDeaths( + ESM::RefId::stringRefId(select.getName())); case SelectWrapper::Function_Choice: @@ -536,19 +536,19 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con case SelectWrapper::Function_NotId: - return !(mActor.getCellRef().getRefId() == ESM::RefId::stringRefId(select.getName())); + return !(mActor.getCellRef().getRefId() == ESM::RefId::stringRefId(select.getName())); case SelectWrapper::Function_NotFaction: - return !(mActor.getClass().getPrimaryFaction(mActor) == ESM::RefId::stringRefId(select.getName())); + return !(mActor.getClass().getPrimaryFaction(mActor) == ESM::RefId::stringRefId(select.getName())); case SelectWrapper::Function_NotClass: - return !(mActor.get()->mBase->mClass == ESM::RefId::stringRefId(select.getName())); + return !(mActor.get()->mBase->mClass == ESM::RefId::stringRefId(select.getName())); case SelectWrapper::Function_NotRace: - return !(mActor.get()->mBase->mRace == ESM::RefId::stringRefId(select.getName())); + return !(mActor.get()->mBase->mRace == ESM::RefId::stringRefId(select.getName())); case SelectWrapper::Function_NotCell: { diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp index c8918b36d1..b49a92e1d5 100644 --- a/apps/openmw/mwdialogue/filter.hpp +++ b/apps/openmw/mwdialogue/filter.hpp @@ -49,7 +49,7 @@ namespace MWDialogue bool hasFactionRankSkillRequirements(const MWWorld::Ptr& actor, const ESM::RefId& factionId, int rank) const; bool hasFactionRankReputationRequirements( - const MWWorld::Ptr& actor,const ESM::RefId& factionId, int rank) const; + const MWWorld::Ptr& actor, const ESM::RefId& factionId, int rank) const; public: Filter(const MWWorld::Ptr& actor, int choice, bool talkedToPlayer); diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index 8095e368a9..c649574c42 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -39,7 +39,8 @@ namespace MWDialogue return; } - throw std::runtime_error("unknown info ID " + mInfoId.getRefIdString() + " for topic " + topic.getRefIdString()); + throw std::runtime_error( + "unknown info ID " + mInfoId.getRefIdString() + " for topic " + topic.getRefIdString()); } Entry::Entry(const ESM::JournalEntry& record) @@ -106,8 +107,8 @@ namespace MWDialogue { } - StampedJournalEntry::StampedJournalEntry( - const ESM::RefId& topic, const ESM::RefId& infoId, int day, int month, int dayOfMonth, const MWWorld::Ptr& actor) + StampedJournalEntry::StampedJournalEntry(const ESM::RefId& topic, const ESM::RefId& infoId, int day, int month, + int dayOfMonth, const MWWorld::Ptr& actor) : JournalEntry(topic, infoId, actor) , mDay(day) , mMonth(month) @@ -131,7 +132,8 @@ namespace MWDialogue entry.mDayOfMonth = mDayOfMonth; } - StampedJournalEntry StampedJournalEntry::makeFromQuest(const ESM::RefId& topic, int index, const MWWorld::Ptr& actor) + StampedJournalEntry StampedJournalEntry::makeFromQuest( + const ESM::RefId& topic, int index, const MWWorld::Ptr& actor) { int day = MWBase::Environment::get().getWorld()->getGlobalInt("dayspassed"); int month = MWBase::Environment::get().getWorld()->getGlobalInt("month"); diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp index 3bd9ddf2ba..34decf0ddf 100644 --- a/apps/openmw/mwdialogue/journalentry.hpp +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -1,9 +1,9 @@ #ifndef GAME_MWDIALOGUE_JOURNALENTRY_H #define GAME_MWDIALOGUE_JOURNALENTRY_H +#include #include #include -#include namespace ESM { diff --git a/apps/openmw/mwdialogue/topic.cpp b/apps/openmw/mwdialogue/topic.cpp index 7d16d948d0..0a84c9476a 100644 --- a/apps/openmw/mwdialogue/topic.cpp +++ b/apps/openmw/mwdialogue/topic.cpp @@ -11,7 +11,8 @@ namespace MWDialogue Topic::Topic(const ESM::RefId& topic) : mTopic(topic) - , mName(MWBase::Environment::get().getWorld()->getStore().get().find(topic)->mId.getRefIdString()) + , mName( + MWBase::Environment::get().getWorld()->getStore().get().find(topic)->mId.getRefIdString()) { } diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 2620307806..ed82a80507 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -96,7 +96,7 @@ namespace MWGui size_t count = mBirthList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (ESM::RefId::stringRefId(*mBirthList->getItemDataAt(i)) == birthId) + if (ESM::RefId::stringRefId(*mBirthList->getItemDataAt(i)) == birthId) { mBirthList->setIndexSelected(i); break; @@ -134,7 +134,7 @@ namespace MWGui return; const ESM::RefId birthId = ESM::RefId::stringRefId(*mBirthList->getItemDataAt(_index)); - if (mCurrentBirthId == birthId) + if (mCurrentBirthId == birthId) return; mCurrentBirthId = birthId; @@ -168,7 +168,7 @@ namespace MWGui mBirthList->setIndexSelected(index); mCurrentBirthId = birthsignPair.first; } - else if (birthsignPair.first == mCurrentBirthId) + else if (birthsignPair.first == mCurrentBirthId) { mBirthList->setIndexSelected(index); } diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index 92bd30866e..498a52c6d4 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -4,7 +4,6 @@ #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -203,7 +202,7 @@ namespace MWGui { if (mCurrentPage > 0) { - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); --mCurrentPage; diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 94bf43948e..a06e4c7266 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -157,7 +157,7 @@ namespace MWGui size_t count = mClassList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (*mClassList->getItemDataAt(i) == classId) + if (*mClassList->getItemDataAt(i) == classId) { mClassList->setIndexSelected(i); break; @@ -195,7 +195,7 @@ namespace MWGui return; const ESM::RefId* classId = mClassList->getItemDataAt(_index); - if (mCurrentClassId == *classId) + if (mCurrentClassId == *classId) return; mCurrentClassId = *classId; @@ -234,7 +234,7 @@ namespace MWGui mCurrentClassId = id; mClassList->setIndexSelected(index); } - else if (id == mCurrentClassId) + else if (id == mCurrentClassId) { mClassList->setIndexSelected(index); } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index b123858839..f6d0513ac1 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -279,19 +278,19 @@ namespace MWGui void Choice::activated() { - MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click")); eventChoiceActivated(mChoiceId); } void Topic::activated() { - MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click")); eventTopicActivated(mTopicId); } void Goodbye::activated() { - MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click")); eventActivated(); } diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index d1bf3b1b6a..d4b8465fd3 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -409,7 +409,7 @@ namespace MWGui mSpellStatus->setProgressPosition(successChancePercent); mSpellBox->setUserString("ToolTipType", "Spell"); - mSpellBox->setUserString("Spell", spellId.getRefIdString()); + mSpellBox->setUserString("Spell", spellId.getRefIdString()); // use the icon of the first effect const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().get().find( diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 0291fe5004..0dd74cfb4b 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -805,7 +805,7 @@ namespace MWGui // skip different stacks of the same item, or we will get stuck as stacking/unstacking them may change their // relative ordering - if (lastId == item.getCellRef().getRefId()) + if (lastId == item.getCellRef().getRefId()) continue; lastId = item.getCellRef().getRefId(); diff --git a/apps/openmw/mwgui/jailscreen.cpp b/apps/openmw/mwgui/jailscreen.cpp index 263780fb21..9ff9a9c791 100644 --- a/apps/openmw/mwgui/jailscreen.cpp +++ b/apps/openmw/mwgui/jailscreen.cpp @@ -58,7 +58,8 @@ namespace MWGui if (mFadeTimeRemaining <= 0) { MWWorld::Ptr player = MWMechanics::getPlayer(); - MWBase::Environment::get().getWorld()->teleportToClosestMarker(player, ESM::RefId::stringRefId("prisonmarker")); + MWBase::Environment::get().getWorld()->teleportToClosestMarker( + player, ESM::RefId::stringRefId("prisonmarker")); MWBase::Environment::get().getWindowManager()->fadeScreenOut( 0.f); // override fade-in caused by cell transition diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 1102909f23..21cf30b556 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -414,7 +413,7 @@ namespace mOptionsMode = false; mTopicsMode = false; - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); } void notifyTopicSelected(const std::string& topicIdString, int id) @@ -424,7 +423,7 @@ namespace intptr_t topicId = 0; /// \todo get rid of intptr ids for (MWBase::Journal::TTopicIter i = journal->topicBegin(); i != journal->topicEnd(); ++i) { - if (i->first == topic) + if (i->first == topic) topicId = intptr_t(&i->second); } @@ -446,7 +445,7 @@ namespace mOptionsMode = false; - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); } void notifyOptions(MyGUI::Widget* _sender) @@ -474,7 +473,7 @@ namespace assert(mStates.size() > 1); popBook(); - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); } void notifyIndexLinkClicked(MWGui::TypesetBook::InteractiveId index) @@ -495,7 +494,7 @@ namespace list->adjustSize(); - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); } void notifyTopics(MyGUI::Widget* _sender) @@ -510,7 +509,7 @@ namespace setVisible(ShowAllBTN, false); setVisible(ShowActiveBTN, false); - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); } struct AddNamesToList @@ -567,7 +566,7 @@ namespace mModel->visitQuestNames(false, setInactive); } - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); } void notifyShowAll(MyGUI::Widget* _sender) @@ -591,7 +590,7 @@ namespace else { setBookMode(); - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); } } @@ -621,7 +620,7 @@ namespace if (page + 2 < book->pageCount()) { - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); page += 2; updateShowingPages(); @@ -639,7 +638,7 @@ namespace if (page >= 2) { - MWBase::Environment::get().getWindowManager()->playSound(ESM::sBookPageSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("book page")); page -= 2; updateShowingPages(); diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index 713f881c39..e417a495b6 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/statemanager.hpp" @@ -90,7 +89,7 @@ namespace MWGui MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager(); const std::string& name = *sender->getUserData(); - winMgr->playSound(ESM::sMenuClickSoundId); + winMgr->playSound(ESM::RefId::stringRefId("Menu Click")); if (name == "return") { winMgr->removeGuiMode(GM_MainMenu); diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index ad227e9f5c..b90ff9a10a 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -165,13 +165,13 @@ namespace MWGui for (unsigned int i = 0; i < mAvailableHeads.size(); ++i) { - if (mAvailableHeads[i] == proto.mHead) + if (mAvailableHeads[i] == proto.mHead) mFaceIndex = i; } for (unsigned int i = 0; i < mAvailableHairs.size(); ++i) { - if (mAvailableHairs[i] == proto.mHair) + if (mAvailableHairs[i] == proto.mHair) mHairIndex = i; } @@ -191,7 +191,7 @@ namespace MWGui size_t count = mRaceList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (ESM::RefId::stringRefId(*mRaceList->getItemDataAt(i)) == raceId) + if (ESM::RefId::stringRefId(*mRaceList->getItemDataAt(i)) == raceId) { mRaceList->setIndexSelected(i); break; @@ -293,7 +293,7 @@ namespace MWGui return; ESM::RefId raceId = ESM::RefId::stringRefId(*mRaceList->getItemDataAt(_index)); - if (mCurrentRaceId == raceId) + if (mCurrentRaceId == raceId) return; mCurrentRaceId = raceId; @@ -334,7 +334,7 @@ namespace MWGui && idString[idString.size() - 2] == 's' && idString[idString.size() - 1] == 't'; if (firstPerson) continue; - if (bodypart.mRace == mCurrentRaceId) + if (bodypart.mRace == mCurrentRaceId) out.push_back(bodypart.mId); } } @@ -393,7 +393,7 @@ namespace MWGui for (auto& item : items) { mRaceList->addItem(item.second, item.first); - if (item.first == mCurrentRaceId) + if (item.first == mCurrentRaceId) mRaceList->setIndexSelected(index); ++index; } diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 49e41f3084..aa18c2b173 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -1,9 +1,9 @@ #ifndef MWGUI_RACE_H #define MWGUI_RACE_H -#include -#include #include "windowbase.hpp" +#include +#include namespace MWRender { diff --git a/apps/openmw/mwgui/statswindow.hpp b/apps/openmw/mwgui/statswindow.hpp index 082570e7c9..6a781cd5cc 100644 --- a/apps/openmw/mwgui/statswindow.hpp +++ b/apps/openmw/mwgui/statswindow.hpp @@ -1,9 +1,9 @@ #ifndef MWGUI_STATS_WINDOW_H #define MWGUI_STATS_WINDOW_H -#include #include "statswatcher.hpp" #include "windowpinnablebase.hpp" +#include namespace MWGui { diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 757e6b66c1..178562f4c4 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -721,7 +721,8 @@ namespace MWGui if (owner.second == std::numeric_limits::max()) ret += std::string("\nStolen from ") + owner.first.getRefIdString(); // for legacy (ESS) savegames else - ret += std::string("\nStolen ") + MyGUI::utility::toString(owner.second) + " from " + owner.first.getRefIdString(); + ret += std::string("\nStolen ") + MyGUI::utility::toString(owner.second) + " from " + + owner.first.getRefIdString(); } ret += getMiscString(cellref.getGlobalVariable(), "Global"); diff --git a/apps/openmw/mwgui/tradeitemmodel.cpp b/apps/openmw/mwgui/tradeitemmodel.cpp index b89b60aca6..2e97e82baa 100644 --- a/apps/openmw/mwgui/tradeitemmodel.cpp +++ b/apps/openmw/mwgui/tradeitemmodel.cpp @@ -166,7 +166,7 @@ namespace MWGui if (!mMerchant.isEmpty()) { MWWorld::Ptr base = item.mBase; - if (base.getCellRef().getRefId() == MWWorld::ContainerStore::sGoldId) + if (base.getCellRef().getRefId() == MWWorld::ContainerStore::sGoldId) continue; if (!base.getClass().showsInInventory(base)) diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 902a5cde3d..184f1868d1 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -92,7 +92,8 @@ namespace MWGui const std::string& nameString = name.getRefIdString(); toAdd->setUserString("price", std::to_string(price)); - toAdd->setCaptionWithReplacing("#{sCell=" + nameString + "} - " + MyGUI::utility::toString(price) + "#{sgp}"); + toAdd->setCaptionWithReplacing( + "#{sCell=" + nameString + "} - " + MyGUI::utility::toString(price) + "#{sgp}"); toAdd->setSize(mDestinationsView->getWidth(), lineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); toAdd->setUserString("Destination", nameString); diff --git a/apps/openmw/mwgui/waitdialog.hpp b/apps/openmw/mwgui/waitdialog.hpp index 698a066e17..488989fc88 100644 --- a/apps/openmw/mwgui/waitdialog.hpp +++ b/apps/openmw/mwgui/waitdialog.hpp @@ -2,8 +2,8 @@ #define MWGUI_WAIT_DIALOG_H #include "timeadvancer.hpp" -#include #include "windowbase.hpp" +#include namespace MWGui { diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index feec562d7f..63a6fd0db9 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -7,9 +7,9 @@ #include #include +#include #include #include -#include namespace MyGUI { diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index ac144c2acf..0455392650 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -933,7 +933,7 @@ namespace MWGui { mMap->requestMapRender(cell); - std::string name = MWBase::Environment::get().getWorld()->getCellName(cell) ; + std::string name = MWBase::Environment::get().getWorld()->getCellName(cell); mMap->setCellName(name); mHud->setCellName(name); diff --git a/apps/openmw/mwinput/controllermanager.cpp b/apps/openmw/mwinput/controllermanager.cpp index 88c6e7b062..919a193d9f 100644 --- a/apps/openmw/mwinput/controllermanager.cpp +++ b/apps/openmw/mwinput/controllermanager.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/inputmanager.hpp" @@ -207,7 +206,8 @@ namespace MWInput MyGUI::Button* b = MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType(false); if (b && b->getEnabled()) - MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId); + MWBase::Environment::get().getWindowManager()->playSound( + ESM::RefId::stringRefId("Menu Click")); } mBindingsManager->setPlayerControlsEnabled(!mousePressSuccess); diff --git a/apps/openmw/mwinput/mousemanager.cpp b/apps/openmw/mwinput/mousemanager.cpp index 4679366038..8caed79e21 100644 --- a/apps/openmw/mwinput/mousemanager.cpp +++ b/apps/openmw/mwinput/mousemanager.cpp @@ -6,7 +6,6 @@ #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/inputmanager.hpp" @@ -167,7 +166,7 @@ namespace MWInput = MyGUI::InputManager::getInstance().getMouseFocusWidget()->castType(false); if (b && b->getEnabled() && id == SDL_BUTTON_LEFT) { - MWBase::Environment::get().getWindowManager()->playSound(ESM::sMenuClickSoundId); + MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click")); } } MWBase::Environment::get().getWindowManager()->setCursorActive(true); diff --git a/apps/openmw/mwlua/localscripts.cpp b/apps/openmw/mwlua/localscripts.cpp index e03f0b7826..f4afd83f29 100644 --- a/apps/openmw/mwlua/localscripts.cpp +++ b/apps/openmw/mwlua/localscripts.cpp @@ -146,8 +146,8 @@ namespace MWLua if (esmCell->isExterior()) ai.stack(MWMechanics::AiEscort(refId, gameHoursDuration, dest.x(), dest.y(), dest.z(), false), ptr); else - ai.stack(MWMechanics::AiEscort( - refId, ESM::RefId::stringRefId(esmCell->mName), gameHoursDuration, dest.x(), dest.y(), dest.z(), false), + ai.stack(MWMechanics::AiEscort(refId, ESM::RefId::stringRefId(esmCell->mName), gameHoursDuration, + dest.x(), dest.y(), dest.z(), false), ptr); }; selfAPI["_startAiWander"] = [](SelfObject& self, int distance, float duration) { diff --git a/apps/openmw/mwlua/types/activator.cpp b/apps/openmw/mwlua/types/activator.cpp index d303d3d18c..569149aabd 100644 --- a/apps/openmw/mwlua/types/activator.cpp +++ b/apps/openmw/mwlua/types/activator.cpp @@ -27,16 +27,19 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); activator["record"] = sol::overload( [](const Object& obj) -> const ESM::Activator* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Activator"); record[sol::meta_function::to_string] = [](const ESM::Activator& rec) { return "ESM3_Activator[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId.getRefIdString(); }); + record["id"] + = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Activator& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] - = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Activator& rec) -> std::string { return rec.mScript.getRefIdString(); }); } } diff --git a/apps/openmw/mwlua/types/apparatus.cpp b/apps/openmw/mwlua/types/apparatus.cpp index 243bee1d57..405f254658 100644 --- a/apps/openmw/mwlua/types/apparatus.cpp +++ b/apps/openmw/mwlua/types/apparatus.cpp @@ -34,17 +34,20 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); apparatus["record"] = sol::overload( [](const Object& obj) -> const ESM::Apparatus* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Apparatus"); record[sol::meta_function::to_string] = [](const ESM::Apparatus& rec) { return "ESM3_Apparatus[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId.getRefIdString(); }); + record["id"] + = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] - = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Apparatus& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["icon"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); diff --git a/apps/openmw/mwlua/types/armor.cpp b/apps/openmw/mwlua/types/armor.cpp index 70205c7875..0145e6dc74 100644 --- a/apps/openmw/mwlua/types/armor.cpp +++ b/apps/openmw/mwlua/types/armor.cpp @@ -40,11 +40,14 @@ namespace MWLua const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); armor["record"] = sol::overload([](const Object& obj) -> const ESM::Armor* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Armor"); record[sol::meta_function::to_string] - = [](const ESM::Armor& rec) -> std::string { return "ESM3_Armor[" + rec.mId + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mId; }); + = [](const ESM::Armor& rec) -> std::string { return "ESM3_Armor[" + rec.mId.getRefIdString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); @@ -52,8 +55,10 @@ namespace MWLua record["icon"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); - record["enchant"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mEnchant; }); - record["mwscript"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mScript; }); + record["enchant"] = sol::readonly_property( + [](const ESM::Armor& rec) -> std::string { return rec.mEnchant.getRefIdString(); }); + record["mwscript"] + = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["weight"] = sol::readonly_property([](const ESM::Armor& rec) -> float { return rec.mData.mWeight; }); record["value"] = sol::readonly_property([](const ESM::Armor& rec) -> int { return rec.mData.mValue; }); record["type"] = sol::readonly_property([](const ESM::Armor& rec) -> int { return rec.mData.mType; }); diff --git a/apps/openmw/mwlua/types/book.cpp b/apps/openmw/mwlua/types/book.cpp index e24c5ea5bc..1c6b17a5d8 100644 --- a/apps/openmw/mwlua/types/book.cpp +++ b/apps/openmw/mwlua/types/book.cpp @@ -35,20 +35,26 @@ namespace MWLua const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); book["record"] = sol::overload([](const Object& obj) -> const ESM::Book* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Book"); - record[sol::meta_function::to_string] = [](const ESM::Book& rec) { return "ESM3_Book[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId.getRefIdString(); }); + record[sol::meta_function::to_string] + = [](const ESM::Book& rec) { return "ESM3_Book[" + rec.mId.getRefIdString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] + = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["icon"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); record["text"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mText; }); - record["enchant"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mEnchant.getRefIdString(); }); + record["enchant"] + = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mEnchant.getRefIdString(); }); record["isScroll"] = sol::readonly_property([](const ESM::Book& rec) -> bool { return rec.mData.mIsScroll; }); record["value"] = sol::readonly_property([](const ESM::Book& rec) -> int { return rec.mData.mValue; }); record["weight"] = sol::readonly_property([](const ESM::Book& rec) -> float { return rec.mData.mWeight; }); diff --git a/apps/openmw/mwlua/types/container.cpp b/apps/openmw/mwlua/types/container.cpp index e72cfeaca0..3300f50f7a 100644 --- a/apps/openmw/mwlua/types/container.cpp +++ b/apps/openmw/mwlua/types/container.cpp @@ -52,17 +52,21 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); container["record"] = sol::overload( [](const Object& obj) -> const ESM::Container* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Container"); - record[sol::meta_function::to_string] - = [](const ESM::Container& rec) -> std::string { return "ESM3_Container[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId.getRefIdString(); }); + record[sol::meta_function::to_string] = [](const ESM::Container& rec) -> std::string { + return "ESM3_Container[" + rec.mId.getRefIdString() + "]"; + }; + record["id"] + = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Container& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] - = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Container& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["weight"] = sol::readonly_property([](const ESM::Container& rec) -> float { return rec.mWeight; }); } } diff --git a/apps/openmw/mwlua/types/creature.cpp b/apps/openmw/mwlua/types/creature.cpp index 3a771f7786..e4df984ef6 100644 --- a/apps/openmw/mwlua/types/creature.cpp +++ b/apps/openmw/mwlua/types/creature.cpp @@ -27,7 +27,9 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); creature["record"] = sol::overload( [](const Object& obj) -> const ESM::Creature* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Creature"); record[sol::meta_function::to_string] = [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId.getRefIdString() + "]"; }; @@ -35,9 +37,9 @@ namespace MWLua record["model"] = sol::readonly_property([vfs](const ESM::Creature& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] - = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mScript.getRefIdString(); }); - record["baseCreature"] - = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mOriginal.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Creature& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["baseCreature"] = sol::readonly_property( + [](const ESM::Creature& rec) -> std::string { return rec.mOriginal.getRefIdString(); }); } } diff --git a/apps/openmw/mwlua/types/door.cpp b/apps/openmw/mwlua/types/door.cpp index c3d67d1d1c..924b0ef1db 100644 --- a/apps/openmw/mwlua/types/door.cpp +++ b/apps/openmw/mwlua/types/door.cpp @@ -48,20 +48,24 @@ namespace MWLua const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); door["record"] = sol::overload([](const Object& obj) -> const ESM::Door* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Door"); record[sol::meta_function::to_string] = [](const ESM::Door& rec) -> std::string { return "ESM3_Door[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId.getRefIdString(); }); + record["id"] + = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Door& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript.getRefIdString(); }); - record["openSound"] - = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mOpenSound.getRefIdString(); }); - record["closeSound"] - = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mCloseSound.getRefIdString(); }); + record["mwscript"] + = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["openSound"] = sol::readonly_property( + [](const ESM::Door& rec) -> std::string { return rec.mOpenSound.getRefIdString(); }); + record["closeSound"] = sol::readonly_property( + [](const ESM::Door& rec) -> std::string { return rec.mCloseSound.getRefIdString(); }); } } diff --git a/apps/openmw/mwlua/types/ingredient.cpp b/apps/openmw/mwlua/types/ingredient.cpp index 1c7abf468f..b3b6106545 100644 --- a/apps/openmw/mwlua/types/ingredient.cpp +++ b/apps/openmw/mwlua/types/ingredient.cpp @@ -26,15 +26,18 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); ingredient["record"] = sol::overload( [](const Object& obj) -> const ESM::Ingredient* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype(("ESM3_Ingredient")); record[sol::meta_function::to_string] = [](const ESM::Potion& rec) { return "ESM3_Ingredient[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mId.getRefIdString(); }); + record["id"] = sol::readonly_property( + [](const ESM::Ingredient& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mModel; }); - record["mwscript"] - = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Ingredient& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["icon"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mIcon; }); record["weight"] = sol::readonly_property([](const ESM::Ingredient& rec) -> float { return rec.mData.mWeight; }); diff --git a/apps/openmw/mwlua/types/light.cpp b/apps/openmw/mwlua/types/light.cpp index aab62f369b..3ec5f53c11 100644 --- a/apps/openmw/mwlua/types/light.cpp +++ b/apps/openmw/mwlua/types/light.cpp @@ -26,11 +26,14 @@ namespace MWLua const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); light["record"] = sol::overload([](const Object& obj) -> const ESM::Light* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Light"); record[sol::meta_function::to_string] - = [](const ESM::Light& rec) -> std::string { return "ESM3_Light[" + rec.mId + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mId; }); + = [](const ESM::Light& rec) -> std::string { return "ESM3_Light[" + rec.mId.getRefIdString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); @@ -39,9 +42,10 @@ namespace MWLua return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); record["sound"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string { - return Misc::ResourceHelpers::correctSoundPath(rec.mSound, vfs); + return Misc::ResourceHelpers::correctSoundPath(rec.mSound.getRefIdString(), vfs); }); - record["mwscript"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mScript; }); + record["mwscript"] + = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["weight"] = sol::readonly_property([](const ESM::Light& rec) -> float { return rec.mData.mWeight; }); record["value"] = sol::readonly_property([](const ESM::Light& rec) -> int { return rec.mData.mValue; }); record["duration"] = sol::readonly_property([](const ESM::Light& rec) -> int { return rec.mData.mTime; }); diff --git a/apps/openmw/mwlua/types/lockpick.cpp b/apps/openmw/mwlua/types/lockpick.cpp index f8b05648ce..f77327d391 100644 --- a/apps/openmw/mwlua/types/lockpick.cpp +++ b/apps/openmw/mwlua/types/lockpick.cpp @@ -27,17 +27,20 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); lockpick["record"] = sol::overload( [](const Object& obj) -> const ESM::Lockpick* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Lockpick"); record[sol::meta_function::to_string] = [](const ESM::Lockpick& rec) { return "ESM3_Lockpick[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId.getRefIdString(); }); + record["id"] + = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] - = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Lockpick& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["icon"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); diff --git a/apps/openmw/mwlua/types/misc.cpp b/apps/openmw/mwlua/types/misc.cpp index 59c5d1387e..43c9180362 100644 --- a/apps/openmw/mwlua/types/misc.cpp +++ b/apps/openmw/mwlua/types/misc.cpp @@ -27,18 +27,21 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); miscellaneous["record"] = sol::overload( [](const Object& obj) -> const ESM::Miscellaneous* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Miscellaneous"); record[sol::meta_function::to_string] = [](const ESM::Miscellaneous& rec) { return "ESM3_Miscellaneous[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mId.getRefIdString(); }); + record["id"] = sol::readonly_property( + [](const ESM::Miscellaneous& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] - = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["icon"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); diff --git a/apps/openmw/mwlua/types/npc.cpp b/apps/openmw/mwlua/types/npc.cpp index 83ca094cf7..e25f02b3cb 100644 --- a/apps/openmw/mwlua/types/npc.cpp +++ b/apps/openmw/mwlua/types/npc.cpp @@ -26,14 +26,22 @@ namespace MWLua const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); npc["record"] = sol::overload([](const Object& obj) -> const ESM::NPC* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_NPC"); - record[sol::meta_function::to_string] = [](const ESM::NPC& rec) { return "ESM3_NPC[" + rec.mId.getRefIdString() + "]"; }; + record[sol::meta_function::to_string] + = [](const ESM::NPC& rec) { return "ESM3_NPC[" + rec.mId.getRefIdString() + "]"; }; record["name"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mName; }); - record["race"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mRace.getRefIdString(); }); - record["class"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mClass.getRefIdString(); }); - record["mwscript"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mScript.getRefIdString(); }); - record["hair"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHair.getRefIdString(); }); - record["head"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.getRefIdString(); }); + record["race"] + = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mRace.getRefIdString(); }); + record["class"] + = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mClass.getRefIdString(); }); + record["mwscript"] + = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["hair"] + = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHair.getRefIdString(); }); + record["head"] + = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.getRefIdString(); }); } } diff --git a/apps/openmw/mwlua/types/potion.cpp b/apps/openmw/mwlua/types/potion.cpp index d1f9f1242c..07f1b62a4d 100644 --- a/apps/openmw/mwlua/types/potion.cpp +++ b/apps/openmw/mwlua/types/potion.cpp @@ -25,12 +25,16 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); potion["record"] = sol::overload([](const Object& obj) -> const ESM::Potion* { return obj.ptr().get()->mBase; }, - [store](const std::string& recordId) -> const ESM::Potion* { return store->find(ESM::RefId::stringRefId(recordId)); }); + [store](const std::string& recordId) -> const ESM::Potion* { + return store->find(ESM::RefId::stringRefId(recordId)); + }); auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); sol::usertype record = context.mLua->sol().new_usertype("ESM3_Potion"); - record[sol::meta_function::to_string] = [](const ESM::Potion& rec) { return "ESM3_Potion[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId.getRefIdString(); }); + record[sol::meta_function::to_string] + = [](const ESM::Potion& rec) { return "ESM3_Potion[" + rec.mId.getRefIdString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); @@ -38,7 +42,8 @@ namespace MWLua record["icon"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); - record["mwscript"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Potion& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["weight"] = sol::readonly_property([](const ESM::Potion& rec) -> float { return rec.mData.mWeight; }); record["value"] = sol::readonly_property([](const ESM::Potion& rec) -> int { return rec.mData.mValue; }); } diff --git a/apps/openmw/mwlua/types/probe.cpp b/apps/openmw/mwlua/types/probe.cpp index 0482cb5c61..8189d73548 100644 --- a/apps/openmw/mwlua/types/probe.cpp +++ b/apps/openmw/mwlua/types/probe.cpp @@ -26,15 +26,20 @@ namespace MWLua const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); probe["record"] = sol::overload([](const Object& obj) -> const ESM::Probe* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Probe"); - record[sol::meta_function::to_string] = [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId.getRefIdString(); }); + record[sol::meta_function::to_string] + = [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId.getRefIdString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] + = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["icon"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); diff --git a/apps/openmw/mwlua/types/repair.cpp b/apps/openmw/mwlua/types/repair.cpp index ed13ebbd14..159f21fab1 100644 --- a/apps/openmw/mwlua/types/repair.cpp +++ b/apps/openmw/mwlua/types/repair.cpp @@ -27,15 +27,20 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); repair["record"] = sol::overload([](const Object& obj) -> const ESM::Repair* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Repair"); - record[sol::meta_function::to_string] = [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId.getRefIdString(); }); + record[sol::meta_function::to_string] + = [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId.getRefIdString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["mwscript"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Repair& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["icon"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); diff --git a/apps/openmw/mwlua/types/static.cpp b/apps/openmw/mwlua/types/static.cpp index d8648412ec..ad7962dd61 100644 --- a/apps/openmw/mwlua/types/static.cpp +++ b/apps/openmw/mwlua/types/static.cpp @@ -27,11 +27,14 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); stat["record"] = sol::overload([](const Object& obj) -> const ESM::Static* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Static"); record[sol::meta_function::to_string] - = [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Static& rec) -> std::string { return rec.mId; }); + = [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId.getRefIdString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::Static& rec) -> std::string { return rec.mId.getRefIdString(); }); record["model"] = sol::readonly_property([vfs](const ESM::Static& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); diff --git a/apps/openmw/mwlua/types/types.cpp b/apps/openmw/mwlua/types/types.cpp index 31be81ba07..02db36e885 100644 --- a/apps/openmw/mwlua/types/types.cpp +++ b/apps/openmw/mwlua/types/types.cpp @@ -2,7 +2,6 @@ #include #include -#include namespace MWLua { @@ -67,7 +66,7 @@ namespace MWLua if (ref == nullptr) throw std::runtime_error("Can't get type name from an empty object."); const ESM::RefId& id = ref->mRef.getRefId(); - if (id == ESM::sPlayerId) + if (id == "Player") return ESM::REC_INTERNAL_PLAYER; if (Misc::ResourceHelpers::isHiddenMarker(id)) return ESM::REC_INTERNAL_MARKER; diff --git a/apps/openmw/mwlua/types/weapon.cpp b/apps/openmw/mwlua/types/weapon.cpp index 308a9adc67..e5cf2d6c45 100644 --- a/apps/openmw/mwlua/types/weapon.cpp +++ b/apps/openmw/mwlua/types/weapon.cpp @@ -44,11 +44,14 @@ namespace MWLua = &MWBase::Environment::get().getWorld()->getStore().get(); weapon["record"] = sol::overload([](const Object& obj) -> const ESM::Weapon* { return obj.ptr().get()->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 record = context.mLua->sol().new_usertype("ESM3_Weapon"); record[sol::meta_function::to_string] = [](const ESM::Weapon& rec) -> std::string { return "ESM3_Weapon[" + rec.mId.getRefIdString() + "]"; }; - record["id"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId.getRefIdString(); }); + record["id"] + = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId.getRefIdString(); }); record["name"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); @@ -56,8 +59,10 @@ namespace MWLua record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string { return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); - record["enchant"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mEnchant.getRefIdString(); }); - record["mwscript"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mScript.getRefIdString(); }); + record["enchant"] = sol::readonly_property( + [](const ESM::Weapon& rec) -> std::string { return rec.mEnchant.getRefIdString(); }); + record["mwscript"] = sol::readonly_property( + [](const ESM::Weapon& rec) -> std::string { return rec.mScript.getRefIdString(); }); record["isMagical"] = sol::readonly_property( [](const ESM::Weapon& rec) -> bool { return rec.mData.mFlags & ESM::Weapon::Magical; }); record["isSilver"] = sol::readonly_property( diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 5ec928f0ff..3a2cb10a82 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -325,7 +325,8 @@ namespace MWMechanics if (reflected) { const ESM::Static* reflectStatic - = MWBase::Environment::get().getWorld()->getStore().get().find(ESM::RefId::stringRefId("VFX_Reflect")); + = MWBase::Environment::get().getWorld()->getStore().get().find( + ESM::RefId::stringRefId("VFX_Reflect")); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); if (animation && !reflectStatic->mModel.empty()) { @@ -418,9 +419,8 @@ namespace MWMechanics bool ActiveSpells::isSpellActive(const ESM::RefId& id) const { - return std::find_if(mSpells.begin(), mSpells.end(), [&](const auto& spell) { - return spell.mId == id; - }) != mSpells.end(); + return std::find_if(mSpells.begin(), mSpells.end(), [&](const auto& spell) { return spell.mId == id; }) + != mSpells.end(); } void ActiveSpells::addSpell(const ActiveSpellParams& params) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index c5eab906b4..5484d068af 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -208,7 +208,8 @@ namespace if (caster == MWMechanics::getPlayer()) MWBase::Environment::get().getWindowManager()->messageBox("#{sSoultrapSuccess}"); - const ESM::Static* const fx = world->getStore().get().search(ESM::RefId::stringRefId("VFX_Soul_Trap")); + const ESM::Static* const fx + = world->getStore().get().search(ESM::RefId::stringRefId("VFX_Soul_Trap")); if (fx != nullptr) { const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); @@ -1833,8 +1834,8 @@ namespace MWMechanics { MWBase::Environment::get().getWorld()->deleteObject(ptr); - const ESM::Static* fx - = MWBase::Environment::get().getWorld()->getStore().get().search(ESM::RefId::stringRefId("VFX_Summon_End")); + const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get().search( + ESM::RefId::stringRefId("VFX_Summon_End")); if (fx) { const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); diff --git a/apps/openmw/mwmechanics/aifollow.hpp b/apps/openmw/mwmechanics/aifollow.hpp index 5f57c11e9c..50143338f6 100644 --- a/apps/openmw/mwmechanics/aifollow.hpp +++ b/apps/openmw/mwmechanics/aifollow.hpp @@ -44,8 +44,8 @@ namespace MWMechanics /// Follow Actor for duration or until you arrive at a world position AiFollow(const ESM::RefId& actorId, float duration, float x, float y, float z, bool repeat); /// Follow Actor for duration or until you arrive at a position in a cell - AiFollow( - const ESM::RefId& actorId, const ESM::RefId& cellId, float duration, float x, float y, float z, bool repeat); + AiFollow(const ESM::RefId& actorId, const ESM::RefId& cellId, float duration, float x, float y, float z, + bool repeat); /// Follow Actor indefinitively AiFollow(const MWWorld::Ptr& actor, bool commanded = false); diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index 160b7b2f75..b58927c993 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -455,8 +455,8 @@ namespace MWMechanics else if (esmPackage.mType == ESM::AI_Escort) { ESM::AITarget data = esmPackage.mTarget; - package = std::make_unique( - ESM::RefId::stringRefId(data.mId.toStringView()), data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0); + package = std::make_unique(ESM::RefId::stringRefId(data.mId.toStringView()), + data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0); } else if (esmPackage.mType == ESM::AI_Travel) { @@ -466,13 +466,14 @@ namespace MWMechanics else if (esmPackage.mType == ESM::AI_Activate) { ESM::AIActivate data = esmPackage.mActivate; - package = std::make_unique(ESM::RefId::stringRefId(data.mName.toStringView()), data.mShouldRepeat != 0); + package = std::make_unique( + ESM::RefId::stringRefId(data.mName.toStringView()), data.mShouldRepeat != 0); } else // if (esmPackage.mType == ESM::AI_Follow) { ESM::AITarget data = esmPackage.mTarget; - package = std::make_unique( - ESM::RefId::stringRefId(data.mId.toStringView()), data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0); + package = std::make_unique(ESM::RefId::stringRefId(data.mId.toStringView()), + data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0); } onPackageAdded(*package); diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 98769884a2..d3e6133784 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -448,8 +448,7 @@ int MWMechanics::Alchemy::addIngredient(const MWWorld::Ptr& ingredient) return -1; for (TIngredientsIterator iter(mIngredients.begin()); iter != mIngredients.end(); ++iter) - if (!iter->isEmpty() - && ingredient.getCellRef().getRefId() == iter->getCellRef().getRefId()) + if (!iter->isEmpty() && ingredient.getCellRef().getRefId() == iter->getCellRef().getRefId()) return -1; mIngredients[slot] = ingredient; diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index b4c0480cc2..743ae1be91 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -100,8 +100,7 @@ namespace MWMechanics if (cap.mReachedLimit) { - auto found - = std::find(selectedSpells.begin(), selectedSpells.end(), cap.mWeakestSpell); + auto found = std::find(selectedSpells.begin(), selectedSpells.end(), cap.mWeakestSpell); if (found != selectedSpells.end()) selectedSpells.erase(found); @@ -148,7 +147,8 @@ namespace MWMechanics return selectedSpells; } - std::vector autoCalcPlayerSpells(const int* actorSkills, const int* actorAttributes, const ESM::Race* race) + std::vector autoCalcPlayerSpells( + const int* actorSkills, const int* actorAttributes, const ESM::Race* race) { const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); diff --git a/apps/openmw/mwmechanics/autocalcspell.hpp b/apps/openmw/mwmechanics/autocalcspell.hpp index d5bbdf1b54..c445321623 100644 --- a/apps/openmw/mwmechanics/autocalcspell.hpp +++ b/apps/openmw/mwmechanics/autocalcspell.hpp @@ -1,9 +1,9 @@ #ifndef OPENMW_AUTOCALCSPELL_H #define OPENMW_AUTOCALCSPELL_H +#include #include #include -#include namespace ESM { struct Spell; diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 4a80926370..2a54152442 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -21,7 +21,6 @@ #include -#include #include #include #include @@ -1443,7 +1442,7 @@ namespace MWMechanics 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 (!sndMgr->getSoundPlaying(mPtr, wolfRun)) @@ -1548,7 +1547,8 @@ namespace MWMechanics const ESM::MagicEffect* effect = store.get().find( effects->back().mEffectID); // use last effect of list for color of VFX_Hands - const ESM::Static* castStatic = world->getStore().get().find(ESM::RefId::stringRefId("VFX_Hands")); + const ESM::Static* castStatic + = world->getStore().get().find(ESM::RefId::stringRefId("VFX_Hands")); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); @@ -2040,18 +2040,18 @@ namespace MWMechanics } } - if (!godmode) - { - // reduce fatigue - float fatigueLoss = 0; - static const float fFatigueRunBase = gmst.find("fFatigueRunBase")->mValue.getFloat(); - static const float fFatigueRunMult = gmst.find("fFatigueRunMult")->mValue.getFloat(); - static const float fFatigueSwimWalkBase = gmst.find("fFatigueSwimWalkBase")->mValue.getFloat(); - static const float fFatigueSwimRunBase = gmst.find("fFatigueSwimRunBase")->mValue.getFloat(); - static const float fFatigueSwimWalkMult = gmst.find("fFatigueSwimWalkMult")->mValue.getFloat(); - static const float fFatigueSwimRunMult = gmst.find("fFatigueSwimRunMult")->mValue.getFloat(); - static const float fFatigueSneakBase = gmst.find("fFatigueSneakBase")->mValue.getFloat(); - static const float fFatigueSneakMult = gmst.find("fFatigueSneakMult")->mValue.getFloat(); + if (!godmode) + { + // reduce fatigue + float fatigueLoss = 0; + static const float fFatigueRunBase = gmst.find("fFatigueRunBase")->mValue.getFloat(); + static const float fFatigueRunMult = gmst.find("fFatigueRunMult")->mValue.getFloat(); + static const float fFatigueSwimWalkBase = gmst.find("fFatigueSwimWalkBase")->mValue.getFloat(); + static const float fFatigueSwimRunBase = gmst.find("fFatigueSwimRunBase")->mValue.getFloat(); + static const float fFatigueSwimWalkMult = gmst.find("fFatigueSwimWalkMult")->mValue.getFloat(); + static const float fFatigueSwimRunMult = gmst.find("fFatigueSwimRunMult")->mValue.getFloat(); + static const float fFatigueSneakBase = gmst.find("fFatigueSneakBase")->mValue.getFloat(); + static const float fFatigueSneakMult = gmst.find("fFatigueSneakMult")->mValue.getFloat(); if (cls.getEncumbrance(mPtr) <= cls.getCapacity(mPtr)) { @@ -2137,7 +2137,7 @@ namespace MWMechanics float realHealthLost = healthLost * (1.0f - 0.25f * fatigueTerm); health.setCurrent(health.getCurrent() - realHealthLost); 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) MWBase::Environment::get().getWindowManager()->activateHitOverlay(); } @@ -2158,19 +2158,17 @@ namespace MWMechanics if (mPtr.getClass().isNpc()) { - const ESM::RefId* sound = nullptr; - static const ESM::RefId defaultLandWater = ESM::RefId::stringRefId("DefaultLandWater"); - static const ESM::RefId defaultLand = ESM::RefId::stringRefId("DefaultLand"); + std::string_view sound; osg::Vec3f pos(mPtr.getRefData().getPosition().asVec3()); if (world->isUnderwater(mPtr.getCell(), pos) || world->isWalkingOnWater(mPtr)) - sound = &defaultLandWater; + sound = "DefaultLandWater"; else if (onground) - sound = &defaultLand; + sound = "DefaultLand"; - if (sound && !sound->empty()) - sndMgr->playSound3D( - mPtr, *sound, 1.f, 1.f, MWSound::Type::Foot, MWSound::PlayMode::NoPlayerLocal); + if (!sound.empty()) + sndMgr->playSound3D(mPtr, ESM::RefId::stringRefId(sound), 1.f, 1.f, MWSound::Type::Foot, + MWSound::PlayMode::NoPlayerLocal); } } diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index 0e5418e32c..dba897c83f 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include "../mwbase/environment.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, 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()) { const ESM::Enchantment* enchantment @@ -269,7 +269,8 @@ namespace MWMechanics static const float fCombatKODamageMult = gmst.find("fCombatKODamageMult")->mValue.getFloat(); damage *= fCombatKODamageMult; 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); 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); } } diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index bd7024b5af..4ac88441a3 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -74,7 +74,7 @@ namespace MWMechanics // Exception for Azura Star, new one will be added after enchanting auto azurasStarId = ESM::RefId::stringRefId("Misc_SoulGem_Azura"); - if (mSoulGemPtr.get()->mBase->mId == azurasStarId) + if (mSoulGemPtr.get()->mBase->mId == azurasStarId) store.add(azurasStarId, 1, player); if (mSelfEnchanting) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 0ff88c7d61..92c6d1990f 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -85,7 +84,8 @@ namespace const MWWorld::CellRef& cellref = target.getCellRef(); 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(); bool isFactionOwned = false; @@ -514,7 +514,7 @@ namespace MWMechanics const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); static const float fDispRaceMod = gmst.find("fDispRaceMod")->mValue.getFloat(); - if (npc->mBase->mRace == player->mBase->mRace) + if (npc->mBase->mRace == player->mBase->mRace) x += fDispRaceMod; static const float fDispPersonalityMult = gmst.find("fDispPersonalityMult")->mValue.getFloat(); @@ -892,7 +892,8 @@ namespace MWMechanics return true; // 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; if (target.getClass().isNpc()) @@ -914,8 +915,7 @@ namespace MWMechanics return false; // 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() == stolenGoods); + return !(cellref.getRefId() == "stolen_goods"); } 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); if (!factionid.empty()) { - OwnerMap::const_iterator factionOwnerFound - = owners.find(std::make_pair(factionid, true)); + OwnerMap::const_iterator factionOwnerFound = owners.find(std::make_pair(factionid, true)); return factionOwnerFound != owners.end(); } @@ -1014,8 +1013,7 @@ namespace MWMechanics owner.second = false; const ESM::RefId& victimFaction = victim.getClass().getPrimaryFaction(victim); - if (!victimFaction.empty() - && item.getCellRef().getFaction() == victimFaction) // Is the item faction-owned? + if (!victimFaction.empty() && item.getCellRef().getFaction() == victimFaction) // Is the item faction-owned? { owner.first = victimFaction; owner.second = true; @@ -1048,8 +1046,7 @@ namespace MWMechanics MWWorld::ContainerStore& containerStore = targetContainer.getClass().getContainerStore(targetContainer); for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) { - StolenItemsMap::iterator stolenIt - = mStolenItems.find(it->getCellRef().getRefId()); + StolenItemsMap::iterator stolenIt = mStolenItems.find(it->getCellRef().getRefId()); if (stolenIt == mStolenItems.end()) continue; OwnerMap& owners = stolenIt->second; @@ -1120,7 +1117,7 @@ namespace MWMechanics } } - if (!(item.getCellRef().getRefId() == MWWorld::ContainerStore::sGoldId)) + if (!(item.getCellRef().getRefId() == MWWorld::ContainerStore::sGoldId)) { if (victim.isEmpty() || (victim.getClass().isActor() && victim.getRefData().getCount() > 0 @@ -1786,7 +1783,8 @@ namespace MWMechanics || (target == getPlayer() && MWBase::Environment::get().getWorld()->getGlobalInt("pcknownwerewolf"))) { const ESM::GameSetting* iWerewolfFightMod - = MWBase::Environment::get().getWorld()->getStore().get().find("iWerewolfFightMod"); + = MWBase::Environment::get().getWorld()->getStore().get().find( + "iWerewolfFightMod"); fight += iWerewolfFightMod->mValue.getInteger(); } } @@ -1840,7 +1838,8 @@ namespace MWMechanics if (werewolf) { 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 { diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 3106960ed3..60278c0678 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -493,8 +493,7 @@ void MWMechanics::NpcStats::writeState(ESM::NpcStats& state) const for (auto iter(mExpelled.begin()); iter != mExpelled.end(); ++iter) state.mFactions[*iter].mExpelled = true; - for (auto iter(mFactionReputation.begin()); iter != mFactionReputation.end(); - ++iter) + for (auto iter(mFactionReputation.begin()); iter != mFactionReputation.end(); ++iter) state.mFactions[iter->first].mReputation = iter->second; state.mReputation = mReputation; @@ -520,8 +519,7 @@ void MWMechanics::NpcStats::readState(const ESM::NpcStats& state) { const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); - for (auto iter(state.mFactions.begin()); - iter != state.mFactions.end(); ++iter) + for (auto iter(state.mFactions.begin()); iter != state.mFactions.end(); ++iter) if (store.get().search(iter->first)) { if (iter->second.mExpelled) diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 5294cd54c0..57f4bbd1e4 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -1,12 +1,12 @@ #ifndef GAME_MWMECHANICS_NPCSTATS_H #define GAME_MWMECHANICS_NPCSTATS_H +#include "creaturestats.hpp" +#include #include #include #include #include -#include -#include "creaturestats.hpp" namespace ESM { diff --git a/apps/openmw/mwmechanics/recharge.cpp b/apps/openmw/mwmechanics/recharge.cpp index 6394a617e1..0a3f6f0d01 100644 --- a/apps/openmw/mwmechanics/recharge.cpp +++ b/apps/openmw/mwmechanics/recharge.cpp @@ -97,9 +97,9 @@ namespace MWMechanics 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 - if (gem.get()->mBase->mId == soulGemAzura) + if (gem.get()->mBase->mId == soulGemAzura) player.getClass().getContainerStore(player).add(soulGemAzura, 1, player); } diff --git a/apps/openmw/mwmechanics/repair.cpp b/apps/openmw/mwmechanics/repair.cpp index 1a35bf3c66..d9f3b64258 100644 --- a/apps/openmw/mwmechanics/repair.cpp +++ b/apps/openmw/mwmechanics/repair.cpp @@ -100,7 +100,7 @@ namespace MWMechanics // try to find a new tool of the same ID for (MWWorld::ContainerStoreIterator iter(store.begin()); iter != store.end(); ++iter) { - if (iter->getCellRef().getRefId() == mTool.getCellRef().getRefId()) + if (iter->getCellRef().getRefId() == mTool.getCellRef().getRefId()) { mTool = *iter; diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 9a6a908727..f5b231c230 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -90,7 +90,8 @@ namespace MWMechanics if (!effect->mAreaSound.empty()) sndMgr->playSound3D(mHitPosition, effect->mAreaSound, 1.0f, 1.0f); 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 std::vector objects; @@ -342,7 +343,8 @@ namespace MWMechanics static const std::string schools[] = { "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" }; 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; } @@ -429,7 +431,8 @@ namespace MWMechanics = { "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" }; 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; } } @@ -600,7 +603,8 @@ namespace MWMechanics if (!effect->mCastSound.empty()) sndMgr->playSound3D(mCaster, effect->mCastSound, 1.0f, 1.0f); 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()) sndMgr->playSound3D(target, magicEffect.mHitSound, 1.0f, 1.0f); 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 @@ -623,7 +628,8 @@ namespace MWMechanics if (!magicEffect.mHit.empty()) castStatic = MWBase::Environment::get().getWorld()->getStore().get().find(magicEffect.mHit); else - castStatic = MWBase::Environment::get().getWorld()->getStore().get().find(ESM::RefId::stringRefId("VFX_DefaultHit")); + castStatic = MWBase::Environment::get().getWorld()->getStore().get().find( + ESM::RefId::stringRefId("VFX_DefaultHit")); bool loop = (magicEffect.mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0; MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(target); diff --git a/apps/openmw/mwmechanics/spelleffects.cpp b/apps/openmw/mwmechanics/spelleffects.cpp index bc097aa215..787eabc5f9 100644 --- a/apps/openmw/mwmechanics/spelleffects.cpp +++ b/apps/openmw/mwmechanics/spelleffects.cpp @@ -206,16 +206,15 @@ namespace void removeBoundItem(const ESM::RefId& itemId, const MWWorld::Ptr& actor) { MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor); - auto item = std::find_if(store.begin(), store.end(), - [&](const auto& it) { return it.getCellRef().getRefId() == itemId; }); + auto item = std::find_if( + store.begin(), store.end(), [&](const auto& it) { return it.getCellRef().getRefId() == itemId; }); if (item == store.end()) return; int slot = getBoundItemSlot(*item); auto currentItem = store.getSlot(slot); - bool wasEquipped - = currentItem != store.end() && currentItem->getCellRef().getRefId() == itemId; + bool wasEquipped = currentItem != store.end() && currentItem->getCellRef().getRefId() == itemId; if (wasEquipped) store.remove(*currentItem, 1, actor); @@ -457,7 +456,8 @@ namespace MWMechanics { MWRender::Animation* anim = world->getAnimation(caster); anim->removeEffect(effect.mEffectId); - const ESM::Static* fx = world->getStore().get().search(ESM::RefId::stringRefId("VFX_Summon_end")); + const ESM::Static* fx + = world->getStore().get().search(ESM::RefId::stringRefId("VFX_Summon_end")); if (fx) { const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); @@ -565,8 +565,9 @@ namespace MWMechanics const auto& magnitudes = target.getClass().getCreatureStats(target).getMagicEffects(); float volume = std::clamp( (magnitudes.get(effect.mEffectId).getModifier() + effect.mMagnitude) / 100.f, 0.f, 1.f); - MWBase::Environment::get().getSoundManager()->playSound3D( - target, ESM::RefId::stringRefId("magic sound"), volume, 1.f, MWSound::Type::Sfx, MWSound::PlayMode::LoopNoEnv); + MWBase::Environment::get().getSoundManager()->playSound3D(target, + ESM::RefId::stringRefId("magic sound"), volume, 1.f, MWSound::Type::Sfx, + MWSound::PlayMode::LoopNoEnv); } break; case ESM::MagicEffect::SummonScamp: @@ -602,8 +603,10 @@ namespace MWMechanics invalid = true; break; } - addBoundItem(ESM::RefId::stringRefId( - world->getStore().get().find("sMagicBoundRightGauntletID")->mValue.getString()), + addBoundItem(ESM::RefId::stringRefId(world->getStore() + .get() + .find("sMagicBoundRightGauntletID") + ->mValue.getString()), target); // left gauntlet added below [[fallthrough]]; @@ -622,7 +625,9 @@ namespace MWMechanics else { const std::string& item = sBoundItemsMap.at(effect.mEffectId); - addBoundItem(ESM::RefId::stringRefId(world->getStore().get().find(item)->mValue.getString()), target); + addBoundItem(ESM::RefId::stringRefId( + world->getStore().get().find(item)->mValue.getString()), + target); } break; case ESM::MagicEffect::FireDamage: @@ -946,7 +951,8 @@ namespace MWMechanics { 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()) MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}"); @@ -955,7 +961,8 @@ namespace MWMechanics } 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 @@ -1105,7 +1112,8 @@ namespace MWMechanics break; case ESM::MagicEffect::Sound: 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; case ESM::MagicEffect::SummonScamp: case ESM::MagicEffect::SummonClannfear: @@ -1145,8 +1153,10 @@ namespace MWMechanics } break; case ESM::MagicEffect::BoundGloves: - removeBoundItem( - ESM::RefId::stringRefId(world->getStore().get().find("sMagicBoundRightGauntletID")->mValue.getString()), + removeBoundItem(ESM::RefId::stringRefId(world->getStore() + .get() + .find("sMagicBoundRightGauntletID") + ->mValue.getString()), target); [[fallthrough]]; case ESM::MagicEffect::BoundDagger: @@ -1161,7 +1171,9 @@ namespace MWMechanics case ESM::MagicEffect::BoundShield: { const std::string& item = sBoundItemsMap.at(effect.mEffectId); - removeBoundItem(ESM::RefId::stringRefId(world->getStore().get().find(item)->mValue.getString()), target); + removeBoundItem( + ESM::RefId::stringRefId(world->getStore().get().find(item)->mValue.getString()), + target); } break; case ESM::MagicEffect::DrainHealth: diff --git a/apps/openmw/mwmechanics/spelllist.cpp b/apps/openmw/mwmechanics/spelllist.cpp index b0b87e07de..5df1686d02 100644 --- a/apps/openmw/mwmechanics/spelllist.cpp +++ b/apps/openmw/mwmechanics/spelllist.cpp @@ -77,7 +77,7 @@ namespace MWMechanics bool changed = withBaseRecord([&](auto& spells) { for (const auto& it : spells) { - if (id == it) + if (id == it) return false; } spells.push_back(id); @@ -96,7 +96,7 @@ namespace MWMechanics bool changed = withBaseRecord([&](auto& spells) { for (auto it = spells.begin(); it != spells.end(); it++) { - if (id == *it) + if (id == *it) { spells.erase(it); return true; @@ -115,7 +115,7 @@ namespace MWMechanics { bool changed = withBaseRecord([&](auto& spells) { const auto it = std::remove_if(spells.begin(), spells.end(), [&](const auto& spell) { - const auto isSpell = [&](const auto& id) { return spell == id; }; + const auto isSpell = [&](const auto& id) { return spell == id; }; return ids.end() != std::find_if(ids.begin(), ids.end(), isSpell); }); if (it == spells.end()) diff --git a/apps/openmw/mwmechanics/spellpriority.cpp b/apps/openmw/mwmechanics/spellpriority.cpp index eb3e865d3a..64afda1af2 100644 --- a/apps/openmw/mwmechanics/spellpriority.cpp +++ b/apps/openmw/mwmechanics/spellpriority.cpp @@ -83,7 +83,7 @@ namespace int actorId = caster.getClass().getCreatureStats(caster).getActorId(); const auto& active = target.getClass().getCreatureStats(target).getActiveSpells(); return std::find_if(active.begin(), active.end(), [&](const auto& spell) { - return spell.getCasterActorId() == actorId && spell.getId() == id; + return spell.getCasterActorId() == actorId && spell.getId() == id; }) != active.end(); } } diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index b856da9c97..9d3621a2a4 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -82,7 +82,7 @@ namespace MWMechanics removeSpell(spell); mSpellList->remove(spell); - if (spellId == mSelectedSpell) + if (spellId == mSelectedSpell) mSelectedSpell = ESM::RefId::sEmpty; } @@ -225,8 +225,7 @@ namespace MWMechanics addSpell(spell); } - for (auto it = state.mUsedPowers.begin(); - it != state.mUsedPowers.end(); ++it) + for (auto it = state.mUsedPowers.begin(); it != state.mUsedPowers.end(); ++it) { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(it->first); @@ -237,9 +236,7 @@ namespace MWMechanics // Permanent effects are used only to keep the custom magnitude of corprus spells effects (after cure too), and // only in old saves. Convert data to the new approach. - for (auto it - = state.mPermanentSpellEffects.begin(); - it != state.mPermanentSpellEffects.end(); ++it) + for (auto it = state.mPermanentSpellEffects.begin(); it != state.mPermanentSpellEffects.end(); ++it) { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(it->first); diff --git a/apps/openmw/mwmechanics/summoning.cpp b/apps/openmw/mwmechanics/summoning.cpp index 5a4dfd7808..9db82c0350 100644 --- a/apps/openmw/mwmechanics/summoning.cpp +++ b/apps/openmw/mwmechanics/summoning.cpp @@ -1,9 +1,9 @@ #include "summoning.hpp" #include +#include #include #include -#include #include #include "../mwbase/environment.hpp" @@ -94,7 +94,8 @@ namespace MWMechanics MWRender::Animation* anim = world->getAnimation(placed); if (anim) { - const ESM::Static* fx = world->getStore().get().search(ESM::RefId::stringRefId("VFX_Summon_Start")); + const ESM::Static* fx + = world->getStore().get().search(ESM::RefId::stringRefId("VFX_Summon_Start")); if (fx) { const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index cef1552f02..a121927935 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "../mwworld/class.hpp" #include "../mwworld/inventorystore.hpp" @@ -544,7 +543,7 @@ namespace MWRender void RaceSelectionPreview::setPrototype(const ESM::NPC& proto) { mBase = proto; - mBase.mId = ESM::sPlayerId; + mBase.mId = ESM::RefId::stringRefId("Player"); rebuild(); } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 3bb8840687..f1bf8f783f 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -519,7 +519,8 @@ namespace MWRender addAnimSource(smodel, smodel); - if (!isWerewolf && Misc::StringUtils::lowerCase(mNpc->mRace.getRefIdString()).find("argonian") != std::string::npos) + if (!isWerewolf + && Misc::StringUtils::lowerCase(mNpc->mRace.getRefIdString()).find("argonian") != std::string::npos) addAnimSource("meshes\\xargonian_swimkna.nif", smodel); } else diff --git a/apps/openmw/mwrender/skyutil.hpp b/apps/openmw/mwrender/skyutil.hpp index 8808d10a89..1018724595 100644 --- a/apps/openmw/mwrender/skyutil.hpp +++ b/apps/openmw/mwrender/skyutil.hpp @@ -10,9 +10,9 @@ #include #include +#include #include #include -#include namespace Resource { diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index 1f88fd5068..722bc45e5b 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include "../mwworld/class.hpp" #include "../mwworld/esmstore.hpp" @@ -356,7 +355,8 @@ namespace MWScript MWMechanics::AiFollow followPackage(actorID, duration, x, y, z, repeat); ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(followPackage, ptr); - Log(Debug::Info) << "AiFollow: " << actorID.getRefIdString() << ", " << x << ", " << y << ", " << z << ", " << duration; + Log(Debug::Info) << "AiFollow: " << actorID.getRefIdString() << ", " << x << ", " << y << ", " << z + << ", " << duration; } }; @@ -396,7 +396,8 @@ namespace MWScript MWMechanics::AiFollow followPackage(actorID, cellID, duration, x, y, z, repeat); ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(followPackage, ptr); - Log(Debug::Info) << "AiFollow: " << actorID.getRefIdString() << ", " << x << ", " << y << ", " << z << ", " << duration; + Log(Debug::Info) << "AiFollow: " << actorID.getRefIdString() << ", " << x << ", " << y << ", " << z + << ", " << duration; } }; @@ -485,7 +486,7 @@ namespace MWScript if (!targetPtr.isEmpty() && targetPtr.getCellRef().getRefId() == testedTargetId) targetsAreEqual = true; } - else if (testedTargetId == ESM::sPlayerId) // Currently the player ID is hardcoded + else if (testedTargetId == "Player") // Currently the player ID is hardcoded { MWBase::MechanicsManager* mechMgr = MWBase::Environment::get().getMechanicsManager(); bool greeting = mechMgr->getGreetingState(actor) == MWMechanics::Greet_InProgress; diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index 9a0fc39312..cba07419de 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -3,6 +3,7 @@ #include "../mwworld/esmstore.hpp" #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include #include -#include #include "../mwbase/environment.hpp" #include "../mwbase/scriptmanager.hpp" diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 9c9e729078..e3d0923da8 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -13,10 +13,9 @@ #include +#include #include #include -#include -#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -104,9 +103,8 @@ namespace MWScript if (count == 0) return; - if (item == ESM::sGoldId005 ||item == ESM::sGoldId010 - || item == ESM::sGoldId025||item == ESM::sGoldId100) - item = ESM::sGoldId001; + if (item == "gold_005" || item == "gold_010" || item == "gold_025" || item == "gold_100") + item = ESM::RefId::stringRefId("gold_001"); // Check if "item" can be placed in a container MWWorld::ManualRef manualRef(MWBase::Environment::get().getWorld()->getStore(), item, 1); @@ -191,9 +189,8 @@ namespace MWScript ESM::RefId item = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); runtime.pop(); - if (item == ESM::sGoldId005 || item == ESM::sGoldId010 - || item == ESM::sGoldId025 || item == ESM::sGoldId100) - item = ESM::sGoldId001; + if (item == "gold_005" || item == "gold_010" || item == "gold_025" || item == "gold_100") + item = ESM::RefId::stringRefId("gold_001"); MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr); @@ -222,9 +219,8 @@ namespace MWScript if (count == 0) return; - if (item == ESM::sGoldId005 || item == ESM::sGoldId010 - || item == ESM::sGoldId025 || item == ESM::sGoldId100) - item = ESM::sGoldId001; + if (item == "gold_005" || item == "gold_010" || item == "gold_025" || item == "gold_100") + item = ESM::RefId::stringRefId("gold_001"); // Explicit calls to non-unique actors affect the base record if (!R::implicit && ptr.getClass().isActor() @@ -260,7 +256,7 @@ namespace MWScript std::string_view itemName; for (MWWorld::ConstContainerStoreIterator iter(store.cbegin()); iter != store.cend(); ++iter) { - if (iter->getCellRef().getRefId() == item) + if (iter->getCellRef().getRefId() == item) { itemName = iter->getClass().getName(*iter); break; @@ -309,7 +305,7 @@ namespace MWScript // With soul gems we prefer filled ones. for (auto it = invStore.begin(); it != invStore.end(); ++it) { - if (it->getCellRef().getRefId() == item) + if (it->getCellRef().getRefId() == item) { found = it; const ESM::RefId& soul = it->getCellRef().getSoul(); @@ -425,7 +421,7 @@ namespace MWScript for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) { MWWorld::ConstContainerStoreIterator it = invStore.getSlot(slot); - if (it != invStore.end() && it->getCellRef().getRefId() == item) + if (it != invStore.end() && it->getCellRef().getRefId() == item) { runtime.push(1); return; @@ -452,7 +448,7 @@ namespace MWScript = invStore.cbegin(MWWorld::ContainerStore::Type_Miscellaneous); it != invStore.cend(); ++it) { - if (it->getCellRef().getSoul() == name) + if (it->getCellRef().getSoul() == name) count += it->getRefData().getCount(); } runtime.push(count); diff --git a/apps/openmw/mwscript/globalscripts.hpp b/apps/openmw/mwscript/globalscripts.hpp index 455913df17..27d81e1ea1 100644 --- a/apps/openmw/mwscript/globalscripts.hpp +++ b/apps/openmw/mwscript/globalscripts.hpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include "locals.hpp" @@ -54,8 +54,7 @@ namespace MWScript class GlobalScripts { const MWWorld::ESMStore& mStore; - std::unordered_map> - mScripts; + std::unordered_map> mScripts; public: GlobalScripts(const MWWorld::ESMStore& store); diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index 07ca70ef09..3db474e2ca 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include "globalscripts.hpp" diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index d30a542b44..bbb7cd4e1a 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -99,7 +99,7 @@ namespace ++it; continue; } - if (itemId == it->mId) + if (itemId == it->mId) it = list->mList.erase(it); else ++it; @@ -612,7 +612,7 @@ namespace MWScript MWWorld::InventoryStore& store = ptr.getClass().getInventoryStore(ptr); for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) { - if (it->getCellRef().getSoul() == soul) + if (it->getCellRef().getSoul() == soul) { store.remove(*it, 1, ptr); return; @@ -655,7 +655,7 @@ namespace MWScript for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) { MWWorld::ConstContainerStoreIterator it = store.getSlot(slot); - if (it != store.end() && it->getCellRef().getRefId() == item) + if (it != store.end() && it->getCellRef().getRefId() == item) { numNotEquipped -= it->getRefData().getCount(); } @@ -664,7 +664,7 @@ namespace MWScript for (int slot = 0; slot < MWWorld::InventoryStore::Slots && amount > numNotEquipped; ++slot) { MWWorld::ContainerStoreIterator it = store.getSlot(slot); - if (it != store.end() && it->getCellRef().getRefId() == item) + if (it != store.end() && it->getCellRef().getRefId() == item) { int numToRemove = std::min(amount - numNotEquipped, it->getRefData().getCount()); store.unequipItemQuantity(*it, ptr, numToRemove); @@ -674,8 +674,7 @@ namespace MWScript for (MWWorld::ContainerStoreIterator iter(store.begin()); iter != store.end(); ++iter) { - if (iter->getCellRef().getRefId() == item - && !store.isEquipped(*iter)) + if (iter->getCellRef().getRefId() == item && !store.isEquipped(*iter)) { int removed = store.remove(*iter, amount, ptr); MWWorld::Ptr dropped @@ -730,7 +729,7 @@ namespace MWScript for (MWWorld::ContainerStoreIterator iter(store.begin()); iter != store.end(); ++iter) { - if (iter->getCellRef().getSoul() == soul) + if (iter->getCellRef().getSoul() == soul) { MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter, 1); store.remove(*iter, 1, ptr); @@ -953,7 +952,7 @@ namespace MWScript runtime.pop(); MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); - bool hit = objectID == stats.getLastHitObject(); + bool hit = objectID == stats.getLastHitObject(); runtime.push(hit); if (hit) stats.clearLastHitObject(); @@ -972,7 +971,7 @@ namespace MWScript runtime.pop(); MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); - bool hit = objectID == stats.getLastHitAttemptObject(); + bool hit = objectID == stats.getLastHitAttemptObject(); runtime.push(hit); if (hit) stats.clearLastHitAttemptObject(); diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 9108fd8581..ce2b584344 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -7,8 +7,8 @@ #include -#include #include +#include #include @@ -155,8 +155,8 @@ namespace MWScript for (auto& script : mStore.get()) { - if (!std::binary_search( - mScriptBlacklist.begin(), mScriptBlacklist.end(), Misc::StringUtils::lowerCase(script.mId.getRefIdString()))) + if (!std::binary_search(mScriptBlacklist.begin(), mScriptBlacklist.end(), + Misc::StringUtils::lowerCase(script.mId.getRefIdString()))) { ++count; @@ -188,7 +188,8 @@ namespace MWScript { Compiler::Locals locals; - const Compiler::ContextOverride override(mErrorHandler, std::string{ name.getRefIdString() } + "[local variables]"); + const Compiler::ContextOverride override( + mErrorHandler, std::string{ name.getRefIdString() } + "[local variables]"); std::istringstream stream(script->mScriptText); Compiler::QuickFileParser parser(mErrorHandler, mCompilerContext, locals); diff --git a/apps/openmw/mwscript/scriptmanagerimp.hpp b/apps/openmw/mwscript/scriptmanagerimp.hpp index 961b62f014..f526ced447 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.hpp +++ b/apps/openmw/mwscript/scriptmanagerimp.hpp @@ -57,11 +57,9 @@ namespace MWScript } }; - std::unordered_map - mScripts; + std::unordered_map mScripts; GlobalScripts mGlobalScripts; - std::unordered_map - mOtherLocals; + std::unordered_map mOtherLocals; std::vector mScriptBlacklist; public: diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index 84d2ca532b..88c1af561a 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -81,7 +81,7 @@ namespace MWScript public: void execute(Interpreter::Runtime& runtime) override { - ESM::RefId region = ESM::RefId::stringRefId( runtime.getStringLiteral(runtime[0].mInteger) ); + ESM::RefId region = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); runtime.pop(); Interpreter::Type_Integer id = runtime[0].mInteger; diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index f99bae6833..262f6727ba 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -255,7 +255,7 @@ namespace MWScript runtime.pop(); // workaround broken endgame scripts that kill dagoth ur - if (!R::implicit && ptr.getCellRef().getRefId() == ESM::RefId::stringRefId("dagoth_ur_1")) + if (!R::implicit && ptr.getCellRef().getRefId() == "dagoth_ur_1") { runtime.push(peek); @@ -870,7 +870,7 @@ namespace MWScript const ESM::RefId& npcRace = ptr.get()->mBase->mRace; - runtime.push(race == npcRace); + runtime.push(race == npcRace); } }; diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 0768cfaf5b..4ab329966c 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -65,8 +65,8 @@ namespace MWScript from = container; else { - std::string error - = "Failed to find the container of object '" + from.getCellRef().getRefId().getRefIdString() + "'"; + std::string error = "Failed to find the container of object '" + + from.getCellRef().getRefId().getRefIdString() + "'"; runtime.getContext().report(error); Log(Debug::Error) << error; runtime.push(0.f); diff --git a/apps/openmw/mwsound/regionsoundselector.hpp b/apps/openmw/mwsound/regionsoundselector.hpp index e1fa688471..ee26bee97b 100644 --- a/apps/openmw/mwsound/regionsoundselector.hpp +++ b/apps/openmw/mwsound/regionsoundselector.hpp @@ -1,9 +1,9 @@ #ifndef GAME_SOUND_REGIONSOUNDSELECTOR_H #define GAME_SOUND_REGIONSOUNDSELECTOR_H +#include #include #include -#include namespace MWBase { diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 7f14eb7aa9..05ee79ae25 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -45,8 +45,7 @@ namespace MWSound settings.mNearWaterPoints = Fallback::Map::getInt("Water_NearWaterPoints"); settings.mNearWaterIndoorTolerance = Fallback::Map::getFloat("Water_NearWaterIndoorTolerance"); settings.mNearWaterOutdoorTolerance = Fallback::Map::getFloat("Water_NearWaterOutdoorTolerance"); - settings.mNearWaterIndoorID - = ESM::RefId::stringRefId(Fallback::Map::getString("Water_NearWaterIndoorID")); + settings.mNearWaterIndoorID = ESM::RefId::stringRefId(Fallback::Map::getString("Water_NearWaterIndoorID")); settings.mNearWaterOutdoorID = ESM::RefId::stringRefId(Fallback::Map::getString("Water_NearWaterOutdoorID")); @@ -1006,7 +1005,8 @@ namespace MWSound { // Play underwater sound (after updating sounds) if (!mUnderwaterSound) - mUnderwaterSound = playSound(ESM::RefId::stringRefId("Underwater"), 1.0f, 1.0f, Type::Sfx, PlayMode::LoopNoEnv); + mUnderwaterSound + = playSound(ESM::RefId::stringRefId("Underwater"), 1.0f, 1.0f, Type::Sfx, PlayMode::LoopNoEnv); } mOutput->finishUpdate(); } diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index 60c1bec632..946ac8717d 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -222,8 +222,8 @@ namespace MWSound ///< Play_NoTrack is specified. ///< @param offset Number of seconds into the sound to start playback. - Sound* playSound3D(const osg::Vec3f& initialPos, const ESM::RefId& soundId, float volume, float pitch, Type type, - PlayMode mode, float offset = 0) override; + Sound* playSound3D(const osg::Vec3f& initialPos, const ESM::RefId& soundId, float volume, float pitch, + Type type, PlayMode mode, float offset = 0) override; ///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated using ///< Sound::setPosition. ///< @param offset Number of seconds into the sound to start playback. diff --git a/apps/openmw/mwsound/watersoundupdater.hpp b/apps/openmw/mwsound/watersoundupdater.hpp index 68ab54cf52..b0538b9848 100644 --- a/apps/openmw/mwsound/watersoundupdater.hpp +++ b/apps/openmw/mwsound/watersoundupdater.hpp @@ -1,8 +1,8 @@ #ifndef GAME_SOUND_WATERSOUNDUPDATER_H #define GAME_SOUND_WATERSOUNDUPDATER_H -#include #include "components/esm/refid.hpp" +#include namespace MWBase { diff --git a/apps/openmw/mwworld/actionapply.hpp b/apps/openmw/mwworld/actionapply.hpp index 34990c39a5..f585179e6f 100644 --- a/apps/openmw/mwworld/actionapply.hpp +++ b/apps/openmw/mwworld/actionapply.hpp @@ -1,9 +1,9 @@ #ifndef GAME_MWWORLD_ACTIONAPPLY_H #define GAME_MWWORLD_ACTIONAPPLY_H -#include -#include #include "action.hpp" +#include +#include namespace MWWorld { diff --git a/apps/openmw/mwworld/cellref.hpp b/apps/openmw/mwworld/cellref.hpp index d21eb218eb..e0b589c408 100644 --- a/apps/openmw/mwworld/cellref.hpp +++ b/apps/openmw/mwworld/cellref.hpp @@ -77,7 +77,7 @@ namespace MWWorld // The NPC that owns this object (and will get angry if you steal it) const ESM::RefId& getOwner() const { return mCellRef.mOwner; } - void setOwner(const ESM::RefId&owner); + void setOwner(const ESM::RefId& owner); // Name of a global variable. If the global variable is set to '1', using the object is temporarily allowed // even if it has an Owner field. diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 8975846ce4..2f4e4107d8 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -92,8 +92,7 @@ namespace template MWWorld::Ptr searchInContainerList(MWWorld::CellRefList& containerList, const ESM::RefId& id) { - for (auto iter(containerList.mList.begin()); - iter != containerList.mList.end(); ++iter) + for (auto iter(containerList.mList.begin()); iter != containerList.mList.end(); ++iter) { MWWorld::Ptr container(&*iter, nullptr); @@ -169,7 +168,7 @@ namespace { for (auto& item : state.mInventory.mItems) { - if (item.mCount > 0 && baseItem.mItem == item.mRef.mRefID) + if (item.mCount > 0 && baseItem.mItem == item.mRef.mRefID) item.mCount = -item.mCount; } } @@ -552,7 +551,10 @@ namespace MWWorld { PtrType mFound; const ESM::RefId& mIdToFind; - SearchVisitor(const ESM::RefId& id) : mIdToFind(id) {} + SearchVisitor(const ESM::RefId& id) + : mIdToFind(id) + { + } bool operator()(const PtrType& ptr) { if (ptr.getCellRef().getRefId() == mIdToFind) diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index c59a06f150..ae03e8c4e7 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -14,8 +14,8 @@ #include "cellreflist.hpp" #include "livecellref.hpp" -#include #include +#include #include #include "ptr.hpp" diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index cf1f223b9a..0e7d85bf27 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -293,8 +293,7 @@ namespace MWWorld // NOTE: Don't show WerewolfRobe objects in the inventory, or allow them to be taken. // Vanilla likely uses a hack like this since there's no other way to prevent it from // being shown or taken. - static const ESM::RefId werewolfrobe = ESM::RefId::stringRefId("werewolfrobe"); - return (ptr.getCellRef().getRefId() != werewolfrobe); + return (ptr.getCellRef().getRefId() != "werewolfrobe"); } bool Class::hasToolTip(const ConstPtr& ptr) const diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index d6c884d4a6..754f0193f8 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -138,7 +137,7 @@ void MWWorld::ContainerStore::storeStates( } } -const ESM::RefId MWWorld::ContainerStore::sGoldId = ESM::sGoldId001; +const ESM::RefId MWWorld::ContainerStore::sGoldId = ESM::RefId::stringRefId("gold_001"); MWWorld::ContainerStore::ContainerStore() : mListener(nullptr) @@ -188,7 +187,7 @@ int MWWorld::ContainerStore::count(const ESM::RefId& id) const { int total = 0; for (const auto&& iter : *this) - if (iter.getCellRef().getRefId() == id) + if (iter.getCellRef().getRefId() == id) total += iter.getRefData().getCount(); return total; } @@ -253,7 +252,7 @@ bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2) const MWWorld::Class& cls1 = ptr1.getClass(); const MWWorld::Class& cls2 = ptr2.getClass(); - if (!(ptr1.getCellRef().getRefId() == ptr2.getCellRef().getRefId())) + if (!(ptr1.getCellRef().getRefId() == ptr2.getCellRef().getRefId())) return false; // If it has an enchantment, don't stack when some of the charge is already used @@ -373,7 +372,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImp(const Ptr& ptr, for (MWWorld::ContainerStoreIterator iter(begin(type)); iter != end(); ++iter) { - if (iter->getCellRef().getRefId() == MWWorld::ContainerStore::sGoldId) + if (iter->getCellRef().getRefId() == MWWorld::ContainerStore::sGoldId) { iter->getRefData().setCount(addItems(iter->getRefData().getCount(false), realCount)); flagAsModified(); @@ -513,7 +512,7 @@ int MWWorld::ContainerStore::remove( int toRemove = count; for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter) - if (iter->getCellRef().getRefId() == itemId) + if (iter->getCellRef().getRefId() == itemId) toRemove -= remove(*iter, toRemove, actor, equipReplacement, resolveFirst); flagAsModified(); @@ -564,8 +563,7 @@ int MWWorld::ContainerStore::remove( return count - toRemove; } -void MWWorld::ContainerStore::fill( - const ESM::InventoryList& items, const ESM::RefId& owner, Misc::Rng::Generator& prng) +void MWWorld::ContainerStore::fill(const ESM::InventoryList& items, const ESM::RefId& owner, Misc::Rng::Generator& prng) { for (const ESM::ContItem& iter : items.mList) { @@ -576,8 +574,7 @@ void MWWorld::ContainerStore::fill( mResolved = true; } -void MWWorld::ContainerStore::fillNonRandom( - const ESM::InventoryList& items, const ESM::RefId& owner, unsigned int seed) +void MWWorld::ContainerStore::fillNonRandom(const ESM::InventoryList& items, const ESM::RefId& owner, unsigned int seed) { mSeed = seed; for (const ESM::ContItem& iter : items.mList) @@ -790,7 +787,7 @@ MWWorld::Ptr MWWorld::ContainerStore::findReplacement(const ESM::RefId& id) for (auto&& iter : *this) { int iterHealth = iter.getClass().hasItemHealth(iter) ? iter.getClass().getItemHealth(iter) : 1; - if (iter.getCellRef().getRefId() == id) + if (iter.getCellRef().getRefId() == id) { // Prefer the stack with the lowest remaining uses // Try to get item with zero durability only if there are no other items found diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index 9df040180b..db5b54ec57 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -84,8 +83,7 @@ namespace } std::vector getNPCsToReplace(const MWWorld::Store& factions, - const MWWorld::Store& classes, - const std::unordered_map& npcs) + const MWWorld::Store& classes, const std::unordered_map& npcs) { // Cache first class from store - we will use it if current class is not found const ESM::RefId& defaultCls = getDefaultClass(classes); @@ -535,7 +533,7 @@ namespace MWWorld void ESMStore::movePlayerRecord() { auto& npcs = getWritable(); - auto player = npcs.find(ESM::sPlayerId); + auto player = npcs.find(ESM::RefId::stringRefId("Player")); npcs.insert(*player); } @@ -652,7 +650,7 @@ namespace MWWorld { setUp(); - const ESM::NPC* player = get().find(ESM::sPlayerId); + const ESM::NPC* player = get().find(ESM::RefId::stringRefId("Player")); if (!get().find(player->mRace) || !get().find(player->mClass)) throw std::runtime_error("Invalid player record (race or class unavailable"); @@ -688,7 +686,7 @@ namespace MWWorld { auto& npcs = getWritable(); - if (npc.mId == ESM::sPlayerId) + if (npc.mId == "Player") { return npcs.insert(npc); } diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 883316abc9..7f5773c957 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -113,8 +113,7 @@ namespace MWWorld unsigned int mDynamicCount; - mutable std::unordered_map> - mSpellListCache; + mutable std::unordered_map> mSpellListCache; template Store& getWritable() diff --git a/apps/openmw/mwworld/groundcoverstore.hpp b/apps/openmw/mwworld/groundcoverstore.hpp index bc55bc4274..2f34aa9675 100644 --- a/apps/openmw/mwworld/groundcoverstore.hpp +++ b/apps/openmw/mwworld/groundcoverstore.hpp @@ -1,10 +1,10 @@ #ifndef GAME_MWWORLD_GROUNDCOVER_STORE_H #define GAME_MWWORLD_GROUNDCOVER_STORE_H +#include #include #include #include -#include namespace ESM { diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index c1a6c21866..8d9a282791 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -98,8 +98,7 @@ void MWWorld::LocalScripts::add(const ESM::RefId& scriptName, const Ptr& ptr) { ptr.getRefData().setLocals(*script); - for (auto iter = mScripts.begin(); iter != mScripts.end(); - ++iter) + for (auto iter = mScripts.begin(); iter != mScripts.end(); ++iter) if (iter->second == ptr) { Log(Debug::Warning) << "Error: tried to add local script twice for " << ptr.getCellRef().getRefId(); diff --git a/apps/openmw/mwworld/manualref.cpp b/apps/openmw/mwworld/manualref.cpp index 7a6daff9d1..ec5a3f5e77 100644 --- a/apps/openmw/mwworld/manualref.cpp +++ b/apps/openmw/mwworld/manualref.cpp @@ -22,7 +22,7 @@ namespace } } -MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store,const ESM::RefId& name, const int count) +MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store, const ESM::RefId& name, const int count) { switch (store.find(name)) { diff --git a/apps/openmw/mwworld/manualref.hpp b/apps/openmw/mwworld/manualref.hpp index ccf57499ca..8356fd0a03 100644 --- a/apps/openmw/mwworld/manualref.hpp +++ b/apps/openmw/mwworld/manualref.hpp @@ -17,7 +17,7 @@ namespace MWWorld ManualRef& operator=(const ManualRef&); public: - ManualRef(const MWWorld::ESMStore& store,const ESM::RefId& name, const int count = 1); + ManualRef(const MWWorld::ESMStore& store, const ESM::RefId& name, const int count = 1); const Ptr& getPtr() const { return mPtr; } }; diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 6b8cb89d7a..e0b0783834 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -50,7 +49,8 @@ namespace MWWorld { ESM::CellRef cellRef; cellRef.blank(); - cellRef.mRefID = ESM::sPlayerId; + cellRef.mRefID = ESM::RefId::stringRefId("Player"); + ; mPlayer = LiveCellRef(cellRef, player); ESM::Position playerPos = mPlayer.mData.getPosition(); diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index 95e82bde46..1b8a0035fb 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -56,8 +56,8 @@ namespace { - ESM::EffectList getMagicBoltData(std::vector& projectileIDs, std::set& sounds, - float& speed, std::string& texture, std::string& sourceName, const ESM::RefId& id) + ESM::EffectList getMagicBoltData(std::vector& projectileIDs, std::set& sounds, float& speed, + std::string& texture, std::string& sourceName, const ESM::RefId& id) { const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); const ESM::EffectList* effects; @@ -543,8 +543,7 @@ namespace MWWorld { MWWorld::InventoryStore& inv = caster.getClass().getInventoryStore(caster); MWWorld::ContainerStoreIterator invIt = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); - if (invIt != inv.end() - && invIt->getCellRef().getRefId() == projectileState.mBowId) + if (invIt != inv.end() && invIt->getCellRef().getRefId() == projectileState.mBowId) bow = *invIt; } if (projectile->getHitWater()) diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index ef4b8f6f87..1abc2264bf 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -86,7 +86,7 @@ namespace MWWorld ~RefData(); - void write(ESM::ObjectState& objectState,const ESM::RefId& scriptId = ESM::RefId::sEmpty) const; + void write(ESM::ObjectState& objectState, const ESM::RefId& scriptId = ESM::RefId::sEmpty) const; ///< Ignores custom data (not enough context available here to /// perform this operations). diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 7d93da7dc1..6c55d35724 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -254,7 +254,7 @@ namespace MWWorld while (sharedIter != mShared.end() && sharedIter != end) { - if ((*sharedIter)->mId == id) + if ((*sharedIter)->mId == id) { mShared.erase(sharedIter); break; @@ -359,7 +359,7 @@ namespace MWWorld ESM::LandTexture* tex = const_cast(search(lt.mIndex, i)); if (tex) { - if (tex->mId == lt.mId) + if (tex->mId == lt.mId) tex->mTexture = lt.mTexture; } } @@ -716,7 +716,7 @@ namespace MWWorld const ESM::Cell* cell = nullptr; for (const ESM::Cell* sharedCell : mSharedExt) { - if (ESM::RefId::stringRefId(sharedCell->mName) == id) + if (ESM::RefId::stringRefId(sharedCell->mName) == id) { if (cell == nullptr || (sharedCell->mData.mX > cell->mData.mX) || (sharedCell->mData.mX == cell->mData.mX && sharedCell->mData.mY > cell->mData.mY)) @@ -732,7 +732,7 @@ namespace MWWorld const ESM::Cell* cell = nullptr; for (const ESM::Cell* sharedCell : mSharedExt) { - if (sharedCell->mRegion == id) + if (sharedCell->mRegion == id) { if (cell == nullptr || (sharedCell->mData.mX > cell->mData.mX) || (sharedCell->mData.mX == cell->mData.mX && sharedCell->mData.mY > cell->mData.mY)) @@ -972,7 +972,8 @@ namespace MWWorld const ESM::GameSetting* Store::search(std::string_view id) const { - return TypedDynamicStore::search(ESM::RefId::stringRefId(id));; + return TypedDynamicStore::search(ESM::RefId::stringRefId(id)); + ; } Store::Store() {} diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 68f4dfdb58..a6f869e362 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -8,13 +8,13 @@ #include #include +#include #include #include +#include +#include #include #include -#include -#include -#include #include #include @@ -229,7 +229,6 @@ namespace MWWorld template class Store : public TypedDynamicStore { - }; template <> @@ -333,8 +332,7 @@ namespace MWWorld } }; - typedef std::unordered_map - DynamicInt; + typedef std::unordered_map DynamicInt; typedef std::map, ESM::Cell, DynamicExtCmp> DynamicExt; DynamicInt mInt; @@ -394,8 +392,7 @@ namespace MWWorld class Store : public DynamicStore { private: - typedef std::unordered_map - Interior; + typedef std::unordered_map Interior; typedef std::map, ESM::Pathgrid> Exterior; Interior mInt; @@ -485,8 +482,7 @@ namespace MWWorld template <> class Store : public DynamicStore { - typedef std::unordered_map - Static; + typedef std::unordered_map Static; Static mStatic; /// @par mShared usually preserves the record order as it came from the content files (this /// is relevant for the spell autocalc code and selection order diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index d6f5a84f6b..22bf4117d0 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -185,10 +185,14 @@ namespace MWWorld { mDL.FogFactor = dlFactor; mDL.FogOffset = dlOffset; - mThunderSoundID[0] = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_0")); - mThunderSoundID[1] = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_1")); - mThunderSoundID[2] = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_2")); - mThunderSoundID[3] = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_3")); + mThunderSoundID[0] + = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_0")); + mThunderSoundID[1] + = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_1")); + mThunderSoundID[2] + = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_2")); + mThunderSoundID[3] + = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_3")); // TODO: support weathers that have both "Ambient Loop Sound ID" and "Rain Loop Sound ID", need to play both // sounds at the same time. @@ -196,14 +200,16 @@ namespace MWWorld if (!mRainEffect.empty()) // NOTE: in vanilla, the weathers with rain seem to be hardcoded; changing // Using_Precip has no effect { - mAmbientLoopSoundID = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Rain_Loop_Sound_ID")); + mAmbientLoopSoundID + = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Rain_Loop_Sound_ID")); if (mAmbientLoopSoundID.empty()) // default to "rain" if not set mAmbientLoopSoundID = ESM::RefId::stringRefId("rain"); } else - mAmbientLoopSoundID = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Ambient_Loop_Sound_ID")); + mAmbientLoopSoundID + = ESM::RefId::stringRefId(Fallback::Map::getString("Weather_" + name + "_Ambient_Loop_Sound_ID")); - if (mAmbientLoopSoundID == ESM::RefId::stringRefId("None")) + if (mAmbientLoopSoundID == "None") mAmbientLoopSoundID = ESM::RefId::sEmpty; } @@ -938,8 +944,7 @@ namespace MWWorld mRegions.clear(); importRegions(); - for (auto it = state.mRegions.begin(); - it != state.mRegions.end(); ++it) + for (auto it = state.mRegions.begin(); it != state.mRegions.end(); ++it) { auto found = mRegions.find(it->first); if (found != mRegions.end()) @@ -991,7 +996,7 @@ namespace MWWorld MWWorld::ConstPtr player = MWMechanics::getPlayer(); if (player.isInCell()) { - if (regionID == mCurrentRegion) + if (regionID == mCurrentRegion) { addWeatherTransition(region.getWeather()); } diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 4ca88ad84b..57c69cde11 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -7,8 +7,8 @@ #include -#include #include +#include #include "../mwbase/soundmanager.hpp" diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index cdebd414b1..a1f0933722 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -12,7 +12,6 @@ #include -#include #include #include #include @@ -326,7 +325,7 @@ namespace MWWorld mPlayer->clear(); mPlayer->setCell(nullptr); mPlayer->getPlayer().getRefData() = RefData(); - mPlayer->set(mStore.get().find(ESM::sPlayerId)); + mPlayer->set(mStore.get().find(ESM::RefId::stringRefId("Player"))); } mWorldModel.clear(); @@ -573,8 +572,7 @@ namespace MWWorld if (cell) return cell; // treat "Wilderness" like an empty string - const std::string defaultName - = mStore.get().find("sDefaultCellname")->mValue.getString(); + const std::string defaultName = mStore.get().find("sDefaultCellname")->mValue.getString(); if (Misc::StringUtils::ciEqual(cellName, defaultName)) { cell = mStore.get().searchExtByName(ESM::RefId::sEmpty); @@ -686,12 +684,11 @@ namespace MWWorld { Ptr ret; // the player is always in an active cell. - if (name == ESM::sPlayerId) + if (name == "Player") { return mPlayer->getPlayer(); } - for (CellStore* cellstore : mWorldScene->getActiveCells()) { // TODO: caching still doesn't work efficiently here (only works for the one CellStore that the reference is @@ -1154,12 +1151,12 @@ namespace MWWorld MWWorld::Ptr newPtr = ptr; if (!isPlayer && !currCell) - throw std::runtime_error( - "Can not move actor \"" + ptr.getCellRef().getRefId().getRefIdString() + "\" to another cell: current cell is nullptr"); + throw std::runtime_error("Can not move actor \"" + ptr.getCellRef().getRefId().getRefIdString() + + "\" to another cell: current cell is nullptr"); if (!newCell) - throw std::runtime_error( - "Can not move actor \"" + ptr.getCellRef().getRefId().getRefIdString() + "\" to another cell: new cell is nullptr"); + throw std::runtime_error("Can not move actor \"" + ptr.getCellRef().getRefId().getRefIdString() + + "\" to another cell: new cell is nullptr"); if (currCell != newCell) { @@ -1760,13 +1757,12 @@ namespace MWWorld { bool update = false; - if (record.mId == ESM::sPlayerId) + if (record.mId == "Player") { const ESM::NPC* player = mPlayer->getPlayer().get()->mBase; - update = record.isMale() != player->isMale() || !(record.mRace == player->mRace) - || !(record.mHead == player->mHead) - || !(record.mHair == player->mHair); + update = record.isMale() != player->isMale() || !(record.mRace == player->mRace) + || !(record.mHead == player->mHead) || !(record.mHair == player->mHair); } const ESM::NPC* ret = mStore.insert(record); if (update) @@ -2437,7 +2433,7 @@ namespace MWWorld void World::setupPlayer() { - const ESM::NPC* player = mStore.get().find(ESM::sPlayerId); + const ESM::NPC* player = mStore.get().find(ESM::RefId::stringRefId("Player")); if (!mPlayer) mPlayer = std::make_unique(player); else @@ -2635,8 +2631,8 @@ namespace MWWorld if (actor == getPlayerPtr()) MWBase::Environment::get().getWindowManager()->activateHitOverlay(false); - auto healthDamage = ESM::sHealthDamageSoundId; - if (!MWBase::Environment::get().getSoundManager()->getSoundPlaying(actor,healthDamage)) + auto healthDamage = ESM::RefId::stringRefId("Health Damage"); + if (!MWBase::Environment::get().getSoundManager()->getSoundPlaying(actor, healthDamage)) MWBase::Environment::get().getSoundManager()->playSound3D(actor, healthDamage, 1.0f, 1.0f); } } @@ -2669,8 +2665,8 @@ namespace MWWorld if (actor == getPlayerPtr()) MWBase::Environment::get().getWindowManager()->activateHitOverlay(false); - auto healthDamage = ESM::sHealthDamageSoundId; - if (!MWBase::Environment::get().getSoundManager()->getSoundPlaying(actor, healthDamage )) + auto healthDamage = ESM::RefId::stringRefId("Health Damage"); + if (!MWBase::Environment::get().getSoundManager()->getSoundPlaying(actor, healthDamage)) MWBase::Environment::get().getSoundManager()->playSound3D(actor, healthDamage, 1.0f, 1.0f); } } @@ -2720,7 +2716,7 @@ namespace MWWorld if (ptr.getClass().getCapacity(ptr) <= 0.f) return true; - if (ptr.getCellRef().getOwner() == mOwner.getCellRef().getRefId()) + if (ptr.getCellRef().getOwner() == mOwner.getCellRef().getRefId()) mOut.push_back(ptr); return true; @@ -2741,8 +2737,7 @@ namespace MWWorld for (CellStore* cellstore : mWorldScene->getActiveCells()) { cellstore->forEach([&](const auto& ptr) { - if (ptr.getRefData().getBaseNode() - && ptr.getCellRef().getOwner() == npc.getCellRef().getRefId()) + if (ptr.getRefData().getBaseNode() && ptr.getCellRef().getOwner() == npc.getCellRef().getRefId()) out.push_back(ptr); return true; }); @@ -2872,7 +2867,8 @@ namespace MWWorld { int x, y; std::from_chars_result xResult = std::from_chars(cellName.data(), cellName.data() + comma, x); - std::from_chars_result yResult = std::from_chars(cellName.data() + comma + 1, cellName.data() + cellName.size(), y); + std::from_chars_result yResult + = std::from_chars(cellName.data() + comma + 1, cellName.data() + cellName.size(), y); if (xResult.ec == std::errc::result_out_of_range || yResult.ec == std::errc::result_out_of_range) throw std::runtime_error("Cell coordinates out of range."); else if (xResult.ec == std::errc{} && yResult.ec == std::errc{}) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index ee3bd26b54..c9a2e03054 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -647,8 +647,8 @@ namespace MWWorld */ void castSpell(const MWWorld::Ptr& actor, bool manualSpell = false) override; - void launchMagicBolt(const ESM::RefId& spellId, const MWWorld::Ptr& caster, - const osg::Vec3f& fallbackDirection, int slot) override; + void launchMagicBolt(const ESM::RefId& spellId, const MWWorld::Ptr& caster, const osg::Vec3f& fallbackDirection, + int slot) override; void launchProjectile(MWWorld::Ptr& actor, MWWorld::Ptr& projectile, const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr& bow, float speed, float attackStrength) override; void updateProjectilesCasters() override; diff --git a/apps/openmw_test_suite/esmloader/esmdata.cpp b/apps/openmw_test_suite/esmloader/esmdata.cpp index 5f91b5f195..3a571ecb30 100644 --- a/apps/openmw_test_suite/esmloader/esmdata.cpp +++ b/apps/openmw_test_suite/esmloader/esmdata.cpp @@ -36,7 +36,8 @@ namespace { EsmData data; GetParam().mPushBack(data); - EXPECT_EQ(EsmLoader::getModel(data, ESM::RefId::stringRefId(GetParam().mRefId), GetParam().mType), GetParam().mResult); + EXPECT_EQ(EsmLoader::getModel(data, ESM::RefId::stringRefId(GetParam().mRefId), GetParam().mType), + GetParam().mResult); } void pushBack(ESM::Activator&& value, EsmData& esmData) diff --git a/apps/openmw_test_suite/lua/test_configuration.cpp b/apps/openmw_test_suite/lua/test_configuration.cpp index f213e31a1e..a166fcf821 100644 --- a/apps/openmw_test_suite/lua/test_configuration.cpp +++ b/apps/openmw_test_suite/lua/test_configuration.cpp @@ -118,16 +118,22 @@ namespace EXPECT_EQ(LuaUtil::scriptCfgToString(conf[1]), "CUSTOM CONTAINER : Script2.lua"); EXPECT_THAT(asVector(conf.getPlayerConf()), ElementsAre(Pair(0, "data1"))); - EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_CONT, ESM::RefId::stringRefId("something"), ESM::RefNum())), ElementsAre(Pair(1, ""))); - EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_CREA, ESM::RefId::stringRefId("guar"), ESM::RefNum())), ElementsAre(Pair(0, "data1"))); - EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_CREA, ESM::RefId::stringRefId("rat"), ESM::RefNum())), ElementsAre()); + EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_CONT, ESM::RefId::stringRefId("something"), ESM::RefNum())), + ElementsAre(Pair(1, ""))); + EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_CREA, ESM::RefId::stringRefId("guar"), ESM::RefNum())), + ElementsAre(Pair(0, "data1"))); EXPECT_THAT( - asVector(conf.getLocalConf(ESM::REC_DOOR, ESM::RefId::stringRefId("record1"), ESM::RefNum())), ElementsAre(Pair(0, "dataRecord1"))); + asVector(conf.getLocalConf(ESM::REC_CREA, ESM::RefId::stringRefId("rat"), ESM::RefNum())), ElementsAre()); + EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_DOOR, ESM::RefId::stringRefId("record1"), ESM::RefNum())), + ElementsAre(Pair(0, "dataRecord1"))); + EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_DOOR, ESM::RefId::stringRefId("record2"), ESM::RefNum())), + ElementsAre(Pair(0, "data1"))); + EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_NPC_, ESM::RefId::stringRefId("record3"), { 1, 1 })), + ElementsAre(Pair(0, "data1"))); EXPECT_THAT( - asVector(conf.getLocalConf(ESM::REC_DOOR, ESM::RefId::stringRefId("record2"), ESM::RefNum())), ElementsAre(Pair(0, "data1"))); - EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_NPC_, ESM::RefId::stringRefId("record3"), { 1, 1 })), ElementsAre(Pair(0, "data1"))); - EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_NPC_, ESM::RefId::stringRefId("record3"), { 2, 3 })), ElementsAre()); - EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_NPC_, ESM::RefId::stringRefId("record3"), { 3, 5 })), ElementsAre(Pair(0, "dataRef35"))); + asVector(conf.getLocalConf(ESM::REC_NPC_, ESM::RefId::stringRefId("record3"), { 2, 3 })), ElementsAre()); + EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_NPC_, ESM::RefId::stringRefId("record3"), { 3, 5 })), + ElementsAre(Pair(0, "dataRef35"))); EXPECT_THAT(asVector(conf.getLocalConf(ESM::REC_CONT, ESM::RefId::stringRefId("record4"), { 2, 4 })), ElementsAre(Pair(0, "data1"), Pair(1, ""))); diff --git a/apps/openmw_test_suite/mwscript/test_utils.hpp b/apps/openmw_test_suite/mwscript/test_utils.hpp index 4c328973b0..5ab655b3d1 100644 --- a/apps/openmw_test_suite/mwscript/test_utils.hpp +++ b/apps/openmw_test_suite/mwscript/test_utils.hpp @@ -147,7 +147,7 @@ namespace std::map> mMembers; public: - const ESM::RefId& getTarget() const override { return ESM::RefId::sEmpty; }; + const ESM::RefId& getTarget() const override { return ESM::RefId::sEmpty; } int getLocalShort(int index) const override { return mLocals.getShort(index); } @@ -234,17 +234,17 @@ namespace void setMemberShort(const ESM::RefId& id, std::string_view name, int value, bool global) override { mMembers[id.getRefIdString()].setShort(name, value); - }; + } void setMemberLong(const ESM::RefId& id, std::string_view name, int value, bool global) override { mMembers[id.getRefIdString()].setLong(name, value); - }; + } void setMemberFloat(const ESM::RefId& id, std::string_view name, float value, bool global) override { mMembers[id.getRefIdString()].setFloat(name, value); - }; + } }; struct CompiledScript diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 001a3fbece..243ea5841c 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -80,7 +80,7 @@ add_component_dir (to_utf8 to_utf8 ) -add_component_dir(esm attr common defs esmcommon records util luascripts format refid refidhardcoded) +add_component_dir(esm attr common defs esmcommon records util luascripts format refid) add_component_dir(fx pass technique lexer widgets stateupdater) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 90d070992d..363d68c30d 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -7,8 +7,8 @@ #include #include -#include #include +#include #include "context.hpp" #include "discardparser.hpp" @@ -303,7 +303,6 @@ namespace Compiler { start(); - char type = mLocals.getType(name); if (type != ' ') diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 36490fadf6..460dcfb2f9 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -2,8 +2,8 @@ #include -#include #include +#include #include "context.hpp" #include "declarationparser.hpp" diff --git a/components/esm/luascripts.hpp b/components/esm/luascripts.hpp index 219376afc9..d552b07c16 100644 --- a/components/esm/luascripts.hpp +++ b/components/esm/luascripts.hpp @@ -1,9 +1,9 @@ #ifndef OPENMW_ESM_LUASCRIPTS_H #define OPENMW_ESM_LUASCRIPTS_H +#include #include #include -#include namespace ESM { diff --git a/components/esm/refid.cpp b/components/esm/refid.cpp index b69dbc6fb3..11d2f7761e 100644 --- a/components/esm/refid.cpp +++ b/components/esm/refid.cpp @@ -4,8 +4,6 @@ #include "components/misc/strings/algorithm.hpp" - - namespace ESM { bool RefId::operator==(const RefId& rhs) const @@ -13,6 +11,16 @@ namespace ESM return this->mId == rhs.mId; } + bool RefId::operator<(const RefId& rhs) const + { + return mId < rhs.mId; + } + + bool RefId::operator>(const RefId& rhs) const + { + return mId > rhs.mId; + } + std::ostream& operator<<(std::ostream& os, const RefId& refId) { os << refId.getRefIdString(); @@ -26,9 +34,10 @@ namespace ESM return newRefId; } + bool RefId::operator==(std::string_view rhs) const + { + return Misc::StringUtils::ciEqual(mId, rhs); + } + const RefId RefId::sEmpty = {}; } - - - - diff --git a/components/esm/refid.hpp b/components/esm/refid.hpp index 008fd1f6b2..e9f4684e1d 100644 --- a/components/esm/refid.hpp +++ b/components/esm/refid.hpp @@ -1,5 +1,6 @@ #ifndef OPENMW_COMPONENTS_ESM_REFID_HPP #define OPENMW_COMPONENTS_ESM_REFID_HPP +#include #include #include #include @@ -13,19 +14,28 @@ namespace ESM bool empty() const { return mId.empty(); } void swap(RefId& rhs) { mId.swap(rhs.mId); } bool operator==(const RefId& rhs) const; - bool operator<(const RefId& rhs) const { return mId < rhs.mId; } - bool operator>(const RefId& rhs) const { return mId > rhs.mId; } + bool operator<(const RefId& rhs) const; + bool operator>(const RefId& rhs) const; friend std::ostream& operator<<(std::ostream& os, const RefId& dt); - //The 2 following functions are used to move back and forth between string and RefID. Used for hard coded RefIds that are as string in the code. - //For serialization, and display. Using explicit conversions make it very clear where in the code we need to convert from string to RefId and Vice versa. - static RefId stringRefId(std::string_view id); - const std::string& getRefIdString() const { return mId; } - + // The 2 following functions are used to move back and forth between string and RefID. Used for hard coded + // RefIds that are as string in the code. For serialization, and display. Using explicit conversions make it + // very clear where in the code we need to convert from string to RefId and Vice versa. + static RefId stringRefId(std::string_view id); + const std::string& getRefIdString() const { return mId; } private: std::string mId; + + bool operator==(std::string_view rhs) const; + + public: + template + bool operator==(const char (&rhs)[size]) const + { + return *this == std::string_view(rhs); + } }; } @@ -35,10 +45,7 @@ namespace std template <> struct hash { - std::size_t operator()(const ESM::RefId& k) const - { - return std::hash()(k.getRefIdString()); - } + std::size_t operator()(const ESM::RefId& k) const { return std::hash()(k.getRefIdString()); } }; } #endif diff --git a/components/esm/refidhardcoded.cpp b/components/esm/refidhardcoded.cpp deleted file mode 100644 index 964750d9ae..0000000000 --- a/components/esm/refidhardcoded.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "refidhardcoded.hpp" - -namespace ESM -{//A few hardcoded ids that are used multiple times accross the codebase - const RefId sPlayerId = ESM::RefId::stringRefId("Player"); - const RefId sMenuClickSoundId = ESM::RefId::stringRefId("Menu Click"); - const RefId sBookPageSoundId = ESM::RefId::stringRefId("book page"); - const RefId sGoldId001 = ESM::RefId::stringRefId("gold_001"); - const RefId sGoldId005 = ESM::RefId::stringRefId("gold_005"); - const RefId sGoldId010 = ESM::RefId::stringRefId("gold_010"); - const RefId sGoldId025 = ESM::RefId::stringRefId("gold_025"); - const RefId sGoldId100 = ESM::RefId::stringRefId("gold_100"); - const RefId sHealthDamageSoundId = ESM::RefId::stringRefId("Health Damage"); -} - - - - diff --git a/components/esm/refidhardcoded.hpp b/components/esm/refidhardcoded.hpp deleted file mode 100644 index e15159328a..0000000000 --- a/components/esm/refidhardcoded.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef OPENMW_COMPONENTS_ESM_REFIDHARDCODED_HPP -#define OPENMW_COMPONENTS_ESM_REFIDHARDCODED_HPP -#include "refid.hpp" - -namespace ESM -{ - extern const RefId sPlayerId, sMenuClickSoundId, sBookPageSoundId, sHealthDamageSoundId; - extern const RefId sGoldId001, sGoldId005, sGoldId010, sGoldId025, sGoldId100; - -} - -#endif diff --git a/components/esm3/cellid.hpp b/components/esm3/cellid.hpp index 15780c26e9..12479dc2c6 100644 --- a/components/esm3/cellid.hpp +++ b/components/esm3/cellid.hpp @@ -2,7 +2,6 @@ #define OPENMW_ESM_CELLID_H #include -#include namespace ESM { diff --git a/components/esm3/cellref.cpp b/components/esm3/cellref.cpp index 179541bb1f..b27df00ade 100644 --- a/components/esm3/cellref.cpp +++ b/components/esm3/cellref.cpp @@ -25,7 +25,7 @@ namespace ESM { cellRef.blank(); cellRef.mRefNum.load(esm, wideRefNum); - cellRef.mRefID = ESM::RefId::stringRefId(esm.getHNOString("NAME")); + cellRef.mRefID = esm.getHNORefId("NAME"); if (cellRef.mRefID.empty()) Log(Debug::Warning) << "Warning: got CellRef with empty RefId in " << esm.getName() << " 0x" @@ -41,8 +41,7 @@ namespace ESM template void loadDataImpl(ESMReader& esm, bool& isDeleted, CellRef& cellRef) { - const auto getRefIdOrSkip = [&](ESM::RefId refId) - { + const auto getRefIdOrSkip = [&](ESM::RefId refId) { if constexpr (load) refId = esm.getRefId(); else diff --git a/components/esm3/dialoguestate.cpp b/components/esm3/dialoguestate.cpp index 52b66ab3fa..2423bbb6b1 100644 --- a/components/esm3/dialoguestate.cpp +++ b/components/esm3/dialoguestate.cpp @@ -40,13 +40,11 @@ namespace ESM esm.writeHNString("TOPI", iter->getRefIdString()); } - for (auto iter = mChangedFactionReaction.begin(); - iter != mChangedFactionReaction.end(); ++iter) + for (auto iter = mChangedFactionReaction.begin(); iter != mChangedFactionReaction.end(); ++iter) { esm.writeHNString("FACT", iter->first.getRefIdString()); - for (auto reactIter = iter->second.begin(); - reactIter != iter->second.end(); ++reactIter) + for (auto reactIter = iter->second.begin(); reactIter != iter->second.end(); ++reactIter) { esm.writeHNString("REA2", reactIter->first.getRefIdString()); esm.writeHNT("INTV", reactIter->second); diff --git a/components/esm3/dialoguestate.hpp b/components/esm3/dialoguestate.hpp index 704ebc806f..70e06737d5 100644 --- a/components/esm3/dialoguestate.hpp +++ b/components/esm3/dialoguestate.hpp @@ -1,10 +1,10 @@ #ifndef OPENMW_ESM_DIALOGUESTATE_H #define OPENMW_ESM_DIALOGUESTATE_H +#include #include #include #include -#include namespace ESM { diff --git a/components/esm3/esmreader.cpp b/components/esm3/esmreader.cpp index 6765a2f486..a358e262c1 100644 --- a/components/esm3/esmreader.cpp +++ b/components/esm3/esmreader.cpp @@ -124,6 +124,13 @@ namespace ESM return ""; } + ESM::RefId ESMReader::getHNORefId(NAME name) + { + if (isNextSub(name)) + return getRefId(); + return ESM::RefId::sEmpty; + } + void ESMReader::skipHNOString(NAME name) { if (isNextSub(name)) @@ -157,7 +164,26 @@ namespace ESM return getString(mCtx.leftSub); } - RefId ESMReader::getRefId() { return ESM::RefId::stringRefId(getHString()); } + RefId ESMReader::getRefId() + { + getSubHeader(); + + // Hack to make MultiMark.esp load. Zero-length strings do not + // occur in any of the official mods, but MultiMark makes use of + // them. For some reason, they break the rules, and contain a byte + // (value 0) even if the header says there is no data. If + // Morrowind accepts it, so should we. + if (mCtx.leftSub == 0 && hasMoreSubs() && !mEsm->peek()) + { + // Skip the following zero byte + mCtx.leftRec--; + char c; + getT(c); + return ESM::RefId::sEmpty; + } + + return getRefId(mCtx.leftSub); + } void ESMReader::skipHString() { @@ -357,6 +383,30 @@ namespace ESM return std::string(ptr, size); } + ESM::RefId ESMReader::getRefId(int size) + { + size_t s = size; + if (mBuffer.size() <= s) + // Add some extra padding to reduce the chance of having to resize + // again later. + mBuffer.resize(3 * s); + + // And make sure the string is zero terminated + mBuffer[s] = 0; + + // read ESM data + char* ptr = mBuffer.data(); + getExact(ptr, size); + + size = static_cast(strnlen(ptr, size)); + + // Convert to UTF8 and return + if (mEncoder) + return ESM::RefId::stringRefId(mEncoder->getUtf8(std::string_view(ptr, size))); + + return ESM::RefId::stringRefId(std::string_view(ptr, size)); + } + [[noreturn]] void ESMReader::fail(const std::string& msg) { std::stringstream ss; diff --git a/components/esm3/esmreader.hpp b/components/esm3/esmreader.hpp index 7898bbd1d2..f6b405f7ae 100644 --- a/components/esm3/esmreader.hpp +++ b/components/esm3/esmreader.hpp @@ -165,6 +165,7 @@ namespace ESM // Read a string by the given name if it is the next record. std::string getHNOString(NAME name); + ESM::RefId getHNORefId(NAME name); void skipHNOString(NAME name); @@ -173,7 +174,7 @@ namespace ESM // Read a string, including the sub-record header (but not the name) std::string getHString(); - RefId getRefId(); + RefId getRefId(); void skipHString(); @@ -271,6 +272,7 @@ namespace ESM // Read the next 'size' bytes and return them as a string. Converts // them from native encoding to UTF8 in the process. std::string getString(int size); + ESM::RefId getRefId(int size); void skip(std::size_t bytes) { diff --git a/components/esm3/globalscript.hpp b/components/esm3/globalscript.hpp index 1ee7d1a089..deea622ea4 100644 --- a/components/esm3/globalscript.hpp +++ b/components/esm3/globalscript.hpp @@ -2,8 +2,8 @@ #define OPENMW_ESM_GLOBALSCRIPT_H #include "cellref.hpp" -#include "locals.hpp" #include "components/esm/refid.hpp" +#include "locals.hpp" namespace ESM { diff --git a/components/esm3/inventorystate.cpp b/components/esm3/inventorystate.cpp index a59a963d74..6f1ceeac11 100644 --- a/components/esm3/inventorystate.cpp +++ b/components/esm3/inventorystate.cpp @@ -120,7 +120,7 @@ namespace ESM const int count = entry.second; for (auto& item : mItems) { - if (item.mCount == count && id == item.mRef.mRefID) + if (item.mCount == count && id == item.mRef.mRefID) item.mCount = -count; } } @@ -138,8 +138,7 @@ namespace ESM } } - for (auto it = mLevelledItemMap.begin(); - it != mLevelledItemMap.end(); ++it) + for (auto it = mLevelledItemMap.begin(); it != mLevelledItemMap.end(); ++it) { esm.writeHNString("LEVM", it->first.first.getRefIdString()); esm.writeHNT("COUN", it->second); diff --git a/components/esm3/journalentry.hpp b/components/esm3/journalentry.hpp index a9a5f32530..770d8128c7 100644 --- a/components/esm3/journalentry.hpp +++ b/components/esm3/journalentry.hpp @@ -1,8 +1,8 @@ #ifndef OPENMW_ESM_JOURNALENTRY_H #define OPENMW_ESM_JOURNALENTRY_H -#include #include +#include namespace ESM { diff --git a/components/esm3/loadbook.hpp b/components/esm3/loadbook.hpp index b4505fc8e7..d2dbfea3ca 100644 --- a/components/esm3/loadbook.hpp +++ b/components/esm3/loadbook.hpp @@ -32,7 +32,7 @@ namespace ESM unsigned int mRecordFlags; RefId mId; RefId mScript, mEnchant; - + void load(ESMReader& esm, bool& isDeleted); void save(ESMWriter& esm, bool isDeleted = false) const; diff --git a/components/esm3/loadlevlist.hpp b/components/esm3/loadlevlist.hpp index b4406e3f64..809c89102e 100644 --- a/components/esm3/loadlevlist.hpp +++ b/components/esm3/loadlevlist.hpp @@ -4,9 +4,9 @@ #include #include +#include "components/esm/refid.hpp" #include #include -#include "components/esm/refid.hpp" namespace ESM { diff --git a/components/esm3/loadscpt.cpp b/components/esm3/loadscpt.cpp index 531441fd20..dbba62d0cc 100644 --- a/components/esm3/loadscpt.cpp +++ b/components/esm3/loadscpt.cpp @@ -188,7 +188,7 @@ namespace ESM mVarNames.clear(); mScriptData.clear(); - std::string stringId = mId.getRefIdString(); + const std::string& stringId = mId.getRefIdString(); if (stringId.find("::") != std::string::npos) mScriptText = "Begin \"" + stringId + "\"\n\nEnd " + stringId + "\n"; else diff --git a/components/esm3/loadstat.hpp b/components/esm3/loadstat.hpp index c12628cf80..abe589563b 100644 --- a/components/esm3/loadstat.hpp +++ b/components/esm3/loadstat.hpp @@ -33,8 +33,8 @@ namespace ESM unsigned int mRecordFlags; RefId mId; - std::string mModel; - + std::string mModel; + void load(ESMReader& esm, bool& isDeleted); void save(ESMWriter& esm, bool isDeleted = false) const; diff --git a/components/esm3/loadweap.hpp b/components/esm3/loadweap.hpp index 2b2eec4a40..d3a2a1f053 100644 --- a/components/esm3/loadweap.hpp +++ b/components/esm3/loadweap.hpp @@ -3,8 +3,8 @@ #include -#include "loadskil.hpp" #include "components/esm/refid.hpp" +#include "loadskil.hpp" namespace ESM { @@ -76,8 +76,8 @@ namespace ESM WPDTstruct mData; unsigned int mRecordFlags; - RefId mId, mEnchant, mScript; - std::string mName, mModel, mIcon; + RefId mId, mEnchant, mScript; + std::string mName, mModel, mIcon; void load(ESMReader& esm, bool& isDeleted); void save(ESMWriter& esm, bool isDeleted = false) const; diff --git a/components/esm3/magiceffects.hpp b/components/esm3/magiceffects.hpp index d0b6c6787b..e528ba3a87 100644 --- a/components/esm3/magiceffects.hpp +++ b/components/esm3/magiceffects.hpp @@ -1,9 +1,9 @@ #ifndef COMPONENTS_ESM_MAGICEFFECTS_H #define COMPONENTS_ESM_MAGICEFFECTS_H +#include #include #include -#include namespace ESM { diff --git a/components/esm3/npcstats.hpp b/components/esm3/npcstats.hpp index 4bf53cde3d..b9e2e6bb9b 100644 --- a/components/esm3/npcstats.hpp +++ b/components/esm3/npcstats.hpp @@ -1,11 +1,11 @@ #ifndef OPENMW_ESM_NPCSTATS_H #define OPENMW_ESM_NPCSTATS_H +#include "statstate.hpp" +#include #include #include #include -#include -#include "statstate.hpp" namespace ESM { diff --git a/components/esm3/projectilestate.hpp b/components/esm3/projectilestate.hpp index 9c61e687ea..afb8047da9 100644 --- a/components/esm3/projectilestate.hpp +++ b/components/esm3/projectilestate.hpp @@ -8,8 +8,8 @@ #include "effectlist.hpp" -#include "components/esm/util.hpp" #include "components/esm/refid.hpp" +#include "components/esm/util.hpp" namespace ESM { diff --git a/components/esm3/queststate.hpp b/components/esm3/queststate.hpp index 78182fc95d..5858714df0 100644 --- a/components/esm3/queststate.hpp +++ b/components/esm3/queststate.hpp @@ -1,8 +1,8 @@ #ifndef OPENMW_ESM_QUESTSTATE_H #define OPENMW_ESM_QUESTSTATE_H -#include #include +#include namespace ESM { diff --git a/components/esm3/quickkeys.hpp b/components/esm3/quickkeys.hpp index ddc29c0e3c..0a525efd75 100644 --- a/components/esm3/quickkeys.hpp +++ b/components/esm3/quickkeys.hpp @@ -1,9 +1,9 @@ #ifndef OPENMW_COMPONENTS_ESM_QUICKKEYS_H #define OPENMW_COMPONENTS_ESM_QUICKKEYS_H +#include "components/esm/refid.hpp" #include #include -#include "components/esm/refid.hpp" namespace ESM { diff --git a/components/esm3/spelllist.cpp b/components/esm3/spelllist.cpp index 6a78700b95..21871d23b9 100644 --- a/components/esm3/spelllist.cpp +++ b/components/esm3/spelllist.cpp @@ -24,7 +24,7 @@ namespace ESM bool SpellList::exists(const ESM::RefId& spell) const { for (auto it = mList.begin(); it != mList.end(); ++it) - if (*it == spell) + if (*it == spell) return true; return false; } diff --git a/components/esm3/spelllist.hpp b/components/esm3/spelllist.hpp index 3d9bf5174b..7677eed11c 100644 --- a/components/esm3/spelllist.hpp +++ b/components/esm3/spelllist.hpp @@ -1,9 +1,9 @@ #ifndef OPENMW_ESM_SPELLLIST_H #define OPENMW_ESM_SPELLLIST_H +#include #include #include -#include namespace ESM { diff --git a/components/esm3/stolenitems.cpp b/components/esm3/stolenitems.cpp index 42d3d28b04..da57dd8339 100644 --- a/components/esm3/stolenitems.cpp +++ b/components/esm3/stolenitems.cpp @@ -11,8 +11,7 @@ namespace ESM for (StolenItemsMap::const_iterator it = mStolenItems.begin(); it != mStolenItems.end(); ++it) { esm.writeHNString("NAME", it->first.getRefIdString()); - for (auto ownerIt = it->second.begin(); - ownerIt != it->second.end(); ++ownerIt) + for (auto ownerIt = it->second.begin(); ownerIt != it->second.end(); ++ownerIt) { if (ownerIt->first.second) esm.writeHNString("FNAM", ownerIt->first.first.getRefIdString()); diff --git a/components/esm3/stolenitems.hpp b/components/esm3/stolenitems.hpp index 14e5860fc7..f400e0edad 100644 --- a/components/esm3/stolenitems.hpp +++ b/components/esm3/stolenitems.hpp @@ -1,9 +1,9 @@ #ifndef OPENMW_COMPONENTS_ESM_STOLENITEMS_H #define OPENMW_COMPONENTS_ESM_STOLENITEMS_H +#include #include #include -#include namespace ESM { diff --git a/components/esm3/weatherstate.hpp b/components/esm3/weatherstate.hpp index 9e352a3500..3fad90ddb4 100644 --- a/components/esm3/weatherstate.hpp +++ b/components/esm3/weatherstate.hpp @@ -1,10 +1,10 @@ #ifndef OPENMW_ESM_WEATHERSTATE_H #define OPENMW_ESM_WEATHERSTATE_H +#include #include #include #include -#include namespace ESM { diff --git a/components/esmloader/lessbyid.hpp b/components/esmloader/lessbyid.hpp index 4fc866264d..adc93c63de 100644 --- a/components/esmloader/lessbyid.hpp +++ b/components/esmloader/lessbyid.hpp @@ -1,8 +1,8 @@ #ifndef OPENMW_COMPONENTS_CONTENT_LESSBYID_H #define OPENMW_COMPONENTS_CONTENT_LESSBYID_H -#include #include +#include namespace EsmLoader { diff --git a/components/interpreter/context.hpp b/components/interpreter/context.hpp index 6162aa340a..d4656eaa85 100644 --- a/components/interpreter/context.hpp +++ b/components/interpreter/context.hpp @@ -1,10 +1,10 @@ #ifndef INTERPRETER_CONTEXT_H_INCLUDED #define INTERPRETER_CONTEXT_H_INCLUDED +#include #include #include #include -#include namespace Interpreter { diff --git a/components/interpreter/defines.cpp b/components/interpreter/defines.cpp index 5d8e0df0da..64090fb9b8 100644 --- a/components/interpreter/defines.cpp +++ b/components/interpreter/defines.cpp @@ -213,11 +213,8 @@ namespace Interpreter /* if list of globals is empty, grab it and sort it by descending string length */ if (globals.empty()) { - auto globalIds = context.getGlobals(); - for (auto id : globalIds) - { - globals.push_back(id); - } + globals = context.getGlobals(); + ; sort(globals.begin(), globals.end(), longerStr); } diff --git a/components/misc/resourcehelpers.cpp b/components/misc/resourcehelpers.cpp index 7d9567bab5..d172b4b8c9 100644 --- a/components/misc/resourcehelpers.cpp +++ b/components/misc/resourcehelpers.cpp @@ -160,12 +160,7 @@ std::string Misc::ResourceHelpers::correctSoundPath(std::string_view resPath, co bool Misc::ResourceHelpers::isHiddenMarker(const ESM::RefId& id) { - static const ESM::RefId prisonMarker = ESM::RefId::stringRefId("prisonmarker"); - static const ESM::RefId divineMarker = ESM::RefId::stringRefId("divinemarker"); - static const ESM::RefId templeMarker = ESM::RefId::stringRefId("templemarker"); - static const ESM::RefId northMarker = ESM::RefId::stringRefId("northmarker"); - - return id == prisonMarker || id == divineMarker || id == templeMarker || id == northMarker; + return id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker"; } namespace