mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-08 03:41:11 -04:00
Implement FillJournal console command
This commit is contained in:
parent
c232ad55b4
commit
6c70c403be
@ -22,6 +22,20 @@
|
|||||||
|
|
||||||
namespace MWScript
|
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
|
namespace Dialogue
|
||||||
{
|
{
|
||||||
template <class R>
|
template <class R>
|
||||||
@ -40,16 +54,7 @@ namespace MWScript
|
|||||||
Interpreter::Type_Integer index = runtime[0].mInteger;
|
Interpreter::Type_Integer index = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
// Invoking Journal with a non-existing index is allowed, and triggers no errors. Seriously? :(
|
addJournalEntry(quest, index, ptr);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,6 +87,39 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OpFillJournal : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void execute(Interpreter::Runtime& runtime) override
|
||||||
|
{
|
||||||
|
const MWWorld::Store<ESM::Dialogue>& dialogues = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>();
|
||||||
|
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<ESM::DialInfo> 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<ESM::DialInfo> 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
|
class OpAddTopic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -288,6 +326,7 @@ namespace MWScript
|
|||||||
interpreter.installSegment5<OpJournal<ExplicitRef>>(Compiler::Dialogue::opcodeJournalExplicit);
|
interpreter.installSegment5<OpJournal<ExplicitRef>>(Compiler::Dialogue::opcodeJournalExplicit);
|
||||||
interpreter.installSegment5<OpSetJournalIndex>(Compiler::Dialogue::opcodeSetJournalIndex);
|
interpreter.installSegment5<OpSetJournalIndex>(Compiler::Dialogue::opcodeSetJournalIndex);
|
||||||
interpreter.installSegment5<OpGetJournalIndex>(Compiler::Dialogue::opcodeGetJournalIndex);
|
interpreter.installSegment5<OpGetJournalIndex>(Compiler::Dialogue::opcodeGetJournalIndex);
|
||||||
|
interpreter.installSegment5<OpFillJournal>(Compiler::Dialogue::opcodeFillJournal);
|
||||||
interpreter.installSegment5<OpAddTopic>(Compiler::Dialogue::opcodeAddTopic);
|
interpreter.installSegment5<OpAddTopic>(Compiler::Dialogue::opcodeAddTopic);
|
||||||
interpreter.installSegment3<OpChoice>(Compiler::Dialogue::opcodeChoice);
|
interpreter.installSegment3<OpChoice>(Compiler::Dialogue::opcodeChoice);
|
||||||
interpreter.installSegment5<OpForceGreeting<ImplicitRef>>(Compiler::Dialogue::opcodeForceGreeting);
|
interpreter.installSegment5<OpForceGreeting<ImplicitRef>>(Compiler::Dialogue::opcodeForceGreeting);
|
||||||
|
@ -485,5 +485,6 @@ op 0x2000322: GetPCVisionBonus
|
|||||||
op 0x2000323: SetPCVisionBonus
|
op 0x2000323: SetPCVisionBonus
|
||||||
op 0x2000324: ModPCVisionBonus
|
op 0x2000324: ModPCVisionBonus
|
||||||
op 0x2000325: TestModels, T3D
|
op 0x2000325: TestModels, T3D
|
||||||
|
op 0x2000326: FillJournal
|
||||||
|
|
||||||
opcodes 0x2000326-0x3ffffff unused
|
opcodes 0x2000327-0x3ffffff unused
|
||||||
|
@ -163,6 +163,7 @@ namespace Compiler
|
|||||||
extensions.registerInstruction("journal", "cl", opcodeJournal, opcodeJournalExplicit);
|
extensions.registerInstruction("journal", "cl", opcodeJournal, opcodeJournalExplicit);
|
||||||
extensions.registerInstruction("setjournalindex", "cl", opcodeSetJournalIndex);
|
extensions.registerInstruction("setjournalindex", "cl", opcodeSetJournalIndex);
|
||||||
extensions.registerFunction("getjournalindex", 'l', "c", opcodeGetJournalIndex);
|
extensions.registerFunction("getjournalindex", 'l', "c", opcodeGetJournalIndex);
|
||||||
|
extensions.registerInstruction("filljournal", "", opcodeFillJournal);
|
||||||
extensions.registerInstruction("addtopic", "S", opcodeAddTopic);
|
extensions.registerInstruction("addtopic", "S", opcodeAddTopic);
|
||||||
extensions.registerInstruction(
|
extensions.registerInstruction(
|
||||||
"choice", "j/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice);
|
"choice", "j/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice);
|
||||||
|
@ -155,6 +155,7 @@ namespace Compiler
|
|||||||
const int opcodeJournalExplicit = 0x200030b;
|
const int opcodeJournalExplicit = 0x200030b;
|
||||||
const int opcodeSetJournalIndex = 0x2000134;
|
const int opcodeSetJournalIndex = 0x2000134;
|
||||||
const int opcodeGetJournalIndex = 0x2000135;
|
const int opcodeGetJournalIndex = 0x2000135;
|
||||||
|
const int opcodeFillJournal = 0x2000326;
|
||||||
const int opcodeAddTopic = 0x200013a;
|
const int opcodeAddTopic = 0x200013a;
|
||||||
const int opcodeChoice = 0x2000a;
|
const int opcodeChoice = 0x2000a;
|
||||||
const int opcodeForceGreeting = 0x200014f;
|
const int opcodeForceGreeting = 0x200014f;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user