From d47de55ce9d017485934b08d354306a8041f1b19 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Aug 2010 15:19:39 +0200 Subject: [PATCH 01/23] read info records --- components/esm/records.hpp | 2 +- components/esm_store/store.cpp | 72 +++++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/components/esm/records.hpp b/components/esm/records.hpp index 4ef8ce564..fb5733c63 100644 --- a/components/esm/records.hpp +++ b/components/esm/records.hpp @@ -14,13 +14,13 @@ #include "loadcont.hpp" #include "loadcrea.hpp" #include "loadcrec.hpp" +#include "loadinfo.hpp" #include "loaddial.hpp" #include "loaddoor.hpp" #include "loadench.hpp" #include "loadfact.hpp" #include "loadglob.hpp" #include "loadgmst.hpp" -#include "loadinfo.hpp" #include "loadingr.hpp" #include "loadland.hpp" #include "loadlevlist.hpp" diff --git a/components/esm_store/store.cpp b/components/esm_store/store.cpp index 2016272e0..622676689 100644 --- a/components/esm_store/store.cpp +++ b/components/esm_store/store.cpp @@ -18,32 +18,68 @@ static string toStr(int i) void ESMStore::load(ESMReader &esm) { - set missing; + set missing; - // Loop through all records - while(esm.hasMoreRecs()) + ESM::Dialogue *dialogue = 0; + + // Loop through all records + while(esm.hasMoreRecs()) { - NAME n = esm.getRecName(); - esm.getRecHeader(); + NAME n = esm.getRecName(); + esm.getRecHeader(); - // Look up the record type. - RecListList::iterator it = recLists.find(n.val); + // Look up the record type. + RecListList::iterator it = recLists.find(n.val); - if(it == recLists.end()) + if(it == recLists.end()) { - // Not found (this would be an error later) - esm.skipRecord(); - missing.insert(n.toString()); - continue; + if (n.val==ESM::REC_INFO) + { + if (dialogue) + { + ESM::DialInfo info; + info.load (esm); + } + else + { + std::cerr << "error: info record without dialog" << std::endl; + esm.skipRecord(); + continue; + } + } + else + { + // Not found (this would be an error later) + esm.skipRecord(); + missing.insert(n.toString()); + continue; + } } + else + { + // Load it + std::string id = esm.getHNOString("NAME"); + it->second->load(esm, id); + + if (n.val==ESM::REC_DIAL) + { + RecListT& recList = static_cast& > (*it->second); + + id = recList.toLower (id); - // Load it - std::string id = esm.getHNOString("NAME"); - it->second->load(esm, id); + RecListT::MapType::iterator iter = recList.list.find (id); - // Insert the reference into the global lookup - if(!id.empty()) - all[id] = n.val; + assert (iter!=recList.list.end()); + + dialogue = &iter->second; + } + else + dialogue = 0; + + // Insert the reference into the global lookup + if(!id.empty()) + all[id] = n.val; + } } /* This information isn't needed on screen. But keep the code around From 6b1b3b20fda3b2286a2a0840347c0b1a907f5d88 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Aug 2010 15:23:13 +0200 Subject: [PATCH 02/23] store info records in dialogue records --- components/esm/loaddial.hpp | 4 ++++ components/esm_store/store.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/components/esm/loaddial.hpp b/components/esm/loaddial.hpp index 4c80fc783..c435eb276 100644 --- a/components/esm/loaddial.hpp +++ b/components/esm/loaddial.hpp @@ -1,7 +1,10 @@ #ifndef _ESM_DIAL_H #define _ESM_DIAL_H +#include + #include "esm_reader.hpp" +#include "loadinfo.hpp" namespace ESM { @@ -23,6 +26,7 @@ struct Dialogue }; char type; + std::vector mInfo; void load(ESMReader &esm) { diff --git a/components/esm_store/store.cpp b/components/esm_store/store.cpp index 622676689..c43855873 100644 --- a/components/esm_store/store.cpp +++ b/components/esm_store/store.cpp @@ -39,6 +39,8 @@ void ESMStore::load(ESMReader &esm) { ESM::DialInfo info; info.load (esm); + + dialogue->mInfo.push_back (info); } else { From 761157206548a33a3aa84c2177e75b195138ca5e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Aug 2010 15:25:54 +0200 Subject: [PATCH 03/23] cleanup --- components/esm_store/store.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp index fd4a47d4b..02b526492 100644 --- a/components/esm_store/store.hpp +++ b/components/esm_store/store.hpp @@ -69,7 +69,6 @@ namespace ESMS // Lists that need special rules CellList cells; RecIDListT gameSettings; - //RecListT dialInfos; //RecListT lands; //RecListT landTexts; //RecListT magicEffects; @@ -92,7 +91,6 @@ namespace ESMS ESMStore() { - recLists[REC_ACTI] = &activators; recLists[REC_ACTI] = &activators; recLists[REC_ALCH] = &potions; recLists[REC_APPA] = &appas; @@ -113,7 +111,6 @@ namespace ESMS recLists[REC_FACT] = &factions; recLists[REC_GLOB] = &globals; recLists[REC_GMST] = &gameSettings; - //recLists[REC_INFO] = &dialInfos; recLists[REC_INGR] = &ingreds; //recLists[REC_LAND] = &lands; recLists[REC_LEVC] = &creatureLists; From 8045320ac94c507c805f511d599d2846b5afd1c9 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Aug 2010 18:01:34 +0200 Subject: [PATCH 04/23] added dialog manager --- apps/openmw/CMakeLists.txt | 12 ++++++++++-- apps/openmw/engine.cpp | 6 ++++++ apps/openmw/mwdialog/dialogmanager.cpp | 17 +++++++++++++++++ apps/openmw/mwdialog/dialogmanager.hpp | 26 ++++++++++++++++++++++++++ apps/openmw/mwworld/environment.hpp | 11 ++++++++--- 5 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 apps/openmw/mwdialog/dialogmanager.cpp create mode 100644 apps/openmw/mwdialog/dialogmanager.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index c9112b0ee..f07143be5 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -41,6 +41,14 @@ set(GAMEGUI ) source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) +set(GAMEDIALOG_HEADER + mwdialog/dialogmanager.hpp +) +set(GAMEDIALOG + mwdialog/dialogmanager.cpp +) +source_group(apps\\openmw\\mwdialog FILES ${GAMEDIALOG_HEADER} ${GAMEDIALOG}) + set(GAMESCRIPT mwscript/scriptmanager.cpp mwscript/compilercontext.cpp @@ -154,11 +162,11 @@ set(GAMEMECHANICS_HEADER source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER}) set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD} - ${GAMECLASS} ${GAMEMECHANICS} + ${GAMECLASS} ${GAMEMECHANICS} ${GAMEDIALOG} ) set(OPENMW_HEADER ${GAME_HEADER} ${GAMEREND_HEADER} ${GAMEINPUT_HEADER} ${GAMESCRIPT_HEADER} ${GAMESOUND_HEADER} ${GAMEGUI_HEADER} ${GAMEWORLD_HEADER} ${GAMECLASS_HEADER} - ${GAMEMECHANICS_HEADER} + ${GAMEMECHANICS_HEADER} ${GAMEDIALOG_HEADER} ) # Main executable diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index b67bcd0ac..2cd738623 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -28,6 +28,8 @@ #include "mwclass/classes.hpp" +#include "mwdialog/dialogmanager.hpp" + #include "mwmechanics/mechanicsmanager.hpp" #include @@ -117,6 +119,7 @@ OMW::Engine::~Engine() delete mEnvironment.mSoundManager; delete mEnvironment.mGlobalScripts; delete mEnvironment.mMechanicsManager; + delete mEnvironment.mDialogManager; delete mScriptManager; delete mScriptContext; } @@ -250,6 +253,9 @@ void OMW::Engine::go() mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager ( mEnvironment.mWorld->getStore(), *mEnvironment.mWindowManager); + // Create dialog system + mEnvironment.mDialogManager = new MWDialog::DialogManager (mEnvironment); + // load cell ESM::Position pos; pos.pos[0] = pos.pos[1] = pos.pos[2] = 0; diff --git a/apps/openmw/mwdialog/dialogmanager.cpp b/apps/openmw/mwdialog/dialogmanager.cpp new file mode 100644 index 000000000..2dfaebb76 --- /dev/null +++ b/apps/openmw/mwdialog/dialogmanager.cpp @@ -0,0 +1,17 @@ + +#include "dialogmanager.hpp" + +#include "../mwworld/class.hpp" + +#include + +namespace MWDialog +{ + DialogManager::DialogManager (MWWorld::Environment& environment) : mEnvironment (environment) {} + + void DialogManager::startDialog (const MWWorld::Ptr& actor) + { + std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; + } + +} diff --git a/apps/openmw/mwdialog/dialogmanager.hpp b/apps/openmw/mwdialog/dialogmanager.hpp new file mode 100644 index 000000000..8f4067c9a --- /dev/null +++ b/apps/openmw/mwdialog/dialogmanager.hpp @@ -0,0 +1,26 @@ +#ifndef GAME_MMDIALOG_DIALOGMANAGER_H +#define GAME_MWDIALOG_DIALOGMANAGER_H + +#include "../mwworld/ptr.hpp" + +namespace MWWorld +{ + class Environment; +} + +namespace MWDialog +{ + class DialogManager + { + MWWorld::Environment& mEnvironment; + + public: + + DialogManager (MWWorld::Environment& environment); + + void startDialog (const MWWorld::Ptr& actor); + + }; +} + +#endif diff --git a/apps/openmw/mwworld/environment.hpp b/apps/openmw/mwworld/environment.hpp index 0c6476d52..1887e619f 100644 --- a/apps/openmw/mwworld/environment.hpp +++ b/apps/openmw/mwworld/environment.hpp @@ -21,17 +21,22 @@ namespace MWMechanics class MechanicsManager; } +namespace MWDialog +{ + class DialogManager; +} + namespace MWWorld { class World; ///< Collection of script-accessable sub-systems class Environment - { + { public: Environment() : mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0), - mMechanicsManager (0), mFrameDuration (0) + mMechanicsManager (0), mDialogManager (0), mFrameDuration (0) {} World *mWorld; @@ -39,9 +44,9 @@ namespace MWWorld MWScript::GlobalScripts *mGlobalScripts; MWGui::WindowManager *mWindowManager; MWMechanics::MechanicsManager *mMechanicsManager; + MWDialog::DialogManager *mDialogManager; float mFrameDuration; }; } #endif - From d6541d4f3cdc4b2003c7ee9d8e2e504999d85d9b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Aug 2010 19:10:56 +0200 Subject: [PATCH 05/23] changed file names to ensure consistent spelling --- apps/openmw/CMakeLists.txt | 14 +++++++------- apps/openmw/engine.cpp | 2 +- .../dialoguemanager.cpp} | 2 +- .../dialoguemanager.hpp} | 0 4 files changed, 9 insertions(+), 9 deletions(-) rename apps/openmw/{mwdialog/dialogmanager.cpp => mwdialogue/dialoguemanager.cpp} (91%) rename apps/openmw/{mwdialog/dialogmanager.hpp => mwdialogue/dialoguemanager.hpp} (100%) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index f07143be5..d27ddae2d 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -41,13 +41,13 @@ set(GAMEGUI ) source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) -set(GAMEDIALOG_HEADER - mwdialog/dialogmanager.hpp +set(GAMEDIALOGUE_HEADER + mwdialogue/dialoguemanager.hpp ) -set(GAMEDIALOG - mwdialog/dialogmanager.cpp +set(GAMEDIALOGUE + mwdialogue/dialoguemanager.cpp ) -source_group(apps\\openmw\\mwdialog FILES ${GAMEDIALOG_HEADER} ${GAMEDIALOG}) +source_group(apps\\openmw\\mwdialogue FILES ${GAMEDIALOGUE_HEADER} ${GAMEDIALOGUE}) set(GAMESCRIPT mwscript/scriptmanager.cpp @@ -162,11 +162,11 @@ set(GAMEMECHANICS_HEADER source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER}) set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD} - ${GAMECLASS} ${GAMEMECHANICS} ${GAMEDIALOG} + ${GAMECLASS} ${GAMEMECHANICS} ${GAMEDIALOGUE} ) set(OPENMW_HEADER ${GAME_HEADER} ${GAMEREND_HEADER} ${GAMEINPUT_HEADER} ${GAMESCRIPT_HEADER} ${GAMESOUND_HEADER} ${GAMEGUI_HEADER} ${GAMEWORLD_HEADER} ${GAMECLASS_HEADER} - ${GAMEMECHANICS_HEADER} ${GAMEDIALOG_HEADER} + ${GAMEMECHANICS_HEADER} ${GAMEDIALOG_HEADERUE} ) # Main executable diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 2cd738623..35200b2d1 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -28,7 +28,7 @@ #include "mwclass/classes.hpp" -#include "mwdialog/dialogmanager.hpp" +#include "mwdialogue/dialoguemanager.hpp" #include "mwmechanics/mechanicsmanager.hpp" diff --git a/apps/openmw/mwdialog/dialogmanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp similarity index 91% rename from apps/openmw/mwdialog/dialogmanager.cpp rename to apps/openmw/mwdialogue/dialoguemanager.cpp index 2dfaebb76..d00c0aa83 100644 --- a/apps/openmw/mwdialog/dialogmanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -1,5 +1,5 @@ -#include "dialogmanager.hpp" +#include "dialoguemanager.hpp" #include "../mwworld/class.hpp" diff --git a/apps/openmw/mwdialog/dialogmanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp similarity index 100% rename from apps/openmw/mwdialog/dialogmanager.hpp rename to apps/openmw/mwdialogue/dialoguemanager.hpp From c806415f08389034a12036c12740a6f115a6e3f3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Aug 2010 19:16:44 +0200 Subject: [PATCH 06/23] changed namespace, class and function names to ensure consistent spelling --- apps/openmw/engine.cpp | 4 ++-- apps/openmw/mwdialogue/dialoguemanager.cpp | 6 +++--- apps/openmw/mwdialogue/dialoguemanager.hpp | 12 ++++++------ apps/openmw/mwworld/environment.hpp | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 35200b2d1..396e4bad1 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -119,7 +119,7 @@ OMW::Engine::~Engine() delete mEnvironment.mSoundManager; delete mEnvironment.mGlobalScripts; delete mEnvironment.mMechanicsManager; - delete mEnvironment.mDialogManager; + delete mEnvironment.mDialogueManager; delete mScriptManager; delete mScriptContext; } @@ -254,7 +254,7 @@ void OMW::Engine::go() mEnvironment.mWorld->getStore(), *mEnvironment.mWindowManager); // Create dialog system - mEnvironment.mDialogManager = new MWDialog::DialogManager (mEnvironment); + mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment); // load cell ESM::Position pos; diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index d00c0aa83..22602a3f7 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -5,11 +5,11 @@ #include -namespace MWDialog +namespace MWDialogue { - DialogManager::DialogManager (MWWorld::Environment& environment) : mEnvironment (environment) {} + DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {} - void DialogManager::startDialog (const MWWorld::Ptr& actor) + void DialogueManager::startDialogue (const MWWorld::Ptr& actor) { std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 8f4067c9a..b31a3d063 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -1,5 +1,5 @@ -#ifndef GAME_MMDIALOG_DIALOGMANAGER_H -#define GAME_MWDIALOG_DIALOGMANAGER_H +#ifndef GAME_MMDIALOG_DIALOGUEMANAGER_H +#define GAME_MWDIALOG_DIALOGUEMANAGER_H #include "../mwworld/ptr.hpp" @@ -8,17 +8,17 @@ namespace MWWorld class Environment; } -namespace MWDialog +namespace MWDialogue { - class DialogManager + class DialogueManager { MWWorld::Environment& mEnvironment; public: - DialogManager (MWWorld::Environment& environment); + DialogueManager (MWWorld::Environment& environment); - void startDialog (const MWWorld::Ptr& actor); + void startDialogue (const MWWorld::Ptr& actor); }; } diff --git a/apps/openmw/mwworld/environment.hpp b/apps/openmw/mwworld/environment.hpp index 1887e619f..f9e2e8a42 100644 --- a/apps/openmw/mwworld/environment.hpp +++ b/apps/openmw/mwworld/environment.hpp @@ -21,9 +21,9 @@ namespace MWMechanics class MechanicsManager; } -namespace MWDialog +namespace MWDialogue { - class DialogManager; + class DialogueManager; } namespace MWWorld @@ -36,7 +36,7 @@ namespace MWWorld public: Environment() : mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0), - mMechanicsManager (0), mDialogManager (0), mFrameDuration (0) + mMechanicsManager (0), mDialogueManager (0), mFrameDuration (0) {} World *mWorld; @@ -44,7 +44,7 @@ namespace MWWorld MWScript::GlobalScripts *mGlobalScripts; MWGui::WindowManager *mWindowManager; MWMechanics::MechanicsManager *mMechanicsManager; - MWDialog::DialogManager *mDialogManager; + MWDialogue::DialogueManager *mDialogueManager; float mFrameDuration; }; } From b5d59edd446c5c3bbea7cea93c1c0d762b826abf Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Aug 2010 19:25:26 +0200 Subject: [PATCH 07/23] re-routed talk action from gui to dialogue manager (master branch should not incooperate this change, because the dialogue window implementer will need the original code for testing) --- apps/openmw/mwworld/actiontalk.cpp | 4 ++-- apps/openmw/mwworld/actiontalk.hpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/actiontalk.cpp b/apps/openmw/mwworld/actiontalk.cpp index 2b4aba735..7d38c22fd 100644 --- a/apps/openmw/mwworld/actiontalk.cpp +++ b/apps/openmw/mwworld/actiontalk.cpp @@ -3,7 +3,7 @@ #include "environment.hpp" -#include "../mwgui/window_manager.hpp" +#include "../mwdialogue/dialoguemanager.hpp" namespace MWWorld { @@ -11,6 +11,6 @@ namespace MWWorld void ActionTalk::execute (Environment& environment) { - environment.mWindowManager->setMode (MWGui::GM_Dialogue); + environment.mDialogueManager->startDialogue (mActor); } } diff --git a/apps/openmw/mwworld/actiontalk.hpp b/apps/openmw/mwworld/actiontalk.hpp index 034d6131c..a60a61660 100644 --- a/apps/openmw/mwworld/actiontalk.hpp +++ b/apps/openmw/mwworld/actiontalk.hpp @@ -13,6 +13,7 @@ namespace MWWorld public: ActionTalk (const Ptr& actor); + ///< \param actor The actor the player is talking to virtual void execute (Environment& environment); }; From 9d25e74a051837a1f70dc09b35d55573d0941829 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 11:34:03 +0200 Subject: [PATCH 08/23] on dialogue start run through the info records of dialogue record 'hello'; currently no testing done -> the first info recrod will match --- apps/openmw/mwdialogue/dialoguemanager.cpp | 61 ++++++++++++++++++++++ apps/openmw/mwdialogue/dialoguemanager.hpp | 7 +++ 2 files changed, 68 insertions(+) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 22602a3f7..c11e2bb0d 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -1,17 +1,78 @@ #include "dialoguemanager.hpp" +#include +#include + +#include + #include "../mwworld/class.hpp" +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" #include namespace MWDialogue { + bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const + { + // TODO check actor id + // TODO check actor race + // TODO check actor class + // TODO check actor faction + // TODO check player faction + // TODO check cell + // TODO check DATAstruct + // TODO check select structures + + std::cout + << "unchecked entries:" << std::endl + << " actor id: " << info.actor << std::endl + << " actor race: " << info.race << std::endl + << " actor class: " << info.clas << std::endl + << " actor faction: " << info.npcFaction << std::endl + << " player faction: " << info.pcFaction << std::endl + << " cell: " << info.cell << std::endl + << " DATAstruct" << std::endl; + + for (std::vector::const_iterator iter (info.selects.begin()); + iter != info.selects.end(); ++iter) + std::cout << " select: " << iter->selectRule << std::endl; + + return true; + } + DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {} void DialogueManager::startDialogue (const MWWorld::Ptr& actor) { std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; + + const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello"); + + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); + iter!=dialogue->mInfo.end(); ++iter) + { + if (isMatching (actor, *iter)) + { + // start dialogue + std::cout << "found matching info record" << std::endl; + + std::cout << "response: " << iter->response << std::endl; + + if (!iter->sound.empty()) + { + // TODO play sound + } + + if (!iter->resultScript.empty()) + { + // TODO execute script + } + + break; + } + } } } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index b31a3d063..d51570b11 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -3,6 +3,11 @@ #include "../mwworld/ptr.hpp" +namespace ESM +{ + struct DialInfo; +} + namespace MWWorld { class Environment; @@ -14,6 +19,8 @@ namespace MWDialogue { MWWorld::Environment& mEnvironment; + bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; + public: DialogueManager (MWWorld::Environment& environment); From a25c7bb2c07cbf00cb12e0dc8082947c4d1a9d0a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 11:37:59 +0200 Subject: [PATCH 09/23] added test for cell name --- apps/openmw/mwdialogue/dialoguemanager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index c11e2bb0d..941c760e7 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -21,7 +21,12 @@ namespace MWDialogue // TODO check actor class // TODO check actor faction // TODO check player faction - // TODO check cell + + // check cell + if (!info.cell.empty()) + if (mEnvironment.mWorld->getPlayerPos().getPlayer().getCell()->cell->name != info.cell) + return false; + // TODO check DATAstruct // TODO check select structures @@ -32,7 +37,6 @@ namespace MWDialogue << " actor class: " << info.clas << std::endl << " actor faction: " << info.npcFaction << std::endl << " player faction: " << info.pcFaction << std::endl - << " cell: " << info.cell << std::endl << " DATAstruct" << std::endl; for (std::vector::const_iterator iter (info.selects.begin()); From 8f4359db08d7ccce87a6723ba41e24d51afa5276 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 13:21:03 +0200 Subject: [PATCH 10/23] added test for select type '3' (Local) --- apps/openmw/mwdialogue/dialoguemanager.cpp | 110 +++++++++++++++++++-- apps/openmw/mwdialogue/dialoguemanager.hpp | 9 +- 2 files changed, 108 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 941c760e7..4f9cf602f 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -1,7 +1,6 @@ #include "dialoguemanager.hpp" -#include #include #include @@ -9,11 +8,110 @@ #include "../mwworld/class.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "../mwworld/refdata.hpp" #include +namespace +{ + template + bool selectCompare (char comp, T1 value1, T2 value2) + { + switch (comp) + { + case '0': return value1==value2; + case '1': return value1!=value2; + case '2': return value1>value2; + case '3': return value1>=value2; + case '4': return value1 + bool checkLocal (char comp, const std::string& name, T value, const MWWorld::Ptr& actor, + const ESMS::ESMStore& store) + { + std::string scriptName = MWWorld::Class::get (actor).getScript (actor); + + if (scriptName.empty()) + return false; // no script + + const ESM::Script *script = store.scripts.find (scriptName); + + int i = 0; + + for (; i (script->varNames.size()); ++i) + if (script->varNames[i]==name) + break; + + if (i>=static_cast (script->varNames.size())) + return false; // script does not have a variable of this name + + const MWScript::Locals& locals = actor.getRefData().getLocals(); + + if (idata.numShorts) + return selectCompare (comp, locals.mShorts[i], value); + else + i -= script->data.numShorts; + + if (idata.numLongs) + return selectCompare (comp, locals.mLongs[i], value); + else + i -= script->data.numShorts; + + return selectCompare (comp, locals.mFloats.at (i), value); + } +} + namespace MWDialogue { + bool DialogueManager::isMatching (const MWWorld::Ptr& actor, + const ESM::DialInfo::SelectStruct& select) const + { + char type = select.selectRule[1]; + + if (type!='0') + { + char comp = select.selectRule[4]; + std::string name = select.selectRule.substr (5); + + // TODO types 1, 2, 4, 5, 6, 7, 8, 9, A, B, C + + switch (type) + { + case '3': // local + + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (!checkLocal (comp, name, select.i, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (!checkLocal (comp, name, select.f, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + default: + + std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl; + } + } + + return true; + } + bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const { // TODO check actor id @@ -28,7 +126,11 @@ namespace MWDialogue return false; // TODO check DATAstruct - // TODO check select structures + + for (std::vector::const_iterator iter (info.selects.begin()); + iter != info.selects.end(); ++iter) + if (!isMatching (actor, *iter)) + return false; std::cout << "unchecked entries:" << std::endl @@ -39,10 +141,6 @@ namespace MWDialogue << " player faction: " << info.pcFaction << std::endl << " DATAstruct" << std::endl; - for (std::vector::const_iterator iter (info.selects.begin()); - iter != info.selects.end(); ++iter) - std::cout << " select: " << iter->selectRule << std::endl; - return true; } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index d51570b11..5b6b26240 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -1,12 +1,9 @@ #ifndef GAME_MMDIALOG_DIALOGUEMANAGER_H #define GAME_MWDIALOG_DIALOGUEMANAGER_H -#include "../mwworld/ptr.hpp" +#include -namespace ESM -{ - struct DialInfo; -} +#include "../mwworld/ptr.hpp" namespace MWWorld { @@ -19,6 +16,8 @@ namespace MWDialogue { MWWorld::Environment& mEnvironment; + bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const; + bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; public: From 2acfe2297538e674f9889d77a4b0d72f46f699b3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 14:28:35 +0200 Subject: [PATCH 11/23] added test for actor ID --- apps/openmw/mwclass/creature.cpp | 8 ++++++++ apps/openmw/mwclass/creature.hpp | 3 +++ apps/openmw/mwclass/npc.cpp | 8 ++++++++ apps/openmw/mwclass/npc.hpp | 3 +++ apps/openmw/mwdialogue/dialoguemanager.cpp | 7 +++++-- apps/openmw/mwworld/class.cpp | 5 +++++ apps/openmw/mwworld/class.hpp | 4 ++++ 7 files changed, 36 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 4529094ec..1cdada64c 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -10,6 +10,14 @@ namespace MWClass { + std::string Creature::getId (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->mId; + } + std::string Creature::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index e964a7708..85a89a919 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -9,6 +9,9 @@ namespace MWClass { public: + virtual std::string getId (const MWWorld::Ptr& ptr) const; + ///< Return ID of \a ptr + virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index ae647c802..b6a4bbc05 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -10,6 +10,14 @@ namespace MWClass { + std::string Npc::getId (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return ref->base->mId; + } + std::string Npc::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 2ef37193a..a6f4a2965 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -9,6 +9,9 @@ namespace MWClass { public: + virtual std::string getId (const MWWorld::Ptr& ptr) const; + ///< Return ID of \a ptr + virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 4f9cf602f..3c3a60180 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -114,7 +114,11 @@ namespace MWDialogue bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const { - // TODO check actor id + // actor id + if (!info.actor.empty()) + if (info.actor!=MWWorld::Class::get (actor).getId (actor)) + return false; + // TODO check actor race // TODO check actor class // TODO check actor faction @@ -134,7 +138,6 @@ namespace MWDialogue std::cout << "unchecked entries:" << std::endl - << " actor id: " << info.actor << std::endl << " actor race: " << info.race << std::endl << " actor class: " << info.clas << std::endl << " actor faction: " << info.npcFaction << std::endl diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 85e5140ea..62e0ee8c9 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -14,6 +14,11 @@ namespace MWWorld Class::~Class() {} + std::string Class::getId (const Ptr& ptr) const + { + throw std::runtime_error ("class does not support ID retrieval"); + } + MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const { throw std::runtime_error ("class does not have creature stats"); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 28d96d69f..d456cc06b 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -36,6 +36,10 @@ namespace MWWorld virtual ~Class(); + virtual std::string getId (const Ptr& ptr) const; + ///< Return ID of \a ptr or throw an exception, if class does not support ID retrieval + /// (default implementation: throw an exception) + virtual std::string getName (const Ptr& ptr) const = 0; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. From c7fab9aad6ae1d7231a589c9ed6b39dbb5d83112 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 14:36:45 +0200 Subject: [PATCH 12/23] added test for actor race --- apps/openmw/mwdialogue/dialoguemanager.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 3c3a60180..26f58dfd2 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -119,7 +119,17 @@ namespace MWDialogue if (info.actor!=MWWorld::Class::get (actor).getId (actor)) return false; - // TODO check actor race + if (!info.race.empty()) + { + ESMS::LiveCellRef *cellRef = actor.get(); + + if (!cellRef) + return false; + + if (info.race!=cellRef->base->race) + return false; + } + // TODO check actor class // TODO check actor faction // TODO check player faction @@ -138,7 +148,6 @@ namespace MWDialogue std::cout << "unchecked entries:" << std::endl - << " actor race: " << info.race << std::endl << " actor class: " << info.clas << std::endl << " actor faction: " << info.npcFaction << std::endl << " player faction: " << info.pcFaction << std::endl From fbe11956a6747e49d5f701ecdebe984384710588 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 14:43:20 +0200 Subject: [PATCH 13/23] added dummy test for select type '1' (Function); always yields false for now --- apps/openmw/mwdialogue/dialoguemanager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 26f58dfd2..11a1cec08 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -82,6 +82,10 @@ namespace MWDialogue switch (type) { + case '1': // function + + return false; // TODO implement functions + case '3': // local if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || From 11bc13141741f676d8a3b94a2bb0d3a05e5fae3a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 15:09:44 +0200 Subject: [PATCH 14/23] added test for global variables --- apps/openmw/mwdialogue/dialoguemanager.cpp | 74 ++++++++++++++++++++-- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 11a1cec08..a862af06d 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -1,6 +1,10 @@ #include "dialoguemanager.hpp" +#include +#include +#include + #include #include @@ -14,6 +18,16 @@ namespace { + std::string toLower (const std::string& name) + { + std::string lowerCase; + + std::transform (name.begin(), name.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + return lowerCase; + } + template bool selectCompare (char comp, T1 value1, T2 value2) { @@ -64,6 +78,36 @@ namespace return selectCompare (comp, locals.mFloats.at (i), value); } + + template + bool checkGlobal (char comp, const std::string& name, T value, MWWorld::World& world) + { + switch (world.getGlobalVariableType (name)) + { + case 's': + + return selectCompare (comp, value, world.getGlobalVariable (name).mShort); + + case 'l': + + return selectCompare (comp, value, world.getGlobalVariable (name).mLong); + + case 'f': + + return selectCompare (comp, value, world.getGlobalVariable (name).mFloat); + + case ' ': + + world.getGlobalVariable (name); // trigger exception + break; + + default: + + throw std::runtime_error ("unsupported gobal variable type"); + } + + return false; + } } namespace MWDialogue @@ -78,7 +122,7 @@ namespace MWDialogue char comp = select.selectRule[4]; std::string name = select.selectRule.substr (5); - // TODO types 1, 2, 4, 5, 6, 7, 8, 9, A, B, C + // TODO types 4, 5, 6, 7, 8, 9, A, B, C switch (type) { @@ -86,18 +130,37 @@ namespace MWDialogue return false; // TODO implement functions + case '2': // global + + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld)) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + case '3': // local if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || select.type==ESM::VT_Long) { - if (!checkLocal (comp, name, select.i, actor, + if (!checkLocal (comp, toLower (name), select.i, actor, mEnvironment.mWorld->getStore())) return false; } else if (select.type==ESM::VT_Float) { - if (!checkLocal (comp, name, select.f, actor, + if (!checkLocal (comp, toLower (name), select.f, actor, mEnvironment.mWorld->getStore())) return false; } @@ -120,7 +183,7 @@ namespace MWDialogue { // actor id if (!info.actor.empty()) - if (info.actor!=MWWorld::Class::get (actor).getId (actor)) + if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) return false; if (!info.race.empty()) @@ -130,7 +193,7 @@ namespace MWDialogue if (!cellRef) return false; - if (info.race!=cellRef->base->race) + if (toLower (info.race)!=toLower (cellRef->base->race)) return false; } @@ -185,6 +248,7 @@ namespace MWDialogue if (!iter->resultScript.empty()) { + std::cout << "script: " << iter->resultScript << std::endl; // TODO execute script } From 594d3cef4f9f16318e978cb38748ac14bbd6a330 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 15:12:53 +0200 Subject: [PATCH 15/23] added test for actor class --- apps/openmw/mwdialogue/dialoguemanager.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index a862af06d..4f99d3a05 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -197,7 +197,17 @@ namespace MWDialogue return false; } - // TODO check actor class + if (!info.clas.empty()) + { + ESMS::LiveCellRef *cellRef = actor.get(); + + if (!cellRef) + return false; + + if (toLower (info.clas)!=toLower (cellRef->base->cls)) + return false; + } + // TODO check actor faction // TODO check player faction @@ -215,7 +225,6 @@ namespace MWDialogue std::cout << "unchecked entries:" << std::endl - << " actor class: " << info.clas << std::endl << " actor faction: " << info.npcFaction << std::endl << " player faction: " << info.pcFaction << std::endl << " DATAstruct" << std::endl; From 19c5ace6029ac2124915f030932858c1b7f039bc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 8 Aug 2010 15:17:49 +0200 Subject: [PATCH 16/23] added test for actor faction --- apps/openmw/mwdialogue/dialoguemanager.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 4f99d3a05..cbb48c6db 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -208,7 +208,17 @@ namespace MWDialogue return false; } - // TODO check actor faction + if (!info.npcFaction.empty()) + { + ESMS::LiveCellRef *cellRef = actor.get(); + + if (!cellRef) + return false; + + if (toLower (info.npcFaction)!=toLower (cellRef->base->faction)) + return false; + } + // TODO check player faction // check cell @@ -225,7 +235,6 @@ namespace MWDialogue std::cout << "unchecked entries:" << std::endl - << " actor faction: " << info.npcFaction << std::endl << " player faction: " << info.pcFaction << std::endl << " DATAstruct" << std::endl; From e42f1bbc11cadcd2ffe672c78ccde52e452d6bd5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 18 Aug 2010 09:19:16 +0200 Subject: [PATCH 17/23] open dialogue window, if a matching greetings info record is found --- apps/openmw/mwdialogue/dialoguemanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index cbb48c6db..85a955992 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -14,6 +14,8 @@ #include "../mwworld/world.hpp" #include "../mwworld/refdata.hpp" +#include "../mwgui/window_manager.hpp" + #include namespace @@ -270,7 +272,7 @@ namespace MWDialogue // TODO execute script } - break; + mEnvironment.mWindowManager->setMode (MWGui::GM_Dialogue); } } } From 62586543833981c2ca396b94bbe591b5f3e56ed7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 18 Aug 2010 09:32:36 +0200 Subject: [PATCH 18/23] fixed a very sloppy merge --- apps/openmw/mwclass/npc.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index a12d939d8..3bc005b06 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -98,15 +98,12 @@ namespace MWClass return *ptr.getRefData().getCreatureStats(); } -<<<<<<< HEAD:apps/openmw/mwclass/npc.cpp -======= boost::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const { return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); } ->>>>>>> master:apps/openmw/mwclass/npc.cpp MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) const { @@ -121,12 +118,6 @@ namespace MWClass } return *ptr.getRefData().getContainerStore(); - } - - boost::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const - { - return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); } std::string Npc::getScript (const MWWorld::Ptr& ptr) const From ef9ed99622a5e3984c9f98ea07313d348628be93 Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Wed, 18 Aug 2010 10:49:45 +0200 Subject: [PATCH 19/23] Mangle update (not important) --- libs/mangle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/mangle b/libs/mangle index cd4ed4e6b..27bef8409 160000 --- a/libs/mangle +++ b/libs/mangle @@ -1 +1 @@ -Subproject commit cd4ed4e6bfb23d736c4b1f30d6096ec164ba937b +Subproject commit 27bef840916581c0dd85b9c8b6ab4109e000dbac From 4f3f1740169bc03e731fe68429e2f85d3f174a2c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 18 Aug 2010 11:06:41 +0200 Subject: [PATCH 20/23] fixed a dialogue bug --- apps/openmw/mwdialogue/dialoguemanager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 85a955992..ab369288e 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -273,6 +273,7 @@ namespace MWDialogue } mEnvironment.mWindowManager->setMode (MWGui::GM_Dialogue); + break; } } } From 31017447eb1d65b3ff66dd8931781e2c394fd65a Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Wed, 18 Aug 2010 11:16:15 +0200 Subject: [PATCH 21/23] Added --nosound switch --- apps/openmw/engine.cpp | 4 +++- apps/openmw/engine.hpp | 4 ++++ apps/openmw/main.cpp | 4 ++++ apps/openmw/mwsound/soundmanager.cpp | 25 ++++++++++++++++++++++--- apps/openmw/mwsound/soundmanager.hpp | 2 +- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 8c5ee33f7..bcf2de40d 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -106,6 +106,7 @@ OMW::Engine::Engine() : mDebug (false) , mVerboseScripts (false) , mNewGame (false) + , mUseSound (true) , mScriptManager (0) , mScriptContext (0) { @@ -239,7 +240,8 @@ void OMW::Engine::go() mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(), mOgre.getCamera(), mEnvironment.mWorld->getStore(), - (mDataDir / "Sound").file_string()); + (mDataDir / "Sound").file_string(), + mUseSound); // Create script system mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full, diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index bc612d13c..d7420889f 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -59,6 +59,7 @@ namespace OMW bool mDebug; bool mVerboseScripts; bool mNewGame; + bool mUseSound; MWWorld::Environment mEnvironment; MWScript::ScriptManager *mScriptManager; @@ -115,6 +116,9 @@ namespace OMW /// Enable verbose script output void enableVerboseScripts(); + /// Disable all sound + void disableSound() { mUseSound = false; } + /// Start as a new game. void setNewGame(); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index ff3f32e3d..b622b1f27 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -31,6 +31,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) ("master", bpo::value()->default_value ("Morrowind"), "master file") ( "debug", "debug mode" ) + ( "nosound", "disable all sound" ) ( "script-verbose", "verbose script output" ) ( "new-game", "activate char gen/new game mechanics" ) ; @@ -64,6 +65,9 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) if (variables.count ("debug")) engine.enableDebugMode(); + + if (variables.count ("nosound")) + engine.disableSound(); if (variables.count ("script-verbose")) engine.enableVerboseScripts(); diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index f8f5eeb00..f9f3dc9cb 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -150,29 +150,37 @@ namespace MWSound SoundManager::SoundManager(Ogre::Root *root, Ogre::Camera *camera, const ESMS::ESMStore &store, - const std::string &soundDir) + const std::string &soundDir, + bool useSound) + : mData(NULL) { - mData = new SoundImpl(root, camera, store, soundDir); + if(useSound) + mData = new SoundImpl(root, camera, store, soundDir); } SoundManager::~SoundManager() { - delete mData; + if(mData) + delete mData; } void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename) { // The range values are not tested + if(!mData) return; mData->add(filename, ptr, "_say_sound", 1, 1, 100, 10000, false); } bool SoundManager::sayDone (MWWorld::Ptr ptr) const { + if(!mData) return false; return !mData->isPlaying(ptr, "_say_sound"); } void SoundManager::streamMusic (const std::string& filename) { + if(!mData) return; + // Play the sound and tell it to stream, if possible. TODO: // Store the reference, the jukebox will need to check status, // control volume etc. @@ -184,6 +192,8 @@ namespace MWSound void SoundManager::playSound (const std::string& soundId, float volume, float pitch) { + if(!mData) return; + // Play and forget float min, max; const std::string &file = mData->lookup(soundId, volume, min, max); @@ -199,6 +209,8 @@ namespace MWSound void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId, float volume, float pitch, bool loop) { + if(!mData) return; + // Look up the sound in the ESM data float min, max; const std::string &file = mData->lookup(soundId, volume, min, max); @@ -208,21 +220,28 @@ namespace MWSound void SoundManager::stopSound3D (MWWorld::Ptr ptr, const std::string& soundId) { + if(!mData) return; mData->remove(ptr, soundId); } void SoundManager::stopSound (MWWorld::Ptr::CellStore *cell) { + if(!mData) return; mData->removeCell(cell); } bool SoundManager::getSoundPlaying (MWWorld::Ptr ptr, const std::string& soundId) const { + // Mark all sounds as playing, otherwise the scripts will just + // keep trying to play them every frame. + if(!mData) return true; + return mData->isPlaying(ptr, soundId); } void SoundManager::updateObject(MWWorld::Ptr ptr) { + if(!mData) return; mData->updatePositions(ptr); } } diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 9b4745203..9f99b34b2 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -28,7 +28,7 @@ namespace MWSound public: SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store, - const std::string &soundDir); + const std::string &soundDir, bool useSound); ~SoundManager(); void say (MWWorld::Ptr reference, const std::string& filename); From 65c2070086aaec0cd60f6fc48d39ec5aa035ee3b Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Wed, 18 Aug 2010 13:05:31 +0200 Subject: [PATCH 22/23] Temporarily disabled music --- apps/openmw/mwsound/soundmanager.cpp | 6 ++++++ libs/mangle | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index f9f3dc9cb..1b21660fc 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -181,6 +181,12 @@ namespace MWSound { if(!mData) return; +#ifdef OPENMW_USE_MPG123 + // Disable music + cout << " - music is temporarily disabled -\n"; + return; +#endif + // Play the sound and tell it to stream, if possible. TODO: // Store the reference, the jukebox will need to check status, // control volume etc. diff --git a/libs/mangle b/libs/mangle index 27bef8409..200fab03e 160000 --- a/libs/mangle +++ b/libs/mangle @@ -1 +1 @@ -Subproject commit 27bef840916581c0dd85b9c8b6ab4109e000dbac +Subproject commit 200fab03efaa2cbe1b8fce4a742b0195f8912295 From 9a5e7816eb7f51c309df411d4f84173aacd05ba3 Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Wed, 18 Aug 2010 14:50:49 +0200 Subject: [PATCH 23/23] Renabled music. WILL CRASH WITH MPG123 v1.12.1. --- apps/openmw/mwsound/soundmanager.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 1b21660fc..f800a39e3 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -20,16 +20,22 @@ using namespace std; #ifdef OPENMW_USE_AUDIERE #include #define SOUND_FACTORY OpenAL_Audiere_Factory +#define SOUND_OUT "OpenAL" +#define SOUND_IN "Audiere" #endif #ifdef OPENMW_USE_FFMPEG #include #define SOUND_FACTORY OpenAL_FFMpeg_Factory +#define SOUND_OUT "OpenAL" +#define SOUND_IN "FFmpeg" #endif #ifdef OPENMW_USE_MPG123 #include #define SOUND_FACTORY OpenAL_SndFile_Mpg123_Factory +#define SOUND_OUT "OpenAL" +#define SOUND_IN "mpg123,sndfile" #endif using namespace Mangle::Sound; @@ -77,6 +83,9 @@ namespace MWSound , cameraTracker(mgr) , store(str) { + cout << "Sound output: " << SOUND_OUT << endl; + cout << "Sound decoder: " << SOUND_IN << endl; + // Attach the camera to the camera tracker cameraTracker.followCamera(camera); @@ -181,12 +190,6 @@ namespace MWSound { if(!mData) return; -#ifdef OPENMW_USE_MPG123 - // Disable music - cout << " - music is temporarily disabled -\n"; - return; -#endif - // Play the sound and tell it to stream, if possible. TODO: // Store the reference, the jukebox will need to check status, // control volume etc.