mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-20 19:39:41 +00:00
[Client] Prevent ObjectState packet spam
This commit is contained in:
parent
b8b3856c73
commit
7173a48f4b
1 changed files with 22 additions and 12 deletions
|
@ -582,47 +582,57 @@ namespace MWScript
|
|||
void InterpreterContext::enable (const std::string& id)
|
||||
{
|
||||
MWWorld::Ptr ref = getReferenceImp (id, false);
|
||||
MWBase::Environment::get().getWorld()->enable (ref);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_STATE packet whenever an object is enabled, as long as
|
||||
the player has finished character generation
|
||||
the player has finished character generation and the object wasn't already
|
||||
enabled previously
|
||||
*/
|
||||
if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen())
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->reset();
|
||||
worldEvent->addObjectState(ref, true);
|
||||
worldEvent->sendObjectState();
|
||||
if (!ref.getRefData().isEnabled())
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->reset();
|
||||
worldEvent->addObjectState(ref, true);
|
||||
worldEvent->sendObjectState();
|
||||
}
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWorld()->enable (ref);
|
||||
}
|
||||
|
||||
void InterpreterContext::disable (const std::string& id)
|
||||
{
|
||||
MWWorld::Ptr ref = getReferenceImp (id, false);
|
||||
MWBase::Environment::get().getWorld()->disable (ref);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_STATE packet whenever an object is disabled, as long as
|
||||
the player has finished character generation
|
||||
the player has finished character generation and the object wasn't already
|
||||
disabled previously
|
||||
*/
|
||||
if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen())
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->reset();
|
||||
worldEvent->addObjectState(ref, false);
|
||||
worldEvent->sendObjectState();
|
||||
if (ref.getRefData().isEnabled())
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->reset();
|
||||
worldEvent->addObjectState(ref, false);
|
||||
worldEvent->sendObjectState();
|
||||
}
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWorld()->disable (ref);
|
||||
}
|
||||
|
||||
int InterpreterContext::getMemberShort (const std::string& id, const std::string& name,
|
||||
|
|
Loading…
Reference in a new issue