From beb1422c774e433ed3a65b9172d9c58cb8e8a45c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 29 Mar 2011 13:57:56 +0200 Subject: [PATCH 01/29] allow multiple --master and --plugin command line arguments --- apps/openmw/main.cpp | 49 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 4d7e6595cc..697b06e93c 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -47,8 +47,14 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) "set resources directory") ("start", bpo::value()->default_value ("Beshara"), "set initial cell") - ("master", bpo::value()->default_value ("Morrowind"), - "master file") + ("master", bpo::value >() + ->default_value (std::vector(), "") + ->multitoken(), + "master file(s)") + ("plugin", bpo::value >() + ->default_value (std::vector(), "") + ->multitoken(), + "plugin file(s)") ( "showfps", "show fps counter") ( "debug", "debug mode" ) ( "nosound", "disable all sound" ) @@ -83,26 +89,51 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) return false; } + // directory settings engine.setDataDir (variables["data"].as()); engine.setResourceDir (variables["resources"].as()); - engine.setCell (variables["start"].as()); - engine.addMaster (variables["master"].as()); - if (variables.count ("showfps")) + // master and plugin + std::vector master = variables["master"].as >(); + if (master.empty()) + { + std::cout << "No master file given. Assuming Morrowind.esm" << std::endl; + master.push_back ("Morrowind"); + } + + if (master.size()>1) + { + std::cout + << "Ignoring all but the first master file (multiple master files not yet supported)." + << std::endl; + } + + engine.addMaster (master[0]); + + std::vector plugin = variables["plugin"].as >(); + + if (!plugin.empty()) + std::cout << "Ignoring plugin files (plugins not yet supported)." << std::endl; + + // startup-settings + engine.setCell (variables["start"].as()); + + if (variables.count ("new-game")) + engine.setNewGame(); + + // other settings + if (variables.count ("fps")) engine.showFPS(); if (variables.count ("debug")) engine.enableDebugMode(); - if (variables.count ("nosound")) + if (variables.count ("no-sound")) engine.disableSound(); if (variables.count ("script-verbose")) engine.enableVerboseScripts(); - if (variables.count ("new-game")) - engine.setNewGame(); - if (variables.count ("script-all")) engine.setCompileAll (true); From 190f77f6c9711582afa282a37983777b9dbd18da Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 4 Apr 2011 11:16:56 +0200 Subject: [PATCH 02/29] added journal class --- apps/openmw/CMakeLists.txt | 2 ++ apps/openmw/engine.cpp | 3 +++ apps/openmw/mwdialogue/journal.cpp | 10 ++++++++++ apps/openmw/mwdialogue/journal.hpp | 21 +++++++++++++++++++++ apps/openmw/mwworld/environment.hpp | 4 +++- 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwdialogue/journal.cpp create mode 100644 apps/openmw/mwdialogue/journal.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 0fa027f0c6..bdc018c108 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -70,9 +70,11 @@ source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) set(GAMEDIALOGUE_HEADER mwdialogue/dialoguemanager.hpp + mwdialogue/journal.hpp ) set(GAMEDIALOGUE mwdialogue/dialoguemanager.cpp + mwdialogue/journal.cpp ) source_group(apps\\openmw\\mwdialogue FILES ${GAMEDIALOGUE_HEADER} ${GAMEDIALOGUE}) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 78ddffbe8c..dd556ba495 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -36,6 +36,7 @@ #include "mwclass/classes.hpp" #include "mwdialogue/dialoguemanager.hpp" +#include "mwdialogue/journal.hpp" #include "mwmechanics/mechanicsmanager.hpp" @@ -228,6 +229,7 @@ OMW::Engine::~Engine() delete mEnvironment.mGlobalScripts; delete mEnvironment.mMechanicsManager; delete mEnvironment.mDialogueManager; + delete mEnvironment.mJournal; delete mScriptManager; delete mScriptContext; delete mPhysicEngine; @@ -396,6 +398,7 @@ void OMW::Engine::go() mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment); // Create dialog system + mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment); mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment); // load cell diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp new file mode 100644 index 0000000000..3b674a53e2 --- /dev/null +++ b/apps/openmw/mwdialogue/journal.cpp @@ -0,0 +1,10 @@ + +#include "journal.hpp" + +namespace MWDialogue +{ + MWDialogue::Journal::Journal (MWWorld::Environment& environment) + : mEnvironment (environment) + {} + +} diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp new file mode 100644 index 0000000000..1988e230d7 --- /dev/null +++ b/apps/openmw/mwdialogue/journal.hpp @@ -0,0 +1,21 @@ +#ifndef GAME_MMDIALOG_JOURNAL_H +#define GAME_MWDIALOG_JOURNAL_H + +namespace MWWorld +{ + struct Environment; +} + +namespace MWDialogue +{ + class Journal + { + MWWorld::Environment& mEnvironment; + + public: + + Journal (MWWorld::Environment& environment); + }; +} + +#endif diff --git a/apps/openmw/mwworld/environment.hpp b/apps/openmw/mwworld/environment.hpp index c04dfcbf10..a403ee1657 100644 --- a/apps/openmw/mwworld/environment.hpp +++ b/apps/openmw/mwworld/environment.hpp @@ -24,6 +24,7 @@ namespace MWMechanics namespace MWDialogue { class DialogueManager; + class Journal; } namespace MWInput @@ -41,7 +42,7 @@ namespace MWWorld public: Environment() : mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0), - mMechanicsManager (0), mDialogueManager (0), mFrameDuration (0), + mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0), mInputManager (0) {} @@ -51,6 +52,7 @@ namespace MWWorld MWGui::WindowManager *mWindowManager; MWMechanics::MechanicsManager *mMechanicsManager; MWDialogue::DialogueManager *mDialogueManager; + MWDialogue::Journal *mJournal; float mFrameDuration; // For setting GUI mode From b40117449a2bd282fe5210f0d1fd775021a989ca Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 4 Apr 2011 11:23:15 +0200 Subject: [PATCH 03/29] added journal script interface --- apps/openmw/mwdialogue/journal.cpp | 18 +++++++++++++++++- apps/openmw/mwdialogue/journal.hpp | 11 +++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 3b674a53e2..031917c1ca 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -1,10 +1,26 @@ #include "journal.hpp" + +#include namespace MWDialogue { - MWDialogue::Journal::Journal (MWWorld::Environment& environment) + Journal::Journal (MWWorld::Environment& environment) : mEnvironment (environment) {} + void Journal::addEntry (const std::string& id, int index) + { + std::cout << "journal: " << id << " at " << index << std::endl; + } + + void Journal::setJournalIndex (const std::string& id, int index) + { + std::cout << "journal (no entry): " << id << " at " << index << std::endl; + } + + int Journal::getJournalIndex (const std::string& id) const + { + return 0; + } } diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp index 1988e230d7..cd48142556 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journal.hpp @@ -1,6 +1,8 @@ #ifndef GAME_MMDIALOG_JOURNAL_H #define GAME_MWDIALOG_JOURNAL_H +#include + namespace MWWorld { struct Environment; @@ -15,6 +17,15 @@ namespace MWDialogue public: Journal (MWWorld::Environment& environment); + + void addEntry (const std::string& id, int index); + ///< Add a journal entry. + + void setJournalIndex (const std::string& id, int index); + ///< Set the journal index without adding an entry. + + int getJournalIndex (const std::string& id) const; + ///< Get the journal index. }; } From e4a0702bb49566225225bf25dbfbec1afe7111a5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 4 Apr 2011 14:49:26 +0200 Subject: [PATCH 04/29] added journal-related script instructions --- apps/openmw/CMakeLists.txt | 2 + apps/openmw/mwscript/dialogueextensions.cpp | 94 +++++++++++++++++++++ apps/openmw/mwscript/dialogueextensions.hpp | 25 ++++++ apps/openmw/mwscript/docs/vmformat.txt | 5 +- apps/openmw/mwscript/extensions.cpp | 3 + apps/openmw/mwscript/interpretercontext.cpp | 5 ++ apps/openmw/mwscript/interpretercontext.hpp | 4 + 7 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwscript/dialogueextensions.cpp create mode 100644 apps/openmw/mwscript/dialogueextensions.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index bdc018c108..3cb08b5f74 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -93,6 +93,7 @@ set(GAMESCRIPT mwscript/controlextensions.cpp mwscript/extensions.cpp mwscript/globalscripts.cpp + mwscript/dialogueextensions.cpp ) set(GAMESCRIPT_HEADER mwscript/locals.hpp @@ -111,6 +112,7 @@ set(GAMESCRIPT_HEADER mwscript/extensions.hpp mwscript/globalscripts.hpp mwscript/ref.hpp + mwscript/dialogueextensions.hpp ) source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER}) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp new file mode 100644 index 0000000000..c2ff9ed8bd --- /dev/null +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -0,0 +1,94 @@ + +#include "dialogueextensions.hpp" + +#include + +#include +#include +#include + +#include "../mwdialogue/journal.hpp" + +#include "interpretercontext.hpp" + +namespace MWScript +{ + namespace Dialogue + { + class OpJournal : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWScript::InterpreterContext& context + = static_cast (runtime.getContext()); + + std::string quest = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + Interpreter::Type_Integer index = runtime[0].mInteger; + runtime.pop(); + + context.getEnvironment().mJournal->addEntry (quest, index); + } + }; + + class OpSetJournalIndex : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWScript::InterpreterContext& context + = static_cast (runtime.getContext()); + + std::string quest = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + Interpreter::Type_Integer index = runtime[0].mInteger; + runtime.pop(); + + context.getEnvironment().mJournal->setJournalIndex (quest, index); + } + }; + + class OpGetJournalIndex : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWScript::InterpreterContext& context + = static_cast (runtime.getContext()); + + std::string quest = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + int index = context.getEnvironment().mJournal->getJournalIndex (quest); + + runtime.push (index); + + } + }; + + const int opcodeJournal = 0x2000133; + const int opcodeSetJournalIndex = 0x2000134; + const int opcodeGetJournalIndex = 0x2000135; + + void registerExtensions (Compiler::Extensions& extensions) + { + extensions.registerInstruction ("journal", "cl", opcodeJournal); + extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex); + extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex); + } + + void installOpcodes (Interpreter::Interpreter& interpreter) + { + interpreter.installSegment5 (opcodeJournal, new OpJournal); + interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex); + interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex); + } + } + +} diff --git a/apps/openmw/mwscript/dialogueextensions.hpp b/apps/openmw/mwscript/dialogueextensions.hpp new file mode 100644 index 0000000000..ece7d62ce8 --- /dev/null +++ b/apps/openmw/mwscript/dialogueextensions.hpp @@ -0,0 +1,25 @@ +#ifndef GAME_SCRIPT_DIALOGUEEXTENSIONS_H +#define GAME_SCRIPT_DIALOGUEEXTENSIONS_H + +namespace Compiler +{ + class Extensions; +} + +namespace Interpreter +{ + class Interpreter; +} + +namespace MWScript +{ + /// \brief Dialogue/Journal-related script functionality + namespace Dialogue + { + void registerExtensions (Compiler::Extensions& extensions); + + void installOpcodes (Interpreter::Interpreter& interpreter); + } +} + +#endif diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index d803d0bac2..90962f56b3 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -104,4 +104,7 @@ op 0x2000115-0x200012f: ModSKill, explicit reference op 0x2000130: ToggleCollision op 0x2000131: GetInterior op 0x2000132: ToggleCollsionDebug -opcodes 0x2000133-0x3ffffff unused +op 0x2000133: Journal +op 0x2000134: SetJournalIndex +op 0x2000135: GetJournalIndex +opcodes 0x2000136-0x3ffffff unused diff --git a/apps/openmw/mwscript/extensions.cpp b/apps/openmw/mwscript/extensions.cpp index 15d482fc19..86161d2b18 100644 --- a/apps/openmw/mwscript/extensions.cpp +++ b/apps/openmw/mwscript/extensions.cpp @@ -13,6 +13,7 @@ #include "containerextensions.hpp" #include "aiextensions.hpp" #include "controlextensions.hpp" +#include "dialogueextensions.hpp" namespace MWScript { @@ -27,6 +28,7 @@ namespace MWScript Container::registerExtensions (extensions); Ai::registerExtensions (extensions); Control::registerExtensions (extensions); + Dialogue::registerExtensions (extensions); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -41,5 +43,6 @@ namespace MWScript Container::installOpcodes (interpreter); Ai::installOpcodes (interpreter); Control::installOpcodes (interpreter); + Dialogue::installOpcodes (interpreter); } } diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index f2f1e6e104..cb6ecb218f 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -260,6 +260,11 @@ namespace MWScript mEnvironment.mWorld->disable (ref); } + MWWorld::Environment& InterpreterContext::getEnvironment() + { + return mEnvironment; + } + MWGui::WindowManager& InterpreterContext::getWindowManager() { return *mEnvironment.mWindowManager; diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index 031820d5dd..aebfc620e5 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -106,6 +106,10 @@ namespace MWScript virtual void disable (const std::string& id = ""); + MWWorld::Environment& getEnvironment(); + + /// \todo remove the following functions (extentions should use getEnvironment instead) + MWWorld::World& getWorld(); MWSound::SoundManager& getSoundManager(); From f321e549a4bb4af4bae0bf6a37e4b5a558156681 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 4 Apr 2011 15:10:37 +0200 Subject: [PATCH 05/29] added instruction GetPCCell --- apps/openmw/mwscript/cellextensions.cpp | 34 +++++++++++++++++++++++++ apps/openmw/mwscript/docs/vmformat.txt | 3 ++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 9c756e11f0..bb52632032 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -102,10 +102,42 @@ namespace MWScript } }; + class OpGetPCCell : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context + = static_cast (runtime.getContext()); + + std::string name = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + const ESM::Cell *cell = context.getWorld().getPlayer().getPlayer().getCell()->cell; + + std::string current = cell->name; + + if (!(cell->data.flags & ESM::Cell::Interior) && current.empty()) + { + const ESM::Region *region = + context.getWorld().getStore().regions.find (cell->region); + + current = region->name; + } + + bool match = current.length()>=name.length() && + current.substr (0, name.length())==name; + + runtime.push (match ? 1 : 0); + } + }; + const int opcodeCellChanged = 0x2000000; const int opcodeCOC = 0x2000026; const int opcodeCOE = 0x200008e; const int opcodeGetInterior = 0x2000131; + const int opcodeGetPCCell = 0x2000136; void registerExtensions (Compiler::Extensions& extensions) { @@ -115,6 +147,7 @@ namespace MWScript extensions.registerInstruction ("coe", "ll", opcodeCOE); extensions.registerInstruction ("centeronexterior", "ll", opcodeCOE); extensions.registerFunction ("getinterior", 'l', "", opcodeGetInterior); + extensions.registerFunction ("getpccell", 'l', "c", opcodeGetPCCell); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -123,6 +156,7 @@ namespace MWScript interpreter.installSegment5 (opcodeCOC, new OpCOC); interpreter.installSegment5 (opcodeCOE, new OpCOE); interpreter.installSegment5 (opcodeGetInterior, new OpGetInterior); + interpreter.installSegment5 (opcodeGetPCCell, new OpGetPCCell); } } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 90962f56b3..fcebaae2be 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -107,4 +107,5 @@ op 0x2000132: ToggleCollsionDebug op 0x2000133: Journal op 0x2000134: SetJournalIndex op 0x2000135: GetJournalIndex -opcodes 0x2000136-0x3ffffff unused +op 0x2000136: GetPCCell +opcodes 0x2000137-0x3ffffff unused From 53e0e3886242511804dbf1454892b139342beee5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 6 Apr 2011 09:49:00 +0200 Subject: [PATCH 06/29] added missing TCL instruction --- apps/openmw/mwscript/controlextensions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index f5a5c08a43..e687b13521 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -74,6 +74,7 @@ namespace MWScript } extensions.registerInstruction ("togglecollision", "", opcodeToggleCollision); + extensions.registerInstruction ("tcl", "", opcodeToggleCollision); } void installOpcodes (Interpreter::Interpreter& interpreter) From 79911b16d0d71cd2cae36cb93e18755785215f8a Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Fri, 8 Apr 2011 22:26:27 +0400 Subject: [PATCH 07/29] Fixed enum formatting in components/esm headers --- components/esm/defs.hpp | 8 ++++++-- components/esm/loadappa.hpp | 5 ++++- components/esm/loadbody.hpp | 7 +++++-- components/esm/loadclas.hpp | 4 +++- components/esm/loadcrea.hpp | 5 ++++- components/esm/loadsndg.hpp | 29 +++++++++++++++-------------- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/components/esm/defs.hpp b/components/esm/defs.hpp index 0fdbe45aa9..917c1031fe 100644 --- a/components/esm/defs.hpp +++ b/components/esm/defs.hpp @@ -23,12 +23,16 @@ enum VarType enum Specialization { - SPC_Combat = 0, SPC_Magic = 1, SPC_Stealth = 2 + SPC_Combat = 0, + SPC_Magic = 1, + SPC_Stealth = 2 }; enum RangeType { - RT_Self = 0, RT_Touch = 1, RT_Target = 2 + RT_Self = 0, + RT_Touch = 1, + RT_Target = 2 }; /** A list of references to spells and spell effects. This is shared diff --git a/components/esm/loadappa.hpp b/components/esm/loadappa.hpp index bbb4aefdea..2caca32b3d 100644 --- a/components/esm/loadappa.hpp +++ b/components/esm/loadappa.hpp @@ -14,7 +14,10 @@ struct Apparatus { enum AppaType { - MortarPestle = 0, Albemic = 1, Calcinator = 2, Retort = 3 + MortarPestle = 0, + Albemic = 1, + Calcinator = 2, + Retort = 3 }; struct AADTstruct diff --git a/components/esm/loadbody.hpp b/components/esm/loadbody.hpp index 14e28f59c4..de3db40fcd 100644 --- a/components/esm/loadbody.hpp +++ b/components/esm/loadbody.hpp @@ -29,12 +29,15 @@ struct BodyPart enum Flags { - BPF_Female = 1, BPF_Playable = 2 + BPF_Female = 1, + BPF_Playable = 2 }; enum MeshType { - MT_Skin = 0, MT_Clothing = 1, MT_Armor = 2 + MT_Skin = 0, + MT_Clothing = 1, + MT_Armor = 2 }; struct BYDTstruct diff --git a/components/esm/loadclas.hpp b/components/esm/loadclas.hpp index 5fc44abe52..08412c8384 100644 --- a/components/esm/loadclas.hpp +++ b/components/esm/loadclas.hpp @@ -38,7 +38,9 @@ struct Class enum Specialization { - Combat = 0, Magic = 1, Stealth = 2 + Combat = 0, + Magic = 1, + Stealth = 2 }; static const Specialization specializationIds[3]; diff --git a/components/esm/loadcrea.hpp b/components/esm/loadcrea.hpp index 40c9292136..3c334ebbd4 100644 --- a/components/esm/loadcrea.hpp +++ b/components/esm/loadcrea.hpp @@ -30,7 +30,10 @@ struct Creature enum Type { - Creatures = 0, Deadra = 1, Undead = 2, Humanoid = 3 + Creatures = 0, + Deadra = 1, + Undead = 2, + Humanoid = 3 }; struct NPDTstruct diff --git a/components/esm/loadsndg.hpp b/components/esm/loadsndg.hpp index f8803f8c0f..2953369c4c 100644 --- a/components/esm/loadsndg.hpp +++ b/components/esm/loadsndg.hpp @@ -3,7 +3,8 @@ #include "esm_reader.hpp" -namespace ESM { +namespace ESM +{ /* * Sound generator. This describes the sounds a creature make. @@ -11,24 +12,24 @@ namespace ESM { struct SoundGenerator { - enum Type + enum Type { - LeftFoot = 0, - RightFoot = 1, - SwimLeft = 2, - SwimRight = 3, - Moan = 4, - Roar = 5, - Scream = 6, - Land = 7 + LeftFoot = 0, + RightFoot = 1, + SwimLeft = 2, + SwimRight = 3, + Moan = 4, + Roar = 5, + Scream = 6, + Land = 7 }; - // Type - int type; + // Type + int type; - std::string creature, sound; + std::string creature, sound; - void load(ESMReader &esm); + void load(ESMReader &esm); }; } #endif From f2faa34bd941ba5805ebd1b33df504b86bb368ed Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sun, 3 Apr 2011 19:37:53 +0200 Subject: [PATCH 08/29] If there is an openmw.cfg in the current path, use it as global config --- apps/openmw/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 4d7e6595cc..64450157d3 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -59,7 +59,13 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) bpo::variables_map variables; - std::string cfgFile = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", "openmw.cfg"); + //If there is an openmw.cfg in the current path use that as global config + //Otherwise try getPath + std::string cfgFile = "openmw.cfg"; + if(!isFile(cfgFile.c_str())) + { + cfgFile = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", "openmw.cfg"); + } std::cout << "Using global config file: " << cfgFile << std::endl; std::ifstream globalConfigFile(cfgFile.c_str()); From 5851e0a28c6d9c24530a24f3bbb6cc87f683ee45 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 19 Apr 2011 10:54:11 +0200 Subject: [PATCH 09/29] added journal entry struct --- apps/openmw/CMakeLists.txt | 2 ++ apps/openmw/mwdialogue/journalentry.cpp | 27 +++++++++++++++++++++++ apps/openmw/mwdialogue/journalentry.hpp | 29 +++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 apps/openmw/mwdialogue/journalentry.cpp create mode 100644 apps/openmw/mwdialogue/journalentry.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 3cb08b5f74..63add2fce4 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -71,10 +71,12 @@ source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) set(GAMEDIALOGUE_HEADER mwdialogue/dialoguemanager.hpp mwdialogue/journal.hpp + mwdialogue/journalentry.hpp ) set(GAMEDIALOGUE mwdialogue/dialoguemanager.cpp mwdialogue/journal.cpp + mwdialogue/journalentry.cpp ) source_group(apps\\openmw\\mwdialogue FILES ${GAMEDIALOGUE_HEADER} ${GAMEDIALOGUE}) diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp new file mode 100644 index 0000000000..8e3aeb93bb --- /dev/null +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -0,0 +1,27 @@ + +#include "journalentry.hpp" + +#include + +#include + +namespace MWDialogue +{ + JournalEntry::JournalEntry() {} + + JournalEntry::JournalEntry (int day, const std::string& topic, const std::string& infoId) + : mDay (day), mTopic (topic), mInfoId (infoId) + {} + + std::string JournalEntry::getText (const ESMS::ESMStore& store) const + { + const ESM::Dialogue *dialogue = store.dialogs.find (mTopic); + + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); + iter!=dialogue->mInfo.end(); ++iter) + if (iter->id==mInfoId) + return iter->response; + + throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic); + } +} diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp new file mode 100644 index 0000000000..8506b9dbcf --- /dev/null +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -0,0 +1,29 @@ +#ifndef GAME_MMDIALOGUE_JOURNALENTRY_H +#define GAME_MWDIALOGUE_JOURNALENTRY_H + +#include + +namespace ESMS +{ + struct ESMStore; +} + +namespace MWDialogue +{ + /// \brief a quest or dialogue entry with a timestamp + struct JournalEntry + { + int mDay; + std::string mTopic; + std::string mInfoId; + + JournalEntry(); + + JournalEntry (int day, const std::string& topic, const std::string& infoId); + + std::string getText (const ESMS::ESMStore& store) const; + }; + +} + +#endif From 23464e403581e48f6d2200b64a2532796de8ee0a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 19 Apr 2011 11:02:22 +0200 Subject: [PATCH 10/29] added interface and container for main journal --- apps/openmw/mwdialogue/journal.cpp | 10 ++++++++++ apps/openmw/mwdialogue/journal.hpp | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 031917c1ca..545e2f3ee4 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -23,4 +23,14 @@ namespace MWDialogue { return 0; } + + Journal::TEntryIter Journal::begin() const + { + return mJournal.begin(); + } + + Journal::TEntryIter Journal::end() const + { + return mJournal.end(); + } } diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp index cd48142556..07090ef4af 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journal.hpp @@ -2,6 +2,9 @@ #define GAME_MWDIALOG_JOURNAL_H #include +#include + +#include "journalentry.hpp" namespace MWWorld { @@ -12,7 +15,15 @@ namespace MWDialogue { class Journal { + public: + + typedef std::deque TEntryContainer; + typedef TEntryContainer::const_iterator TEntryIter; + + private: + MWWorld::Environment& mEnvironment; + std::deque mJournal; public: @@ -26,6 +37,14 @@ namespace MWDialogue int getJournalIndex (const std::string& id) const; ///< Get the journal index. + + TEntryIter begin() const; + ///< Iterator pointing to the begin of the main journal. + /// + /// \note Iterators to main journal entries will never become invalid. + + TEntryIter end() const; + ///< Iterator pointing past the end of the main journal. }; } From 717b5e1784106dc70f949d829ce65a40af8ba49c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 21 Apr 2011 10:49:45 +0200 Subject: [PATCH 11/29] fixed a constness problem --- apps/openmw/mwgui/birth.cpp | 6 +++--- apps/openmw/mwgui/class.cpp | 18 +++++++++--------- apps/openmw/mwgui/race.cpp | 8 ++++---- apps/openmw/mwgui/stats_window.cpp | 2 +- apps/openmw/mwgui/widgets.cpp | 6 +++--- apps/openmw/mwgui/window_manager.cpp | 2 +- apps/openmw/mwgui/window_manager.hpp | 2 +- apps/openmw/mwworld/world.cpp | 2 +- apps/openmw/mwworld/world.hpp | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 7db93a5087..93dde9f1bf 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -119,8 +119,8 @@ void BirthDialog::updateBirths() { birthList->removeAllItems(); - ESMS::ESMStore &store = mWindowManager.getStore(); - + const ESMS::ESMStore &store = mWindowManager.getStore(); + ESMS::RecListT::MapType::const_iterator it = store.birthSigns.list.begin(); ESMS::RecListT::MapType::const_iterator end = store.birthSigns.list.end(); int index = 0; @@ -149,7 +149,7 @@ void BirthDialog::updateSpells() const int lineHeight = 18; MyGUI::IntCoord coord(0, 0, spellArea->getWidth(), 18); - ESMS::ESMStore &store = mWindowManager.getStore(); + const ESMS::ESMStore &store = mWindowManager.getStore(); const ESM::BirthSign *birth = store.birthSigns.find(currentBirthId); std::string texturePath = std::string("textures\\") + birth->texture; diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 01516cfe25..ad94f30b1e 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -50,7 +50,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId) { currentClassId = classId; classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); - ESMS::ESMStore &store = mWindowManager.getStore(); + const ESMS::ESMStore &store = mWindowManager.getStore(); className->setCaption(store.classes.find(currentClassId)->name); } @@ -196,8 +196,8 @@ void PickClassDialog::updateClasses() { classList->removeAllItems(); - ESMS::ESMStore &store = mWindowManager.getStore(); - + const ESMS::ESMStore &store = mWindowManager.getStore(); + ESMS::RecListT::MapType::const_iterator it = store.classes.list.begin(); ESMS::RecListT::MapType::const_iterator end = store.classes.list.end(); int index = 0; @@ -220,7 +220,7 @@ void PickClassDialog::updateStats() { if (currentClassId.empty()) return; - ESMS::ESMStore &store = mWindowManager.getStore(); + const ESMS::ESMStore &store = mWindowManager.getStore(); const ESM::Class *klass = store.classes.search(currentClassId); if (!klass) return; @@ -767,7 +767,7 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) { char theIndex = '0'+i; getWidget(combatSkill[i], std::string("CombatSkill").append(1, theIndex)); - getWidget(magicSkill[i], std::string("MagicSkill").append(1, theIndex)); + getWidget(magicSkill[i], std::string("MagicSkill").append(1, theIndex)); getWidget(stealthSkill[i], std::string("StealthSkill").append(1, theIndex)); } @@ -782,8 +782,8 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) {combatSkill[6], ESM::Skill::Axe}, {combatSkill[7], ESM::Skill::Spear}, {combatSkill[8], ESM::Skill::Athletics} - }, - { + }, + { {magicSkill[0], ESM::Skill::Enchant}, {magicSkill[1], ESM::Skill::Destruction}, {magicSkill[2], ESM::Skill::Alteration}, @@ -793,8 +793,8 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) {magicSkill[6], ESM::Skill::Restoration}, {magicSkill[7], ESM::Skill::Alchemy}, {magicSkill[8], ESM::Skill::Unarmored} - }, - { + }, + { {stealthSkill[0], ESM::Skill::Security}, {stealthSkill[1], ESM::Skill::Sneak}, {stealthSkill[2], ESM::Skill::Acrobatics}, diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 65e6afd2ea..037f97fc36 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -212,8 +212,8 @@ void RaceDialog::updateRaces() { raceList->removeAllItems(); - ESMS::ESMStore &store = mWindowManager.getStore(); - + const ESMS::ESMStore &store = mWindowManager.getStore(); + ESMS::RecListT::MapType::const_iterator it = store.races.list.begin(); ESMS::RecListT::MapType::const_iterator end = store.races.list.end(); int index = 0; @@ -246,7 +246,7 @@ void RaceDialog::updateSkills() const int lineHeight = 18; MyGUI::IntCoord coord1(0, 0, skillList->getWidth(), 18); - ESMS::ESMStore &store = mWindowManager.getStore(); + const ESMS::ESMStore &store = mWindowManager.getStore(); const ESM::Race *race = store.races.find(currentRaceId); int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? for (int i = 0; i < count; ++i) @@ -282,7 +282,7 @@ void RaceDialog::updateSpellPowers() const int lineHeight = 18; MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18); - ESMS::ESMStore &store = mWindowManager.getStore(); + const ESMS::ESMStore &store = mWindowManager.getStore(); const ESM::Race *race = store.races.find(currentRaceId); std::vector::const_iterator it = race->powers.list.begin(); diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index d08e6384d2..30a4015e33 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -323,7 +323,7 @@ void StatsWindow::updateSkillArea() if (!miscSkills.empty()) addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); - ESMS::ESMStore &store = mWindowManager.getStore(); + const ESMS::ESMStore &store = mWindowManager.getStore(); if (!factions.empty()) { diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 861939b7ed..f62da2bab9 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -278,7 +278,7 @@ void MWSpell::setSpellId(const std::string &spellId) void MWSpell::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord) { - ESMS::ESMStore &store = mWindowManager->getStore(); + const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::Spell *spell = store.spells.search(id); MYGUI_ASSERT(spell, "spell with id '" << id << "' not found"); @@ -298,7 +298,7 @@ void MWSpell::updateWidgets() { if (spellNameWidget && mWindowManager) { - ESMS::ESMStore &store = mWindowManager->getStore(); + const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::Spell *spell = store.spells.search(id); if (spell) spellNameWidget->setCaption(spell->name); @@ -363,7 +363,7 @@ void MWSpellEffect::updateWidgets() if (!mWindowManager) return; - ESMS::ESMStore &store = mWindowManager->getStore(); + const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::MagicEffect *magicEffect = store.magicEffects.search(effect.effectID); if (textWidget) { diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index f0c409cbe3..2d7f70ef86 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -940,7 +940,7 @@ void WindowManager::onReviewActivateDialog(int parDialog) }; } -ESMS::ESMStore& WindowManager::getStore() +const ESMS::ESMStore& WindowManager::getStore() const { return environment.mWorld->getStore(); } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 1bf6204969..d3fbf3ea31 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -257,7 +257,7 @@ namespace MWGui */ const std::string &getGameSettingString(const std::string &id, const std::string &default_); - ESMS::ESMStore& getStore(); + const ESMS::ESMStore& getStore() const; private: diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 63019349c8..dde3ff711b 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -460,7 +460,7 @@ namespace MWWorld return *mPlayer; } - ESMS::ESMStore& World::getStore() + const ESMS::ESMStore& World::getStore() const { return mStore; } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 6965aebc6a..76d6bd9220 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -115,7 +115,7 @@ namespace MWWorld MWWorld::Player& getPlayer(); - ESMS::ESMStore& getStore(); + const ESMS::ESMStore& getStore() const; const ScriptList& getLocalScripts() const; ///< Names and local variable state of all local scripts in active cells. From 792de880cf738530bdb11dc3b378c834e941585c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 21 Apr 2011 11:00:00 +0200 Subject: [PATCH 12/29] another constness fix --- apps/openmw/mwworld/world.cpp | 5 +++++ apps/openmw/mwworld/world.hpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index dde3ff711b..f10bbfc9a9 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -480,6 +480,11 @@ namespace MWWorld return (*mGlobalVariables)[name]; } + Globals::Data World::getGlobalVariable (const std::string& name) const + { + return (*mGlobalVariables)[name]; + } + char World::getGlobalVariableType (const std::string& name) const { return mGlobalVariables->getType (name); diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 76d6bd9220..f7e5bd3f75 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -125,6 +125,8 @@ namespace MWWorld Globals::Data& getGlobalVariable (const std::string& name); + Globals::Data getGlobalVariable (const std::string& name) const; + char getGlobalVariableType (const std::string& name) const; ///< Return ' ', if there is no global variable with this name. From f3fecdc627d366f2a146a9f2961d989574c5529e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 21 Apr 2011 11:05:49 +0200 Subject: [PATCH 13/29] quest entries are added to main journal now --- apps/openmw/mwdialogue/journal.cpp | 2 ++ apps/openmw/mwdialogue/journalentry.cpp | 18 ++++++++++++++++++ apps/openmw/mwdialogue/journalentry.hpp | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 545e2f3ee4..8f84edabc8 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -1,6 +1,7 @@ #include "journal.hpp" +#include "../mwworld/environment.hpp" #include namespace MWDialogue @@ -11,6 +12,7 @@ namespace MWDialogue void Journal::addEntry (const std::string& id, int index) { + mJournal.push_back (JournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld)); std::cout << "journal: " << id << " at " << index << std::endl; } diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index 8e3aeb93bb..6cfee7cf45 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -5,6 +5,8 @@ #include +#include "../mwworld/world.hpp" + namespace MWDialogue { JournalEntry::JournalEntry() {} @@ -24,4 +26,20 @@ namespace MWDialogue throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic); } + + JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index, + const MWWorld::World& world) + { + const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic); + + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); + iter!=dialogue->mInfo.end(); ++iter) + if (iter->data.disposition==index) /// \todo cleanup info structure + { + int day = world.getGlobalVariable ("dayspassed").mLong; + return JournalEntry (day, topic, iter->id); + } + + throw std::runtime_error ("unknown journal index for topic " + topic); + } } diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp index 8506b9dbcf..f19e9c52c9 100644 --- a/apps/openmw/mwdialogue/journalentry.hpp +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -8,6 +8,11 @@ namespace ESMS struct ESMStore; } +namespace MWWorld +{ + class World; +} + namespace MWDialogue { /// \brief a quest or dialogue entry with a timestamp @@ -22,6 +27,9 @@ namespace MWDialogue JournalEntry (int day, const std::string& topic, const std::string& infoId); std::string getText (const ESMS::ESMStore& store) const; + + static JournalEntry makeFromQuest (const std::string& topic, int index, + const MWWorld::World& world); }; } From 8915e8a751c26ee7205daedf4aa513de62c32bcc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 21 Apr 2011 18:10:35 +0200 Subject: [PATCH 14/29] change in multi_es branch broke fps switch; fixed now --- apps/openmw/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 697b06e93c..059bf39f75 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -55,7 +55,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) ->default_value (std::vector(), "") ->multitoken(), "plugin file(s)") - ( "showfps", "show fps counter") + ( "fps", "show fps counter") ( "debug", "debug mode" ) ( "nosound", "disable all sound" ) ( "script-verbose", "verbose script output" ) From f4f12e885f43cf1382340d3288958d2fba114dea Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 21 Apr 2011 18:23:46 +0200 Subject: [PATCH 15/29] all program options (except help) can now be used from a cfg file --- apps/openmw/main.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 059bf39f75..f6f0235920 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -55,12 +55,20 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) ->default_value (std::vector(), "") ->multitoken(), "plugin file(s)") - ( "fps", "show fps counter") - ( "debug", "debug mode" ) - ( "nosound", "disable all sound" ) - ( "script-verbose", "verbose script output" ) - ( "new-game", "activate char gen/new game mechanics" ) - ( "script-all", "compile all scripts (excluding dialogue scripts) at startup") + ( "fps", boost::program_options::value()-> + implicit_value (true)->default_value (false), "show fps counter") + ( "debug", boost::program_options::value()-> + implicit_value (true)->default_value (false), "debug mode" ) + ( "nosound", boost::program_options::value()-> + implicit_value (true)->default_value (false), "disable all sound" ) + ( "script-verbose", boost::program_options::value()-> + implicit_value (true)->default_value (false), "verbose script output" ) + ( "new-game", boost::program_options::value()-> + implicit_value (true)->default_value (false), + "activate char gen/new game mechanics" ) + ( "script-all", boost::program_options::value()-> + implicit_value (true)->default_value (false), + "compile all scripts (excluding dialogue scripts) at startup") ; bpo::variables_map variables; @@ -118,23 +126,23 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) // startup-settings engine.setCell (variables["start"].as()); - if (variables.count ("new-game")) + if (variables["new-game"].as()==true) engine.setNewGame(); // other settings - if (variables.count ("fps")) + if (variables["fps"].as()==true) engine.showFPS(); - if (variables.count ("debug")) + if (variables["debug"].as()==true) engine.enableDebugMode(); - if (variables.count ("no-sound")) + if (variables["nosound"].as()==true) engine.disableSound(); - if (variables.count ("script-verbose")) + if (variables["script-verbose"].as()==true) engine.enableVerboseScripts(); - if (variables.count ("script-all")) + if (variables["script-all"].as()==true) engine.setCompileAll (true); return true; From 65e43c448a9a31bfdbcc5d7aa5ef6c2da28f2515 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 22 Apr 2011 11:16:39 +0200 Subject: [PATCH 16/29] splitted StampedJournalEntry class off from JournalEntry --- apps/openmw/mwdialogue/journal.cpp | 2 +- apps/openmw/mwdialogue/journal.hpp | 4 ++-- apps/openmw/mwdialogue/journalentry.cpp | 32 +++++++++++++++++++++---- apps/openmw/mwdialogue/journalentry.hpp | 23 +++++++++++++++--- 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 8f84edabc8..570d32d36d 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -12,7 +12,7 @@ namespace MWDialogue void Journal::addEntry (const std::string& id, int index) { - mJournal.push_back (JournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld)); + mJournal.push_back (StampedJournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld)); std::cout << "journal: " << id << " at " << index << std::endl; } diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp index 07090ef4af..6b2b12cacc 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journal.hpp @@ -17,13 +17,13 @@ namespace MWDialogue { public: - typedef std::deque TEntryContainer; + typedef std::deque TEntryContainer; typedef TEntryContainer::const_iterator TEntryIter; private: MWWorld::Environment& mEnvironment; - std::deque mJournal; + TEntryContainer mJournal; public: diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index 6cfee7cf45..5e9dfa674a 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -11,8 +11,8 @@ namespace MWDialogue { JournalEntry::JournalEntry() {} - JournalEntry::JournalEntry (int day, const std::string& topic, const std::string& infoId) - : mDay (day), mTopic (topic), mInfoId (infoId) + JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId) + : mTopic (topic), mInfoId (infoId) {} std::string JournalEntry::getText (const ESMS::ESMStore& store) const @@ -29,6 +29,12 @@ namespace MWDialogue JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index, const MWWorld::World& world) + { + return JournalEntry (topic, idFromIndex (topic, index, world)); + } + + std::string JournalEntry::idFromIndex (const std::string& topic, int index, + const MWWorld::World& world) { const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic); @@ -36,10 +42,28 @@ namespace MWDialogue iter!=dialogue->mInfo.end(); ++iter) if (iter->data.disposition==index) /// \todo cleanup info structure { - int day = world.getGlobalVariable ("dayspassed").mLong; - return JournalEntry (day, topic, iter->id); + iter->id; } throw std::runtime_error ("unknown journal index for topic " + topic); } + + StampedJournalEntry::StampedJournalEntry() + : mDay (0), mMonth (0), mDayOfMonth (0) + {} + + StampedJournalEntry::StampedJournalEntry (const std::string& topic, const std::string& infoId, + int day, int month, int dayOfMonth) + : JournalEntry (topic, infoId), mDay (day), mMonth (month), mDayOfMonth (dayOfMonth) + {} + + StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index, + const MWWorld::World& world) + { + int day = world.getGlobalVariable ("dayspassed").mLong; + int month = world.getGlobalVariable ("day").mLong; + int dayOfMonth = world.getGlobalVariable ("month").mLong; + + return StampedJournalEntry (topic, idFromIndex (topic, index, world), day, month, dayOfMonth); + } } diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp index f19e9c52c9..058843008d 100644 --- a/apps/openmw/mwdialogue/journalentry.hpp +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -15,23 +15,40 @@ namespace MWWorld namespace MWDialogue { - /// \brief a quest or dialogue entry with a timestamp + /// \brief A quest or dialogue entry struct JournalEntry { - int mDay; std::string mTopic; std::string mInfoId; JournalEntry(); - JournalEntry (int day, const std::string& topic, const std::string& infoId); + JournalEntry (const std::string& topic, const std::string& infoId); std::string getText (const ESMS::ESMStore& store) const; static JournalEntry makeFromQuest (const std::string& topic, int index, const MWWorld::World& world); + + static std::string idFromIndex (const std::string& topic, int index, + const MWWorld::World& world); }; + /// \biref A quest entry with a timestamp. + struct StampedJournalEntry : public JournalEntry + { + int mDay; + int mMonth; + int mDayOfMonth; + + StampedJournalEntry(); + + StampedJournalEntry (const std::string& topic, const std::string& infoId, + int day, int month, int dayOfMonth); + + static StampedJournalEntry makeFromQuest (const std::string& topic, int index, + const MWWorld::World& world); + }; } #endif From 0c4e9d92070c606ce0906572d6783973f286a55a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 24 Apr 2011 12:39:50 +0200 Subject: [PATCH 17/29] create local openmw.cfg file for uninstalled version --- CMakeLists.txt | 6 +++++- files/openmw.cfg.local | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 files/openmw.cfg.local diff --git a/CMakeLists.txt b/CMakeLists.txt index 22ba839b2c..3273ccef81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -336,6 +336,10 @@ endif (APPLE) # Other files +configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local + "${OpenMW_BINARY_DIR}/openmw.cfg" COPYONLY) + + if (WIN32) configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32 "${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY) @@ -424,7 +428,7 @@ if(DPKG_PROGRAM) endif() #Install global configuration files - INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + INSTALL(FILES "${OpenMW_SOURCE_DIR}/openmw.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") #Install resources diff --git a/files/openmw.cfg.local b/files/openmw.cfg.local new file mode 100644 index 0000000000..dd116e1080 --- /dev/null +++ b/files/openmw.cfg.local @@ -0,0 +1,2 @@ +data=./data +resources=./resources From 573090a07fb747f7a7399c0c305b3fabcb9aa3a4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 24 Apr 2011 12:41:55 +0200 Subject: [PATCH 18/29] improved description of openmw.cfg related cmake-variable --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3273ccef81..8de24f57f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,15 +14,15 @@ find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") # Location of morrowind data files if(DPKG_PROGRAM) set(MORROWIND_DATA_FILES "/usr/share/games/openmw/data/" CACHE PATH "location of Morrowind data files") - set(MORROWIND_RESOURCE_FILES "/usr/share/games/openmw/resources/" CACHE PATH "location of Morrowind data files") + set(MORROWIND_RESOURCE_FILES "/usr/share/games/openmw/resources/" CACHE PATH "location of OpenMW resources files") else() if (APPLE) # set path inside bundle set(MORROWIND_DATA_FILES "../data" CACHE PATH "location of Morrowind data files") - set(MORROWIND_RESOURCE_FILES "Contents/Resources/resources" CACHE PATH "location of Morrowind data files") + set(MORROWIND_RESOURCE_FILES "Contents/Resources/resources" CACHE PATH "location of OpenMW resources files") else() set(MORROWIND_DATA_FILES "data" CACHE PATH "location of Morrowind data files") - set(MORROWIND_RESOURCE_FILES "resources" CACHE PATH "location of Morrowind data files") + set(MORROWIND_RESOURCE_FILES "resources" CACHE PATH "location of OpenMW resources files") endif(APPLE) endif(DPKG_PROGRAM) From 944291d34fa06706de59adf95eb1d812ecf85802 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 26 Apr 2011 20:08:37 +0200 Subject: [PATCH 19/29] added quest tracking to the journal --- apps/openmw/CMakeLists.txt | 2 + apps/openmw/mwdialogue/journal.cpp | 40 +++++++++-- apps/openmw/mwdialogue/journal.hpp | 14 ++++ apps/openmw/mwdialogue/journalentry.hpp | 2 +- apps/openmw/mwdialogue/quest.cpp | 96 +++++++++++++++++++++++++ apps/openmw/mwdialogue/quest.hpp | 60 ++++++++++++++++ 6 files changed, 209 insertions(+), 5 deletions(-) create mode 100644 apps/openmw/mwdialogue/quest.cpp create mode 100644 apps/openmw/mwdialogue/quest.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 63add2fce4..8fa6d65917 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -72,11 +72,13 @@ set(GAMEDIALOGUE_HEADER mwdialogue/dialoguemanager.hpp mwdialogue/journal.hpp mwdialogue/journalentry.hpp + mwdialogue/quest.hpp ) set(GAMEDIALOGUE mwdialogue/dialoguemanager.cpp mwdialogue/journal.cpp mwdialogue/journalentry.cpp + mwdialogue/quest.cpp ) source_group(apps\\openmw\\mwdialogue FILES ${GAMEDIALOGUE_HEADER} ${GAMEDIALOGUE}) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 570d32d36d..b1d85f729b 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -3,22 +3,44 @@ #include "../mwworld/environment.hpp" -#include namespace MWDialogue { + Quest& Journal::getQuest (const std::string& id) + { + TQuestContainer::iterator iter = mQuests.find (id); + + if (iter==mQuests.end()) + { + std::pair result = + mQuests.insert (std::make_pair (id, Quest (id))); + + iter = result.first; + } + + return iter->second; + } + Journal::Journal (MWWorld::Environment& environment) : mEnvironment (environment) {} void Journal::addEntry (const std::string& id, int index) { - mJournal.push_back (StampedJournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld)); - std::cout << "journal: " << id << " at " << index << std::endl; + StampedJournalEntry entry = + StampedJournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld); + + mJournal.push_back (entry); + + Quest& quest = getQuest (id); + + quest.addEntry (entry, *mEnvironment.mWorld); // we are doing slicing on purpose here } void Journal::setJournalIndex (const std::string& id, int index) { - std::cout << "journal (no entry): " << id << " at " << index << std::endl; + Quest& quest = getQuest (id); + + quest.setIndex (index, *mEnvironment.mWorld); } int Journal::getJournalIndex (const std::string& id) const @@ -35,4 +57,14 @@ namespace MWDialogue { return mJournal.end(); } + + Journal::TQuestIter Journal::questBegin() const + { + return mQuests.begin(); + } + + Journal::TQuestIter Journal::questEnd() const + { + return mQuests.end(); + } } diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp index 6b2b12cacc..5477ae5a53 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journal.hpp @@ -3,8 +3,10 @@ #include #include +#include #include "journalentry.hpp" +#include "quest.hpp" namespace MWWorld { @@ -13,17 +15,23 @@ namespace MWWorld namespace MWDialogue { + /// \brief The player's journal class Journal { public: typedef std::deque TEntryContainer; typedef TEntryContainer::const_iterator TEntryIter; + typedef std::map TQuestContainer; // topc, quest + typedef TQuestContainer::const_iterator TQuestIter; private: MWWorld::Environment& mEnvironment; TEntryContainer mJournal; + TQuestContainer mQuests; + + Quest& getQuest (const std::string& id); public: @@ -45,6 +53,12 @@ namespace MWDialogue TEntryIter end() const; ///< Iterator pointing past the end of the main journal. + + TQuestIter questBegin() const; + ///< Iterator pointing to the first quest (sorted by topic ID) + + TQuestIter questEnd() const; + ///< Iterator pointing past the last quest. }; } diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp index 058843008d..11b7156301 100644 --- a/apps/openmw/mwdialogue/journalentry.hpp +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -1,5 +1,5 @@ #ifndef GAME_MMDIALOGUE_JOURNALENTRY_H -#define GAME_MWDIALOGUE_JOURNALENTRY_H +#define GAME_MMDIALOGUE_JOURNALENTRY_H #include diff --git a/apps/openmw/mwdialogue/quest.cpp b/apps/openmw/mwdialogue/quest.cpp new file mode 100644 index 0000000000..13e4327624 --- /dev/null +++ b/apps/openmw/mwdialogue/quest.cpp @@ -0,0 +1,96 @@ + +#include "quest.hpp" + +#include + +#include "../mwworld/world.hpp" + +namespace MWDialogue +{ + Quest::Quest() + : mIndex (0), mFinished (false) + {} + + Quest::Quest (const std::string& topic) + : mTopic (topic), mIndex (0), mFinished (false) + {} + + const std::string Quest::getName (const MWWorld::World& world) const + { + const ESM::Dialogue *dialogue = world.getStore().dialogs.find (mTopic); + + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); + iter!=dialogue->mInfo.end(); ++iter) + if (iter->questStatus==ESM::DialInfo::QS_Name) + return iter->response; + + return ""; + } + + int Quest::getIndex() const + { + return mIndex; + } + + void Quest::setIndex (int index, const MWWorld::World& world) + { + const ESM::Dialogue *dialogue = world.getStore().dialogs.find (mTopic); + + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); + iter!=dialogue->mInfo.end(); ++iter) + if (iter->data.disposition==index && iter->questStatus!=ESM::DialInfo::QS_Name) + { + mIndex = index; + + if (iter->questStatus==ESM::DialInfo::QS_Finished) + mFinished = true; + else if (iter->questStatus==ESM::DialInfo::QS_Restart) + mFinished = false; + + return; + } + + throw std::runtime_error ("unknown journal index for topic " + mTopic); + } + + bool Quest::isFinished() const + { + return mFinished; + } + + void Quest::addEntry (const JournalEntry& entry, const MWWorld::World& world) + { + int index = -1; + + const ESM::Dialogue *dialogue = world.getStore().dialogs.find (entry.mTopic); + + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); + iter!=dialogue->mInfo.end(); ++iter) + if (iter->id==entry.mInfoId) + { + index = iter->data.disposition; /// \todo cleanup info structure + break; + } + + if (index==-1) + throw std::runtime_error ("unknown journal entry for topic " + mTopic); + + setIndex (index, world); + + for (TEntryIter iter (mEntries.begin()); iter!=mEntries.end(); ++iter) + if (iter->mInfoId==entry.mInfoId) + return; + + mEntries.push_back (entry); + } + + Quest::TEntryIter Quest::begin() + { + return mEntries.begin(); + } + + Quest::TEntryIter Quest::end() + { + return mEntries.end(); + } +} diff --git a/apps/openmw/mwdialogue/quest.hpp b/apps/openmw/mwdialogue/quest.hpp new file mode 100644 index 0000000000..f484dfaf7b --- /dev/null +++ b/apps/openmw/mwdialogue/quest.hpp @@ -0,0 +1,60 @@ +#ifndef GAME_MMDIALOG_QUEST_H +#define GAME_MWDIALOG_QUEST_H + +#include +#include + +#include "journalentry.hpp" + +namespace MWWorld +{ + class World; +} + +namespace MWDialogue +{ + /// \brief A quest in progress or a compelted quest + class Quest + { + public: + + typedef std::vector TEntryContainer; + typedef TEntryContainer::const_iterator TEntryIter; + + private: + + std::string mTopic; + int mIndex; + std::vector mEntries; + bool mFinished; + + public: + + Quest(); + + Quest (const std::string& topic); + + const std::string getName (const MWWorld::World& world) const; + ///< May be an empty string + + int getIndex() const; + + void setIndex (int index, const MWWorld::World& world); + ///< Calling this function with a non-existant index while throw an exception. + + bool isFinished() const; + + void addEntry (const JournalEntry& entry, const MWWorld::World& world); + ///< Add entry and adjust index accordingly. + /// + /// \note Redundant entries are ignored, but the index is still adjusted. + + TEntryIter begin(); + ///< Iterator pointing to the begin of the journal for this quest. + + TEntryIter end(); + ///< Iterator pointing past the end of the journal for this quest. + }; +} + +#endif From 3406d2fa89234cddd542a8ef97ddd1f107664a22 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 26 Apr 2011 20:22:50 +0200 Subject: [PATCH 20/29] removed redundant data from quest class --- apps/openmw/mwdialogue/quest.cpp | 9 +++++++-- apps/openmw/mwdialogue/quest.hpp | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwdialogue/quest.cpp b/apps/openmw/mwdialogue/quest.cpp index 13e4327624..d47c78c6e6 100644 --- a/apps/openmw/mwdialogue/quest.cpp +++ b/apps/openmw/mwdialogue/quest.cpp @@ -78,10 +78,10 @@ namespace MWDialogue setIndex (index, world); for (TEntryIter iter (mEntries.begin()); iter!=mEntries.end(); ++iter) - if (iter->mInfoId==entry.mInfoId) + if (*iter==entry.mInfoId) return; - mEntries.push_back (entry); + mEntries.push_back (entry.mInfoId); } Quest::TEntryIter Quest::begin() @@ -93,4 +93,9 @@ namespace MWDialogue { return mEntries.end(); } + + JournalEntry Quest::getEntry (const std::string& infoId) + { + return JournalEntry (mTopic, infoId); + } } diff --git a/apps/openmw/mwdialogue/quest.hpp b/apps/openmw/mwdialogue/quest.hpp index f484dfaf7b..9f173f6d33 100644 --- a/apps/openmw/mwdialogue/quest.hpp +++ b/apps/openmw/mwdialogue/quest.hpp @@ -18,14 +18,14 @@ namespace MWDialogue { public: - typedef std::vector TEntryContainer; + typedef std::vector TEntryContainer; typedef TEntryContainer::const_iterator TEntryIter; private: std::string mTopic; int mIndex; - std::vector mEntries; + TEntryContainer mEntries; // info-IDs bool mFinished; public: @@ -54,6 +54,8 @@ namespace MWDialogue TEntryIter end(); ///< Iterator pointing past the end of the journal for this quest. + + JournalEntry getEntry (const std::string& infoId); }; } From 7a1b215b6abdf00d36d5bba9341a9c0b9ac7a6e5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 26 Apr 2011 20:39:59 +0200 Subject: [PATCH 21/29] splitting of topic class from quest class --- apps/openmw/CMakeLists.txt | 2 ++ apps/openmw/mwdialogue/quest.cpp | 19 ++---------- apps/openmw/mwdialogue/quest.hpp | 31 ++----------------- apps/openmw/mwdialogue/topic.cpp | 46 ++++++++++++++++++++++++++++ apps/openmw/mwdialogue/topic.hpp | 52 ++++++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 45 deletions(-) create mode 100644 apps/openmw/mwdialogue/topic.cpp create mode 100644 apps/openmw/mwdialogue/topic.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 8fa6d65917..3145082edc 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -73,12 +73,14 @@ set(GAMEDIALOGUE_HEADER mwdialogue/journal.hpp mwdialogue/journalentry.hpp mwdialogue/quest.hpp + mwdialogue/topic.hpp ) set(GAMEDIALOGUE mwdialogue/dialoguemanager.cpp mwdialogue/journal.cpp mwdialogue/journalentry.cpp mwdialogue/quest.cpp + mwdialogue/topic.cpp ) source_group(apps\\openmw\\mwdialogue FILES ${GAMEDIALOGUE_HEADER} ${GAMEDIALOGUE}) diff --git a/apps/openmw/mwdialogue/quest.cpp b/apps/openmw/mwdialogue/quest.cpp index d47c78c6e6..1f387e8621 100644 --- a/apps/openmw/mwdialogue/quest.cpp +++ b/apps/openmw/mwdialogue/quest.cpp @@ -8,11 +8,11 @@ namespace MWDialogue { Quest::Quest() - : mIndex (0), mFinished (false) + : Topic(), mIndex (0), mFinished (false) {} Quest::Quest (const std::string& topic) - : mTopic (topic), mIndex (0), mFinished (false) + : Topic (topic), mIndex (0), mFinished (false) {} const std::string Quest::getName (const MWWorld::World& world) const @@ -83,19 +83,4 @@ namespace MWDialogue mEntries.push_back (entry.mInfoId); } - - Quest::TEntryIter Quest::begin() - { - return mEntries.begin(); - } - - Quest::TEntryIter Quest::end() - { - return mEntries.end(); - } - - JournalEntry Quest::getEntry (const std::string& infoId) - { - return JournalEntry (mTopic, infoId); - } } diff --git a/apps/openmw/mwdialogue/quest.hpp b/apps/openmw/mwdialogue/quest.hpp index 9f173f6d33..c162c03f45 100644 --- a/apps/openmw/mwdialogue/quest.hpp +++ b/apps/openmw/mwdialogue/quest.hpp @@ -1,31 +1,14 @@ #ifndef GAME_MMDIALOG_QUEST_H #define GAME_MWDIALOG_QUEST_H -#include -#include - -#include "journalentry.hpp" - -namespace MWWorld -{ - class World; -} +#include "topic.hpp" namespace MWDialogue { /// \brief A quest in progress or a compelted quest - class Quest + class Quest : public Topic { - public: - - typedef std::vector TEntryContainer; - typedef TEntryContainer::const_iterator TEntryIter; - - private: - - std::string mTopic; int mIndex; - TEntryContainer mEntries; // info-IDs bool mFinished; public: @@ -44,18 +27,10 @@ namespace MWDialogue bool isFinished() const; - void addEntry (const JournalEntry& entry, const MWWorld::World& world); + virtual void addEntry (const JournalEntry& entry, const MWWorld::World& world); ///< Add entry and adjust index accordingly. /// /// \note Redundant entries are ignored, but the index is still adjusted. - - TEntryIter begin(); - ///< Iterator pointing to the begin of the journal for this quest. - - TEntryIter end(); - ///< Iterator pointing past the end of the journal for this quest. - - JournalEntry getEntry (const std::string& infoId); }; } diff --git a/apps/openmw/mwdialogue/topic.cpp b/apps/openmw/mwdialogue/topic.cpp new file mode 100644 index 0000000000..8f165d3c8a --- /dev/null +++ b/apps/openmw/mwdialogue/topic.cpp @@ -0,0 +1,46 @@ + +#include "topic.hpp" + +#include + +#include "../mwworld/world.hpp" + +namespace MWDialogue +{ + Topic::Topic() + {} + + Topic::Topic (const std::string& topic) + : mTopic (topic) + {} + + Topic::~Topic() + {} + + void Topic::addEntry (const JournalEntry& entry, const MWWorld::World& world) + { + if (entry.mTopic!=mTopic) + throw std::runtime_error ("topic does not match: " + mTopic); + + for (TEntryIter iter = begin(); iter!=end(); ++iter) + if (*iter==entry.mInfoId) + return; + + mEntries.push_back (entry.mInfoId); + } + + Topic::TEntryIter Topic::begin() + { + return mEntries.begin(); + } + + Topic::TEntryIter Topic::end() + { + return mEntries.end(); + } + + JournalEntry Topic::getEntry (const std::string& infoId) + { + return JournalEntry (mTopic, infoId); + } +} diff --git a/apps/openmw/mwdialogue/topic.hpp b/apps/openmw/mwdialogue/topic.hpp new file mode 100644 index 0000000000..c085f1ed98 --- /dev/null +++ b/apps/openmw/mwdialogue/topic.hpp @@ -0,0 +1,52 @@ +#ifndef GAME_MMDIALOG_TOPIC_H +#define GAME_MWDIALOG_TOPIC_H + +#include +#include + +#include "journalentry.hpp" + +namespace MWWorld +{ + class World; +} + +namespace MWDialogue +{ + /// \brief Collection of seen responses for a topic + class Topic + { + public: + + typedef std::vector TEntryContainer; + typedef TEntryContainer::const_iterator TEntryIter; + + protected: + + std::string mTopic; + TEntryContainer mEntries; // info-IDs + + public: + + Topic(); + + Topic (const std::string& topic); + + virtual ~Topic(); + + virtual void addEntry (const JournalEntry& entry, const MWWorld::World& world); + ///< Add entry + /// + /// \note Redundant entries are ignored. + + TEntryIter begin(); + ///< Iterator pointing to the begin of the journal for this topic. + + TEntryIter end(); + ///< Iterator pointing past the end of the journal for this topic. + + JournalEntry getEntry (const std::string& infoId); + }; +} + +#endif From e18dde45711c99be9954e69aa348096b652ae2a3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 26 Apr 2011 20:48:36 +0200 Subject: [PATCH 22/29] added topic tracking --- apps/openmw/mwdialogue/journal.cpp | 25 +++++++++++++++++++++++++ apps/openmw/mwdialogue/journal.hpp | 13 +++++++++++++ 2 files changed, 38 insertions(+) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index b1d85f729b..42cce5cf55 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -43,6 +43,21 @@ namespace MWDialogue quest.setIndex (index, *mEnvironment.mWorld); } + void Journal::addTopic (const std::string& topicId, const std::string& infoId) + { + TTopicContainer::iterator iter = mTopics.find (topicId); + + if (iter==mTopics.end()) + { + std::pair result + = mTopics.insert (std::make_pair (topicId, Topic (topicId))); + + iter = result.first; + } + + iter->second.addEntry (JournalEntry (topicId, infoId), *mEnvironment.mWorld); + } + int Journal::getJournalIndex (const std::string& id) const { return 0; @@ -67,4 +82,14 @@ namespace MWDialogue { return mQuests.end(); } + + Journal::TTopicIter Journal::topicBegin() const + { + return mTopics.begin(); + } + + Journal::TTopicIter Journal::topicEnd() const + { + return mTopics.end(); + } } diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp index 5477ae5a53..ff1343945d 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journal.hpp @@ -24,12 +24,15 @@ namespace MWDialogue typedef TEntryContainer::const_iterator TEntryIter; typedef std::map TQuestContainer; // topc, quest typedef TQuestContainer::const_iterator TQuestIter; + typedef std::map TTopicContainer; // topic-id, topic-content + typedef TTopicContainer::const_iterator TTopicIter; private: MWWorld::Environment& mEnvironment; TEntryContainer mJournal; TQuestContainer mQuests; + TTopicContainer mTopics; Quest& getQuest (const std::string& id); @@ -46,6 +49,8 @@ namespace MWDialogue int getJournalIndex (const std::string& id) const; ///< Get the journal index. + void addTopic (const std::string& topicId, const std::string& infoId); + TEntryIter begin() const; ///< Iterator pointing to the begin of the main journal. /// @@ -59,6 +64,14 @@ namespace MWDialogue TQuestIter questEnd() const; ///< Iterator pointing past the last quest. + + TTopicIter topicBegin() const; + ///< Iterator pointing to the first topic (sorted by topic ID) + /// + /// \note The topic ID is identical with the user-visible topic string. + + TTopicIter topicEnd() const; + ///< Iterator pointing past the last topic. }; } From f52e6bd5ef9dad530134a39ba1446b64caab6755 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 26 Apr 2011 21:38:21 +0200 Subject: [PATCH 23/29] made toggle-type script instructions more verbose --- apps/openmw/mwrender/mwscene.cpp | 13 +++-- apps/openmw/mwrender/mwscene.hpp | 6 ++- apps/openmw/mwscript/controlextensions.cpp | 4 +- apps/openmw/mwscript/miscextensions.cpp | 6 ++- apps/openmw/mwscript/skyextensions.cpp | 55 +++++++++++----------- apps/openmw/mwworld/world.cpp | 12 +++-- apps/openmw/mwworld/world.hpp | 9 ++-- 7 files changed, 63 insertions(+), 42 deletions(-) diff --git a/apps/openmw/mwrender/mwscene.cpp b/apps/openmw/mwrender/mwscene.cpp index 890bf2cd6c..e4d449bf21 100644 --- a/apps/openmw/mwrender/mwscene.cpp +++ b/apps/openmw/mwrender/mwscene.cpp @@ -191,7 +191,7 @@ void MWScene::scaleObject (const std::string& handle, float scale) } -void MWScene::toggleCollisionMode() +bool MWScene::toggleCollisionMode() { for(std::map::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++) { @@ -203,6 +203,7 @@ void MWScene::toggleCollisionMode() act->setGravity(0.); act->setVerticalVelocity(0); mFreeFly = true; + return false; } else { @@ -210,11 +211,15 @@ void MWScene::toggleCollisionMode() act->enableCollisions(true); act->setGravity(4.); act->setVerticalVelocity(0); + return true; } } + + return false; // This should never happen, but it shall not bother us now, since + // this part of the code needs a rewrite anyway. } -void MWScene::toggleRenderMode (int mode) +bool MWScene::toggleRenderMode (int mode) { switch (mode) { @@ -223,6 +228,8 @@ void MWScene::toggleRenderMode (int mode) // TODO use a proper function instead of accessing the member variable // directly. eng->setDebugRenderingMode (!eng->isDebugCreated); - break; + return eng->isDebugCreated; } + + return false; } diff --git a/apps/openmw/mwrender/mwscene.hpp b/apps/openmw/mwrender/mwscene.hpp index fd14fcce01..7429ff21e8 100644 --- a/apps/openmw/mwrender/mwscene.hpp +++ b/apps/openmw/mwrender/mwscene.hpp @@ -91,12 +91,14 @@ namespace MWRender /// Toggle collision mode for player. If disabled player object should ignore /// collisions and gravity. - void toggleCollisionMode(); + /// \return Resulting mode + bool toggleCollisionMode(); /// Toggle render mode /// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed /// when the mw*-refactoring is done. - void toggleRenderMode (int mode); + /// \return Resulting mode + bool toggleRenderMode (int mode); }; } diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index e687b13521..3d65c57057 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -46,7 +46,9 @@ namespace MWScript InterpreterContext& context = static_cast (runtime.getContext()); - context.getWorld().toggleCollisionMode(); + bool enabled = context.getWorld().toggleCollisionMode(); + + context.messageBox (enabled ? "Collsion -> On" : "Collision -> Off"); } }; diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 9bfb8774d1..e1c9eae3b7 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -99,7 +99,11 @@ namespace MWScript InterpreterContext& context = static_cast (runtime.getContext()); - context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug); + bool enabled = + context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug); + + context.messageBox (enabled ? + "Collsion Mesh Rendering -> On" : "Collision Mesh Rendering -> Off"); } }; diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index f53168240d..1a761e3bb8 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -16,68 +16,70 @@ namespace MWScript class OpToggleSky : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); - - context.getWorld().toggleSky(); - } - }; - + + bool enabled = context.getWorld().toggleSky(); + + context.messageBox (enabled ? "Sky -> On" : "Sky -> Off"); + } + }; + class OpTurnMoonWhite : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); - + context.getWorld().setMoonColour (false); - } - }; + } + }; class OpTurnMoonRed : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); - + context.getWorld().setMoonColour (true); - } - }; - + } + }; + class OpGetMasserPhase : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); - + runtime.push (context.getWorld().getMasserPhase()); - } - }; + } + }; class OpGetSecundaPhase : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); - + runtime.push (context.getWorld().getSecundaPhase()); - } - }; - + } + }; + const int opcodeToggleSky = 0x2000021; const int opcodeTurnMoonWhite = 0x2000022; const int opcodeTurnMoonRed = 0x2000023; @@ -93,7 +95,7 @@ namespace MWScript extensions.registerFunction ("getmasserphase", 'l', "", opcodeGetMasserPhase); extensions.registerFunction ("getsecundaphase", 'l', "", opcodeGetSecundaPhase); } - + void installOpcodes (Interpreter::Interpreter& interpreter) { interpreter.installSegment5 (opcodeToggleSky, new OpToggleSky); @@ -101,7 +103,6 @@ namespace MWScript interpreter.installSegment5 (opcodeTurnMoonRed, new OpTurnMoonRed); interpreter.installSegment5 (opcodeGetMasserPhase, new OpGetMasserPhase); interpreter.installSegment5 (opcodeGetSecundaPhase, new OpGetSecundaPhase); - } + } } } - diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 63019349c8..a4001169d2 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -645,12 +645,13 @@ namespace MWWorld mSkyManager->setDate (mGlobalVariables->getInt ("day"), month); } - void World::toggleSky() + bool World::toggleSky() { if (mSky) { mSky = false; mSkyManager->disable(); + return false; } else { @@ -660,6 +661,7 @@ namespace MWWorld mSkyManager->setDate (mGlobalVariables->getInt ("day"), mGlobalVariables->getInt ("month")); mSkyManager->enable(); + return true; } } @@ -853,13 +855,13 @@ namespace MWWorld mScene.doPhysics (duration, *this, actors); } - void World::toggleCollisionMode() + bool World::toggleCollisionMode() { - mScene.toggleCollisionMode(); + return mScene.toggleCollisionMode(); } - void World::toggleRenderMode (RenderMode mode) + bool World::toggleRenderMode (RenderMode mode) { - mScene.toggleRenderMode (mode); + return mScene.toggleRenderMode (mode); } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 6965aebc6a..7393533947 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -147,7 +147,8 @@ namespace MWWorld void setDay (int day); - void toggleSky(); + bool toggleSky(); + ///< \return Resulting mode int getMasserPhase() const; @@ -185,12 +186,14 @@ namespace MWWorld float duration); ///< Run physics simulation and modify \a world accordingly. - void toggleCollisionMode(); + bool toggleCollisionMode(); ///< Toggle collision mode for player. If disabled player object should ignore /// collisions and gravity. + ///< \return Resulting mode - void toggleRenderMode (RenderMode mode); + bool toggleRenderMode (RenderMode mode); ///< Toggle a render mode. + ///< \return Resulting mode }; } From 125319c441559378993437059756236c78236a8a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 26 Apr 2011 21:48:13 +0200 Subject: [PATCH 24/29] splitting off console output from messageBox channel --- apps/openmw/mwgui/console.cpp | 7 ++++ apps/openmw/mwscript/controlextensions.cpp | 2 +- apps/openmw/mwscript/interpretercontext.cpp | 5 +++ apps/openmw/mwscript/interpretercontext.hpp | 4 ++ apps/openmw/mwscript/miscextensions.cpp | 2 +- apps/openmw/mwscript/skyextensions.cpp | 2 +- components/interpreter/context.hpp | 42 ++++++++++----------- 7 files changed, 40 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 836a0f0db9..0421dc370f 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -17,6 +17,8 @@ namespace MWGui ConsoleInterpreterContext (Console& console, MWWorld::Environment& environment, MWWorld::Ptr reference); + + virtual void report (const std::string& message); }; ConsoleInterpreterContext::ConsoleInterpreterContext (Console& console, @@ -26,6 +28,11 @@ namespace MWGui mConsole (console) {} + void ConsoleInterpreterContext::report (const std::string& message) + { + mConsole.printOK (message); + } + bool Console::compile (const std::string& cmd, Compiler::Output& output) { try diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 3d65c57057..893af259fc 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -48,7 +48,7 @@ namespace MWScript bool enabled = context.getWorld().toggleCollisionMode(); - context.messageBox (enabled ? "Collsion -> On" : "Collision -> Off"); + context.report (enabled ? "Collsion -> On" : "Collision -> Off"); } }; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index cb6ecb218f..77a71a1d4d 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -110,6 +110,11 @@ namespace MWScript mEnvironment.mWindowManager->messageBox (message, buttons); } + void InterpreterContext::report (const std::string& message) + { + messageBox (message); + } + bool InterpreterContext::menuMode() { return mEnvironment.mWindowManager->isGuiMode(); diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index aebfc620e5..35b4a169d2 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -57,9 +57,13 @@ namespace MWScript virtual void setLocalFloat (int index, float value); using Interpreter::Context::messageBox; + virtual void messageBox (const std::string& message, const std::vector& buttons); + virtual void report (const std::string& message); + ///< By default echo via messageBox. + virtual bool menuMode(); virtual int getGlobalShort (const std::string& name) const; diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index e1c9eae3b7..d8dfbdde47 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -102,7 +102,7 @@ namespace MWScript bool enabled = context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug); - context.messageBox (enabled ? + context.report (enabled ? "Collsion Mesh Rendering -> On" : "Collision Mesh Rendering -> Off"); } }; diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index 1a761e3bb8..caa07c0952 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -24,7 +24,7 @@ namespace MWScript bool enabled = context.getWorld().toggleSky(); - context.messageBox (enabled ? "Sky -> On" : "Sky -> Off"); + context.report (enabled ? "Sky -> On" : "Sky -> Off"); } }; diff --git a/components/interpreter/context.hpp b/components/interpreter/context.hpp index 0d77903f42..973b22d350 100644 --- a/components/interpreter/context.hpp +++ b/components/interpreter/context.hpp @@ -18,21 +18,23 @@ namespace Interpreter virtual float getLocalFloat (int index) const = 0; - virtual void setLocalShort (int index, int value) = 0; + virtual void setLocalShort (int index, int value) = 0; - virtual void setLocalLong (int index, int value) = 0; + virtual void setLocalLong (int index, int value) = 0; virtual void setLocalFloat (int index, float value) = 0; - + virtual void messageBox (const std::string& message, - const std::vector& buttons) = 0; - + const std::vector& buttons) = 0; + void messageBox (const std::string& message) { std::vector empty; messageBox (message, empty); } - + + virtual void report (const std::string& message) = 0; + virtual bool menuMode() = 0; virtual int getGlobalShort (const std::string& name) const = 0; @@ -41,31 +43,29 @@ namespace Interpreter virtual float getGlobalFloat (const std::string& name) const = 0; - virtual void setGlobalShort (const std::string& name, int value) = 0; + virtual void setGlobalShort (const std::string& name, int value) = 0; - virtual void setGlobalLong (const std::string& name, int value) = 0; + virtual void setGlobalLong (const std::string& name, int value) = 0; + + virtual void setGlobalFloat (const std::string& name, float value) = 0; - virtual void setGlobalFloat (const std::string& name, float value) = 0; - virtual bool isScriptRunning (const std::string& name) const = 0; - + virtual void startScript (const std::string& name) = 0; - + virtual void stopScript (const std::string& name) = 0; - + virtual float getDistance (const std::string& name, const std::string& id = "") const - = 0; - + = 0; + virtual float getSecondsPassed() const = 0; - + virtual bool isDisabled (const std::string& id = "") const = 0; - + virtual void enable (const std::string& id = "") = 0; - - virtual void disable (const std::string& id = "") = 0; + + virtual void disable (const std::string& id = "") = 0; }; } #endif - - From 861dc6a16e7f52d44e8877c11f581929b1ad43bb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 26 Apr 2011 22:07:27 +0200 Subject: [PATCH 25/29] redirecting output of expression evalutation to new report channel --- components/compiler/generator.cpp | 13 +++ components/compiler/generator.hpp | 2 + components/compiler/lineparser.cpp | 4 +- components/interpreter/docs/vmformat.txt | 6 +- components/interpreter/installopcodes.cpp | 2 +- components/interpreter/miscopcodes.hpp | 135 +++++++++++++--------- 6 files changed, 103 insertions(+), 59 deletions(-) diff --git a/components/compiler/generator.cpp b/components/compiler/generator.cpp index 3d3b21d650..ee9876a147 100644 --- a/components/compiler/generator.cpp +++ b/components/compiler/generator.cpp @@ -125,6 +125,11 @@ namespace code.push_back (Compiler::Generator::segment3 (0, buttons)); } + void opReport (Compiler::Generator::CodeContainer& code) + { + code.push_back (Compiler::Generator::segment5 (58)); + } + void opFetchLocalShort (Compiler::Generator::CodeContainer& code) { code.push_back (Compiler::Generator::segment5 (21)); @@ -516,6 +521,14 @@ namespace Compiler opMessageBox (code, buttons); } + void report (CodeContainer& code, Literals& literals, const std::string& message) + { + int index = literals.addString (message); + + opPushInt (code, index); + opReport (code); + } + void fetchLocal (CodeContainer& code, char localType, int localIndex) { opPushInt (code, localIndex); diff --git a/components/compiler/generator.hpp b/components/compiler/generator.hpp index 5671949f20..fd1f954cad 100644 --- a/components/compiler/generator.hpp +++ b/components/compiler/generator.hpp @@ -81,6 +81,8 @@ namespace Compiler void message (CodeContainer& code, Literals& literals, const std::string& message, int buttons); + void report (CodeContainer& code, Literals& literals, const std::string& message); + void fetchLocal (CodeContainer& code, char localType, int localIndex); void jump (CodeContainer& code, int offset); diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 5462f77886..834cd27b48 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -30,12 +30,12 @@ namespace Compiler { case 'l': - Generator::message (mCode, mLiterals, "%g", 0); + Generator::report (mCode, mLiterals, "%g"); break; case 'f': - Generator::message (mCode, mLiterals, "%f", 0); + Generator::report (mCode, mLiterals, "%f"); break; default: diff --git a/components/interpreter/docs/vmformat.txt b/components/interpreter/docs/vmformat.txt index 6619fc30a1..3e513aa44e 100644 --- a/components/interpreter/docs/vmformat.txt +++ b/components/interpreter/docs/vmformat.txt @@ -117,5 +117,9 @@ op 55: explicit reference = stack[0]; pop; disable explicit reference op 56: explicit reference = stack[0]; pop; push 1, if explicit reference is disabled, 0 else op 57: explicit reference = stack[0]; pop; replace stack[0] with distance between explicit reference and a reference of ID stack[0] -opcodes 58-33554431 unused +op 58: report string literal index in stack[0]; + additional arguments (if any) in stack[n]..stack[1]; + n is determined according to the message string + all arguments are removed from stack +opcodes 59-33554431 unused opcodes 33554432-67108863 reserved for extensions diff --git a/components/interpreter/installopcodes.cpp b/components/interpreter/installopcodes.cpp index f383ff47c2..556477af25 100644 --- a/components/interpreter/installopcodes.cpp +++ b/components/interpreter/installopcodes.cpp @@ -95,6 +95,7 @@ namespace Interpreter interpreter.installSegment5 (54, new OpEnableExplicit); interpreter.installSegment5 (55, new OpDisableExplicit); interpreter.installSegment5 (56, new OpGetDisabledExplicit); + interpreter.installSegment5 (58, new OpReport); // script control interpreter.installSegment5 (46, new OpScriptRunning); @@ -106,4 +107,3 @@ namespace Interpreter interpreter.installSegment5 (57, new OpGetDistanceExplicit); } } - diff --git a/components/interpreter/miscopcodes.hpp b/components/interpreter/miscopcodes.hpp index fbee0aa266..37c38fc306 100644 --- a/components/interpreter/miscopcodes.hpp +++ b/components/interpreter/miscopcodes.hpp @@ -13,6 +13,66 @@ namespace Interpreter { + inline std::string formatMessage (const std::string& message, Runtime& runtime) + { + std::string formattedMessage; + + for (std::size_t i=0; i Date: Thu, 28 Apr 2011 09:30:45 +0200 Subject: [PATCH 26/29] fixed the openmw.cfg install problem (I hope) --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8de24f57f8..949a6e5226 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,8 +337,9 @@ endif (APPLE) # Other files configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local - "${OpenMW_BINARY_DIR}/openmw.cfg" COPYONLY) - + "${OpenMW_BINARY_DIR}/openmw.cfg") +configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg + "${OpenMW_BINARY_DIR}/openmw.cfg.install") if (WIN32) configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32 @@ -428,7 +429,7 @@ if(DPKG_PROGRAM) endif() #Install global configuration files - INSTALL(FILES "${OpenMW_SOURCE_DIR}/openmw.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") #Install resources From 7131c08ca499d9718bfb916c9f4a72582c4073e2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 28 Apr 2011 09:39:40 +0200 Subject: [PATCH 27/29] moved path.hpp/path.cpp to a new component --- CMakeLists.txt | 12 ++++++++++-- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/engine.cpp | 3 ++- apps/openmw/main.cpp | 3 ++- {apps/openmw => components/files}/path.cpp | 0 {apps/openmw => components/files}/path.hpp | 0 6 files changed, 15 insertions(+), 5 deletions(-) rename {apps/openmw => components/files}/path.cpp (100%) rename {apps/openmw => components/files}/path.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 949a6e5226..7d02e50f48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,6 +181,14 @@ set(MISC_HEADER ${COMP_DIR}/misc/stringops.hpp) source_group(components\\misc FILES ${MISC} ${MISC_HEADER}) +set(FILES + ${COMP_DIR}/files/path.cpp + ) +set(FILES_HEADER + ${COMP_DIR}/files/path.hpp + ) +source_group(components\\files FILES ${FILES} ${FILES_HEADER}) + file(GLOB COMPILER ${COMP_DIR}/compiler/*.cpp) file(GLOB COMPILER_HEADER ${COMP_DIR}/compiler/*.hpp) source_group(components\\compiler FILES ${COMPILER} ${COMPILER_HEADER}) @@ -190,10 +198,10 @@ file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp) source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER}) set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8} - ${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET}) + ${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET} ${FILES}) set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER} ${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER} - ${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER}) + ${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER} ${FILES_HEADER}) # source directory: libs diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 0fa027f0c6..9bc27b16dd 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -5,7 +5,7 @@ project(OpenMW) set(GAME main.cpp engine.cpp - path.cpp) + ) set(GAME_HEADER engine.hpp) source_group(game FILES ${GAME} ${GAME_HEADER}) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 78ddffbe8c..39ab430087 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -14,6 +14,8 @@ #include #include #include +#include + #include #include "mwgui/window_manager.hpp" @@ -47,7 +49,6 @@ #include #include "mwgui/class.hpp" -#include "path.hpp" #include "components/nifbullet/bullet_nif_loader.hpp" diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 7ba3fb4d6e..7546276028 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -6,8 +6,9 @@ #include #include +#include + #include "engine.hpp" -#include "path.hpp" #if defined(_WIN32) && !defined(_CONSOLE) #include diff --git a/apps/openmw/path.cpp b/components/files/path.cpp similarity index 100% rename from apps/openmw/path.cpp rename to components/files/path.cpp diff --git a/apps/openmw/path.hpp b/components/files/path.hpp similarity index 100% rename from apps/openmw/path.hpp rename to components/files/path.hpp From bdfd28f44d052905b05492262303c619c3c3b0cf Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 28 Apr 2011 09:56:50 +0200 Subject: [PATCH 28/29] adjusted components/files namespace; some related cleanup --- apps/openmw/engine.cpp | 6 ++---- apps/openmw/main.cpp | 4 ++-- components/files/path.cpp | 15 ++++++++++----- components/files/path.hpp | 26 +++++++++----------------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 39ab430087..c6b57efc02 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -323,12 +323,10 @@ void OMW::Engine::go() test.name = ""; total = 0; - - std::cout << "Data directory: " << mDataDir << "\n"; - std::string cfgDir = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", ""); - std::string cfgUserDir = OMW::Path::getPath(OMW::Path::USER_CFG_PATH, "openmw", ""); + std::string cfgDir = Files::getPath (Files::Path_ConfigUser, "openmw", ""); + std::string cfgUserDir = Files::getPath (Files::Path_ConfigGlobal, "openmw", ""); std::string plugCfg = "plugins.cfg"; std::string ogreCfg = "ogre.cfg"; ogreCfg.insert(0, cfgUserDir); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 7546276028..c5f53d7b56 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -79,12 +79,12 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) std::string cfgFile = "openmw.cfg"; if(!isFile(cfgFile.c_str())) { - cfgFile = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", "openmw.cfg"); + cfgFile = Files::getPath (Files::Path_ConfigGlobal, "openmw", "openmw.cfg"); } std::cout << "Using global config file: " << cfgFile << std::endl; std::ifstream globalConfigFile(cfgFile.c_str()); - cfgFile = OMW::Path::getPath(OMW::Path::USER_CFG_PATH, "openmw", "openmw.cfg"); + cfgFile = Files::getPath (Files::Path_ConfigUser, "openmw", "openmw.cfg"); std::cout << "Using user config file: " << cfgFile << std::endl; std::ifstream userConfigFile(cfgFile.c_str()); diff --git a/components/files/path.cpp b/components/files/path.cpp index e7dbc04715..a7b66822fd 100644 --- a/components/files/path.cpp +++ b/components/files/path.cpp @@ -2,15 +2,21 @@ #include +#include +#include + +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +#include +#endif + #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX #include //getenv #endif - -std::string OMW::Path::getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile) +std::string Files::getPath (PathTypeEnum parType, const std::string parApp, const std::string parFile) { std::string theBasePath; - if(parType == GLOBAL_CFG_PATH) + if (parType==Path_ConfigGlobal) { #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE theBasePath = Ogre::macBundlePath() + "/Contents/MacOS/"; //FIXME do we have global/local with OSX? @@ -21,7 +27,7 @@ std::string OMW::Path::getPath(PathTypeEnum parType, const std::string parApp, c #endif } - else + else if (parType==Path_ConfigUser) { #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE theBasePath = Ogre::macBundlePath() + "/Contents/MacOS/"; //FIXME do we have global/local with OSX? @@ -53,4 +59,3 @@ std::string OMW::Path::getPath(PathTypeEnum parType, const std::string parApp, c theBasePath.append(parFile); return theBasePath; } - diff --git a/components/files/path.hpp b/components/files/path.hpp index 84ff9ecab3..a426464040 100644 --- a/components/files/path.hpp +++ b/components/files/path.hpp @@ -1,25 +1,17 @@ -#ifndef PATH__HPP -#define PATH__HPP +#ifndef COMPONENTS_FILES_PATH_HPP +#define COMPONENTS_FILES_PATH_HPP -#include #include -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE -#include -#endif - -namespace OMW +namespace Files { - class Path + enum PathTypeEnum { - public: - enum PathTypeEnum - { - USER_CFG_PATH, - GLOBAL_CFG_PATH - }; - - static std::string getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile); + Path_ConfigUser, + Path_ConfigGlobal }; + + std::string getPath (PathTypeEnum parType, const std::string parApp, const std::string parFile); } + #endif From 8b9ee30924663155c2e87290bd80a4df102cebc7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 28 Apr 2011 10:15:04 +0200 Subject: [PATCH 29/29] user/global mixup --- apps/openmw/engine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index c6b57efc02..047bc3751d 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -325,8 +325,8 @@ void OMW::Engine::go() std::cout << "Data directory: " << mDataDir << "\n"; - std::string cfgDir = Files::getPath (Files::Path_ConfigUser, "openmw", ""); - std::string cfgUserDir = Files::getPath (Files::Path_ConfigGlobal, "openmw", ""); + std::string cfgDir = Files::getPath (Files::Path_ConfigGlobal, "openmw", ""); + std::string cfgUserDir = Files::getPath (Files::Path_ConfigUser, "openmw", ""); std::string plugCfg = "plugins.cfg"; std::string ogreCfg = "ogre.cfg"; ogreCfg.insert(0, cfgUserDir);