[Client] Only send PlayerJournal packets for new journal entries

0.6.1
David Cernat 8 years ago
parent 6918ae7bc7
commit 7f6c5e2f48

@ -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).

@ -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...

@ -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).

@ -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 (...)
{ {

Loading…
Cancel
Save