OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
EstateManagementCommands.cs
Go to the documentation of this file.
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 
28 using System;
29 using System.Collections.Generic;
30 using System.IO;
31 using System.Reflection;
32 using System.Security;
33 using System.Text;
34 using log4net;
35 using Nini.Config;
36 using OpenMetaverse;
37 using OpenSim.Framework;
38 using OpenSim.Framework.Console;
39 using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
40 using OpenSim.Region.Framework.Interfaces;
41 using OpenSim.Region.Framework.Scenes;
42 using OpenSim.Services.Interfaces;
43 
44 namespace OpenSim.Region.CoreModules.World.Estate
45 {
50  {
51  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 
54 
56  {
57  m_module = module;
58  }
59 
60  public void Initialise()
61  {
62 // m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName);
63 
64  m_module.Scene.AddCommand("Regions", m_module, "set terrain texture",
65  "set terrain texture <number> <uuid> [<x>] [<y>]",
66  "Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " +
67  "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
68  " that coordinate.",
69  consoleSetTerrainTexture);
70 
71  m_module.Scene.AddCommand("Regions", m_module, "set terrain heights",
72  "set terrain heights <corner> <min> <max> [<x>] [<y>]",
73  "Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
74  "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
75  " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3, all corners = -1.",
76  consoleSetTerrainHeights);
77 
78  m_module.Scene.AddCommand("Regions", m_module, "set water height",
79  "set water height <height> [<x>] [<y>]",
80  "Sets the water height in meters. If <x> and <y> are specified, it will only set it on regions with a matching coordinate. " +
81  "Specify -1 in <x> or <y> to wildcard that coordinate.",
82  consoleSetWaterHeight);
83 
84  m_module.Scene.AddCommand(
85  "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand);
86  }
87 
88  public void Close() {}
89 
90  #region CommandHandlers
91  protected void consoleSetTerrainTexture(string module, string[] args)
92  {
93  string num = args[3];
94  string uuid = args[4];
95  int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
96  int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
97 
98  if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
99  {
100  if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
101  {
102  int corner = int.Parse(num);
103  UUID texture = UUID.Parse(uuid);
104 
105  m_log.Debug("[ESTATEMODULE]: Setting terrain textures for " + m_module.Scene.RegionInfo.RegionName +
106  string.Format(" (C#{0} = {1})", corner, texture));
107 
108  switch (corner)
109  {
110  case 0:
111  m_module.Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
112  break;
113  case 1:
114  m_module.Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
115  break;
116  case 2:
117  m_module.Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
118  break;
119  case 3:
120  m_module.Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
121  break;
122  }
123 
124  m_module.Scene.RegionInfo.RegionSettings.Save();
125  m_module.TriggerRegionInfoChange();
126  m_module.sendRegionHandshakeToAll();
127  }
128  }
129  }
130  protected void consoleSetWaterHeight(string module, string[] args)
131  {
132  string heightstring = args[3];
133 
134  int x = (args.Length > 4 ? int.Parse(args[4]) : -1);
135  int y = (args.Length > 5 ? int.Parse(args[5]) : -1);
136 
137  if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
138  {
139  if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
140  {
141  double selectedheight = double.Parse(heightstring);
142 
143  m_log.Debug("[ESTATEMODULE]: Setting water height in " + m_module.Scene.RegionInfo.RegionName + " to " +
144  string.Format(" {0}", selectedheight));
145  m_module.Scene.RegionInfo.RegionSettings.WaterHeight = selectedheight;
146 
147  m_module.Scene.RegionInfo.RegionSettings.Save();
148  m_module.TriggerRegionInfoChange();
149  m_module.sendRegionHandshakeToAll();
150  }
151  }
152  }
153  protected void consoleSetTerrainHeights(string module, string[] args)
154  {
155  string num = args[3];
156  string min = args[4];
157  string max = args[5];
158  int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
159  int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
160 
161  if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
162  {
163  if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
164  {
165  int corner = int.Parse(num);
166  float lowValue = float.Parse(min, Culture.NumberFormatInfo);
167  float highValue = float.Parse(max, Culture.NumberFormatInfo);
168 
169  m_log.Debug("[ESTATEMODULE]: Setting terrain heights " + m_module.Scene.RegionInfo.RegionName +
170  string.Format(" (C{0}, {1}-{2}", corner, lowValue, highValue));
171 
172  switch (corner)
173  {
174  case -1:
175  m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
176  m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
177  m_module.Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
178  m_module.Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
179  m_module.Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
180  m_module.Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
181  m_module.Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
182  m_module.Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
183  break;
184  case 0:
185  m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
186  m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
187  break;
188  case 1:
189  m_module.Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
190  m_module.Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
191  break;
192  case 2:
193  m_module.Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
194  m_module.Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
195  break;
196  case 3:
197  m_module.Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
198  m_module.Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
199  break;
200  }
201 
202  m_module.Scene.RegionInfo.RegionSettings.Save();
203  m_module.TriggerRegionInfoChange();
204  m_module.sendRegionHandshakeToAll();
205  }
206  }
207  }
208 
209  protected void ShowEstatesCommand(string module, string[] cmd)
210  {
211  StringBuilder report = new StringBuilder();
213  EstateSettings es = ri.EstateSettings;
214 
215  report.AppendFormat("Estate information for region {0}\n", ri.RegionName);
216  report.AppendFormat(
217  "{0,-20} {1,-7} {2,-20}\n",
218  "Estate Name",
219  "ID",
220  "Owner");
221 
222  report.AppendFormat(
223  "{0,-20} {1,-7} {2,-20}\n",
224  es.EstateName, es.EstateID, m_module.UserManager.GetUserName(es.EstateOwner));
225 
226  MainConsole.Instance.Output(report.ToString());
227  }
228  #endregion
229  }
230 }
OpenSim.Framework.RegionInfo RegionInfo
Interactive OpenSim region server
Definition: OpenSim.cs:55