diff options
author | Dave Simmons <simon@lindenlab.com> | 2009-03-20 20:00:47 +0000 |
---|---|---|
committer | Dave Simmons <simon@lindenlab.com> | 2009-03-20 20:00:47 +0000 |
commit | 24b26d71ee01211aa796b8061b66ec06a133e4ce (patch) | |
tree | 96bffcd019c933ad3ebbfd5f096968108b22aab5 /indra/newview/llagentaccess.cpp | |
parent | 5dfd435872e36445dcc82f99443dfc5a7ee0805a (diff) |
svn merge -r113004:115000 svn+ssh://svn.lindenlab.com/svn/linden/branches/server/server-1.26
Merge latest 1.26 into trunk
Diffstat (limited to 'indra/newview/llagentaccess.cpp')
-rw-r--r-- | indra/newview/llagentaccess.cpp | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/indra/newview/llagentaccess.cpp b/indra/newview/llagentaccess.cpp new file mode 100644 index 0000000000..a4fbc04855 --- /dev/null +++ b/indra/newview/llagentaccess.cpp @@ -0,0 +1,154 @@ +/** + * @file llagentaccess.cpp + * @brief LLAgentAccess class implementation - manages maturity and godmode info + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * Copyright (c) 2001-2009, Linden Research, Inc. + * $/LicenseInfo$ + */ +#include "llviewerprecompiledheaders.h" + +#include "llagentaccess.h" +#include "indra_constants.h" +#include "llcontrolgroupreader.h" + +LLAgentAccess::LLAgentAccess(LLControlGroupReader& savedSettings) : + mSavedSettings(savedSettings), + mAccess(SIM_ACCESS_PG), + mAdminOverride(false), + mGodLevel(GOD_NOT), + mAOTransition(false) +{ +} + +bool LLAgentAccess::getAdminOverride() const +{ + return mAdminOverride; +} + +void LLAgentAccess::setAdminOverride(bool b) +{ + mAdminOverride = b; +} + +void LLAgentAccess::setGodLevel(U8 god_level) +{ + mGodLevel = god_level; +} + +bool LLAgentAccess::isGodlike() const +{ +#ifdef HACKED_GODLIKE_VIEWER + return true; +#else + if(mAdminOverride) return true; + return mGodLevel > GOD_NOT; +#endif +} + +U8 LLAgentAccess::getGodLevel() const +{ +#ifdef HACKED_GODLIKE_VIEWER + return GOD_MAINTENANCE; +#else + if(mAdminOverride) return GOD_FULL; + return mGodLevel; +#endif +} + +bool LLAgentAccess::wantsPGOnly() const +{ + return (prefersPG() || isTeen()) && !isGodlike(); +} + +bool LLAgentAccess::canAccessMature() const +{ + // if you prefer mature, you're either mature or adult, and + // therefore can access all mature content + return isGodlike() || (prefersMature() && !isTeen()); +} + +bool LLAgentAccess::canAccessAdult() const +{ + // if you prefer adult, you must BE adult. + return isGodlike() || (prefersAdult() && isAdult()); +} + +bool LLAgentAccess::prefersPG() const +{ + U32 access = mSavedSettings.getU32("PreferredMaturity"); + return access < SIM_ACCESS_MATURE; +} + +bool LLAgentAccess::prefersMature() const +{ + U32 access = mSavedSettings.getU32("PreferredMaturity"); + return access >= SIM_ACCESS_MATURE; +} + +bool LLAgentAccess::prefersAdult() const +{ + U32 access = mSavedSettings.getU32("PreferredMaturity"); + return access >= SIM_ACCESS_ADULT; +} + +bool LLAgentAccess::isTeen() const +{ + return mAccess < SIM_ACCESS_MATURE; +} + +bool LLAgentAccess::isMature() const +{ + return mAccess >= SIM_ACCESS_MATURE; +} + +bool LLAgentAccess::isAdult() const +{ + return mAccess >= SIM_ACCESS_ADULT; +} + +void LLAgentAccess::setTeen(bool teen) +{ + if (teen) + { + mAccess = SIM_ACCESS_PG; + } + else + { + mAccess = SIM_ACCESS_MATURE; + } +} + +//static +int LLAgentAccess::convertTextToMaturity(char text) +{ + if ('A' == text) + { + return SIM_ACCESS_ADULT; + } + else if ('M'== text) + { + return SIM_ACCESS_MATURE; + } + else if ('P'== text) + { + return SIM_ACCESS_PG; + } + return SIM_ACCESS_MIN; +} + +void LLAgentAccess::setMaturity(char text) +{ + mAccess = LLAgentAccess::convertTextToMaturity(text); +} + +void LLAgentAccess::setTransition() +{ + mAOTransition = true; +} + +bool LLAgentAccess::isInTransition() const +{ + return mAOTransition; +} + |