2014-02-16 12:54:27 +01:00
|
|
|
#include "dialoguestate.hpp"
|
|
|
|
|
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
|
|
|
|
2022-04-12 00:18:39 +02:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
|
|
|
|
void DialogueState::load(ESMReader& esm)
|
2014-05-27 14:54:29 +02:00
|
|
|
{
|
2014-02-16 12:54:27 +01:00
|
|
|
while (esm.isNextSub("TOPI"))
|
2014-05-27 14:54:29 +02:00
|
|
|
mKnownTopics.push_back(esm.getHString());
|
|
|
|
|
2015-01-19 23:55:17 +01:00
|
|
|
while (esm.isNextSub("FACT"))
|
2014-05-27 14:54:29 +02:00
|
|
|
{
|
2015-01-19 23:55:17 +01:00
|
|
|
std::string faction = esm.getHString();
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2014-05-27 14:54:29 +02:00
|
|
|
while (esm.isNextSub("REA2"))
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2014-05-27 14:54:29 +02:00
|
|
|
std::string faction2 = esm.getHString();
|
|
|
|
int reaction;
|
|
|
|
esm.getHNT(reaction, "INTV");
|
2015-01-19 23:55:17 +01:00
|
|
|
mChangedFactionReaction[faction][faction2] = reaction;
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2015-01-19 23:55:17 +01:00
|
|
|
// no longer used
|
|
|
|
while (esm.isNextSub("REAC"))
|
|
|
|
{
|
|
|
|
esm.skipHSub();
|
2015-01-24 14:32:02 +01:00
|
|
|
esm.getSubName();
|
2015-01-19 23:55:17 +01:00
|
|
|
esm.skipHSub();
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-05-27 14:54:29 +02:00
|
|
|
}
|
|
|
|
}
|
2014-02-16 12:54:27 +01:00
|
|
|
|
2022-04-12 00:18:39 +02:00
|
|
|
void DialogueState::save(ESMWriter& esm) const
|
2014-02-16 12:54:27 +01:00
|
|
|
{
|
2015-01-19 23:55:17 +01:00
|
|
|
for (std::vector<std::string>::const_iterator iter(mKnownTopics.begin()); iter != mKnownTopics.end(); ++iter)
|
2014-05-27 14:54:29 +02:00
|
|
|
{
|
|
|
|
esm.writeHNString("TOPI", *iter);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-02-16 12:54:27 +01:00
|
|
|
|
2014-05-27 14:54:29 +02:00
|
|
|
for (std::map<std::string, std::map<std::string, int>>::const_iterator iter = mChangedFactionReaction.begin();
|
|
|
|
iter != mChangedFactionReaction.end(); ++iter)
|
|
|
|
{
|
2014-02-16 12:54:27 +01:00
|
|
|
esm.writeHNString("FACT", iter->first);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2015-01-19 23:55:17 +01:00
|
|
|
for (std::map<std::string, int>::const_iterator reactIter = iter->second.begin();
|
|
|
|
reactIter != iter->second.end(); ++reactIter)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2015-01-19 23:55:17 +01:00
|
|
|
esm.writeHNString("REA2", reactIter->first);
|
2014-05-27 14:54:29 +02:00
|
|
|
esm.writeHNT("INTV", reactIter->second);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-05-27 14:54:29 +02:00
|
|
|
}
|
2014-02-16 12:54:27 +01:00
|
|
|
}
|
2022-04-12 00:18:39 +02:00
|
|
|
|
|
|
|
}
|