aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs206
1 files changed, 206 insertions, 0 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