mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-05 22:19:42 +00:00
[Client] Fix logic for sending ObjectState packets
The previous logic was meant to prevent packet spam from local scripts, but inadvertently prevented objects from being enabled or disabled correctly from dialogue in certain quests. Enabling and disabling objects from dialogue and the console is now always allowed to go through.
This commit is contained in:
parent
3af57f0858
commit
aa92128cf2
1 changed files with 16 additions and 12 deletions
|
@ -195,21 +195,23 @@ namespace MWScript
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_STATE packet whenever an object is enabled, as long as
|
||||
the player is logged in on the server, the object is still disabled, and our last
|
||||
packet regarding its state did not already attempt to enable it (to prevent
|
||||
Send an ID_OBJECT_STATE packet whenever an object should be enabled, as long as the
|
||||
player is logged in on the server and — if triggered from a clientside script — our
|
||||
last packet regarding its state did not already attempt to enable it (to prevent
|
||||
packet spam)
|
||||
*/
|
||||
if (mwmp::Main::get().getLocalPlayer()->isLoggedIn())
|
||||
{
|
||||
if (ptr.isInCell() && !ptr.getRefData().isEnabled() &&
|
||||
ptr.getRefData().getLastCommunicatedState() != MWWorld::RefData::StateCommunication::Enabled)
|
||||
unsigned char packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||
|
||||
if (packetOrigin == Interpreter::Context::CONSOLE || packetOrigin == Interpreter::Context::DIALOGUE ||
|
||||
(ptr.isInCell() && ptr.getRefData().getLastCommunicatedState() != MWWorld::RefData::StateCommunication::Enabled))
|
||||
{
|
||||
ptr.getRefData().setLastCommunicatedState(MWWorld::RefData::StateCommunication::Enabled);
|
||||
|
||||
mwmp::ObjectList* objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||
objectList->reset();
|
||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||
objectList->packetOrigin = packetOrigin;
|
||||
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||
objectList->addObjectState(ptr, true);
|
||||
objectList->sendObjectState();
|
||||
|
@ -244,21 +246,23 @@ namespace MWScript
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_STATE packet whenever an object should be disabled, as long as
|
||||
the player is logged in on the server, the object is still enabled, and our last
|
||||
packet regarding its state did not already attempt to disable it (to prevent
|
||||
Send an ID_OBJECT_STATE packet whenever an object should be disabled, as long as the
|
||||
player is logged in on the server and — if triggered from a clientside script — our
|
||||
last packet regarding its state did not already attempt to disable it (to prevent
|
||||
packet spam)
|
||||
*/
|
||||
if (mwmp::Main::get().getLocalPlayer()->isLoggedIn())
|
||||
{
|
||||
if (ptr.isInCell() && ptr.getRefData().isEnabled() &&
|
||||
ptr.getRefData().getLastCommunicatedState() != MWWorld::RefData::StateCommunication::Disabled)
|
||||
unsigned char packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||
|
||||
if (packetOrigin == Interpreter::Context::CONSOLE || packetOrigin == Interpreter::Context::DIALOGUE ||
|
||||
(ptr.isInCell() && ptr.getRefData().getLastCommunicatedState() != MWWorld::RefData::StateCommunication::Disabled))
|
||||
{
|
||||
ptr.getRefData().setLastCommunicatedState(MWWorld::RefData::StateCommunication::Disabled);
|
||||
|
||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||
objectList->reset();
|
||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||
objectList->packetOrigin = packetOrigin;
|
||||
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||
objectList->addObjectState(ptr, false);
|
||||
objectList->sendObjectState();
|
||||
|
|
Loading…
Reference in a new issue