diff options
author | Jacek Antonelli | 2009-04-30 13:04:20 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-30 13:07:16 -0500 |
commit | ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch) | |
tree | 8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llagentaccess.cpp | |
parent | Second Life viewer sources 1.22.11 (diff) | |
download | meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2 meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz |
Second Life viewer sources 1.23.0-RC
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llagentaccess.cpp | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/linden/indra/newview/llagentaccess.cpp b/linden/indra/newview/llagentaccess.cpp new file mode 100644 index 0000000..46fb8b2 --- /dev/null +++ b/linden/indra/newview/llagentaccess.cpp | |||
@@ -0,0 +1,177 @@ | |||
1 | /** | ||
2 | * @file llagentaccess.cpp | ||
3 | * @brief LLAgentAccess class implementation - manages maturity and godmode info | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2001-2009, Linden Research, Inc. | ||
8 | * | ||
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 | |||