diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 08c6a7284..ea7487095 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -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,