diff options
author | Justin Clark-Casey (justincc) | 2012-10-05 04:16:38 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-05 04:16:38 +0100 |
commit | 16feed456adbcf43a9ec797d1a499599aadda6b9 (patch) | |
tree | c65069b9374d5a5e9688cc14e8bc0fae88e3cb00 /OpenSim/Region/CoreModules | |
parent | Add Vector3.Zero return on TryParseConsoleVector() which fails on mono 2.4.3 ... (diff) | |
download | opensim-SC_OLD-16feed456adbcf43a9ec797d1a499599aadda6b9.zip opensim-SC_OLD-16feed456adbcf43a9ec797d1a499599aadda6b9.tar.gz opensim-SC_OLD-16feed456adbcf43a9ec797d1a499599aadda6b9.tar.bz2 opensim-SC_OLD-16feed456adbcf43a9ec797d1a499599aadda6b9.tar.xz |
refactor: eliminate some now duplicate code in ObjectCommandsModule
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 5ecf5a1..fbc64e3 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | |||
@@ -139,7 +139,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
139 | + "show object pos 20,20 to 40,40\n" | 139 | + "show object pos 20,20 to 40,40\n" |
140 | + "show object pos ,20,20 to ,40,40\n" | 140 | + "show object pos ,20,20 to ,40,40\n" |
141 | + "show object pos ,,30 to ,,~\n" | 141 | + "show object pos ,,30 to ,,~\n" |
142 | + "show object pos ,,-~ to ,,30\n", | 142 | + "show object pos ,,-~ to ,,30", |
143 | HandleShowObjectByPos); | 143 | HandleShowObjectByPos); |
144 | 144 | ||
145 | m_console.Commands.AddCommand( | 145 | m_console.Commands.AddCommand( |
@@ -169,6 +169,23 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
169 | // m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | 169 | // m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); |
170 | } | 170 | } |
171 | 171 | ||
172 | private void OutputSogsToConsole(Predicate<SceneObjectGroup> searchPredicate) | ||
173 | { | ||
174 | List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups().FindAll(searchPredicate); | ||
175 | |||
176 | StringBuilder sb = new StringBuilder(); | ||
177 | |||
178 | foreach (SceneObjectGroup so in sceneObjects) | ||
179 | { | ||
180 | AddSceneObjectReport(sb, so); | ||
181 | sb.Append("\n"); | ||
182 | } | ||
183 | |||
184 | sb.AppendFormat("{0} object(s) found in {1}\n", sceneObjects.Count, m_scene.Name); | ||
185 | |||
186 | m_console.OutputFormat(sb.ToString()); | ||
187 | } | ||
188 | |||
172 | private void HandleShowObjectByUuid(string module, string[] cmd) | 189 | private void HandleShowObjectByUuid(string module, string[] cmd) |
173 | { | 190 | { |
174 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 191 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
@@ -219,32 +236,19 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
219 | 236 | ||
220 | string name = mainParams[3]; | 237 | string name = mainParams[3]; |
221 | 238 | ||
222 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); | 239 | Predicate<SceneObjectGroup> searchPredicate; |
223 | Action<SceneObjectGroup> searchAction; | ||
224 | 240 | ||
225 | if (useRegex) | 241 | if (useRegex) |
226 | { | 242 | { |
227 | Regex nameRegex = new Regex(name); | 243 | Regex nameRegex = new Regex(name); |
228 | searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }}; | 244 | searchPredicate = so => nameRegex.IsMatch(so.Name); |
229 | } | 245 | } |
230 | else | 246 | else |
231 | { | 247 | { |
232 | searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }}; | 248 | searchPredicate = so => so.Name == name; |
233 | } | 249 | } |
234 | 250 | ||
235 | m_scene.ForEachSOG(searchAction); | 251 | OutputSogsToConsole(searchPredicate); |
236 | |||
237 | StringBuilder sb = new StringBuilder(); | ||
238 | |||
239 | foreach (SceneObjectGroup so in sceneObjects) | ||
240 | { | ||
241 | AddSceneObjectReport(sb, so); | ||
242 | sb.Append("\n"); | ||
243 | } | ||
244 | |||
245 | sb.AppendFormat("{0} objects found in {1}\n", sceneObjects.Count, m_scene.Name); | ||
246 | |||
247 | m_console.OutputFormat(sb.ToString()); | ||
248 | } | 252 | } |
249 | 253 | ||
250 | private void HandleShowObjectByPos(string module, string[] cmdparams) | 254 | private void HandleShowObjectByPos(string module, string[] cmdparams) |
@@ -276,23 +280,10 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
276 | return; | 280 | return; |
277 | } | 281 | } |
278 | 282 | ||
279 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); | 283 | Predicate<SceneObjectGroup> searchPredicate |
280 | Action<SceneObjectGroup> searchAction | 284 | = so => Util.IsInsideBox(so.AbsolutePosition, startVector, endVector); |
281 | = so => { if (Util.IsInsideBox(so.AbsolutePosition, startVector, endVector)) { sceneObjects.Add(so); }}; | ||
282 | |||
283 | m_scene.ForEachSOG(searchAction); | ||
284 | 285 | ||
285 | StringBuilder sb = new StringBuilder(); | 286 | OutputSogsToConsole(searchPredicate); |
286 | |||
287 | foreach (SceneObjectGroup so in sceneObjects) | ||
288 | { | ||
289 | AddSceneObjectReport(sb, so); | ||
290 | sb.Append("\n"); | ||
291 | } | ||
292 | |||
293 | sb.AppendFormat("{0} objects found in {1}\n", sceneObjects.Count, m_scene.Name); | ||
294 | |||
295 | m_console.OutputFormat(sb.ToString()); | ||
296 | } | 287 | } |
297 | 288 | ||
298 | private void HandleShowPartByUuid(string module, string[] cmd) | 289 | private void HandleShowPartByUuid(string module, string[] cmd) |