diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 3b1e894ed3c0e27d0471b5a5a05ad379884ba6c2..5d5e585563068b737c9b5ce690ac2107e48bcd94 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -325,7 +325,7 @@ LLAgent::LLAgent() : mTeleportFinishedSlot(), mTeleportFailedSlot(), mIsMaturityRatingChangingDuringTeleport(false), - mMaturityRatingChange(0), + mMaturityRatingChange(0U), mTeleportState( TELEPORT_NONE ), mRegionp(NULL), @@ -3618,7 +3618,7 @@ void LLAgent::clearFailedTeleportRequest() } } -void LLAgent::setMaturityRatingChangeDuringTeleport(int pMaturityRatingChange) +void LLAgent::setMaturityRatingChangeDuringTeleport(U8 pMaturityRatingChange) { mIsMaturityRatingChangingDuringTeleport = true; mMaturityRatingChange = pMaturityRatingChange; diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 07ceaf11b10c35e240d33016f57b4e9279315f2c..cbfe8af90c5ed94c55049aee3be1f781f3eddbfc 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -580,7 +580,7 @@ class LLAgent : public LLOldEvents::LLObservable inline bool hasFailedTeleportRequest() {return (mFailedTeleportRequest != NULL);}; void restartFailedTeleportRequest(); void clearFailedTeleportRequest(); - void setMaturityRatingChangeDuringTeleport(int pMaturityRatingChange); + void setMaturityRatingChangeDuringTeleport(U8 pMaturityRatingChange); private: friend class LLTeleportRequest; @@ -595,7 +595,7 @@ class LLAgent : public LLOldEvents::LLObservable boost::signals2::connection mTeleportFailedSlot; bool mIsMaturityRatingChangingDuringTeleport; - int mMaturityRatingChange; + U8 mMaturityRatingChange; void teleportRequest(const U64& region_handle, const LLVector3& pos_local, // Go to a named location home diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index d88a6f1a9b7c1125f44ca9e8c46966e7cb410da5..84de54986f6d8ac04797e926e6879901f0741355 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -42,6 +42,7 @@ #include "llinventorydefines.h" #include "lllslconstants.h" #include "llregionhandle.h" +#include "llsd.h" #include "llsdserialize.h" #include "llteleportflags.h" #include "lltransactionflags.h" @@ -107,6 +108,7 @@ #include "llagentui.h" #include "llpanelblockedlist.h" #include "llpanelplaceprofile.h" +#include "llviewerregion.h" #include <boost/algorithm/string/split.hpp> // #include <boost/regex.hpp> @@ -5385,18 +5387,102 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) } } -void handle_maturity_preference_change(const LLSD &pResponse, int pMaturityRatingChange) +void handle_maturity_preference_change(const LLSD &pResponse, U8 pMaturityRatingChange) { - if (pResponse.isUndefined()) + bool isMaturityPreferenceElevated = false; + U8 actualPrefValue = SIM_ACCESS_MIN; + + llassert(!pResponse.isUndefined()); + llassert(pResponse.isMap()); + llassert(pResponse.has("access_prefs")); + llassert(pResponse.get("access_prefs").isMap()); + llassert(pResponse.get("access_prefs").has("max")); + llassert(pResponse.get("access_prefs").get("max").isString()); + + if (!pResponse.isUndefined() && pResponse.isMap() && pResponse.has("access_prefs") && + pResponse.get("access_prefs").isMap() && pResponse.get("access_prefs").has("max") && + pResponse.get("access_prefs").get("max").isString()) { - // XXX stinson 05/15/2012 : should report some notification that the preference has not changed - gAgent.clearFailedTeleportRequest(); + LLSD::String actualPreference = pResponse.get("access_prefs").get("max").asString(); + LLStringUtil::trim(actualPreference); + actualPrefValue = LLViewerRegion::shortStringToAccess(actualPreference); } - else + + switch (actualPrefValue) + { + case SIM_ACCESS_MIN : + switch (pMaturityRatingChange) + { + case SIM_ACCESS_MIN : + isMaturityPreferenceElevated = true; + break; + case SIM_ACCESS_PG : + case SIM_ACCESS_MATURE : + case SIM_ACCESS_ADULT : + default : + isMaturityPreferenceElevated = false; + break; + } + break; + case SIM_ACCESS_PG : + switch (pMaturityRatingChange) + { + case SIM_ACCESS_MIN : + case SIM_ACCESS_PG : + isMaturityPreferenceElevated = true; + break; + case SIM_ACCESS_MATURE : + case SIM_ACCESS_ADULT : + default : + isMaturityPreferenceElevated = false; + break; + } + break; + case SIM_ACCESS_MATURE : + switch (pMaturityRatingChange) + { + case SIM_ACCESS_MIN : + case SIM_ACCESS_PG : + case SIM_ACCESS_MATURE : + isMaturityPreferenceElevated = true; + break; + case SIM_ACCESS_ADULT : + default : + isMaturityPreferenceElevated = false; + break; + } + break; + case SIM_ACCESS_ADULT : + switch (pMaturityRatingChange) + { + case SIM_ACCESS_MIN : + case SIM_ACCESS_PG : + case SIM_ACCESS_MATURE : + case SIM_ACCESS_ADULT : + isMaturityPreferenceElevated = true; + break; + default : + isMaturityPreferenceElevated = false; + break; + } + break; + default : + isMaturityPreferenceElevated = false; + break; + } + + if (isMaturityPreferenceElevated) { gAgent.setMaturityRatingChangeDuringTeleport(pMaturityRatingChange); gAgent.restartFailedTeleportRequest(); } + else + { + LLSD args; + args["RATING"] = LLViewerRegion::accessToString(pMaturityRatingChange); + LLNotificationsUtil::add("MaturityCouldNotBeChanged", args); + gAgent.clearFailedTeleportRequest(); + } } bool handle_special_notification_callback(const LLSD& notification, const LLSD& response) @@ -5406,8 +5492,8 @@ bool handle_special_notification_callback(const LLSD& notification, const LLSD& if (0 == option) { // set the preference to the maturity of the region we're calling - int preferredMaturity = notification["payload"]["_region_access"].asInteger(); - gSavedSettings.setU32("PreferredMaturity", preferredMaturity); + U8 preferredMaturity = static_cast<U8>(notification["payload"]["_region_access"].asInteger()); + gSavedSettings.setU32("PreferredMaturity", static_cast<U32>(preferredMaturity)); gAgent.sendMaturityPreferenceToServer(preferredMaturity, boost::bind(&handle_maturity_preference_change, _1, preferredMaturity)); } else @@ -5421,7 +5507,7 @@ bool handle_special_notification_callback(const LLSD& notification, const LLSD& // some of the server notifications need special handling. This is where we do that. bool handle_special_notification(std::string notificationID, LLSD& llsdBlock) { - int regionAccess = llsdBlock["_region_access"].asInteger(); + U8 regionAccess = static_cast<U8>(llsdBlock["_region_access"].asInteger()); llsdBlock["REGIONMATURITY"] = LLViewerRegion::accessToString(regionAccess); bool returnValue = false; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index e3cb985ddb3a35bab24412d0d2a6f5d20f9613b0..f3771e93d974ba4efd4fbded988e49497f9da092 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -654,6 +654,31 @@ std::string LLViewerRegion::accessToShortString(U8 sim_access) } } +// static +U8 LLViewerRegion::shortStringToAccess(const std::string &sim_access) +{ + U8 accessValue; + + if (LLStringUtil::compareStrings(sim_access, "PG") == 0) + { + accessValue = SIM_ACCESS_PG; + } + else if (LLStringUtil::compareStrings(sim_access, "M") == 0) + { + accessValue = SIM_ACCESS_MATURE; + } + else if (LLStringUtil::compareStrings(sim_access, "A") == 0) + { + accessValue = SIM_ACCESS_ADULT; + } + else + { + accessValue = SIM_ACCESS_MIN; + } + + return accessValue; +} + // static void LLViewerRegion::processRegionInfo(LLMessageSystem* msg, void**) { diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index c483c6ef5294a5fc99ee29315bc12d1c069039ea..7280c7f2e6b9b44102cfb47350f1e999e0039a95 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -202,6 +202,7 @@ class LLViewerRegion: public LLCapabilityProvider // implements this interface // Returns "M", "PG", "A" etc. static std::string accessToShortString(U8 sim_access); + static U8 shortStringToAccess(const std::string &sim_access); // Return access icon name static std::string getAccessIcon(U8 sim_access); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 649d1982b14cbbf984997c4f907999a5c47c23f3..c76c28579b2936d43f7d7b4047cf263679d8bd69 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -4137,6 +4137,17 @@ You won't receive any more notifications that you're about to visit a region wit yestext="OK"/> </notification> + <notification + icon="alertmodal.tga" + name="MaturityCouldNotBeChanged" + type="alertmodal"> +We were unable to change your preferences to view [RATING] content at this time. Please attempt to change your preferences by using Me > Preferences > General from the menu bar, and then retrying your teleport. + <tag>confirm</tag> + <usetemplate + name="okbutton" + yestext="OK"/> + </notification> + <notification icon="alertmodal.tga" name="LandClaimAccessBlocked"