aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorlbsa712007-09-17 06:57:17 +0000
committerlbsa712007-09-17 06:57:17 +0000
commit6961013c249e7761060bec71ad25d5968424e812 (patch)
tree4306987f6229b83e2a23ad236586522a77327dbc /OpenSim/Region/Environment
parentadded version (diff)
downloadopensim-SC-6961013c249e7761060bec71ad25d5968424e812.zip
opensim-SC-6961013c249e7761060bec71ad25d5968424e812.tar.gz
opensim-SC-6961013c249e7761060bec71ad25d5968424e812.tar.bz2
opensim-SC-6961013c249e7761060bec71ad25d5968424e812.tar.xz
* CHANGED SOME CONSOLE COMMAND BEHAVIOURS
* Normalized 'change-region' so (almost) all commands are context sensitive (use 'root' or '..' to set 'all scenes' context) * 'terrain-sim' is thusly obsolete, use 'change-region', followed by 'terrain' * Introduced SceneManager to administrate operations on group of scenes and moved relevant funcs there. * In it, there's a ForEach(Action<Scene>) that either passes all scenes, or only current scene depending on context. * Changed default prim backup (save-xml/load-xml) xml to "prim-backup.xml" * Changed Disable/EnablePermissions to BypassPermissions = true/false; Also: * Removed unused and non-existent project ref
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/PermissionManager.cs36
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs210
2 files changed, 232 insertions, 14 deletions
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs
index 3e481e8..110a130 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -19,21 +19,17 @@ namespace OpenSim.Region.Environment
19 // disable in any production environment 19 // disable in any production environment
20 // TODO: Change this to false when permissions are a desired default 20 // TODO: Change this to false when permissions are a desired default
21 // TODO: Move to configuration option. 21 // TODO: Move to configuration option.
22 private bool bypassPermissions = true; 22 private bool m_bypassPermissions = true;
23 23 public bool BypassPermissions
24 public PermissionManager(Scene scene)
25 { 24 {
26 m_scene = scene; 25 get { return m_bypassPermissions; }
26 set { m_bypassPermissions = value; }
27 } 27 }
28 28
29 public void DisablePermissions()
30 {
31 bypassPermissions = true;
32 }
33 29
34 public void EnablePermissions() 30 public PermissionManager(Scene scene)
35 { 31 {
36 bypassPermissions = false; 32 m_scene = scene;
37 } 33 }
38 34
39 protected virtual void SendPermissionError(LLUUID user, string reason) 35 protected virtual void SendPermissionError(LLUUID user, string reason)
@@ -43,16 +39,20 @@ namespace OpenSim.Region.Environment
43 39
44 protected virtual bool IsAdministrator(LLUUID user) 40 protected virtual bool IsAdministrator(LLUUID user)
45 { 41 {
46 if (bypassPermissions) 42 if (m_bypassPermissions)
47 return bypassPermissions; 43 {
44 return true;
45 }
48 46
49 return m_scene.RegionInfo.MasterAvatarAssignedUUID == user; 47 return m_scene.RegionInfo.MasterAvatarAssignedUUID == user;
50 } 48 }
51 49
52 protected virtual bool IsEstateManager(LLUUID user) 50 protected virtual bool IsEstateManager(LLUUID user)
53 { 51 {
54 if (bypassPermissions) 52 if (m_bypassPermissions)
55 return bypassPermissions; 53 {
54 return true;
55 }
56 56
57 return false; 57 return false;
58 } 58 }
@@ -74,14 +74,22 @@ namespace OpenSim.Region.Environment
74 string reason = "Insufficient permission"; 74 string reason = "Insufficient permission";
75 75
76 if (IsAdministrator(user)) 76 if (IsAdministrator(user))
77 {
77 permission = true; 78 permission = true;
79 }
78 else 80 else
81 {
79 reason = "Not an administrator"; 82 reason = "Not an administrator";
83 }
80 84
81 if (GenericParcelPermission(user, position)) 85 if (GenericParcelPermission(user, position))
86 {
82 permission = true; 87 permission = true;
88 }
83 else 89 else
90 {
84 reason = "Not the parcel owner"; 91 reason = "Not the parcel owner";
92 }
85 93
86 if (!permission) 94 if (!permission)
87 SendPermissionError(user, reason); 95 SendPermissionError(user, reason);
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
new file mode 100644
index 0000000..9773407
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -0,0 +1,210 @@
1using System.Collections.Generic;
2using System;
3using OpenSim.Framework.Console;
4using OpenSim.Framework.Types;
5
6namespace OpenSim.Region.Environment.Scenes
7{
8 public class SceneManager
9 {
10 private readonly List<Scene> m_localScenes;
11 private Scene m_currentScene = null;
12 public Scene CurrentScene
13 {
14 get
15 {
16 return m_currentScene;
17 }
18 }
19
20 private Scene CurrentOrFirstScene
21 {
22 get
23 {
24 if (m_currentScene == null)
25 {
26 return m_localScenes[0];
27 }
28 else
29 {
30 return m_currentScene;
31 }
32 }
33 }
34
35 public SceneManager()
36 {
37 m_localScenes = new List<Scene>();
38 }
39
40 public void Close()
41 {
42 for (int i = 0; i < m_localScenes.Count; i++)
43 {
44 m_localScenes[i].Close();
45 }
46 }
47
48 public void Add(Scene scene)
49 {
50 m_localScenes.Add(scene);
51 }
52
53 public void SavePrimsToXml(string filename)
54 {
55 CurrentOrFirstScene.SavePrimsToXml(filename);
56 }
57
58 public void LoadPrimsFromXml(string filename)
59 {
60 CurrentOrFirstScene.LoadPrimsFromXml(filename);
61 }
62
63 public bool RunTerrainCmd(string[] cmdparams, ref string result)
64 {
65 if (m_currentScene == null)
66 {
67 bool success = true;
68 foreach (Scene scene in m_localScenes)
69 {
70 if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
71 {
72 success = false;
73 }
74 }
75
76 return success;
77 }
78 else
79 {
80 return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
81 }
82 }
83
84 public void SendCommandToScripts(string[] cmdparams)
85 {
86 ForEach(delegate(Scene scene)
87 {
88 scene.SendCommandToScripts(cmdparams);
89 });
90 }
91
92 public void BypassPermissions(bool bypassPermissions)
93 {
94 ForEach(delegate(Scene scene)
95 {
96 scene.PermissionsMngr.BypassPermissions = bypassPermissions;
97 });
98 }
99
100 private void ForEach(Action<Scene> func)
101 {
102 if (m_currentScene == null)
103 {
104 m_localScenes.ForEach(func);
105 }
106 else
107 {
108 func(m_currentScene);
109 }
110 }
111
112 public void Backup()
113 {
114 ForEach(delegate(Scene scene)
115 {
116 scene.Backup();
117 });
118 }
119
120 public void HandleAlertCommand(string[] cmdparams)
121 {
122 ForEach(delegate(Scene scene)
123 {
124 scene.HandleAlertCommand(cmdparams);
125 });
126 }
127
128 public bool TrySetCurrentRegion(string regionName)
129 {
130 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
131 {
132 m_currentScene = null;
133 return true;
134 }
135 else
136 {
137 Console.WriteLine("Searching for Region: '" + regionName + "'");
138 Scene foundScene = null;
139
140 foreach (Scene scene in m_localScenes)
141 {
142 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
143 {
144 m_currentScene = scene;
145 return true;
146 }
147 }
148
149 return false;
150 }
151 }
152
153 public void DebugPacket(LogBase log, int newDebug)
154 {
155 ForEach(delegate(Scene scene)
156 {
157 foreach (EntityBase entity in scene.Entities.Values)
158 {
159 if (entity is ScenePresence)
160 {
161 ScenePresence scenePrescence = entity as ScenePresence;
162 if (!scenePrescence.childAgent)
163 {
164 log.Error(String.Format("Packet debug for {0} {1} set to {2}",
165 scenePrescence.Firstname, scenePrescence.Lastname,
166 newDebug));
167
168 scenePrescence.ControllingClient.SetDebug(newDebug);
169 }
170 }
171 }
172 });
173 }
174
175 public List<ScenePresence> GetAvatars()
176 {
177 List<ScenePresence> avatars = new List<ScenePresence>();
178
179 ForEach(delegate(Scene scene)
180 {
181 foreach (EntityBase entity in scene.Entities.Values)
182 {
183 if (entity is ScenePresence)
184 {
185 ScenePresence scenePrescence = entity as ScenePresence;
186 if (!scenePrescence.childAgent)
187 {
188 avatars.Add(scenePrescence);
189 }
190 }
191 }
192 });
193
194 return avatars;
195 }
196
197 public RegionInfo GetRegionInfo(ulong regionHandle)
198 {
199 foreach (Scene scene in m_localScenes)
200 {
201 if( scene.RegionInfo.RegionHandle == regionHandle )
202 {
203 return scene.RegionInfo;
204 }
205 }
206
207 return null;
208 }
209 }
210}