[Client] Only send PlayerJournal packets for new journal entries

This commit is contained in:
David Cernat 2017-05-27 22:49:11 +03:00
parent 6918ae7bc7
commit 7f6c5e2f48
4 changed files with 43 additions and 4 deletions

View file

@ -50,6 +50,16 @@ namespace MWBase
virtual ~Journal() {} virtual ~Journal() {}
/*
Start of tes3mp addition
Make it possible to check whether a journal entry already exists from elsewhere in the code
*/
virtual bool hasEntry(const std::string& id, int index) = 0;
/*
End of tes3mp addition
*/
virtual void addEntry (const std::string& id, int index, const MWWorld::Ptr& actor) = 0; virtual void addEntry (const std::string& id, int index, const MWWorld::Ptr& actor) = 0;
///< Add a journal entry. ///< Add a journal entry.
/// @param actor Used as context for replacing of escape sequences (%name, etc). /// @param actor Used as context for replacing of escape sequences (%name, etc).

View file

@ -75,6 +75,24 @@ namespace MWDialogue
mTopics.clear(); mTopics.clear();
} }
/*
Start of tes3mp addition
Make it possible to check whether a journal entry already exists from elsewhere in the code
*/
bool Journal::hasEntry(const std::string& id, int index)
{
std::string infoId = JournalEntry::idFromIndex(id, index);
for (TEntryIter i = mJournal.begin(); i != mJournal.end(); ++i)
if (i->mTopic == id && i->mInfoId == infoId)
return true;
return false;
}
/*
End of tes3mp addition
*/
void Journal::addEntry (const std::string& id, int index, const MWWorld::Ptr& actor) void Journal::addEntry (const std::string& id, int index, const MWWorld::Ptr& actor)
{ {
// bail out of we already have heard this... // bail out of we already have heard this...

View file

@ -29,6 +29,16 @@ namespace MWDialogue
virtual void clear(); virtual void clear();
/*
Start of tes3mp addition
Make it possible to check whether a journal entry already exists from elsewhere in the code
*/
virtual bool hasEntry(const std::string& id, int index);
/*
End of tes3mp addition
*/
virtual void addEntry (const std::string& id, int index, const MWWorld::Ptr& actor); virtual void addEntry (const std::string& id, int index, const MWWorld::Ptr& actor);
///< Add a journal entry. ///< Add a journal entry.
/// @param actor Used as context for replacing of escape sequences (%name, etc). /// @param actor Used as context for replacing of escape sequences (%name, etc).

View file

@ -53,18 +53,19 @@ namespace MWScript
// Invoking Journal with a non-existing index is allowed, and triggers no errors. Seriously? :( // Invoking Journal with a non-existing index is allowed, and triggers no errors. Seriously? :(
try try
{ {
MWBase::Environment::get().getJournal()->addEntry (quest, index, ptr);
/* /*
Start of tes3mp addition Start of tes3mp addition
Send an ID_PLAYER_JOURNAL packet every time a journal entry is added Send an ID_PLAYER_JOURNAL packet every time a new journal entry is added
through a script through a script
*/ */
mwmp::Main::get().getLocalPlayer()->sendJournalEntry(quest, index, ptr); if (!MWBase::Environment::get().getJournal()->hasEntry(quest, index))
mwmp::Main::get().getLocalPlayer()->sendJournalEntry(quest, index, ptr);
/* /*
End of tes3mp addition End of tes3mp addition
*/ */
MWBase::Environment::get().getJournal()->addEntry (quest, index, ptr);
} }
catch (...) catch (...)
{ {