Annotation of /trunk/indra/newview/llagentaccess.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llagentaccess.cpp | ||
| 3 : | * @brief LLAgentAccess class implementation - manages maturity and godmode info | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2001-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | #include "llviewerprecompiledheaders.h" | ||
| 33 : | |||
| 34 : | #include "llagentaccess.h" | ||
| 35 : | #include "indra_constants.h" | ||
| 36 : | #include "llcontrolgroupreader.h" | ||
| 37 : | |||
| 38 : | LLAgentAccess::LLAgentAccess(LLControlGroupReader& savedSettings) : | ||
| 39 : | mSavedSettings(savedSettings), | ||
| 40 : | mAccess(SIM_ACCESS_PG), | ||
| 41 : | mAdminOverride(false), | ||
| 42 : | mGodLevel(GOD_NOT), | ||
| 43 : | mAOTransition(false) | ||
| 44 : | { | ||
| 45 : | } | ||
| 46 : | |||
| 47 : | bool LLAgentAccess::getAdminOverride() const | ||
| 48 : | { | ||
| 49 : | return mAdminOverride; | ||
| 50 : | } | ||
| 51 : | |||
| 52 : | void LLAgentAccess::setAdminOverride(bool b) | ||
| 53 : | { | ||
| 54 : | mAdminOverride = b; | ||
| 55 : | } | ||
| 56 : | |||
| 57 : | void LLAgentAccess::setGodLevel(U8 god_level) | ||
| 58 : | { | ||
| 59 : | mGodLevel = god_level; | ||
| 60 : | } | ||
| 61 : | |||
| 62 : | bool LLAgentAccess::isGodlike() const | ||
| 63 : | { | ||
| 64 : | #ifdef HACKED_GODLIKE_VIEWER | ||
| 65 : | return true; | ||
| 66 : | #else | ||
| 67 : | if(mAdminOverride) return true; | ||
| 68 : | return mGodLevel > GOD_NOT; | ||
| 69 : | #endif | ||
| 70 : | } | ||
| 71 : | |||
| 72 : | U8 LLAgentAccess::getGodLevel() const | ||
| 73 : | { | ||
| 74 : | #ifdef HACKED_GODLIKE_VIEWER | ||
| 75 : | return GOD_MAINTENANCE; | ||
| 76 : | #else | ||
| 77 : | if(mAdminOverride) return GOD_FULL; | ||
| 78 : | return mGodLevel; | ||
| 79 : | #endif | ||
| 80 : | } | ||
| 81 : | |||
| 82 : | bool LLAgentAccess::wantsPGOnly() const | ||
| 83 : | { | ||
| 84 : | return (prefersPG() || isTeen()) && !isGodlike(); | ||
| 85 : | } | ||
| 86 : | |||
| 87 : | bool LLAgentAccess::canAccessMature() const | ||
| 88 : | { | ||
| 89 : | // if you prefer mature, you're either mature or adult, and | ||
| 90 : | // therefore can access all mature content | ||
| 91 : | return isGodlike() || (prefersMature() && !isTeen()); | ||
| 92 : | } | ||
| 93 : | |||
| 94 : | bool LLAgentAccess::canAccessAdult() const | ||
| 95 : | { | ||
| 96 : | // if you prefer adult, you must BE adult. | ||
| 97 : | return isGodlike() || (prefersAdult() && isAdult()); | ||
| 98 : | } | ||
| 99 : | |||
| 100 : | bool LLAgentAccess::prefersPG() const | ||
| 101 : | { | ||
| 102 : | U32 access = mSavedSettings.getU32("PreferredMaturity"); | ||
| 103 : | return access < SIM_ACCESS_MATURE; | ||
| 104 : | } | ||
| 105 : | |||
| 106 : | bool LLAgentAccess::prefersMature() const | ||
| 107 : | { | ||
| 108 : | U32 access = mSavedSettings.getU32("PreferredMaturity"); | ||
| 109 : | return access >= SIM_ACCESS_MATURE; | ||
| 110 : | } | ||
| 111 : | |||
| 112 : | bool LLAgentAccess::prefersAdult() const | ||
| 113 : | { | ||
| 114 : | U32 access = mSavedSettings.getU32("PreferredMaturity"); | ||
| 115 : | return access >= SIM_ACCESS_ADULT; | ||
| 116 : | } | ||
| 117 : | |||
| 118 : | bool LLAgentAccess::isTeen() const | ||
| 119 : | { | ||
| 120 : | return mAccess < SIM_ACCESS_MATURE; | ||
| 121 : | } | ||
| 122 : | |||
| 123 : | bool LLAgentAccess::isMature() const | ||
| 124 : | { | ||
| 125 : | return mAccess >= SIM_ACCESS_MATURE; | ||
| 126 : | } | ||
| 127 : | |||
| 128 : | bool LLAgentAccess::isAdult() const | ||
| 129 : | { | ||
| 130 : | return mAccess >= SIM_ACCESS_ADULT; | ||
| 131 : | } | ||
| 132 : | |||
| 133 : | void LLAgentAccess::setTeen(bool teen) | ||
| 134 : | { | ||
| 135 : | if (teen) | ||
| 136 : | { | ||
| 137 : | mAccess = SIM_ACCESS_PG; | ||
| 138 : | } | ||
| 139 : | else | ||
| 140 : | { | ||
| 141 : | mAccess = SIM_ACCESS_MATURE; | ||
| 142 : | } | ||
| 143 : | } | ||
| 144 : | |||
| 145 : | //static | ||
| 146 : | int LLAgentAccess::convertTextToMaturity(char text) | ||
| 147 : | { | ||
| 148 : | if ('A' == text) | ||
| 149 : | { | ||
| 150 : | return SIM_ACCESS_ADULT; | ||
| 151 : | } | ||
| 152 : | else if ('M'== text) | ||
| 153 : | { | ||
| 154 : | return SIM_ACCESS_MATURE; | ||
| 155 : | } | ||
| 156 : | else if ('P'== text) | ||
| 157 : | { | ||
| 158 : | return SIM_ACCESS_PG; | ||
| 159 : | } | ||
| 160 : | return SIM_ACCESS_MIN; | ||
| 161 : | } | ||
| 162 : | |||
| 163 : | void LLAgentAccess::setMaturity(char text) | ||
| 164 : | { | ||
| 165 : | mAccess = LLAgentAccess::convertTextToMaturity(text); | ||
| 166 : | } | ||
| 167 : | |||
| 168 : | void LLAgentAccess::setTransition() | ||
| 169 : | { | ||
| 170 : | mAOTransition = true; | ||
| 171 : | } | ||
| 172 : | |||
| 173 : | bool LLAgentAccess::isInTransition() const | ||
| 174 : | { | ||
| 175 : | return mAOTransition; | ||
| 176 : | } | ||
| 177 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

