opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 eva 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  
43 namespace 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("Regions", 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("Regions", 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, all corners = -1.",
77 consoleSetTerrainHeights);
78  
79 m_module.Scene.AddCommand("Regions", m_module, "set water height",
80 "set water height <height> [<x>] [<y>]",
81 "Sets the water height in meters. If <x> and <y> are specified, it will only set it on regions with a matching coordinate. " +
82 "Specify -1 in <x> or <y> to wildcard that coordinate.",
83 consoleSetWaterHeight);
84  
85  
86 m_module.Scene.AddCommand(
87 "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand);
88 }
89  
90 public void Close() {}
91  
92 protected void consoleSetTerrainTexture(string module, string[] args)
93 {
94 string num = args[3];
95 string uuid = args[4];
96 int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
97 int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
98  
99 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
100 {
101 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
102 {
103 int corner = int.Parse(num);
104 UUID texture = UUID.Parse(uuid);
105  
106 m_log.Debug("[ESTATEMODULE]: Setting terrain textures for " + m_module.Scene.RegionInfo.RegionName +
107 string.Format(" (C#{0} = {1})", corner, texture));
108  
109 switch (corner)
110 {
111 case 0:
112 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
113 break;
114 case 1:
115 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
116 break;
117 case 2:
118 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
119 break;
120 case 3:
121 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
122 break;
123 }
124  
125 m_module.Scene.RegionInfo.RegionSettings.Save();
126 m_module.TriggerRegionInfoChange();
127 m_module.sendRegionHandshakeToAll();
128 }
129 }
130 }
131 protected void consoleSetWaterHeight(string module, string[] args)
132 {
133 string heightstring = args[3];
134  
135 int x = (args.Length > 4 ? int.Parse(args[4]) : -1);
136 int y = (args.Length > 5 ? int.Parse(args[5]) : -1);
137  
138 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
139 {
140 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
141 {
142 double selectedheight = double.Parse(heightstring);
143  
144 m_log.Debug("[ESTATEMODULE]: Setting water height in " + m_module.Scene.RegionInfo.RegionName + " to " +
145 string.Format(" {0}", selectedheight));
146 m_module.Scene.RegionInfo.RegionSettings.WaterHeight = selectedheight;
147  
148 m_module.Scene.RegionInfo.RegionSettings.Save();
149 m_module.TriggerRegionInfoChange();
150 m_module.sendRegionHandshakeToAll();
151 }
152 }
153 }
154 protected void consoleSetTerrainHeights(string module, string[] args)
155 {
156 string num = args[3];
157 string min = args[4];
158 string max = args[5];
159 int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
160 int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
161  
162 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
163 {
164 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
165 {
166 int corner = int.Parse(num);
167 float lowValue = float.Parse(min, Culture.NumberFormatInfo);
168 float highValue = float.Parse(max, Culture.NumberFormatInfo);
169  
170 m_log.Debug("[ESTATEMODULE]: Setting terrain heights " + m_module.Scene.RegionInfo.RegionName +
171 string.Format(" (C{0}, {1}-{2}", corner, lowValue, highValue));
172  
173 switch (corner)
174 {
175 case -1:
176 m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
177 m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
178 m_module.Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
179 m_module.Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
180 m_module.Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
181 m_module.Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
182 m_module.Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
183 m_module.Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
184 break;
185 case 0:
186 m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
187 m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
188 break;
189 case 1:
190 m_module.Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
191 m_module.Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
192 break;
193 case 2:
194 m_module.Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
195 m_module.Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
196 break;
197 case 3:
198 m_module.Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
199 m_module.Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
200 break;
201 }
202  
203 m_module.Scene.RegionInfo.RegionSettings.Save();
204 m_module.TriggerRegionInfoChange();
205 m_module.sendRegionHandshakeToAll();
206 }
207 }
208 }
209  
210 protected void ShowEstatesCommand(string module, string[] cmd)
211 {
212 StringBuilder report = new StringBuilder();
213 RegionInfo ri = m_module.Scene.RegionInfo;
214 EstateSettings es = ri.EstateSettings;
215  
216 report.AppendFormat("Estate information for region {0}\n", ri.RegionName);
217 report.AppendFormat(
218 "{0,-20} {1,-7} {2,-20}\n",
219 "Estate Name",
220 "ID",
221 "Owner");
222  
223 report.AppendFormat(
224 "{0,-20} {1,-7} {2,-20}\n",
225 es.EstateName, es.EstateID, m_module.UserManager.GetUserName(es.EstateOwner));
226  
227 MainConsole.Instance.Output(report.ToString());
228 }
229 }
230 }