From 6bd777214c535b91048533c792cb2dd499ec6ebf Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Mon, 18 Nov 2013 19:05:34 -0500 Subject: add callbacks to LLAgent for Region and Parcel changes --- indra/newview/llagent.cpp | 48 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'indra/newview/llagent.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 325707bbf1..da29aaff50 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -259,9 +259,9 @@ bool handleSlowMotionAnimation(const LLSD& newvalue) return true; } -// static -void LLAgent::parcelChangedCallback() +void LLAgent::setCanEditParcel() // called via mParcelChangedSignal { + LL_DEBUGS("AgentLocation") << LL_ENDL; bool can_edit = LLToolMgr::getInstance()->canEdit(); gAgent.mCanEditParcel = can_edit; @@ -425,6 +425,8 @@ LLAgent::LLAgent() : mListener.reset(new LLAgentListener(*this)); + addParcelChangedCallback(&setCanEditParcel); + mMoveTimer.stop(); } @@ -451,8 +453,6 @@ void LLAgent::init() mLastKnownRequestMaturity = mLastKnownResponseMaturity; mIsDoSendMaturityPreferenceToServer = true; - LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(boost::bind(&LLAgent::parcelChangedCallback)); - if (!mTeleportFinishedSlot.connected()) { mTeleportFinishedSlot = LLViewerParcelMgr::getInstance()->setTeleportFinishedCallback(boost::bind(&LLAgent::handleTeleportFinished, this)); @@ -835,22 +835,34 @@ void LLAgent::handleServerBakeRegionTransition(const LLUUID& region_id) } } +void LLAgent::changeParcels() +{ + LL_DEBUGS("AgentLocation") << LL_ENDL; + // Notify anything that wants to know about parcel changes + mParcelChangedSignal(); +} + +boost::signals2::connection LLAgent::addParcelChangedCallback(parcel_changed_callback_t cb) +{ + return mParcelChangedSignal.connect(cb); +} + //----------------------------------------------------------------------------- // setRegion() //----------------------------------------------------------------------------- void LLAgent::setRegion(LLViewerRegion *regionp) { bool teleport = true; - + bool notifyRegionChange; + llassert(regionp); if (mRegionp != regionp) { - // std::string host_name; - // host_name = regionp->getHost().getHostName(); - + notifyRegionChange = true; + std::string ip = regionp->getHost().getString(); - llinfos << "Moving agent into region: " << regionp->getName() - << " located at " << ip << llendl; + LL_INFOS("AgentLocation") << "Moving agent into region: " << regionp->getName() + << " located at " << ip << LL_ENDL; if (mRegionp) { // We've changed regions, we're now going to change our agent coordinate frame. @@ -902,6 +914,10 @@ void LLAgent::setRegion(LLViewerRegion *regionp) // Pass new region along to metrics components that care about this level of detail. LLAppViewer::metricsUpdateRegion(regionp->getHandle()); } + else + { + notifyRegionChange = false; + } mRegionp = regionp; // Pass the region host to LLUrlEntryParcel to resolve parcel name @@ -943,6 +959,12 @@ void LLAgent::setRegion(LLViewerRegion *regionp) // Need to handle via callback after caps arrive. mRegionp->setCapabilitiesReceivedCallback(boost::bind(&LLAgent::handleServerBakeRegionTransition,this,_1)); } + + if (notifyRegionChange) + { + LL_DEBUGS("AgentLocation") << "Calling RegionChanged callbacks" << LL_ENDL; + mRegionChangedSignal(); + } } @@ -967,6 +989,12 @@ LLHost LLAgent::getRegionHost() const } } +boost::signals2::connection LLAgent::addRegionChangedCallback(region_changed_callback_t cb) +{ + return mRegionChangedSignal.connect(cb); +} + + //----------------------------------------------------------------------------- // inPrelude() //----------------------------------------------------------------------------- -- cgit v1.2.3 From a5db4f6c3d1f6804c20b3095b39203887728d3a6 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 19 Nov 2013 09:28:58 -0500 Subject: add documentation to LLAgent::addRegionChangedCallback and improve logging --- indra/newview/llagent.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llagent.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index da29aaff50..5302ae2636 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -261,9 +261,7 @@ bool handleSlowMotionAnimation(const LLSD& newvalue) void LLAgent::setCanEditParcel() // called via mParcelChangedSignal { - LL_DEBUGS("AgentLocation") << LL_ENDL; bool can_edit = LLToolMgr::getInstance()->canEdit(); - gAgent.mCanEditParcel = can_edit; } @@ -837,7 +835,7 @@ void LLAgent::handleServerBakeRegionTransition(const LLUUID& region_id) void LLAgent::changeParcels() { - LL_DEBUGS("AgentLocation") << LL_ENDL; + LL_DEBUGS("AgentLocation") << "Calling ParcelChanged callbacks" << LL_ENDL; // Notify anything that wants to know about parcel changes mParcelChangedSignal(); } @@ -920,6 +918,8 @@ void LLAgent::setRegion(LLViewerRegion *regionp) } mRegionp = regionp; + // TODO - most of what follows probably should be moved into callbacks + // Pass the region host to LLUrlEntryParcel to resolve parcel name // with a server request. LLUrlEntryParcel::setRegionHost(getRegionHost()); -- cgit v1.2.3 From fcc885d4fc5ef63dad33e89a9324edc39d466d37 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 19 Nov 2013 15:51:27 -0500 Subject: replace uses of LLEnvManagerNew::setRegionChangeCallback with LLAgent::addRegionChangedCallback --- indra/newview/llagent.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'indra/newview/llagent.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 5302ae2636..6ee8f26b9f 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -850,7 +850,6 @@ boost::signals2::connection LLAgent::addParcelChangedCallback(parcel_changed_cal //----------------------------------------------------------------------------- void LLAgent::setRegion(LLViewerRegion *regionp) { - bool teleport = true; bool notifyRegionChange; llassert(regionp); @@ -888,9 +887,6 @@ void LLAgent::setRegion(LLViewerRegion *regionp) { gSky.mVOGroundp->setRegion(regionp); } - - // Notify windlight managers - teleport = (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE); } else { @@ -938,15 +934,6 @@ void LLAgent::setRegion(LLViewerRegion *regionp) LLFloaterMove::sUpdateFlyingStatus(); - if (teleport) - { - LLEnvManagerNew::instance().onTeleport(); - } - else - { - LLEnvManagerNew::instance().onRegionCrossing(); - } - // If the newly entered region is using server bakes, and our // current appearance is non-baked, request appearance update from // server. -- cgit v1.2.3 From 0e346960bb45900cf1d9472834687c9b7b928e1f Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 17 Dec 2013 13:05:12 -0500 Subject: add LLAgent::removeRegionChangedCallback --- indra/newview/llagent.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llagent.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 6ee8f26b9f..b1cd68140e 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -981,6 +981,10 @@ boost::signals2::connection LLAgent::addRegionChangedCallback(region_changed_cal return mRegionChangedSignal.connect(cb); } +void LLAgent::removeRegionChangedCallback(boost::signals2::connection callback) +{ + mRegionChangedSignal.disconnect(callback); +} //----------------------------------------------------------------------------- // inPrelude() -- cgit v1.2.3 From 1886428638c2cb1e82db9f97ad311c2a506677a6 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Wed, 18 Dec 2013 06:26:22 +0000 Subject: STORM-1831 Changing addRegionChangedCallback to more closely resemble the feature it replaces. This fixes the crashes reported by Whirly ;-) --- indra/newview/llagent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llagent.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index b1cd68140e..14a2508697 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -976,7 +976,7 @@ LLHost LLAgent::getRegionHost() const } } -boost::signals2::connection LLAgent::addRegionChangedCallback(region_changed_callback_t cb) +boost::signals2::connection LLAgent::addRegionChangedCallback(const region_changed_signal_t::slot_type& cb) { return mRegionChangedSignal.connect(cb); } -- cgit v1.2.3