forked from mirror/openmw-tes3mp
[Client] Only send PlayerJournal packets for new journal entries
This commit is contained in:
parent
6918ae7bc7
commit
7f6c5e2f48
4 changed files with 43 additions and 4 deletions
|
@ -50,6 +50,16 @@ namespace MWBase
|
|||
|
||||
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;
|
||||
///< Add a journal entry.
|
||||
/// @param actor Used as context for replacing of escape sequences (%name, etc).
|
||||
|
|
|
@ -75,6 +75,24 @@ namespace MWDialogue
|
|||
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)
|
||||
{
|
||||
// bail out of we already have heard this...
|
||||
|
|
|
@ -29,6 +29,16 @@ namespace MWDialogue
|
|||
|
||||
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);
|
||||
///< Add a journal entry.
|
||||
/// @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? :(
|
||||
try
|
||||
{
|
||||
MWBase::Environment::get().getJournal()->addEntry (quest, index, ptr);
|
||||
|
||||
/*
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getJournal()->addEntry (quest, index, ptr);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue