From a7c6c184dab2539a86d6ad719a1438ee10c78dba Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Thu, 31 Jul 2014 22:50:02 -0400 Subject: [PATCH] Now that I'm more awake, this is a far better solution for the default sim features issues. Adds const Type mDefaultValue reset() and getDefault() to SignaledType Cleans up code by not needing to reset to the default by value every time, nice template function to do this~ Leaves in hg boolean, but commented out in case opensim ever decides to make that a reality. --- indra/newview/lfsimfeaturehandler.cpp | 42 +++++++++++++++++---------- indra/newview/lfsimfeaturehandler.h | 7 +++-- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/indra/newview/lfsimfeaturehandler.cpp b/indra/newview/lfsimfeaturehandler.cpp index e5c44a9ce..2e6b55b37 100644 --- a/indra/newview/lfsimfeaturehandler.cpp +++ b/indra/newview/lfsimfeaturehandler.cpp @@ -56,42 +56,52 @@ void LFSimFeatureHandler::handleRegionChange() } } +template +void has_feature_or_default(SignaledType& type, const LLSD& features, const std::string& feature) +{ + type = (features.has(feature)) ? static_cast(features[feature]) : type.getDefault(); +} +template<> +void has_feature_or_default(SignaledType& type, const LLSD& features, const std::string& feature) +{ + type = (features.has(feature)) ? features[feature].asInteger() : type.getDefault(); +} + void LFSimFeatureHandler::setSupportedFeatures() { if (LLViewerRegion* region = gAgent.getRegion()) { LLSD info; region->getSimulatorFeatures(info); - bool hg(!gHippoGridManager->getCurrentGrid()->isAvination()); // Singu Note: There should be a flag for this some day. - static bool init(false); // This could be a grid where OpenSimExtras aren't implemented, in that case, don't alter the hg specific members. + //bool hg(); // Singu Note: There should probably be a flag for this some day. if (info.has("OpenSimExtras")) // OpenSim specific sim features { // For definition of OpenSimExtras please see // http://opensimulator.org/wiki/SimulatorFeatures_Extras const LLSD& extras(info["OpenSimExtras"]); - mSupportsExport = extras.has("ExportSupported") ? extras["ExportSupported"].asBoolean() : false; - if (hg) + has_feature_or_default(mSupportsExport, extras, "ExportSupported"); + //if (hg) { - mDestinationGuideURL = extras.has("destination-guide-url") ? extras["destination-guide-url"].asString() : ""; + has_feature_or_default(mDestinationGuideURL, extras, "destination-guide-url"); mMapServerURL = extras.has("map-server-url") ? extras["map-server-url"].asString() : ""; - mSearchURL = extras.has("search-server-url") ? extras["search-server-url"].asString() : ""; - init = true; + has_feature_or_default(mSearchURL, extras, "search-server-url"); } - mSayRange = extras.has("say-range") ? extras["say-range"].asInteger() : 20; - mShoutRange = extras.has("shout-range") ? extras["shout-range"].asInteger() : 100; - mWhisperRange = extras.has("whisper-range") ? extras["whisper-range"].asInteger() : 10; + has_feature_or_default(mSayRange, extras, "say-range"); + has_feature_or_default(mShoutRange, extras, "shout-range"); + has_feature_or_default(mWhisperRange, extras, "whisper-range"); } else // OpenSim specifics are unsupported reset all to default { - mSupportsExport = false; - if (hg && init) + mSupportsExport.reset(); + //if (hg) { + mDestinationGuideURL.reset(); mMapServerURL = ""; - mSearchURL = ""; + mSearchURL.reset(); } - mSayRange = 20; - mShoutRange = 100; - mWhisperRange = 10; + mSayRange.reset(); + mShoutRange.reset(); + mWhisperRange.reset(); } } } diff --git a/indra/newview/lfsimfeaturehandler.h b/indra/newview/lfsimfeaturehandler.h index 371ec5e0c..c1260d4cc 100644 --- a/indra/newview/lfsimfeaturehandler.h +++ b/indra/newview/lfsimfeaturehandler.h @@ -25,8 +25,8 @@ template