diff options
| author | Rider Linden <rider@lindenlab.com> | 2018-08-20 14:59:02 -0700 | 
|---|---|---|
| committer | Rider Linden <rider@lindenlab.com> | 2018-08-20 14:59:02 -0700 | 
| commit | 8fc3956a5eeaa2dffabdcda60800d9c4d4e49c43 (patch) | |
| tree | b7c884d7283eb25c43505131f97d899c43efae29 /indra | |
| parent | 1e3ee272ae811b862a529b6f3bbebb50a0c22580 (diff) | |
Use the EnvironmentInfo structure to pass information back from legacy environment requests.
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llenvironment.cpp | 91 | ||||
| -rw-r--r-- | indra/newview/llenvironment.h | 4 | ||||
| -rw-r--r-- | indra/newview/llpanelenvironment.cpp | 9 | ||||
| -rw-r--r-- | indra/newview/llwlhandlers.cpp | 32 | ||||
| -rw-r--r-- | indra/newview/llwlhandlers.h | 13 | 
5 files changed, 88 insertions, 61 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 84e915a95d..4f7ffe0724 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -431,26 +431,6 @@ void LLEnvironment::onParcelChange()      requestParcel(parcel_id);  } -void LLEnvironment::onLegacyRegionSettings(LLSD data) -{ -    LLUUID regionId = data[0]["regionID"].asUUID(); - -    LLSettingsDay::ptr_t regionday; -    if (!data[1].isUndefined()) -        regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); - -    clearEnvironment(ENV_PARCEL); -    if (!regionday) -    { -        LL_WARNS("ENVIRONMENT") << "Unable to create day from legacy.  Using default day cycle." << LL_ENDL; -        setEnvironment(LLEnvironment::ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); -    } -    else -        setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); - -    updateEnvironment(); -} -  //-------------------------------------------------------------------------  F32 LLEnvironment::getCamHeight() const  { @@ -1017,23 +997,11 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI  //=========================================================================  void LLEnvironment::requestRegion(environment_apply_fn cb)  { -    if (!isExtendedEnvironmentEnabled()) -    {   /*TODO: When EEP is live on the entire grid, this can go away. */ -        LLEnvironmentRequest::initiate(); -        return; -    } -      requestParcel(INVALID_PARCEL_ID, cb);  }  void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb)  { -    if (!isExtendedEnvironmentEnabled()) -    { -        LLEnvironmentApply::initiateRequest( LLSettingsVODay::convertToLegacy(pday) ); -        return; -    } -      updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, cb);  } @@ -1067,6 +1035,27 @@ void LLEnvironment::resetRegion(environment_apply_fn cb)  void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb)  { +    if (!isExtendedEnvironmentEnabled()) +    {   /*TODO: When EEP is live on the entire grid, this can go away. */ +        if (!cb) +        { +            cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo)  +            {  +                if (envinfo->mDayCycle) recordEnvironment(pid, envinfo);  +                else +                { +                    clearEnvironment(ENV_PARCEL); +                    setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); +                    updateEnvironment(); +                } +            }; +        } + +        if (parcel_id == INVALID_PARCEL_ID) +            LLEnvironmentRequest::initiate(cb); +        return; +    } +      if (!cb)      {          cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }; @@ -1358,7 +1347,7 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environmen  //========================================================================= -LLEnvironment::UserPrefs::UserPrefs(): +LLEnvironment::UserPrefs::UserPrefs() :      mUseRegionSettings(true),      mUseDayCycle(true),      mPersistEnvironment(false), @@ -1402,7 +1391,8 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo():      mDayHash(0),      mDayCycle(),      mAltitudes({ { 0.0, 0.0, 0.0, 0.0 } }), -    mIsDefault(false) +    mIsDefault(false), +    mIsLegacy(false)  {  } @@ -1413,6 +1403,7 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL      pinfo->mIsDefault = environment.has(KEY_ISDEFAULT) ? environment[KEY_ISDEFAULT].asBoolean() : true;      pinfo->mParcelId = environment.has(KEY_PARCELID) ? environment[KEY_PARCELID].asInteger() : INVALID_PARCEL_ID;      pinfo->mRegionId = environment.has(KEY_REGIONID) ? environment[KEY_REGIONID].asUUID() : LLUUID::null; +    pinfo->mIsLegacy = false;      if (environment.has(KEY_TRACKALTS))      { @@ -1434,13 +1425,41 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL      if (environment.has(KEY_DAYASSET))      {          pinfo->mAssetId = environment[KEY_DAYASSET].asUUID(); -        LL_WARNS("LAPRAS") << "Environment asset ID is " << pinfo->mAssetId << LL_ENDL; -        LL_WARNS("LAPRAS") << "(day cycle claims " << pinfo->mDayCycle->getAssetId() << ")" << LL_ENDL;      }      return pinfo;  } + +LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extractLegacy(LLSD legacy) +{ +    if (!legacy.isArray() || !legacy[0].has("regionID")) +    { +        LL_WARNS("ENVIRONMENT") << "Invalid legacy settings for environment: " << legacy << LL_ENDL; +        return ptr_t(); +    } + +    ptr_t pinfo = std::make_shared<EnvironmentInfo>(); + +    pinfo->mIsDefault = false; +    pinfo->mParcelId = INVALID_PARCEL_ID; +    pinfo->mRegionId = legacy[0]["regionID"].asUUID(); +    pinfo->mIsLegacy = true; + +    pinfo->mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH; +    pinfo->mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; +    pinfo->mDayCycle = LLSettingsVODay::buildFromLegacyMessage(pinfo->mRegionId, legacy[1], legacy[2], legacy[3]); +    if (pinfo->mDayCycle) +        pinfo->mDayHash = pinfo->mDayCycle->getHash(); + +    pinfo->mAltitudes[0] = 0; +    pinfo->mAltitudes[2] = 10001; +    pinfo->mAltitudes[3] = 10002; +    pinfo->mAltitudes[4] = 10003; + +    return pinfo; +} +  //=========================================================================  LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename)  { diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index eadbb3e941..b5bd353066 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -83,8 +83,10 @@ public:          std::array<F32, 4>      mAltitudes;          bool                    mIsDefault;          LLUUID                  mAssetId; +        bool                    mIsLegacy;          static ptr_t            extract(LLSD); +        static ptr_t            extractLegacy(LLSD);      };      enum EnvSelection_t @@ -229,8 +231,6 @@ public:      //-------------------------------------------      connection_t                setEnvironmentChanged(environment_changed_fn cb); -    void                        onLegacyRegionSettings(LLSD data); -      void                        requestRegion(environment_apply_fn cb = environment_apply_fn());      void                        updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn());      void                        updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index 1f29e4c054..5bdd2ecff8 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -207,13 +207,14 @@ LLFloaterSettingsPicker *LLPanelEnvironmentInfo::getSettingsPicker()  LLFloaterEditExtDayCycle * LLPanelEnvironmentInfo::getEditFloater()  { +    static const S32 FOURHOURS(4 * 60 * 60);      LLFloaterEditExtDayCycle *editor = static_cast<LLFloaterEditExtDayCycle *>(mEditFloater.get());      // Show the dialog      if (!editor)      {          LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT, (mCurrentParcelId == INVALID_PARCEL_ID) ? LLFloaterEditExtDayCycle::CONTEXT_REGION : LLFloaterEditExtDayCycle::CONTEXT_PARCEL) -            (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, static_cast<S32>(mCurrentEnvironment->mDayLength.value()))); +            (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mCurrentEnvironment ? (S32)(mCurrentEnvironment->mDayLength.value()) : FOURHOURS));          editor = (LLFloaterEditExtDayCycle *)LLFloaterReg::getInstance(FLOATER_DAY_CYCLE_EDIT, params); @@ -321,10 +322,12 @@ void LLPanelEnvironmentInfo::onBtnReset()  void LLPanelEnvironmentInfo::onBtnEdit()  { +    static const S32 FOURHOURS(4 * 60 * 60); +      LLFloaterEditExtDayCycle *dayeditor = getEditFloater(); -    LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT, (mCurrentParcelId == INVALID_PARCEL_ID) ? LLFloaterEditExtDayCycle::VALUE_CONTEXT_REGION: LLFloaterEditExtDayCycle::VALUE_CONTEXT_PARCEL) -        (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, static_cast<S32>(mCurrentEnvironment->mDayLength.value()))); +    LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT, (mCurrentParcelId == INVALID_PARCEL_ID) ? LLFloaterEditExtDayCycle::CONTEXT_REGION : LLFloaterEditExtDayCycle::CONTEXT_PARCEL) +        (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mCurrentEnvironment ? (S32)(mCurrentEnvironment->mDayLength.value()) : FOURHOURS));      dayeditor->openFloater(params);      if (mCurrentEnvironment->mDayCycle) diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index f0453b4d6d..6b8374fd48 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -33,13 +33,12 @@  #include "llnotificationsutil.h"  #include "llcorehttputil.h" -#include "llenvironment.h" - +#include "llparcel.h"  /****   * LLEnvironmentRequest   ****/  // static -bool LLEnvironmentRequest::initiate() +bool LLEnvironmentRequest::initiate(LLEnvironment::environment_apply_fn cb)  {  	LLViewerRegion* cur_region = gAgent.getRegion(); @@ -52,15 +51,15 @@ bool LLEnvironmentRequest::initiate()  	if (!cur_region->capabilitiesReceived())  	{  		LL_INFOS("WindlightCaps") << "Deferring windlight settings request until we've got region caps" << LL_ENDL; -        cur_region->setCapabilitiesReceivedCallback([](LLUUID region_id) { LLEnvironmentRequest::onRegionCapsReceived(region_id); }); +        cur_region->setCapabilitiesReceivedCallback([cb](LLUUID region_id) { LLEnvironmentRequest::onRegionCapsReceived(region_id, cb); });  		return false;  	} -	return doRequest(); +	return doRequest(cb);  }  // static -void LLEnvironmentRequest::onRegionCapsReceived(const LLUUID& region_id) +void LLEnvironmentRequest::onRegionCapsReceived(const LLUUID& region_id, LLEnvironment::environment_apply_fn cb)  {  	if (region_id != gAgent.getRegion()->getRegionID())  	{ @@ -69,11 +68,11 @@ void LLEnvironmentRequest::onRegionCapsReceived(const LLUUID& region_id)  	}  	LL_DEBUGS("WindlightCaps") << "Received region capabilities" << LL_ENDL; -	doRequest(); +	doRequest(cb);  }  // static -bool LLEnvironmentRequest::doRequest() +bool LLEnvironmentRequest::doRequest(LLEnvironment::environment_apply_fn cb)  {  	std::string url = gAgent.getRegionCapability("EnvironmentSettings");  	if (url.empty()) @@ -88,7 +87,7 @@ bool LLEnvironmentRequest::doRequest()      std::string coroname =          LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro", -        [url]() { LLEnvironmentRequest::environmentRequestCoro(url); }); +        [url, cb]() { LLEnvironmentRequest::environmentRequestCoro(url, cb); });      LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL;      return true; @@ -97,7 +96,7 @@ bool LLEnvironmentRequest::doRequest()  S32 LLEnvironmentRequest::sLastRequest = 0;  //static  -void LLEnvironmentRequest::environmentRequestCoro(std::string url) +void LLEnvironmentRequest::environmentRequestCoro(std::string url, LLEnvironment::environment_apply_fn cb)  {      LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);      S32 requestId = ++LLEnvironmentRequest::sLastRequest; @@ -141,7 +140,12 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url)          return;      } -    LLEnvironment::instance().onLegacyRegionSettings(result); +    if (cb) +    { +        LLEnvironment::EnvironmentInfo::ptr_t pinfo = LLEnvironment::EnvironmentInfo::extractLegacy(result); + +        cb(INVALID_PARCEL_ID, pinfo); +    }  } @@ -153,7 +157,7 @@ clock_t LLEnvironmentApply::UPDATE_WAIT_SECONDS = clock_t(3.f);  clock_t LLEnvironmentApply::sLastUpdate = clock_t(0.f);  // static -bool LLEnvironmentApply::initiateRequest(const LLSD& content) +bool LLEnvironmentApply::initiateRequest(const LLSD& content, LLEnvironment::environment_apply_fn cb)  {  	clock_t current = clock(); @@ -181,11 +185,11 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content)      std::string coroname =          LLCoros::instance().launch("LLEnvironmentApply::environmentApplyCoro", -        [url, content]() { LLEnvironmentApply::environmentApplyCoro(url, content); }); +        [url, content, cb]() { LLEnvironmentApply::environmentApplyCoro(url, content, cb); });  	return true;  } -void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content) +void LLEnvironmentApply::environmentApplyCoro(std::string url, LLSD content, LLEnvironment::environment_apply_fn cb)  {      LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);      LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index 857ffa9bd3..b09d2df60f 100644 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -29,19 +29,20 @@  #include "llviewerprecompiledheaders.h"  #include "llcoros.h" +#include "llenvironment.h"  class LLEnvironmentRequest  {  	LOG_CLASS(LLEnvironmentRequest);  public:  	/// @return true if request was successfully sent -	static bool initiate(); +    static bool initiate(LLEnvironment::environment_apply_fn cb);  private: -	static void onRegionCapsReceived(const LLUUID& region_id); -	static bool doRequest(); +    static void onRegionCapsReceived(const LLUUID& region_id, LLEnvironment::environment_apply_fn cb); +    static bool doRequest(LLEnvironment::environment_apply_fn cb); -    static void environmentRequestCoro(std::string url); +    static void environmentRequestCoro(std::string url, LLEnvironment::environment_apply_fn cb);      static S32 sLastRequest;  }; @@ -51,13 +52,13 @@ class LLEnvironmentApply  	LOG_CLASS(LLEnvironmentApply);  public:  	/// @return true if request was successfully sent -	static bool initiateRequest(const LLSD& content); +    static bool initiateRequest(const LLSD& content, LLEnvironment::environment_apply_fn cb);  private:  	static clock_t sLastUpdate;  	static clock_t UPDATE_WAIT_SECONDS; -    static void environmentApplyCoro(std::string url, LLSD content); +    static void environmentApplyCoro(std::string url, LLSD content, LLEnvironment::environment_apply_fn cb);  };  | 
