From 6c70c403be951d8da2d9ea949c63dabd320a3e64 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Wed, 14 May 2025 23:04:11 -0600 Subject: [PATCH 01/18] Implement FillJournal console command --- apps/openmw/mwscript/dialogueextensions.cpp | 59 +++++++++++++++++---- apps/openmw/mwscript/docs/vmformat.txt | 3 +- components/compiler/extensions0.cpp | 1 + components/compiler/opcodes.hpp | 1 + 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 6511fbdb01..643efb3d07 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -22,6 +22,20 @@ namespace MWScript { + static void addJournalEntry(ESM::RefId quest, int index, MWWorld::Ptr ptr) + { + // Invoking Journal with a non-existing index is allowed, and triggers no errors. Seriously? :( + try + { + MWBase::Environment::get().getJournal()->addEntry(quest, index, ptr); + } + catch (...) + { + if (MWBase::Environment::get().getJournal()->getJournalIndex(quest) < index) + MWBase::Environment::get().getJournal()->setJournalIndex(quest, index); + } + } + namespace Dialogue { template @@ -40,16 +54,7 @@ namespace MWScript Interpreter::Type_Integer index = runtime[0].mInteger; runtime.pop(); - // Invoking Journal with a non-existing index is allowed, and triggers no errors. Seriously? :( - try - { - MWBase::Environment::get().getJournal()->addEntry(quest, index, ptr); - } - catch (...) - { - if (MWBase::Environment::get().getJournal()->getJournalIndex(quest) < index) - MWBase::Environment::get().getJournal()->setJournalIndex(quest, index); - } + addJournalEntry(quest, index, ptr); } }; @@ -82,6 +87,39 @@ namespace MWScript } }; + class OpFillJournal : public Interpreter::Opcode0 + { + public: + void execute(Interpreter::Runtime& runtime) override + { + const MWWorld::Store& dialogues = MWBase::Environment::get().getESMStore()->get(); + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr(); + + for (auto it = dialogues.begin(); it != dialogues.end(); ++it) + { + const ESM::Dialogue::Type type = it->mType; + if (type == ESM::Dialogue::Type::Journal) + { + ESM::RefId quest = ESM::RefId::stringRefId(it->mStringId); + const std::list orderedInfo = it->mInfoOrder.getOrderedInfo(); + for (auto info = orderedInfo.begin(); info != orderedInfo.end(); ++info) + { + addJournalEntry(quest, info->mData.mJournalIndex, ptr); + } + } + else if (type == ESM::Dialogue::Type::Topic) + { + ESM::RefId topic = ESM::RefId::stringRefId(it->mStringId); + const std::list orderedInfo = it->mInfoOrder.getOrderedInfo(); + for (auto info = orderedInfo.begin(); info != orderedInfo.end(); ++info) + { + MWBase::Environment::get().getJournal()->addTopic(topic, info->mId, ptr); + } + } + } + } + }; + class OpAddTopic : public Interpreter::Opcode0 { public: @@ -288,6 +326,7 @@ namespace MWScript interpreter.installSegment5>(Compiler::Dialogue::opcodeJournalExplicit); interpreter.installSegment5(Compiler::Dialogue::opcodeSetJournalIndex); interpreter.installSegment5(Compiler::Dialogue::opcodeGetJournalIndex); + interpreter.installSegment5(Compiler::Dialogue::opcodeFillJournal); interpreter.installSegment5(Compiler::Dialogue::opcodeAddTopic); interpreter.installSegment3(Compiler::Dialogue::opcodeChoice); interpreter.installSegment5>(Compiler::Dialogue::opcodeForceGreeting); diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index d34c39c9df..56eb1c2351 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -485,5 +485,6 @@ op 0x2000322: GetPCVisionBonus op 0x2000323: SetPCVisionBonus op 0x2000324: ModPCVisionBonus op 0x2000325: TestModels, T3D +op 0x2000326: FillJournal -opcodes 0x2000326-0x3ffffff unused +opcodes 0x2000327-0x3ffffff unused diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index 6f57ee7673..103fb41641 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -163,6 +163,7 @@ namespace Compiler extensions.registerInstruction("journal", "cl", opcodeJournal, opcodeJournalExplicit); extensions.registerInstruction("setjournalindex", "cl", opcodeSetJournalIndex); extensions.registerFunction("getjournalindex", 'l', "c", opcodeGetJournalIndex); + extensions.registerInstruction("filljournal", "", opcodeFillJournal); extensions.registerInstruction("addtopic", "S", opcodeAddTopic); extensions.registerInstruction( "choice", "j/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice); diff --git a/components/compiler/opcodes.hpp b/components/compiler/opcodes.hpp index 2ec31c7588..55f431f049 100644 --- a/components/compiler/opcodes.hpp +++ b/components/compiler/opcodes.hpp @@ -155,6 +155,7 @@ namespace Compiler const int opcodeJournalExplicit = 0x200030b; const int opcodeSetJournalIndex = 0x2000134; const int opcodeGetJournalIndex = 0x2000135; + const int opcodeFillJournal = 0x2000326; const int opcodeAddTopic = 0x200013a; const int opcodeChoice = 0x2000a; const int opcodeForceGreeting = 0x200014f; From 2e1f3d5d2c0da9e7a680ce6bd79fcb00d49a6dbe Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Wed, 14 May 2025 23:17:32 -0600 Subject: [PATCH 02/18] Clang format --- apps/openmw/mwscript/dialogueextensions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 643efb3d07..93241c3ff4 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -92,7 +92,8 @@ namespace MWScript public: void execute(Interpreter::Runtime& runtime) override { - const MWWorld::Store& dialogues = MWBase::Environment::get().getESMStore()->get(); + const MWWorld::Store& dialogues + = MWBase::Environment::get().getESMStore()->get(); MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr(); for (auto it = dialogues.begin(); it != dialogues.end(); ++it) From 34194f9c0841fda8e06615b1bfbea2a9a7aac7ce Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Wed, 14 May 2025 23:28:05 -0600 Subject: [PATCH 03/18] Add topics as known topics in addition to journal topics --- apps/openmw/mwscript/dialogueextensions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 93241c3ff4..17145e9b32 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -116,6 +116,7 @@ namespace MWScript { MWBase::Environment::get().getJournal()->addTopic(topic, info->mId, ptr); } + MWBase::Environment::get().getDialogueManager()->addTopic(topic); } } } From 4b9852026637ecaf39ac83fceb6d5341d1edca39 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Thu, 15 May 2025 12:32:05 -0600 Subject: [PATCH 04/18] Revert shared addJournalEntry --- apps/openmw/mwscript/dialogueextensions.cpp | 27 +++++++++------------ 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 17145e9b32..869b626728 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -22,20 +22,6 @@ namespace MWScript { - static void addJournalEntry(ESM::RefId quest, int index, MWWorld::Ptr ptr) - { - // Invoking Journal with a non-existing index is allowed, and triggers no errors. Seriously? :( - try - { - MWBase::Environment::get().getJournal()->addEntry(quest, index, ptr); - } - catch (...) - { - if (MWBase::Environment::get().getJournal()->getJournalIndex(quest) < index) - MWBase::Environment::get().getJournal()->setJournalIndex(quest, index); - } - } - namespace Dialogue { template @@ -54,7 +40,16 @@ namespace MWScript Interpreter::Type_Integer index = runtime[0].mInteger; runtime.pop(); - addJournalEntry(quest, index, ptr); + // Invoking Journal with a non-existing index is allowed, and triggers no errors. Seriously? :( + try + { + MWBase::Environment::get().getJournal()->addEntry(quest, index, ptr); + } + catch (...) + { + if (MWBase::Environment::get().getJournal()->getJournalIndex(quest) < index) + MWBase::Environment::get().getJournal()->setJournalIndex(quest, index); + } } }; @@ -105,7 +100,7 @@ namespace MWScript const std::list orderedInfo = it->mInfoOrder.getOrderedInfo(); for (auto info = orderedInfo.begin(); info != orderedInfo.end(); ++info) { - addJournalEntry(quest, info->mData.mJournalIndex, ptr); + MWBase::Environment::get().getJournal()->addEntry(quest, info->mData.mJournalIndex, ptr); } } else if (type == ESM::Dialogue::Type::Topic) From 83903455f9f22257cbc649ceda6bbd31b96a1c38 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Thu, 15 May 2025 12:51:53 -0600 Subject: [PATCH 05/18] Address review comments --- apps/openmw/mwscript/dialogueextensions.cpp | 22 +++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 869b626728..ab48807c36 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -91,27 +91,23 @@ namespace MWScript = MWBase::Environment::get().getESMStore()->get(); MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr(); - for (auto it = dialogues.begin(); it != dialogues.end(); ++it) + for (const auto& dialogue : dialogues) { - const ESM::Dialogue::Type type = it->mType; - if (type == ESM::Dialogue::Type::Journal) + if (dialogue.mType == ESM::Dialogue::Type::Journal) { - ESM::RefId quest = ESM::RefId::stringRefId(it->mStringId); - const std::list orderedInfo = it->mInfoOrder.getOrderedInfo(); - for (auto info = orderedInfo.begin(); info != orderedInfo.end(); ++info) + for (const auto& journalInfo : dialogue.mInfoOrder.getOrderedInfo()) { - MWBase::Environment::get().getJournal()->addEntry(quest, info->mData.mJournalIndex, ptr); + MWBase::Environment::get().getJournal()->addEntry(dialogue.mId, + journalInfo.mData.mJournalIndex, ptr); } } - else if (type == ESM::Dialogue::Type::Topic) + else if (dialogue.mType == ESM::Dialogue::Type::Topic) { - ESM::RefId topic = ESM::RefId::stringRefId(it->mStringId); - const std::list orderedInfo = it->mInfoOrder.getOrderedInfo(); - for (auto info = orderedInfo.begin(); info != orderedInfo.end(); ++info) + for (const auto& topicInfo : dialogue.mInfoOrder.getOrderedInfo()) { - MWBase::Environment::get().getJournal()->addTopic(topic, info->mId, ptr); + MWBase::Environment::get().getJournal()->addTopic(dialogue.mId, topicInfo.mId, ptr); } - MWBase::Environment::get().getDialogueManager()->addTopic(topic); + MWBase::Environment::get().getDialogueManager()->addTopic(dialogue.mId); } } } From 565b199380c8176ebbc2910f0ee57dbff60d60ed Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Thu, 15 May 2025 12:54:27 -0600 Subject: [PATCH 06/18] Clang format --- apps/openmw/mwscript/dialogueextensions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index ab48807c36..6b3787f948 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -97,8 +97,8 @@ namespace MWScript { for (const auto& journalInfo : dialogue.mInfoOrder.getOrderedInfo()) { - MWBase::Environment::get().getJournal()->addEntry(dialogue.mId, - journalInfo.mData.mJournalIndex, ptr); + MWBase::Environment::get().getJournal()->addEntry( + dialogue.mId, journalInfo.mData.mJournalIndex, ptr); } } else if (dialogue.mType == ESM::Dialogue::Type::Topic) From 30140d95488b13b8dfe6dbbb778fa32343a979ab Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Fri, 16 May 2025 11:34:00 -0600 Subject: [PATCH 07/18] Get the journal only once --- apps/openmw/mwscript/dialogueextensions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 6b3787f948..1c7de21d57 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -90,6 +90,7 @@ namespace MWScript const MWWorld::Store& dialogues = MWBase::Environment::get().getESMStore()->get(); MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr(); + MWBase::Journal* journal = MWBase::Environment::get().getJournal(); for (const auto& dialogue : dialogues) { @@ -97,7 +98,7 @@ namespace MWScript { for (const auto& journalInfo : dialogue.mInfoOrder.getOrderedInfo()) { - MWBase::Environment::get().getJournal()->addEntry( + journal->addEntry( dialogue.mId, journalInfo.mData.mJournalIndex, ptr); } } @@ -105,7 +106,7 @@ namespace MWScript { for (const auto& topicInfo : dialogue.mInfoOrder.getOrderedInfo()) { - MWBase::Environment::get().getJournal()->addTopic(dialogue.mId, topicInfo.mId, ptr); + journal->addTopic(dialogue.mId, topicInfo.mId, ptr); } MWBase::Environment::get().getDialogueManager()->addTopic(dialogue.mId); } From 73a3033e0ffd6a93386890690c1692550159c11a Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Fri, 16 May 2025 11:42:27 -0600 Subject: [PATCH 08/18] Get the dialogue manager once --- apps/openmw/mwscript/dialogueextensions.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 1c7de21d57..edf6f4b6df 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -89,8 +89,9 @@ namespace MWScript { const MWWorld::Store& dialogues = MWBase::Environment::get().getESMStore()->get(); - MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr(); + MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWBase::Journal* journal = MWBase::Environment::get().getJournal(); + MWBase::DialogueManager* dialogueManager = MWBase::Environment::get().getDialogueManager(); for (const auto& dialogue : dialogues) { @@ -99,16 +100,16 @@ namespace MWScript for (const auto& journalInfo : dialogue.mInfoOrder.getOrderedInfo()) { journal->addEntry( - dialogue.mId, journalInfo.mData.mJournalIndex, ptr); + dialogue.mId, journalInfo.mData.mJournalIndex, playerPtr); } } else if (dialogue.mType == ESM::Dialogue::Type::Topic) { for (const auto& topicInfo : dialogue.mInfoOrder.getOrderedInfo()) { - journal->addTopic(dialogue.mId, topicInfo.mId, ptr); + journal->addTopic(dialogue.mId, topicInfo.mId, playerPtr); } - MWBase::Environment::get().getDialogueManager()->addTopic(dialogue.mId); + dialogueManager->addTopic(dialogue.mId); } } } From 0e1ed078e9380fc1b4ce3213de2bd8bee312daac Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Fri, 16 May 2025 11:56:43 -0600 Subject: [PATCH 09/18] Clang format --- apps/openmw/mwscript/dialogueextensions.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index edf6f4b6df..23d8049a5d 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -99,8 +99,7 @@ namespace MWScript { for (const auto& journalInfo : dialogue.mInfoOrder.getOrderedInfo()) { - journal->addEntry( - dialogue.mId, journalInfo.mData.mJournalIndex, playerPtr); + journal->addEntry(dialogue.mId, journalInfo.mData.mJournalIndex, playerPtr); } } else if (dialogue.mType == ESM::Dialogue::Type::Topic) From d207c2251ffe4693f73e275c8df95bc7127c0010 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Thu, 3 Jul 2025 11:38:15 -0600 Subject: [PATCH 10/18] Fix unneeded runtime errors --- apps/openmw/mwscript/interpretercontext.cpp | 26 ++++++-- components/interpreter/defines.cpp | 70 +++++++++++---------- 2 files changed, 60 insertions(+), 36 deletions(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 15c9100b98..9aeccfc886 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "../mwworld/esmstore.hpp" @@ -300,7 +301,15 @@ namespace MWScript std::string_view InterpreterContext::getNPCFaction() const { - const ESM::NPC* npc = getReferenceImp().get()->mBase; + const MWWorld::Ptr& ptr = getReferenceImp(); + const ESM::RefId& factionId = ptr.getClass().getPrimaryFaction(ptr); + if (factionId.empty()) + { + Log(Debug::Warning) << "getNPCFaction(): NPC is not in a faction"; + return "%"; + } + + const ESM::NPC* npc = ptr.get()->mBase; const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get().find(npc->mFaction); return faction->mName; } @@ -310,7 +319,10 @@ namespace MWScript const MWWorld::Ptr& ptr = getReferenceImp(); const ESM::RefId& faction = ptr.getClass().getPrimaryFaction(ptr); if (faction.empty()) - throw std::runtime_error("getNPCRank(): NPC is not in a faction"); + { + Log(Debug::Warning) << "getNPCRank(): NPC is not in a faction"; + return "%"; + } int rank = ptr.getClass().getPrimaryFactionRank(ptr); if (rank < 0 || rank > 9) @@ -349,7 +361,10 @@ namespace MWScript const ESM::RefId& factionId = getReferenceImp().getClass().getPrimaryFaction(getReferenceImp()); if (factionId.empty()) - throw std::runtime_error("getPCRank(): NPC is not in a faction"); + { + Log(Debug::Warning) << "getPCRank(): NPC is not in a faction"; + return "%"; + } const auto& ranks = player.getClass().getNpcStats(player).getFactionRanks(); auto it = ranks.find(factionId); @@ -378,7 +393,10 @@ namespace MWScript const ESM::RefId& factionId = getReferenceImp().getClass().getPrimaryFaction(getReferenceImp()); if (factionId.empty()) - throw std::runtime_error("getPCNextRank(): NPC is not in a faction"); + { + Log(Debug::Warning) << "getPCNextRank(): NPC is not in a faction"; + return "%"; + } const auto& ranks = player.getClass().getNpcStats(player).getFactionRanks(); auto it = ranks.find(factionId); diff --git a/components/interpreter/defines.cpp b/components/interpreter/defines.cpp index e7a8e35328..6d51a72cca 100644 --- a/components/interpreter/defines.cpp +++ b/components/interpreter/defines.cpp @@ -26,40 +26,40 @@ namespace std::vector globals; const std::initializer_list> sActionBindings{ - { "actionslideright", "#{sRight}" }, - { "actionreadymagic", "#{sReady_Magic}" }, - { "actionprevweapon", "#{sPrevWeapon}" }, - { "actionnextweapon", "#{sNextWeapon}" }, - { "actiontogglerun", "#{sAuto_Run}" }, - { "actionslideleft", "#{sLeft}" }, - { "actionreadyitem", "#{sReady_Weapon}" }, - { "actionprevspell", "#{sPrevSpell}" }, - { "actionnextspell", "#{sNextSpell}" }, - { "actionrestmenu", "#{sRestKey}" }, - { "actionmenumode", "#{sInventory}" }, - { "actionactivate", "#{sActivate}" }, - { "actionjournal", "#{sJournal}" }, - { "actionforward", "#{sForward}" }, - { "actioncrouch", "#{sCrouch_Sneak}" }, - { "actionjump", "#{sJump}" }, - { "actionback", "#{sBack}" }, - { "actionuse", "#{sUse}" }, - { "actionrun", "#{sRun}" }, + { "ActionSlideRight", "#{sRight}" }, + { "ActionReadyMagic", "#{sReady_Magic}" }, + { "ActionPrevWeapon", "#{sPrevWeapon}" }, + { "ActionNextWeapon", "#{sNextWeapon}" }, + { "ActionToggleRun", "#{sAuto_Run}" }, + { "ActionSlideLeft", "#{sLeft}" }, + { "ActionReadyItem", "#{sReady_Weapon}" }, + { "ActionPrevSpell", "#{sPrevSpell}" }, + { "ActionNextSpell", "#{sNextSpell}" }, + { "ActionRestMenu", "#{sRestKey}" }, + { "ActionMenuMode", "#{sInventory}" }, + { "ActionActivate", "#{sActivate}" }, + { "ActionJournal", "#{sJournal}" }, + { "ActionForward", "#{sForward}" }, + { "ActionCrouch", "#{sCrouch_Sneak}" }, + { "ActionJump", "#{sJump}" }, + { "ActionBack", "#{sBack}" }, + { "ActionUse", "#{sUse}" }, + { "ActionRun", "#{sRun}" }, }; using ContextMethod = std::string_view (Interpreter::Context::*)() const; const std::initializer_list>> sContextMethods{ - { "nextpcrank", { &Interpreter::Context::getPCNextRank, nullptr } }, - { "pcnextrank", { &Interpreter::Context::getPCNextRank, nullptr } }, - { "faction", { &Interpreter::Context::getNPCFaction, nullptr } }, - { "pcclass", { &Interpreter::Context::getPCClass, &Interpreter::Context::getPCClass } }, - { "pcname", { &Interpreter::Context::getPCName, &Interpreter::Context::getPCName } }, - { "pcrace", { &Interpreter::Context::getPCRace, &Interpreter::Context::getPCRace } }, - { "pcrank", { &Interpreter::Context::getPCRank, nullptr } }, - { "class", { &Interpreter::Context::getNPCClass, &Interpreter::Context::getPCClass } }, - { "cell", { &Interpreter::Context::getCurrentCellName, &Interpreter::Context::getCurrentCellName } }, - { "race", { &Interpreter::Context::getNPCRace, &Interpreter::Context::getPCRace } }, - { "rank", { &Interpreter::Context::getNPCRank, nullptr } }, - { "name", { &Interpreter::Context::getActorName, &Interpreter::Context::getPCName } }, + { "NextPCRank", { &Interpreter::Context::getPCNextRank, nullptr } }, + { "PCNextRank", { &Interpreter::Context::getPCNextRank, nullptr } }, + { "Faction", { &Interpreter::Context::getNPCFaction, nullptr } }, + { "PCClass", { &Interpreter::Context::getPCClass, &Interpreter::Context::getPCClass } }, + { "PCName", { &Interpreter::Context::getPCName, &Interpreter::Context::getPCName } }, + { "PCRace", { &Interpreter::Context::getPCRace, &Interpreter::Context::getPCRace } }, + { "PCRank", { &Interpreter::Context::getPCRank, nullptr } }, + { "Class", { &Interpreter::Context::getNPCClass, &Interpreter::Context::getPCClass } }, + { "Cell", { &Interpreter::Context::getCurrentCellName, &Interpreter::Context::getCurrentCellName } }, + { "Race", { &Interpreter::Context::getNPCRace, &Interpreter::Context::getPCRace } }, + { "Rank", { &Interpreter::Context::getNPCRank, nullptr } }, + { "Name", { &Interpreter::Context::getActorName, &Interpreter::Context::getPCName } }, }; bool longerStr(std::string_view a, std::string_view b) @@ -78,7 +78,7 @@ namespace return true; } } - if (check(temp, "pccrimelevel", i, start)) + if (check(temp, "PCCrimeLevel", i, start)) { retval << context.getPCBounty(); return true; @@ -89,7 +89,13 @@ namespace if (check(temp, name, i, start)) { if (method) // Not all variables are available outside of dialogue + { retval << (context.*method)(); + + // Re-add the token if replacement failed without an error + if ((context.*method)() == "%") + retval << name; + } return true; } } From 555721141d8d1a6b1587b38400addbb2fc7e6d43 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Thu, 3 Jul 2025 15:22:52 -0600 Subject: [PATCH 11/18] Skip quest names (vanilla improvement) --- apps/openmw/mwscript/dialogueextensions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 23d8049a5d..6c219a52a3 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -99,7 +99,8 @@ namespace MWScript { for (const auto& journalInfo : dialogue.mInfoOrder.getOrderedInfo()) { - journal->addEntry(dialogue.mId, journalInfo.mData.mJournalIndex, playerPtr); + if (journalInfo.mQuestStatus != ESM::DialInfo::QS_Name) + journal->addEntry(dialogue.mId, journalInfo.mData.mJournalIndex, playerPtr); } } else if (dialogue.mType == ESM::Dialogue::Type::Topic) From 67795543a296a415e47a516c883a8f5e3a410f21 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Sun, 6 Jul 2025 20:51:53 -0600 Subject: [PATCH 12/18] Revert "Fix unneeded runtime errors" This reverts commit d207c2251ffe4693f73e275c8df95bc7127c0010. --- apps/openmw/mwscript/interpretercontext.cpp | 26 ++------ components/interpreter/defines.cpp | 70 ++++++++++----------- 2 files changed, 36 insertions(+), 60 deletions(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 9aeccfc886..15c9100b98 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include "../mwworld/esmstore.hpp" @@ -301,15 +300,7 @@ namespace MWScript std::string_view InterpreterContext::getNPCFaction() const { - const MWWorld::Ptr& ptr = getReferenceImp(); - const ESM::RefId& factionId = ptr.getClass().getPrimaryFaction(ptr); - if (factionId.empty()) - { - Log(Debug::Warning) << "getNPCFaction(): NPC is not in a faction"; - return "%"; - } - - const ESM::NPC* npc = ptr.get()->mBase; + const ESM::NPC* npc = getReferenceImp().get()->mBase; const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get().find(npc->mFaction); return faction->mName; } @@ -319,10 +310,7 @@ namespace MWScript const MWWorld::Ptr& ptr = getReferenceImp(); const ESM::RefId& faction = ptr.getClass().getPrimaryFaction(ptr); if (faction.empty()) - { - Log(Debug::Warning) << "getNPCRank(): NPC is not in a faction"; - return "%"; - } + throw std::runtime_error("getNPCRank(): NPC is not in a faction"); int rank = ptr.getClass().getPrimaryFactionRank(ptr); if (rank < 0 || rank > 9) @@ -361,10 +349,7 @@ namespace MWScript const ESM::RefId& factionId = getReferenceImp().getClass().getPrimaryFaction(getReferenceImp()); if (factionId.empty()) - { - Log(Debug::Warning) << "getPCRank(): NPC is not in a faction"; - return "%"; - } + throw std::runtime_error("getPCRank(): NPC is not in a faction"); const auto& ranks = player.getClass().getNpcStats(player).getFactionRanks(); auto it = ranks.find(factionId); @@ -393,10 +378,7 @@ namespace MWScript const ESM::RefId& factionId = getReferenceImp().getClass().getPrimaryFaction(getReferenceImp()); if (factionId.empty()) - { - Log(Debug::Warning) << "getPCNextRank(): NPC is not in a faction"; - return "%"; - } + throw std::runtime_error("getPCNextRank(): NPC is not in a faction"); const auto& ranks = player.getClass().getNpcStats(player).getFactionRanks(); auto it = ranks.find(factionId); diff --git a/components/interpreter/defines.cpp b/components/interpreter/defines.cpp index 6d51a72cca..e7a8e35328 100644 --- a/components/interpreter/defines.cpp +++ b/components/interpreter/defines.cpp @@ -26,40 +26,40 @@ namespace std::vector globals; const std::initializer_list> sActionBindings{ - { "ActionSlideRight", "#{sRight}" }, - { "ActionReadyMagic", "#{sReady_Magic}" }, - { "ActionPrevWeapon", "#{sPrevWeapon}" }, - { "ActionNextWeapon", "#{sNextWeapon}" }, - { "ActionToggleRun", "#{sAuto_Run}" }, - { "ActionSlideLeft", "#{sLeft}" }, - { "ActionReadyItem", "#{sReady_Weapon}" }, - { "ActionPrevSpell", "#{sPrevSpell}" }, - { "ActionNextSpell", "#{sNextSpell}" }, - { "ActionRestMenu", "#{sRestKey}" }, - { "ActionMenuMode", "#{sInventory}" }, - { "ActionActivate", "#{sActivate}" }, - { "ActionJournal", "#{sJournal}" }, - { "ActionForward", "#{sForward}" }, - { "ActionCrouch", "#{sCrouch_Sneak}" }, - { "ActionJump", "#{sJump}" }, - { "ActionBack", "#{sBack}" }, - { "ActionUse", "#{sUse}" }, - { "ActionRun", "#{sRun}" }, + { "actionslideright", "#{sRight}" }, + { "actionreadymagic", "#{sReady_Magic}" }, + { "actionprevweapon", "#{sPrevWeapon}" }, + { "actionnextweapon", "#{sNextWeapon}" }, + { "actiontogglerun", "#{sAuto_Run}" }, + { "actionslideleft", "#{sLeft}" }, + { "actionreadyitem", "#{sReady_Weapon}" }, + { "actionprevspell", "#{sPrevSpell}" }, + { "actionnextspell", "#{sNextSpell}" }, + { "actionrestmenu", "#{sRestKey}" }, + { "actionmenumode", "#{sInventory}" }, + { "actionactivate", "#{sActivate}" }, + { "actionjournal", "#{sJournal}" }, + { "actionforward", "#{sForward}" }, + { "actioncrouch", "#{sCrouch_Sneak}" }, + { "actionjump", "#{sJump}" }, + { "actionback", "#{sBack}" }, + { "actionuse", "#{sUse}" }, + { "actionrun", "#{sRun}" }, }; using ContextMethod = std::string_view (Interpreter::Context::*)() const; const std::initializer_list>> sContextMethods{ - { "NextPCRank", { &Interpreter::Context::getPCNextRank, nullptr } }, - { "PCNextRank", { &Interpreter::Context::getPCNextRank, nullptr } }, - { "Faction", { &Interpreter::Context::getNPCFaction, nullptr } }, - { "PCClass", { &Interpreter::Context::getPCClass, &Interpreter::Context::getPCClass } }, - { "PCName", { &Interpreter::Context::getPCName, &Interpreter::Context::getPCName } }, - { "PCRace", { &Interpreter::Context::getPCRace, &Interpreter::Context::getPCRace } }, - { "PCRank", { &Interpreter::Context::getPCRank, nullptr } }, - { "Class", { &Interpreter::Context::getNPCClass, &Interpreter::Context::getPCClass } }, - { "Cell", { &Interpreter::Context::getCurrentCellName, &Interpreter::Context::getCurrentCellName } }, - { "Race", { &Interpreter::Context::getNPCRace, &Interpreter::Context::getPCRace } }, - { "Rank", { &Interpreter::Context::getNPCRank, nullptr } }, - { "Name", { &Interpreter::Context::getActorName, &Interpreter::Context::getPCName } }, + { "nextpcrank", { &Interpreter::Context::getPCNextRank, nullptr } }, + { "pcnextrank", { &Interpreter::Context::getPCNextRank, nullptr } }, + { "faction", { &Interpreter::Context::getNPCFaction, nullptr } }, + { "pcclass", { &Interpreter::Context::getPCClass, &Interpreter::Context::getPCClass } }, + { "pcname", { &Interpreter::Context::getPCName, &Interpreter::Context::getPCName } }, + { "pcrace", { &Interpreter::Context::getPCRace, &Interpreter::Context::getPCRace } }, + { "pcrank", { &Interpreter::Context::getPCRank, nullptr } }, + { "class", { &Interpreter::Context::getNPCClass, &Interpreter::Context::getPCClass } }, + { "cell", { &Interpreter::Context::getCurrentCellName, &Interpreter::Context::getCurrentCellName } }, + { "race", { &Interpreter::Context::getNPCRace, &Interpreter::Context::getPCRace } }, + { "rank", { &Interpreter::Context::getNPCRank, nullptr } }, + { "name", { &Interpreter::Context::getActorName, &Interpreter::Context::getPCName } }, }; bool longerStr(std::string_view a, std::string_view b) @@ -78,7 +78,7 @@ namespace return true; } } - if (check(temp, "PCCrimeLevel", i, start)) + if (check(temp, "pccrimelevel", i, start)) { retval << context.getPCBounty(); return true; @@ -89,13 +89,7 @@ namespace if (check(temp, name, i, start)) { if (method) // Not all variables are available outside of dialogue - { retval << (context.*method)(); - - // Re-add the token if replacement failed without an error - if ((context.*method)() == "%") - retval << name; - } return true; } } From 61ebb4b259652f4267af0f47e12b3936ed318813 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Sun, 13 Jul 2025 02:07:49 -0600 Subject: [PATCH 13/18] Redo debug warnings in interpreter --- apps/openmw/mwscript/interpretercontext.cpp | 66 ++++++++++++++------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 15c9100b98..3063e8b6bb 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "../mwworld/esmstore.hpp" @@ -300,7 +301,16 @@ namespace MWScript std::string_view InterpreterContext::getNPCFaction() const { - const ESM::NPC* npc = getReferenceImp().get()->mBase; + const MWWorld::Ptr& ptr = getReferenceImp(); + const MWWorld::Class& ptrClass = ptr.getClass(); + const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); + if (factionId.empty()) + { + Log(Debug::Warning) << "getNPCFaction(): NPC " << ptrClass.getName(ptr) << " has no primary faction"; + return "%"; + } + + const ESM::NPC* npc = ptr.get()->mBase; const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get().find(npc->mFaction); return faction->mName; } @@ -308,18 +318,26 @@ namespace MWScript std::string_view InterpreterContext::getNPCRank() const { const MWWorld::Ptr& ptr = getReferenceImp(); - const ESM::RefId& faction = ptr.getClass().getPrimaryFaction(ptr); - if (faction.empty()) - throw std::runtime_error("getNPCRank(): NPC is not in a faction"); - - int rank = ptr.getClass().getPrimaryFactionRank(ptr); - if (rank < 0 || rank > 9) - throw std::runtime_error("getNPCRank(): invalid rank"); + const MWWorld::Class& ptrClass = ptr.getClass(); + const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); + if (factionId.empty()) + { + Log(Debug::Warning) << "getNPCRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction"; + return "%"; + } MWBase::World* world = MWBase::Environment::get().getWorld(); const MWWorld::ESMStore& store = world->getStore(); - const ESM::Faction* fact = store.get().find(faction); - return fact->mRanks[rank]; + const ESM::Faction* faction = store.get().find(factionId); + + int rank = ptrClass.getPrimaryFactionRank(ptr); + if (rank < 0 || rank > 9) + { + Log(Debug::Warning) << "getNPCRank(): NPC " << ptrClass.getName(ptr) << " has invalid rank " << rank + << " in faction " << faction->mName; + return "%"; + } + return faction->mRanks[rank]; } std::string_view InterpreterContext::getPCName() const @@ -344,13 +362,17 @@ namespace MWScript std::string_view InterpreterContext::getPCRank() const { + const MWWorld::Ptr& ptr = getReferenceImp(); + const MWWorld::Class& ptrClass = ptr.getClass(); + const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); + if (factionId.empty()) + { + Log(Debug::Warning) << "getPCRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction"; + return "%"; + } + MWBase::World* world = MWBase::Environment::get().getWorld(); MWWorld::Ptr player = world->getPlayerPtr(); - - const ESM::RefId& factionId = getReferenceImp().getClass().getPrimaryFaction(getReferenceImp()); - if (factionId.empty()) - throw std::runtime_error("getPCRank(): NPC is not in a faction"); - const auto& ranks = player.getClass().getNpcStats(player).getFactionRanks(); auto it = ranks.find(factionId); int rank = -1; @@ -373,13 +395,17 @@ namespace MWScript std::string_view InterpreterContext::getPCNextRank() const { + const MWWorld::Ptr& ptr = getReferenceImp(); + const MWWorld::Class& ptrClass = ptr.getClass(); + const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); + if (factionId.empty()) + { + Log(Debug::Warning) << "getPCNextRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction"; + return "%"; + } + MWBase::World* world = MWBase::Environment::get().getWorld(); MWWorld::Ptr player = world->getPlayerPtr(); - - const ESM::RefId& factionId = getReferenceImp().getClass().getPrimaryFaction(getReferenceImp()); - if (factionId.empty()) - throw std::runtime_error("getPCNextRank(): NPC is not in a faction"); - const auto& ranks = player.getClass().getNpcStats(player).getFactionRanks(); auto it = ranks.find(factionId); int rank = -1; From cef180753667b0e0eab744cf099c02ea6218caa2 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Sun, 13 Jul 2025 02:30:55 -0600 Subject: [PATCH 14/18] Use RefId instead of name --- apps/openmw/mwscript/interpretercontext.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 3063e8b6bb..dbd139d180 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -306,7 +306,7 @@ namespace MWScript const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); if (factionId.empty()) { - Log(Debug::Warning) << "getNPCFaction(): NPC " << ptrClass.getName(ptr) << " has no primary faction"; + Log(Debug::Warning) << "getNPCFaction(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; return "%"; } @@ -322,7 +322,7 @@ namespace MWScript const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); if (factionId.empty()) { - Log(Debug::Warning) << "getNPCRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction"; + Log(Debug::Warning) << "getNPCRank(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; return "%"; } @@ -333,7 +333,7 @@ namespace MWScript int rank = ptrClass.getPrimaryFactionRank(ptr); if (rank < 0 || rank > 9) { - Log(Debug::Warning) << "getNPCRank(): NPC " << ptrClass.getName(ptr) << " has invalid rank " << rank + Log(Debug::Warning) << "getNPCRank(): NPC " << ptr.mRef->mRef.getRefId() << " has invalid rank " << rank << " in faction " << faction->mName; return "%"; } @@ -367,7 +367,7 @@ namespace MWScript const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); if (factionId.empty()) { - Log(Debug::Warning) << "getPCRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction"; + Log(Debug::Warning) << "getPCRank(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; return "%"; } @@ -400,7 +400,7 @@ namespace MWScript const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); if (factionId.empty()) { - Log(Debug::Warning) << "getPCNextRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction"; + Log(Debug::Warning) << "getPCNextRank(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; return "%"; } From 87e41425bb1bb7e6cb9e4fedf801eb4b20cdc4df Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Sun, 13 Jul 2025 02:36:16 -0600 Subject: [PATCH 15/18] Unnecessary ptrClass --- apps/openmw/mwscript/interpretercontext.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index dbd139d180..d24420ec91 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -302,8 +302,7 @@ namespace MWScript std::string_view InterpreterContext::getNPCFaction() const { const MWWorld::Ptr& ptr = getReferenceImp(); - const MWWorld::Class& ptrClass = ptr.getClass(); - const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); + const ESM::RefId& factionId = ptr.getClass().getPrimaryFaction(ptr); if (factionId.empty()) { Log(Debug::Warning) << "getNPCFaction(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; @@ -363,8 +362,7 @@ namespace MWScript std::string_view InterpreterContext::getPCRank() const { const MWWorld::Ptr& ptr = getReferenceImp(); - const MWWorld::Class& ptrClass = ptr.getClass(); - const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); + const ESM::RefId& factionId = ptr.getClass().getPrimaryFaction(ptr); if (factionId.empty()) { Log(Debug::Warning) << "getPCRank(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; @@ -396,8 +394,7 @@ namespace MWScript std::string_view InterpreterContext::getPCNextRank() const { const MWWorld::Ptr& ptr = getReferenceImp(); - const MWWorld::Class& ptrClass = ptr.getClass(); - const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); + const ESM::RefId& factionId = ptr.getClass().getPrimaryFaction(ptr); if (factionId.empty()) { Log(Debug::Warning) << "getPCNextRank(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; From 11947286d937e41c572e420a0eca709305e2d82e Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Sun, 13 Jul 2025 02:36:59 -0600 Subject: [PATCH 16/18] Reuse factionId --- apps/openmw/mwscript/interpretercontext.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index d24420ec91..7d71f3607c 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -309,8 +309,9 @@ namespace MWScript return "%"; } - const ESM::NPC* npc = ptr.get()->mBase; - const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get().find(npc->mFaction); + MWBase::World* world = MWBase::Environment::get().getWorld(); + const MWWorld::ESMStore& store = world->getStore(); + const ESM::Faction* faction = store.get().find(factionId); return faction->mName; } From bb1214ed69f855874f9fc13296cb65025e26b3c7 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Sun, 13 Jul 2025 02:48:37 -0600 Subject: [PATCH 17/18] factionId instead of faction->mName --- apps/openmw/mwscript/interpretercontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 7d71f3607c..546968ebf7 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -334,7 +334,7 @@ namespace MWScript if (rank < 0 || rank > 9) { Log(Debug::Warning) << "getNPCRank(): NPC " << ptr.mRef->mRef.getRefId() << " has invalid rank " << rank - << " in faction " << faction->mName; + << " in faction " << factionId; return "%"; } return faction->mRanks[rank]; From 445cf1742de45836350bcff0ce560c6df6f15af0 Mon Sep 17 00:00:00 2001 From: Aussiemon Date: Sun, 13 Jul 2025 10:20:58 -0600 Subject: [PATCH 18/18] ptr.getCellRef().getRefId() --- apps/openmw/mwscript/interpretercontext.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 546968ebf7..f6c20c9c10 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -305,7 +305,7 @@ namespace MWScript const ESM::RefId& factionId = ptr.getClass().getPrimaryFaction(ptr); if (factionId.empty()) { - Log(Debug::Warning) << "getNPCFaction(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; + Log(Debug::Warning) << "getNPCFaction(): NPC " << ptr.getCellRef().getRefId() << " has no primary faction"; return "%"; } @@ -322,7 +322,7 @@ namespace MWScript const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr); if (factionId.empty()) { - Log(Debug::Warning) << "getNPCRank(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; + Log(Debug::Warning) << "getNPCRank(): NPC " << ptr.getCellRef().getRefId() << " has no primary faction"; return "%"; } @@ -333,7 +333,7 @@ namespace MWScript int rank = ptrClass.getPrimaryFactionRank(ptr); if (rank < 0 || rank > 9) { - Log(Debug::Warning) << "getNPCRank(): NPC " << ptr.mRef->mRef.getRefId() << " has invalid rank " << rank + Log(Debug::Warning) << "getNPCRank(): NPC " << ptr.getCellRef().getRefId() << " has invalid rank " << rank << " in faction " << factionId; return "%"; } @@ -366,7 +366,7 @@ namespace MWScript const ESM::RefId& factionId = ptr.getClass().getPrimaryFaction(ptr); if (factionId.empty()) { - Log(Debug::Warning) << "getPCRank(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; + Log(Debug::Warning) << "getPCRank(): NPC " << ptr.getCellRef().getRefId() << " has no primary faction"; return "%"; } @@ -398,7 +398,7 @@ namespace MWScript const ESM::RefId& factionId = ptr.getClass().getPrimaryFaction(ptr); if (factionId.empty()) { - Log(Debug::Warning) << "getPCNextRank(): NPC " << ptr.mRef->mRef.getRefId() << " has no primary faction"; + Log(Debug::Warning) << "getPCNextRank(): NPC " << ptr.getCellRef().getRefId() << " has no primary faction"; return "%"; }