2012-08-09 12:56:03 +02:00
|
|
|
#include "journalimp.hpp"
|
2011-04-04 11:16:56 +02:00
|
|
|
|
2013-12-03 14:28:46 +01:00
|
|
|
#include <iterator>
|
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/esmreader.hpp>
|
|
|
|
#include <components/esm3/esmwriter.hpp>
|
|
|
|
#include <components/esm3/journalentry.hpp>
|
|
|
|
#include <components/esm3/queststate.hpp>
|
2013-12-03 14:28:46 +01:00
|
|
|
|
2022-08-03 00:00:54 +02:00
|
|
|
#include <components/misc/strings/algorithm.hpp>
|
2022-02-12 13:25:27 +01:00
|
|
|
|
2014-06-10 15:42:50 +02:00
|
|
|
#include "../mwworld/class.hpp"
|
2012-10-01 19:17:04 +04:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-08-12 14:36:46 +02:00
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-08-12 18:11:09 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
#include "../mwbase/world.hpp"
|
2011-04-04 11:23:15 +02:00
|
|
|
|
2011-04-04 11:16:56 +02:00
|
|
|
namespace MWDialogue
|
|
|
|
{
|
2023-07-01 01:30:25 +02:00
|
|
|
Quest& Journal::getOrStartQuest(const ESM::RefId& id)
|
2011-04-26 20:08:37 +02:00
|
|
|
{
|
|
|
|
TQuestContainer::iterator iter = mQuests.find(id);
|
|
|
|
|
|
|
|
if (iter == mQuests.end())
|
2023-07-01 01:30:25 +02:00
|
|
|
iter = mQuests.emplace(id, Quest(id)).first;
|
2011-04-26 20:08:37 +02:00
|
|
|
|
|
|
|
return iter->second;
|
|
|
|
}
|
2023-07-01 01:30:25 +02:00
|
|
|
|
|
|
|
Quest* Journal::getQuestOrNull(const ESM::RefId& id)
|
2023-06-12 21:35:00 -05:00
|
|
|
{
|
|
|
|
TQuestContainer::iterator iter = mQuests.find(id);
|
|
|
|
if (iter == mQuests.end())
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &(iter->second);
|
|
|
|
}
|
2011-04-26 20:08:37 +02:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
Topic& Journal::getTopic(const ESM::RefId& id)
|
2013-12-03 14:28:46 +01:00
|
|
|
{
|
|
|
|
TTopicContainer::iterator iter = mTopics.find(id);
|
|
|
|
|
|
|
|
if (iter == mTopics.end())
|
|
|
|
{
|
|
|
|
std::pair<TTopicContainer::iterator, bool> result = mTopics.insert(std::make_pair(id, Topic(id)));
|
|
|
|
|
|
|
|
iter = result.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iter->second;
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
bool Journal::isThere(const ESM::RefId& topicId, const ESM::RefId& infoId) const
|
2013-12-03 14:39:54 +01:00
|
|
|
{
|
|
|
|
if (const ESM::Dialogue* dialogue
|
2023-04-20 21:07:53 +02:00
|
|
|
= MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(topicId))
|
2013-12-03 14:39:54 +01:00
|
|
|
{
|
|
|
|
if (infoId.empty())
|
|
|
|
return true;
|
|
|
|
|
2014-02-20 16:59:20 +01:00
|
|
|
for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin());
|
2013-12-03 14:39:54 +01:00
|
|
|
iter != dialogue->mInfo.end(); ++iter)
|
|
|
|
if (iter->mId == infoId)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-03 14:28:46 +01:00
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
Journal::Journal() {}
|
2011-04-04 11:16:56 +02:00
|
|
|
|
2013-05-15 17:54:18 +02:00
|
|
|
void Journal::clear()
|
|
|
|
{
|
|
|
|
mJournal.clear();
|
|
|
|
mQuests.clear();
|
|
|
|
mTopics.clear();
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void Journal::addEntry(const ESM::RefId& id, int index, const MWWorld::Ptr& actor)
|
2011-04-04 11:23:15 +02:00
|
|
|
{
|
2017-10-22 19:30:55 +02:00
|
|
|
// bail out if we already have heard this...
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& infoId = JournalEntry::idFromIndex(id, index);
|
2013-01-20 14:24:55 +00:00
|
|
|
for (TEntryIter i = mJournal.begin(); i != mJournal.end(); ++i)
|
2013-01-19 16:21:15 -08:00
|
|
|
if (i->mTopic == id && i->mInfoId == infoId)
|
2017-10-22 19:30:55 +02:00
|
|
|
{
|
2017-10-24 20:02:35 +00:00
|
|
|
if (getJournalIndex(id) < index)
|
2018-02-18 16:01:50 +03:00
|
|
|
{
|
2017-10-24 20:02:35 +00:00
|
|
|
setJournalIndex(id, index);
|
2018-02-18 16:01:50 +03:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sJournalEntry}");
|
|
|
|
}
|
2013-01-19 16:21:15 -08:00
|
|
|
return;
|
2017-10-22 19:30:55 +02:00
|
|
|
}
|
2013-01-19 16:21:15 -08:00
|
|
|
|
2016-01-11 23:07:01 +01:00
|
|
|
StampedJournalEntry entry = StampedJournalEntry::makeFromQuest(id, index, actor);
|
2011-04-26 20:08:37 +02:00
|
|
|
|
2023-07-01 01:30:25 +02:00
|
|
|
Quest& quest = getOrStartQuest(id);
|
2022-02-12 13:25:27 +01:00
|
|
|
if (quest.addEntry(entry)) // we are doing slicing on purpose here
|
|
|
|
{
|
|
|
|
// Restart all "other" quests with the same name as well
|
2022-08-24 20:38:52 +02:00
|
|
|
std::string_view name = quest.getName();
|
2022-02-12 13:25:27 +01:00
|
|
|
for (auto& it : mQuests)
|
|
|
|
{
|
|
|
|
if (it.second.isFinished() && Misc::StringUtils::ciEqual(it.second.getName(), name))
|
|
|
|
it.second.setFinished(false);
|
|
|
|
}
|
|
|
|
}
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2017-06-27 15:54:16 +04:00
|
|
|
// there is no need to show empty entries in journal
|
|
|
|
if (!entry.getText().empty())
|
|
|
|
{
|
|
|
|
mJournal.push_back(entry);
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sJournalEntry}");
|
|
|
|
}
|
2011-04-04 11:23:15 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void Journal::setJournalIndex(const ESM::RefId& id, int index)
|
2011-04-04 11:23:15 +02:00
|
|
|
{
|
2023-07-01 01:30:25 +02:00
|
|
|
Quest& quest = getOrStartQuest(id);
|
2011-04-26 20:08:37 +02:00
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
quest.setIndex(index);
|
2011-04-04 11:23:15 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void Journal::addTopic(const ESM::RefId& topicId, const ESM::RefId& infoId, const MWWorld::Ptr& actor)
|
2011-04-26 20:48:36 +02:00
|
|
|
{
|
2013-12-03 14:28:46 +01:00
|
|
|
Topic& topic = getTopic(topicId);
|
2011-04-26 20:48:36 +02:00
|
|
|
|
2014-06-10 15:42:50 +02:00
|
|
|
JournalEntry entry(topicId, infoId, actor);
|
|
|
|
entry.mActorName = actor.getClass().getName(actor);
|
2014-01-25 23:53:50 +01:00
|
|
|
topic.addEntry(entry);
|
2011-04-26 20:48:36 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void Journal::removeLastAddedTopicResponse(const ESM::RefId& topicId, std::string_view actorName)
|
2014-06-10 16:36:22 +02:00
|
|
|
{
|
|
|
|
Topic& topic = getTopic(topicId);
|
|
|
|
|
|
|
|
topic.removeLastAddedResponse(actorName);
|
|
|
|
|
|
|
|
if (topic.begin() == topic.end())
|
|
|
|
mTopics.erase(mTopics.find(topicId)); // All responses removed -> remove topic
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
int Journal::getJournalIndex(const ESM::RefId& id) const
|
2011-04-04 11:23:15 +02:00
|
|
|
{
|
2012-03-18 19:05:35 +01:00
|
|
|
TQuestContainer::const_iterator iter = mQuests.find(id);
|
|
|
|
|
|
|
|
if (iter == mQuests.end())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return iter->second.getIndex();
|
2011-04-04 11:23:15 +02:00
|
|
|
}
|
2011-04-19 11:02:22 +02:00
|
|
|
|
|
|
|
Journal::TEntryIter Journal::begin() const
|
|
|
|
{
|
|
|
|
return mJournal.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
Journal::TEntryIter Journal::end() const
|
|
|
|
{
|
|
|
|
return mJournal.end();
|
|
|
|
}
|
2011-04-26 20:08:37 +02:00
|
|
|
|
|
|
|
Journal::TQuestIter Journal::questBegin() const
|
|
|
|
{
|
|
|
|
return mQuests.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
Journal::TQuestIter Journal::questEnd() const
|
|
|
|
{
|
|
|
|
return mQuests.end();
|
|
|
|
}
|
2011-04-26 20:48:36 +02:00
|
|
|
|
|
|
|
Journal::TTopicIter Journal::topicBegin() const
|
|
|
|
{
|
|
|
|
return mTopics.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
Journal::TTopicIter Journal::topicEnd() const
|
|
|
|
{
|
|
|
|
return mTopics.end();
|
|
|
|
}
|
2013-12-03 14:28:46 +01:00
|
|
|
|
|
|
|
int Journal::countSavedGameRecords() const
|
|
|
|
{
|
|
|
|
int count = static_cast<int>(mQuests.size());
|
|
|
|
|
|
|
|
for (TQuestIter iter(mQuests.begin()); iter != mQuests.end(); ++iter)
|
|
|
|
count += std::distance(iter->second.begin(), iter->second.end());
|
|
|
|
|
|
|
|
count += std::distance(mJournal.begin(), mJournal.end());
|
|
|
|
|
|
|
|
for (TTopicIter iter(mTopics.begin()); iter != mTopics.end(); ++iter)
|
|
|
|
count += std::distance(iter->second.begin(), iter->second.end());
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2014-04-28 11:29:57 +02:00
|
|
|
void Journal::write(ESM::ESMWriter& writer, Loading::Listener& progress) const
|
2013-12-03 14:28:46 +01:00
|
|
|
{
|
|
|
|
for (TQuestIter iter(mQuests.begin()); iter != mQuests.end(); ++iter)
|
|
|
|
{
|
|
|
|
const Quest& quest = iter->second;
|
|
|
|
|
|
|
|
ESM::QuestState state;
|
|
|
|
quest.write(state);
|
|
|
|
writer.startRecord(ESM::REC_QUES);
|
|
|
|
state.save(writer);
|
|
|
|
writer.endRecord(ESM::REC_QUES);
|
|
|
|
|
2016-10-15 00:10:36 +09:00
|
|
|
for (Topic::TEntryIter entryIter(quest.begin()); entryIter != quest.end(); ++entryIter)
|
2013-12-03 14:28:46 +01:00
|
|
|
{
|
|
|
|
ESM::JournalEntry entry;
|
|
|
|
entry.mType = ESM::JournalEntry::Type_Quest;
|
|
|
|
entry.mTopic = quest.getTopic();
|
2016-10-15 00:10:36 +09:00
|
|
|
entryIter->write(entry);
|
2013-12-03 14:28:46 +01:00
|
|
|
writer.startRecord(ESM::REC_JOUR);
|
|
|
|
entry.save(writer);
|
|
|
|
writer.endRecord(ESM::REC_JOUR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TEntryIter iter(mJournal.begin()); iter != mJournal.end(); ++iter)
|
|
|
|
{
|
|
|
|
ESM::JournalEntry entry;
|
|
|
|
entry.mType = ESM::JournalEntry::Type_Journal;
|
|
|
|
iter->write(entry);
|
|
|
|
writer.startRecord(ESM::REC_JOUR);
|
|
|
|
entry.save(writer);
|
|
|
|
writer.endRecord(ESM::REC_JOUR);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TTopicIter iter(mTopics.begin()); iter != mTopics.end(); ++iter)
|
|
|
|
{
|
|
|
|
const Topic& topic = iter->second;
|
|
|
|
|
2016-10-15 00:10:36 +09:00
|
|
|
for (Topic::TEntryIter entryIter(topic.begin()); entryIter != topic.end(); ++entryIter)
|
2013-12-03 14:28:46 +01:00
|
|
|
{
|
|
|
|
ESM::JournalEntry entry;
|
|
|
|
entry.mType = ESM::JournalEntry::Type_Topic;
|
|
|
|
entry.mTopic = topic.getTopic();
|
2016-10-15 00:10:36 +09:00
|
|
|
entryIter->write(entry);
|
2013-12-03 14:28:46 +01:00
|
|
|
writer.startRecord(ESM::REC_JOUR);
|
|
|
|
entry.save(writer);
|
|
|
|
writer.endRecord(ESM::REC_JOUR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-22 19:04:59 +01:00
|
|
|
void Journal::readRecord(ESM::ESMReader& reader, uint32_t type)
|
2013-12-03 14:28:46 +01:00
|
|
|
{
|
2023-11-30 22:08:30 +01:00
|
|
|
if (type == ESM::REC_JOUR)
|
2013-12-03 14:28:46 +01:00
|
|
|
{
|
|
|
|
ESM::JournalEntry record;
|
|
|
|
record.load(reader);
|
|
|
|
|
2013-12-03 14:39:54 +01:00
|
|
|
if (isThere(record.mTopic, record.mInfo))
|
|
|
|
switch (record.mType)
|
|
|
|
{
|
|
|
|
case ESM::JournalEntry::Type_Quest:
|
2013-12-03 14:28:46 +01:00
|
|
|
|
2023-07-01 01:30:25 +02:00
|
|
|
getOrStartQuest(record.mTopic).insertEntry(record);
|
2013-12-03 14:39:54 +01:00
|
|
|
break;
|
2013-12-03 14:28:46 +01:00
|
|
|
|
2013-12-03 14:39:54 +01:00
|
|
|
case ESM::JournalEntry::Type_Journal:
|
2013-12-03 14:28:46 +01:00
|
|
|
|
2013-12-03 14:39:54 +01:00
|
|
|
mJournal.push_back(record);
|
|
|
|
break;
|
2013-12-03 14:28:46 +01:00
|
|
|
|
2013-12-03 14:39:54 +01:00
|
|
|
case ESM::JournalEntry::Type_Topic:
|
2013-12-03 14:28:46 +01:00
|
|
|
|
2013-12-03 14:39:54 +01:00
|
|
|
getTopic(record.mTopic).insertEntry(record);
|
|
|
|
break;
|
|
|
|
}
|
2013-12-03 14:28:46 +01:00
|
|
|
}
|
|
|
|
else if (type == ESM::REC_QUES)
|
|
|
|
{
|
|
|
|
ESM::QuestState record;
|
|
|
|
record.load(reader);
|
|
|
|
|
2013-12-03 14:39:54 +01:00
|
|
|
if (isThere(record.mTopic))
|
2015-01-27 01:53:51 +01:00
|
|
|
{
|
|
|
|
std::pair<TQuestContainer::iterator, bool> result
|
|
|
|
= mQuests.insert(std::make_pair(record.mTopic, record));
|
|
|
|
// reapply quest index, this is to handle users upgrading from only
|
|
|
|
// Morrowind.esm (no quest states) to Morrowind.esm + Tribunal.esm
|
|
|
|
result.first->second.setIndex(record.mState);
|
|
|
|
}
|
2013-12-03 14:28:46 +01:00
|
|
|
}
|
|
|
|
}
|
2011-04-04 11:16:56 +02:00
|
|
|
}
|