diff options
author | UbitUmarov | 2017-01-07 16:02:52 +0000 |
---|---|---|
committer | UbitUmarov | 2017-01-07 16:02:52 +0000 |
commit | d761a20ccebc0b20237c86bb55683155f0eeaf15 (patch) | |
tree | 61129c3353a437e4bdc8ebe69906d41677f7de15 /OpenSim/Region/Framework/Scenes/GodController.cs | |
parent | try to work around some broken viewers math on handles (diff) | |
download | opensim-SC-d761a20ccebc0b20237c86bb55683155f0eeaf15.zip opensim-SC-d761a20ccebc0b20237c86bb55683155f0eeaf15.tar.gz opensim-SC-d761a20ccebc0b20237c86bb55683155f0eeaf15.tar.bz2 opensim-SC-d761a20ccebc0b20237c86bb55683155f0eeaf15.tar.xz |
more changes to god level control. Not that this is work in progress, for now it still works mainly as with option implicit_gods = true. speed up some regions child updates, some cleanup
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/GodController.cs | 200 |
1 files changed, 127 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index 36483fb..8035760 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs | |||
@@ -47,6 +47,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
47 | { | 47 | { |
48 | public class GodController | 48 | public class GodController |
49 | { | 49 | { |
50 | public enum ImplicitGodLevels : int | ||
51 | { | ||
52 | EstateManager = 210, // estate manager implicit god level | ||
53 | RegionOwner = 220 // region owner implicit god level should be >= than estate | ||
54 | } | ||
55 | |||
50 | ScenePresence m_scenePresence; | 56 | ScenePresence m_scenePresence; |
51 | Scene m_scene; | 57 | Scene m_scene; |
52 | protected bool m_allowGridGods; | 58 | protected bool m_allowGridGods; |
@@ -56,14 +62,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
56 | protected bool m_forceGodModeAlwaysOn; | 62 | protected bool m_forceGodModeAlwaysOn; |
57 | protected bool m_allowGodActionsWithoutGodMode; | 63 | protected bool m_allowGodActionsWithoutGodMode; |
58 | 64 | ||
59 | protected bool m_viewerUiIsGod = false; | ||
60 | |||
61 | protected int m_userLevel = 0; | 65 | protected int m_userLevel = 0; |
62 | 66 | // the god level from local or grid user rights | |
63 | public GodController(Scene scene, ScenePresence sp) | 67 | protected int m_rightsGodLevel = 0; |
68 | // the level seen by viewers | ||
69 | protected int m_godlevel = 0; | ||
70 | // new level that can be fixed or equal to godlevel, acording to options | ||
71 | protected int m_effectivegodlevel = 0; | ||
72 | protected int m_lastLevelToViewer = 0; | ||
73 | |||
74 | public GodController(Scene scene, ScenePresence sp, int userlevel) | ||
64 | { | 75 | { |
65 | m_scene = scene; | 76 | m_scene = scene; |
66 | m_scenePresence = sp; | 77 | m_scenePresence = sp; |
78 | m_userLevel = userlevel; | ||
67 | 79 | ||
68 | IConfigSource config = scene.Config; | 80 | IConfigSource config = scene.Config; |
69 | 81 | ||
@@ -81,7 +93,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
81 | Util.GetConfigVarFromSections<bool>(config, | 93 | Util.GetConfigVarFromSections<bool>(config, |
82 | "force_grid_gods_only", sections, false); | 94 | "force_grid_gods_only", sections, false); |
83 | 95 | ||
84 | if(!m_forceGridGodsOnly) // damm redundant and error prone option | 96 | if(!m_forceGridGodsOnly) |
85 | { | 97 | { |
86 | // The owner of a region is a god in his region only. | 98 | // The owner of a region is a god in his region only. |
87 | m_regionOwnerIsGod = | 99 | m_regionOwnerIsGod = |
@@ -95,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
95 | 107 | ||
96 | } | 108 | } |
97 | else | 109 | else |
98 | m_allowGridGods = true; // reduce user mistakes increased by this over complex options set | 110 | m_allowGridGods = true; // reduce potencial user mistakes |
99 | 111 | ||
100 | // God mode should be turned on in the viewer whenever | 112 | // God mode should be turned on in the viewer whenever |
101 | // the user has god rights somewhere. They may choose | 113 | // the user has god rights somewhere. They may choose |
@@ -110,76 +122,122 @@ namespace OpenSim.Region.Framework.Scenes | |||
110 | m_allowGodActionsWithoutGodMode = | 122 | m_allowGodActionsWithoutGodMode = |
111 | Util.GetConfigVarFromSections<bool>(config, | 123 | Util.GetConfigVarFromSections<bool>(config, |
112 | "implicit_gods", sections, false); | 124 | "implicit_gods", sections, false); |
113 | } | ||
114 | 125 | ||
115 | protected int PotentialGodLevel() | 126 | m_rightsGodLevel = CalcRightsGodLevel(); |
116 | { | 127 | |
117 | int godLevel = m_allowGridGods ? m_userLevel : 200; | 128 | if(m_allowGodActionsWithoutGodMode) |
118 | if ((!m_forceGridGodsOnly) && m_userLevel < 200) | 129 | { |
119 | godLevel = 200; | 130 | m_effectivegodlevel = m_rightsGodLevel; |
131 | |||
132 | m_forceGodModeAlwaysOn = false; | ||
133 | } | ||
134 | |||
135 | else if(m_forceGodModeAlwaysOn) | ||
136 | { | ||
137 | m_godlevel = m_rightsGodLevel; | ||
138 | m_effectivegodlevel = m_rightsGodLevel; | ||
139 | } | ||
120 | 140 | ||
121 | return godLevel; | 141 | m_scenePresence.isGod = (m_effectivegodlevel >= 200); |
142 | m_scenePresence.isLegacyGod = (m_godlevel >= 200); | ||
122 | } | 143 | } |
123 | 144 | ||
124 | protected bool CanBeGod() | 145 | // calculates god level at sp creation from local and grid user god rights |
146 | // for now this is assumed static until user leaves region. | ||
147 | // later estate and gride level updates may update this | ||
148 | protected int CalcRightsGodLevel() | ||
125 | { | 149 | { |
126 | if (m_allowGridGods && m_userLevel > 0) | 150 | int level = 0; |
127 | return true; | 151 | if (m_allowGridGods && m_userLevel >= 200) |
152 | level = m_userLevel; | ||
128 | 153 | ||
129 | if(m_forceGridGodsOnly) | 154 | if(m_forceGridGodsOnly || level >= (int)ImplicitGodLevels.RegionOwner) |
130 | return false; | 155 | return level; |
131 | 156 | ||
132 | if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID)) | 157 | if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID)) |
133 | return true; | 158 | level = (int)ImplicitGodLevels.RegionOwner; |
159 | |||
160 | if(level >= (int)ImplicitGodLevels.EstateManager) | ||
161 | return level; | ||
134 | 162 | ||
135 | if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID)) | 163 | if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID)) |
136 | return true; | 164 | level = (int)ImplicitGodLevels.EstateManager; |
137 | 165 | ||
138 | return false; | 166 | return level; |
139 | } | 167 | } |
140 | 168 | ||
141 | public void SyncViewerState() | 169 | protected bool CanBeGod() |
142 | { | 170 | { |
143 | bool canBeGod = CanBeGod(); | 171 | return m_rightsGodLevel >= 200; |
144 | 172 | } | |
145 | bool shoudBeGod = m_forceGodModeAlwaysOn ? canBeGod : (m_viewerUiIsGod && canBeGod); | ||
146 | 173 | ||
147 | int godLevel = PotentialGodLevel(); | 174 | protected void UpdateGodLevels(bool viewerState) |
175 | { | ||
176 | if(!CanBeGod()) | ||
177 | { | ||
178 | m_godlevel = 0; | ||
179 | m_effectivegodlevel = 0; | ||
180 | m_scenePresence.isGod = false; | ||
181 | m_scenePresence.isLegacyGod = false; | ||
182 | return; | ||
183 | } | ||
148 | 184 | ||
149 | if (!shoudBeGod) | 185 | // legacy some are controled by viewer, others are static |
150 | godLevel = 0; | 186 | if(m_allowGodActionsWithoutGodMode) |
187 | { | ||
188 | if(viewerState) | ||
189 | m_godlevel = m_rightsGodLevel; | ||
190 | else | ||
191 | m_godlevel = 0; | ||
151 | 192 | ||
152 | if (m_viewerUiIsGod != shoudBeGod && (!m_scenePresence.IsChildAgent)) | 193 | m_effectivegodlevel = m_rightsGodLevel; |
194 | } | ||
195 | else | ||
153 | { | 196 | { |
154 | m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); | 197 | // new all change with viewer |
155 | m_viewerUiIsGod = shoudBeGod; | 198 | if(viewerState) |
199 | { | ||
200 | m_godlevel = m_rightsGodLevel; | ||
201 | m_effectivegodlevel = m_rightsGodLevel; | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | m_godlevel = 0; | ||
206 | m_effectivegodlevel = 0; | ||
207 | } | ||
156 | } | 208 | } |
209 | m_scenePresence.isGod = (m_effectivegodlevel >= 200); | ||
210 | m_scenePresence.isLegacyGod = (m_godlevel >= 200); | ||
157 | } | 211 | } |
158 | 212 | ||
159 | public bool RequestGodMode(bool god) | 213 | public void SyncViewerState() |
160 | { | 214 | { |
161 | // this is used by viewer protocol | 215 | if(m_lastLevelToViewer == m_godlevel) |
162 | // and they may want a answer | 216 | return; |
163 | if (!god) | 217 | |
164 | { | 218 | m_lastLevelToViewer = m_godlevel; |
165 | m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, 0); | ||
166 | m_viewerUiIsGod = false; | ||
167 | return true; | ||
168 | } | ||
169 | 219 | ||
170 | if (!CanBeGod()) | 220 | if(m_scenePresence.IsChildAgent) |
171 | return false; | 221 | return; |
172 | 222 | ||
173 | int godLevel = PotentialGodLevel(); | 223 | m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)m_godlevel); |
174 | m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); | ||
175 | m_viewerUiIsGod = true; | ||
176 | return true; | ||
177 | } | 224 | } |
178 | 225 | ||
179 | public OSD State() | 226 | public void RequestGodMode(bool god) |
180 | { | 227 | { |
181 | OSDMap godMap = new OSDMap(2); | 228 | UpdateGodLevels(god); |
182 | 229 | ||
230 | if(m_lastLevelToViewer != m_godlevel) | ||
231 | { | ||
232 | m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)m_godlevel); | ||
233 | m_lastLevelToViewer = m_godlevel; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | public OSD State() | ||
238 | { | ||
239 | OSDMap godMap = new OSDMap(2); | ||
240 | bool m_viewerUiIsGod = m_godlevel >= 200; | ||
183 | godMap.Add("ViewerUiIsGod", OSD.FromBoolean(m_viewerUiIsGod)); | 241 | godMap.Add("ViewerUiIsGod", OSD.FromBoolean(m_viewerUiIsGod)); |
184 | 242 | ||
185 | return godMap; | 243 | return godMap; |
@@ -187,13 +245,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
187 | 245 | ||
188 | public void SetState(OSD state) | 246 | public void SetState(OSD state) |
189 | { | 247 | { |
190 | if(state == null) | 248 | bool newstate = false; |
191 | return; | 249 | if(m_forceGodModeAlwaysOn) |
192 | 250 | newstate = true; | |
193 | OSDMap s = (OSDMap)state; | 251 | else |
252 | { | ||
253 | if(state != null) | ||
254 | { | ||
255 | OSDMap s = (OSDMap)state; | ||
256 | |||
257 | if (s.ContainsKey("ViewerUiIsGod")) | ||
258 | newstate = s["ViewerUiIsGod"].AsBoolean(); | ||
259 | m_lastLevelToViewer = m_godlevel; // we are not changing viewer level by default | ||
260 | } | ||
261 | } | ||
262 | UpdateGodLevels(newstate); | ||
263 | } | ||
194 | 264 | ||
195 | if (s.ContainsKey("ViewerUiIsGod")) | 265 | public void HasMovedAway() |
196 | m_viewerUiIsGod = s["ViewerUiIsGod"].AsBoolean(); | 266 | { |
267 | m_lastLevelToViewer = 0; | ||
197 | } | 268 | } |
198 | 269 | ||
199 | public int UserLevel | 270 | public int UserLevel |
@@ -204,29 +275,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | 275 | ||
205 | public int GodLevel | 276 | public int GodLevel |
206 | { | 277 | { |
207 | get | 278 | get { return m_godlevel; } |
208 | { | ||
209 | int godLevel = PotentialGodLevel(); | ||
210 | if (!m_viewerUiIsGod) | ||
211 | godLevel = 0; | ||
212 | |||
213 | return godLevel; | ||
214 | } | ||
215 | } | 279 | } |
216 | 280 | ||
217 | public int EffectiveLevel | 281 | public int EffectiveLevel |
218 | { | 282 | { |
219 | get | 283 | get { return m_effectivegodlevel; } |
220 | { | ||
221 | int godLevel = PotentialGodLevel(); | ||
222 | if (m_viewerUiIsGod) | ||
223 | return godLevel; | ||
224 | |||
225 | if (m_allowGodActionsWithoutGodMode && CanBeGod()) | ||
226 | return godLevel; | ||
227 | |||
228 | return 0; | ||
229 | } | ||
230 | } | 284 | } |
231 | } | 285 | } |
232 | } | 286 | } |