forked from mirror/openmw-tes3mp
store list of known topics in saved game files
This commit is contained in:
parent
6ac64bbe15
commit
9f721fd144
8 changed files with 110 additions and 2 deletions
|
@ -3,6 +3,14 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <libs/platform/stdint.h>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
|
@ -52,6 +60,12 @@ namespace MWBase
|
|||
virtual void persuade (int type) = 0;
|
||||
virtual int getTemporaryDispositionChange () const = 0;
|
||||
virtual void applyDispositionChange (int delta) = 0;
|
||||
|
||||
virtual int countSavedGameRecords() const = 0;
|
||||
|
||||
virtual void write (ESM::ESMWriter& writer) const = 0;
|
||||
|
||||
virtual void readRecord (ESM::ESMReader& reader, int32_t type) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <components/esm/loaddial.hpp>
|
||||
#include <components/esm/loadinfo.hpp>
|
||||
#include <components/esm/dialoguestate.hpp>
|
||||
|
||||
#include <components/compiler/exception.hpp>
|
||||
#include <components/compiler/errorhandler.hpp>
|
||||
|
@ -591,6 +592,41 @@ namespace MWDialogue
|
|||
}
|
||||
}
|
||||
|
||||
int DialogueManager::countSavedGameRecords() const
|
||||
{
|
||||
return 1; // known topics
|
||||
}
|
||||
|
||||
void DialogueManager::write (ESM::ESMWriter& writer) const
|
||||
{
|
||||
ESM::DialogueState state;
|
||||
|
||||
for (std::map<std::string, bool>::const_iterator iter (mKnownTopics.begin());
|
||||
iter!=mKnownTopics.end(); ++iter)
|
||||
if (iter->second)
|
||||
state.mKnownTopics.push_back (iter->first);
|
||||
|
||||
writer.startRecord (ESM::REC_DIAS);
|
||||
state.save (writer);
|
||||
writer.endRecord (ESM::REC_DIAS);
|
||||
}
|
||||
|
||||
void DialogueManager::readRecord (ESM::ESMReader& reader, int32_t type)
|
||||
{
|
||||
if (type==ESM::REC_DIAS)
|
||||
{
|
||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
|
||||
ESM::DialogueState state;
|
||||
state.load (reader);
|
||||
|
||||
for (std::vector<std::string>::const_iterator iter (state.mKnownTopics.begin());
|
||||
iter!=state.mKnownTopics.end(); ++iter)
|
||||
if (store.get<ESM::Dialogue>().search (*iter))
|
||||
mKnownTopics.insert (std::make_pair (*iter, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<HyperTextToken> ParseHyperText(const std::string& text)
|
||||
{
|
||||
|
|
|
@ -78,6 +78,12 @@ namespace MWDialogue
|
|||
virtual void persuade (int type);
|
||||
virtual int getTemporaryDispositionChange () const;
|
||||
virtual void applyDispositionChange (int delta);
|
||||
|
||||
virtual int countSavedGameRecords() const;
|
||||
|
||||
virtual void write (ESM::ESMWriter& writer) const;
|
||||
|
||||
virtual void readRecord (ESM::ESMReader& reader, int32_t type);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -193,7 +193,8 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
|||
+MWBase::Environment::get().getJournal()->countSavedGameRecords()
|
||||
+MWBase::Environment::get().getWorld()->countSavedGameRecords()
|
||||
+MWBase::Environment::get().getScriptManager()->getGlobalScripts().countSavedGameRecords()
|
||||
+ 1 // global map
|
||||
+MWBase::Environment::get().getDialogueManager()->countSavedGameRecords()
|
||||
+1 // global map
|
||||
);
|
||||
|
||||
writer.save (stream);
|
||||
|
@ -203,6 +204,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
|||
writer.endRecord (ESM::REC_SAVE);
|
||||
|
||||
MWBase::Environment::get().getJournal()->write (writer);
|
||||
MWBase::Environment::get().getDialogueManager()->write (writer);
|
||||
MWBase::Environment::get().getWorld()->write (writer);
|
||||
MWBase::Environment::get().getScriptManager()->getGlobalScripts().write (writer);
|
||||
MWBase::Environment::get().getWindowManager()->write(writer);
|
||||
|
@ -245,6 +247,11 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
|
|||
MWBase::Environment::get().getJournal()->readRecord (reader, n.val);
|
||||
break;
|
||||
|
||||
case ESM::REC_DIAS:
|
||||
|
||||
MWBase::Environment::get().getDialogueManager()->readRecord (reader, n.val);
|
||||
break;
|
||||
|
||||
case ESM::REC_ALCH:
|
||||
case ESM::REC_ARMO:
|
||||
case ESM::REC_BOOK:
|
||||
|
|
|
@ -44,7 +44,7 @@ add_component_dir (esm
|
|||
loadinfo loadingr loadland loadlevlist loadligh loadlock loadprob loadrepa loadltex loadmgef loadmisc loadnpcc
|
||||
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
|
||||
loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter
|
||||
savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate
|
||||
savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate dialoguestate
|
||||
)
|
||||
|
||||
add_component_dir (misc
|
||||
|
|
|
@ -91,6 +91,7 @@ enum RecNameInts
|
|||
REC_PLAY = 0x59414c50,
|
||||
REC_CSTA = 0x41545343,
|
||||
REC_GMAP = 0x50414d47,
|
||||
REC_DIAS = 0x53414944,
|
||||
|
||||
// format 1
|
||||
REC_FILT = 0x544C4946
|
||||
|
|
21
components/esm/dialoguestate.cpp
Normal file
21
components/esm/dialoguestate.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
#include "dialoguestate.hpp"
|
||||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
void ESM::DialogueState::load (ESMReader &esm)
|
||||
{
|
||||
while (esm.isNextSub ("TOPI"))
|
||||
mKnownTopics.push_back (esm.getHString());
|
||||
}
|
||||
|
||||
void ESM::DialogueState::save (ESMWriter &esm) const
|
||||
{
|
||||
for (std::vector<std::string>::const_iterator iter (mKnownTopics.begin());
|
||||
iter!=mKnownTopics.end(); ++iter)
|
||||
{
|
||||
esm.writeHNString ("TOPI", *iter);
|
||||
|
||||
}
|
||||
}
|
23
components/esm/dialoguestate.hpp
Normal file
23
components/esm/dialoguestate.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef OPENMW_ESM_DIALOGUESTATE_H
|
||||
#define OPENMW_ESM_DIALOGUESTATE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
|
||||
// format 0, saved games only
|
||||
|
||||
struct DialogueState
|
||||
{
|
||||
std::vector<std::string> mKnownTopics;
|
||||
|
||||
void load (ESMReader &esm);
|
||||
void save (ESMWriter &esm) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue