[Client] Prevent ObjectState packet spam

0.6.1
David Cernat 8 years ago
parent b8b3856c73
commit 7173a48f4b

@ -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…
Cancel
Save