aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-01-31 21:57:45 +0000
committerJustin Clark-Casey (justincc)2012-01-31 21:57:45 +0000
commit9bd02b5da19ae758bfb7a543976b26ced0cd1ba2 (patch)
treeb93dfbe692746cf0e178d0d7beffd56e7d7f8ae6 /OpenSim/Region
parentminor: remove mono compiler warning (diff)
downloadopensim-SC_OLD-9bd02b5da19ae758bfb7a543976b26ced0cd1ba2.zip
opensim-SC_OLD-9bd02b5da19ae758bfb7a543976b26ced0cd1ba2.tar.gz
opensim-SC_OLD-9bd02b5da19ae758bfb7a543976b26ced0cd1ba2.tar.bz2
opensim-SC_OLD-9bd02b5da19ae758bfb7a543976b26ced0cd1ba2.tar.xz
Move object delete commands into a commands region module, in preparation for adding similar show commands.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs206
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs104
2 files changed, 206 insertions, 104 deletions
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
new file mode 100644
index 0000000..57c109e
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -0,0 +1,206 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Statistics;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41
42namespace OpenSim.Region.CoreModules.World.Objects.Commands
43{
44 /// <summary>
45 /// A module that holds commands for manipulating objects in the scene.
46 /// </summary>
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ObjectCommandsModule")]
48 public class ObjectCommandsModule : INonSharedRegionModule
49 {
50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private Scene m_scene;
53
54 public string Name { get { return "Object Commands Module"; } }
55
56 public Type ReplaceableInterface { get { return null; } }
57
58 public void Initialise(IConfigSource source)
59 {
60// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: INITIALIZED MODULE");
61 }
62
63 public void PostInitialise()
64 {
65// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: POST INITIALIZED MODULE");
66 }
67
68 public void Close()
69 {
70// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: CLOSED MODULE");
71 }
72
73 public void AddRegion(Scene scene)
74 {
75// m_log.DebugFormat("[OBJECT COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
76
77 m_scene = scene;
78 }
79
80 public void RemoveRegion(Scene scene)
81 {
82// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
83 }
84
85 public void RegionLoaded(Scene scene)
86 {
87// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
88
89 MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner",
90 "delete object owner <UUID>",
91 "Delete object by owner", HandleDeleteObject);
92 MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator",
93 "delete object creator <UUID>",
94 "Delete object by creator", HandleDeleteObject);
95 MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid",
96 "delete object uuid <UUID>",
97 "Delete object by uuid", HandleDeleteObject);
98 MainConsole.Instance.Commands.AddCommand("region", false, "delete object name",
99 "delete object name <name>",
100 "Delete object by name", HandleDeleteObject);
101 MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside",
102 "delete object outside",
103 "Delete all objects outside boundaries", HandleDeleteObject);
104 }
105
106 private void HandleDeleteObject(string module, string[] cmd)
107 {
108 if (cmd.Length < 3)
109 return;
110
111 string mode = cmd[2];
112 string o = "";
113
114 if (mode != "outside")
115 {
116 if (cmd.Length < 4)
117 return;
118
119 o = cmd[3];
120 }
121
122 List<SceneObjectGroup> deletes = new List<SceneObjectGroup>();
123
124 UUID match;
125
126 switch (mode)
127 {
128 case "owner":
129 if (!UUID.TryParse(o, out match))
130 return;
131
132 m_scene.ForEachSOG(delegate (SceneObjectGroup g)
133 {
134 if (g.OwnerID == match && !g.IsAttachment)
135 deletes.Add(g);
136 });
137
138 break;
139
140 case "creator":
141 if (!UUID.TryParse(o, out match))
142 return;
143
144 m_scene.ForEachSOG(delegate (SceneObjectGroup g)
145 {
146 if (g.RootPart.CreatorID == match && !g.IsAttachment)
147 deletes.Add(g);
148 });
149
150 break;
151
152 case "uuid":
153 if (!UUID.TryParse(o, out match))
154 return;
155
156 m_scene.ForEachSOG(delegate (SceneObjectGroup g)
157 {
158 if (g.UUID == match && !g.IsAttachment)
159 deletes.Add(g);
160 });
161
162 break;
163
164 case "name":
165 m_scene.ForEachSOG(delegate (SceneObjectGroup g)
166 {
167 if (g.RootPart.Name == o && !g.IsAttachment)
168 deletes.Add(g);
169 });
170
171 break;
172
173 case "outside":
174 m_scene.ForEachSOG(delegate (SceneObjectGroup g)
175 {
176 SceneObjectPart rootPart = g.RootPart;
177 bool delete = false;
178
179 if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0)
180 {
181 delete = true;
182 }
183 else
184 {
185 ILandObject parcel
186 = m_scene.LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);
187
188 if (parcel == null || parcel.LandData.Name == "NO LAND")
189 delete = true;
190 }
191
192 if (delete && !g.IsAttachment && !deletes.Contains(g))
193 deletes.Add(g);
194 });
195
196 break;
197 }
198
199 foreach (SceneObjectGroup g in deletes)
200 {
201 MainConsole.Instance.OutputFormat("Deleting object {0}", g.UUID);
202 m_scene.DeleteSceneObject(g, false);
203 }
204 }
205 }
206} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 975d769..df6c88f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -600,23 +600,6 @@ namespace OpenSim.Region.Framework.Scenes
600 "reload estate", 600 "reload estate",
601 "Reload the estate data", HandleReloadEstate); 601 "Reload the estate data", HandleReloadEstate);
602 602
603 MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner",
604 "delete object owner <UUID>",
605 "Delete object by owner", HandleDeleteObject);
606 MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator",
607 "delete object creator <UUID>",
608 "Delete object by creator", HandleDeleteObject);
609 MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid",
610 "delete object uuid <UUID>",
611 "Delete object by uuid", HandleDeleteObject);
612 MainConsole.Instance.Commands.AddCommand("region", false, "delete object name",
613 "delete object name <name>",
614 "Delete object by name", HandleDeleteObject);
615
616 MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside",
617 "delete object outside",
618 "Delete all objects outside boundaries", HandleDeleteObject);
619
620 //Bind Storage Manager functions to some land manager functions for this scene 603 //Bind Storage Manager functions to some land manager functions for this scene
621 EventManager.OnLandObjectAdded += 604 EventManager.OnLandObjectAdded +=
622 new EventManager.LandObjectAdded(simDataService.StoreLandObject); 605 new EventManager.LandObjectAdded(simDataService.StoreLandObject);
@@ -4860,93 +4843,6 @@ namespace OpenSim.Region.Framework.Scenes
4860 } 4843 }
4861 } 4844 }
4862 4845
4863 private void HandleDeleteObject(string module, string[] cmd)
4864 {
4865 if (cmd.Length < 3)
4866 return;
4867
4868 string mode = cmd[2];
4869 string o = "";
4870
4871 if (mode != "outside")
4872 {
4873 if (cmd.Length < 4)
4874 return;
4875
4876 o = cmd[3];
4877 }
4878
4879 List<SceneObjectGroup> deletes = new List<SceneObjectGroup>();
4880
4881 UUID match;
4882
4883 switch (mode)
4884 {
4885 case "owner":
4886 if (!UUID.TryParse(o, out match))
4887 return;
4888 ForEachSOG(delegate (SceneObjectGroup g)
4889 {
4890 if (g.OwnerID == match && !g.IsAttachment)
4891 deletes.Add(g);
4892 });
4893 break;
4894 case "creator":
4895 if (!UUID.TryParse(o, out match))
4896 return;
4897 ForEachSOG(delegate (SceneObjectGroup g)
4898 {
4899 if (g.RootPart.CreatorID == match && !g.IsAttachment)
4900 deletes.Add(g);
4901 });
4902 break;
4903 case "uuid":
4904 if (!UUID.TryParse(o, out match))
4905 return;
4906 ForEachSOG(delegate (SceneObjectGroup g)
4907 {
4908 if (g.UUID == match && !g.IsAttachment)
4909 deletes.Add(g);
4910 });
4911 break;
4912 case "name":
4913 ForEachSOG(delegate (SceneObjectGroup g)
4914 {
4915 if (g.RootPart.Name == o && !g.IsAttachment)
4916 deletes.Add(g);
4917 });
4918 break;
4919 case "outside":
4920 ForEachSOG(delegate (SceneObjectGroup g)
4921 {
4922 SceneObjectPart rootPart = g.RootPart;
4923 bool delete = false;
4924
4925 if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0)
4926 {
4927 delete = true;
4928 }
4929 else
4930 {
4931 ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);
4932
4933 if (parcel == null || parcel.LandData.Name == "NO LAND")
4934 delete = true;
4935 }
4936
4937 if (delete && !g.IsAttachment && !deletes.Contains(g))
4938 deletes.Add(g);
4939 });
4940 break;
4941 }
4942
4943 foreach (SceneObjectGroup g in deletes)
4944 {
4945 m_log.InfoFormat("[SCENE]: Deleting object {0}", g.UUID);
4946 DeleteSceneObject(g, false);
4947 }
4948 }
4949
4950 private void HandleReloadEstate(string module, string[] cmd) 4846 private void HandleReloadEstate(string module, string[] cmd)
4951 { 4847 {
4952 if (MainConsole.Instance.ConsoleScene == null || 4848 if (MainConsole.Instance.ConsoleScene == null ||