aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs224
1 files changed, 224 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
new file mode 100644
index 0000000..f6d1a82
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
@@ -0,0 +1,224 @@
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.IO;
31using System.Reflection;
32using System.Security;
33using System.Text;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42
43namespace OpenSim.Region.CoreModules.World.Estate
44{
45 /// <summary>
46 /// Estate management console commands.
47 /// </summary>
48 public class EstateManagementCommands
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 protected EstateManagementModule m_module;
53
54 protected Commander m_commander = new Commander("estate");
55
56 public EstateManagementCommands(EstateManagementModule module)
57 {
58 m_module = module;
59 }
60
61 public void Initialise()
62 {
63 m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName);
64
65 m_module.Scene.AddCommand(m_module, "set terrain texture",
66 "set terrain texture <number> <uuid> [<x>] [<y>]",
67 "Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " +
68 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
69 " that coordinate.",
70 consoleSetTerrainTexture);
71
72 m_module.Scene.AddCommand(m_module, "set terrain heights",
73 "set terrain heights <corner> <min> <max> [<x>] [<y>]",
74 "Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
75 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
76 " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
77 consoleSetTerrainHeights);
78
79 Command showCommand
80 = new Command("show", CommandIntentions.COMMAND_STATISTICAL, ShowEstatesCommand, "Shows all estates on the simulator.");
81
82 m_commander.RegisterCommand("show", showCommand);
83
84 m_module.Scene.RegisterModuleCommander(m_commander);
85
86 m_module.Scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole;
87 }
88
89 public void Close()
90 {
91 m_module.Scene.EventManager.OnPluginConsole -= EventManagerOnPluginConsole;
92 m_module.Scene.UnregisterModuleCommander(m_commander.Name);
93 }
94
95 /// <summary>
96 /// Processes commandline input. Do not call directly.
97 /// </summary>
98 /// <param name="args">Commandline arguments</param>
99 protected void EventManagerOnPluginConsole(string[] args)
100 {
101 if (args[0] == "estate")
102 {
103 if (args.Length == 1)
104 {
105 m_commander.ProcessConsoleCommand("help", new string[0]);
106 return;
107 }
108
109 string[] tmpArgs = new string[args.Length - 2];
110 int i;
111 for (i = 2; i < args.Length; i++)
112 tmpArgs[i - 2] = args[i];
113
114 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
115 }
116 }
117
118 protected void consoleSetTerrainTexture(string module, string[] args)
119 {
120 string num = args[3];
121 string uuid = args[4];
122 int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
123 int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
124
125 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
126 {
127 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
128 {
129 int corner = int.Parse(num);
130 UUID texture = UUID.Parse(uuid);
131
132 m_log.Debug("[ESTATEMODULE]: Setting terrain textures for " + m_module.Scene.RegionInfo.RegionName +
133 string.Format(" (C#{0} = {1})", corner, texture));
134
135 switch (corner)
136 {
137 case 0:
138 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
139 break;
140 case 1:
141 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
142 break;
143 case 2:
144 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
145 break;
146 case 3:
147 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
148 break;
149 }
150
151 m_module.Scene.RegionInfo.RegionSettings.Save();
152 m_module.TriggerRegionInfoChange();
153 m_module.sendRegionInfoPacketToAll();
154 }
155 }
156 }
157
158 protected void consoleSetTerrainHeights(string module, string[] args)
159 {
160 string num = args[3];
161 string min = args[4];
162 string max = args[5];
163 int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
164 int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
165
166 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
167 {
168 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
169 {
170 int corner = int.Parse(num);
171 float lowValue = float.Parse(min, Culture.NumberFormatInfo);
172 float highValue = float.Parse(max, Culture.NumberFormatInfo);
173
174 m_log.Debug("[ESTATEMODULE]: Setting terrain heights " + m_module.Scene.RegionInfo.RegionName +
175 string.Format(" (C{0}, {1}-{2}", corner, lowValue, highValue));
176
177 switch (corner)
178 {
179 case 0:
180 m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
181 m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
182 break;
183 case 1:
184 m_module.Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
185 m_module.Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
186 break;
187 case 2:
188 m_module.Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
189 m_module.Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
190 break;
191 case 3:
192 m_module.Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
193 m_module.Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
194 break;
195 }
196
197 m_module.Scene.RegionInfo.RegionSettings.Save();
198 m_module.TriggerRegionInfoChange();
199 m_module.sendRegionHandshakeToAll();
200 }
201 }
202 }
203
204 protected void ShowEstatesCommand(Object[] args)
205 {
206 StringBuilder report = new StringBuilder();
207 RegionInfo ri = m_module.Scene.RegionInfo;
208 EstateSettings es = ri.EstateSettings;
209
210 report.AppendFormat("Estate information for region {0}\n", ri.RegionName);
211 report.AppendFormat(
212 "{0,-20} {1,-7} {2,-20}\n",
213 "Estate Name",
214 "ID",
215 "Owner");
216
217 report.AppendFormat(
218 "{0,-20} {1,-7} {2,-20}\n",
219 es.EstateName, es.EstateID, m_module.UserManager.GetUserName(es.EstateOwner));
220
221 MainConsole.Instance.Output(report.ToString());
222 }
223 }
224} \ No newline at end of file