diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llenvmanager.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llviewerregion.cpp | 15 | ||||
-rw-r--r-- | indra/newview/llviewerregion.h | 5 | ||||
-rw-r--r-- | indra/newview/llwlhandlers.cpp | 52 | ||||
-rw-r--r-- | indra/newview/llwlhandlers.h | 14 |
5 files changed, 76 insertions, 16 deletions
diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index b69586e88e..687f9974b1 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -261,7 +261,7 @@ void LLEnvManager::refreshFromStorage(LLEnvKey::EScope scope) case LLEnvKey::SCOPE_LOCAL: break; case LLEnvKey::SCOPE_REGION: - if (!LLEnvironmentRequestResponder::initiateRequest()) + if (!LLEnvironmentRequest::initiate()) { // don't have a cap for this, presume invalid response processIncomingMessage(LLSD(), scope); @@ -297,11 +297,11 @@ bool LLEnvManager::processIncomingMessage(const LLSD& unvalidated_content, const // end HACK mLastReceivedID = unvalidated_content[0]["messageID"].asUUID(); // if the message was valid, grab the UUID from it and save it for next outbound update message + LL_DEBUGS("Windlight Sync") << "mLastReceivedID: " << mLastReceivedID << LL_ENDL; + LL_DEBUGS("Windlight Sync") << "windlight_llsd: " << windlight_llsd << LL_ENDL; if (valid) { - LL_DEBUGS("Windlight Sync") << "windlight_llsd: " << windlight_llsd << LL_ENDL; - F32 sun_hour = LLPanelRegionTerrainInfo::instance()->getSunHour(); // this slider is kept up to date LLWLParamManager::getInstance()->addAllSkies(scope, windlight_llsd[2]); LLEnvironmentSettings newSettings(windlight_llsd[1], windlight_llsd[2], windlight_llsd[3], sun_hour); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index f6935b0598..04563c9154 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1491,6 +1491,21 @@ bool LLViewerRegion::capabilitiesReceived() const void LLViewerRegion::setCapabilitiesReceived(bool received) { mCapabilitiesReceived = received; + + // Tell interested parties that we've received capabilities, + // so that they can safely use getCapability(). + if (received) + { + mCapabilitiesReceivedSignal(mRegionID); + + // This is a single-shot signal. Forget callbacks to save resources. + mCapabilitiesReceivedSignal.disconnect_all_slots(); + } +} + +boost::signals2::connection LLViewerRegion::setCapabilitiesReceivedCallback(const caps_received_signal_t::slot_type& cb) +{ + return mCapabilitiesReceivedSignal.connect(cb); } void LLViewerRegion::logActiveCapabilities() const diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 8ba4775c29..05443ee415 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -30,6 +30,7 @@ // A ViewerRegion is a class that contains a bunch of objects and surfaces // that are in to a particular region. #include <string> +#include <boost/signals2.hpp> #include "lldarray.h" #include "llwind.h" @@ -87,6 +88,8 @@ public: NUM_PARTITIONS } eObjectPartitions; + typedef boost::signals2::signal<void(const LLUUID& region_id)> caps_received_signal_t; + LLViewerRegion(const U64 &handle, const LLHost &host, const U32 surface_grid_width, @@ -234,6 +237,7 @@ public: // has region received its final (not seed) capability list? bool capabilitiesReceived() const; void setCapabilitiesReceived(bool received); + boost::signals2::connection setCapabilitiesReceivedCallback(const caps_received_signal_t::slot_type& cb); static bool isSpecialCapabilityName(const std::string &name); void logActiveCapabilities() const; @@ -432,6 +436,7 @@ private: private: bool mAlive; // can become false if circuit disconnects bool mCapabilitiesReceived; + caps_received_signal_t mCapabilitiesReceivedSignal; //spatial partitions for objects in this region std::vector<LLSpatialPartition*> mObjectPartition; diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 92dfa686d5..c116265c86 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -40,11 +40,38 @@ #include "llnotificationsutil.h" /**** - * LLEnvironmentRequestResponder + * LLEnvironmentRequest ****/ -int LLEnvironmentRequestResponder::sCount = 0; // init to 0 +// static +bool LLEnvironmentRequest::initiate() +{ + LLViewerRegion* cur_region = gAgent.getRegion(); + + if (!cur_region->capabilitiesReceived()) + { + LL_INFOS("WindlightCaps") << "Deferring windlight settings request until we've got region caps" << LL_ENDL; + cur_region->setCapabilitiesReceivedCallback(boost::bind(&LLEnvironmentRequest::onRegionCapsReceived, _1)); + return false; + } -/*static*/ bool LLEnvironmentRequestResponder::initiateRequest() + return doRequest(); +} + +// static +void LLEnvironmentRequest::onRegionCapsReceived(const LLUUID& region_id) +{ + if (region_id != gAgent.getRegion()->getRegionID()) + { + LL_INFOS("WindlightCaps") << "Got caps for a non-current region" << LL_ENDL; + return; + } + + LL_DEBUGS("WindlightCaps") << "Received region capabilities" << LL_ENDL; + doRequest(); +} + +// static +bool LLEnvironmentRequest::doRequest() { std::string url = gAgent.getRegion()->getCapability("EnvironmentSettings"); if (url.empty()) @@ -53,20 +80,24 @@ int LLEnvironmentRequestResponder::sCount = 0; // init to 0 // region is apparently not capable of this; don't respond at all return false; } - else - { - LL_DEBUGS("WindlightCaps") << "Requesting windlight settings via " << url << LL_ENDL; - LLHTTPClient::get(url, new LLEnvironmentRequestResponder()); - return true; - } + + LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL; + LLHTTPClient::get(url, new LLEnvironmentRequestResponder()); + return true; } + +/**** + * LLEnvironmentRequestResponder + ****/ +int LLEnvironmentRequestResponder::sCount = 0; // init to 0 + LLEnvironmentRequestResponder::LLEnvironmentRequestResponder() { mID = ++sCount; } /*virtual*/ void LLEnvironmentRequestResponder::result(const LLSD& unvalidated_content) { - LL_DEBUGS("WindlightCaps") << "Receiving windlight settings..." << LL_ENDL; + LL_INFOS("WindlightCaps") << "Received region windlight settings" << LL_ENDL; if (mID != sCount) { @@ -82,7 +113,6 @@ LLEnvironmentRequestResponder::LLEnvironmentRequestResponder() return; } - LL_DEBUGS("WindlightCaps") << "content: " << unvalidated_content << LL_ENDL; LLEnvManager::getInstance()->processIncomingMessage(unvalidated_content, LLEnvKey::SCOPE_REGION); } /*virtual*/ void LLEnvironmentRequestResponder::error(U32 status, const std::string& reason) diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index 811dc4bb73..4929b4d27b 100644 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -38,6 +38,17 @@ class LLEnvManager; +class LLEnvironmentRequest +{ +public: + /// @return true if request was successfully sent + static bool initiate(); + +private: + static void onRegionCapsReceived(const LLUUID& region_id); + static bool doRequest(); +}; + class LLEnvironmentRequestResponder: public LLHTTPClient::Responder { public: @@ -45,9 +56,8 @@ public: virtual void error(U32 status, const std::string& reason); private: + friend class LLEnvironmentRequest; friend class LLEnvManager; - // returns true if request was sucessfully sent - static bool initiateRequest(); LLEnvironmentRequestResponder(); static int sCount; |