aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.World/Estate/EstateManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.World/Estate/EstateManager.cs')
-rw-r--r--OpenSim/OpenSim.World/Estate/EstateManager.cs296
1 files changed, 296 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.World/Estate/EstateManager.cs b/OpenSim/OpenSim.World/Estate/EstateManager.cs
new file mode 100644
index 0000000..37abc6d
--- /dev/null
+++ b/OpenSim/OpenSim.World/Estate/EstateManager.cs
@@ -0,0 +1,296 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Framework.Types;
6using OpenSim.Framework.Interfaces;
7using OpenSim.world;
8using OpenSim;
9
10using libsecondlife;
11using libsecondlife.Packets;
12
13namespace OpenSim.world.Estate
14{
15
16 /// <summary>
17 /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings
18 /// </summary>
19 public class EstateManager
20 {
21 private World m_world;
22
23 public EstateManager(World world)
24 {
25 m_world = world; //Estate settings found at world.m_regInfo.estateSettings
26 }
27
28 private bool convertParamStringToBool(byte[] field)
29 {
30 string s = Helpers.FieldToUTF8String(field);
31 if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
32 {
33 return true;
34 }
35 return false;
36 }
37
38 public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
39 {
40 if (remote_client.AgentId == m_world.m_regInfo.MasterAvatarAssignedUUID)
41 {
42 switch (Helpers.FieldToUTF8String(packet.MethodData.Method))
43 {
44 case "getinfo":
45 Console.WriteLine("GETINFO Requested");
46 this.sendRegionInfoPacketToAll();
47
48 break;
49 case "setregioninfo":
50 if (packet.ParamList.Length != 9)
51 {
52 OpenSim.Framework.Console.MainConsole.Instance.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length");
53 }
54 else
55 {
56 m_world.m_regInfo.estateSettings.regionFlags = libsecondlife.Simulator.RegionFlags.None;
57
58 if (convertParamStringToBool(packet.ParamList[0].Parameter))
59 {
60 m_world.m_regInfo.estateSettings.regionFlags = m_world.m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.BlockTerraform;
61 }
62
63 if (convertParamStringToBool(packet.ParamList[1].Parameter))
64 {
65 m_world.m_regInfo.estateSettings.regionFlags = m_world.m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.NoFly;
66 }
67
68 if (convertParamStringToBool(packet.ParamList[2].Parameter))
69 {
70 m_world.m_regInfo.estateSettings.regionFlags = m_world.m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.AllowDamage;
71 }
72
73 if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
74 {
75 m_world.m_regInfo.estateSettings.regionFlags = m_world.m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.BlockLandResell;
76 }
77
78
79 int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
80 m_world.m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents;
81
82 float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
83 m_world.m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor;
84
85 int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
86 m_world.m_regInfo.estateSettings.simAccess = (libsecondlife.Simulator.SimAccess)tempMatureLevel;
87
88
89 if (convertParamStringToBool(packet.ParamList[7].Parameter))
90 {
91 m_world.m_regInfo.estateSettings.regionFlags = m_world.m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.RestrictPushObject;
92 }
93
94 if (convertParamStringToBool(packet.ParamList[8].Parameter))
95 {
96 m_world.m_regInfo.estateSettings.regionFlags = m_world.m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.AllowParcelChanges;
97 }
98
99 sendRegionInfoPacketToAll();
100
101 }
102 break;
103 case "texturebase":
104 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
105 {
106 string s = Helpers.FieldToUTF8String(block.Parameter);
107 string[] splitField = s.Split(' ');
108 if (splitField.Length == 2)
109 {
110 LLUUID tempUUID = new LLUUID(splitField[1]);
111 switch (Convert.ToInt16(splitField[0]))
112 {
113 case 0:
114 m_world.m_regInfo.estateSettings.terrainBase0 = tempUUID;
115 break;
116 case 1:
117 m_world.m_regInfo.estateSettings.terrainBase1 = tempUUID;
118 break;
119 case 2:
120 m_world.m_regInfo.estateSettings.terrainBase2 = tempUUID;
121 break;
122 case 3:
123 m_world.m_regInfo.estateSettings.terrainBase3 = tempUUID;
124 break;
125 }
126 }
127 }
128 break;
129 case "texturedetail":
130 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
131 {
132
133 string s = Helpers.FieldToUTF8String(block.Parameter);
134 string[] splitField = s.Split(' ');
135 if (splitField.Length == 2)
136 {
137 LLUUID tempUUID = new LLUUID(splitField[1]);
138 switch (Convert.ToInt16(splitField[0]))
139 {
140 case 0:
141 m_world.m_regInfo.estateSettings.terrainDetail0 = tempUUID;
142 break;
143 case 1:
144 m_world.m_regInfo.estateSettings.terrainDetail1 = tempUUID;
145 break;
146 case 2:
147 m_world.m_regInfo.estateSettings.terrainDetail2 = tempUUID;
148 break;
149 case 3:
150 m_world.m_regInfo.estateSettings.terrainDetail3 = tempUUID;
151 break;
152 }
153 }
154 }
155 break;
156 case "textureheights":
157 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
158 {
159
160 string s = Helpers.FieldToUTF8String(block.Parameter);
161 string[] splitField = s.Split(' ');
162 if (splitField.Length == 3)
163 {
164
165 float tempHeightLow = (float)Convert.ToDecimal(splitField[1]);
166 float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]);
167
168 switch (Convert.ToInt16(splitField[0]))
169 {
170 case 0:
171 m_world.m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow;
172 m_world.m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh;
173 break;
174 case 1:
175 m_world.m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow;
176 m_world.m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh;
177 break;
178 case 2:
179 m_world.m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow;
180 m_world.m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh;
181 break;
182 case 3:
183 m_world.m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow;
184 m_world.m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh;
185 break;
186 }
187 }
188 }
189 break;
190 case "texturecommit":
191 sendRegionHandshakeToAll();
192 break;
193 case "setregionterrain":
194 if (packet.ParamList.Length != 9)
195 {
196 OpenSim.Framework.Console.MainConsole.Instance.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
197 }
198 else
199 {
200 m_world.m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter));
201 m_world.m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
202 m_world.m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
203 m_world.m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter);
204 m_world.m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
205
206 sendRegionInfoPacketToAll();
207 }
208 break;
209 default:
210 OpenSim.Framework.Console.MainConsole.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
211 break;
212 }
213 }
214 }
215
216 public void sendRegionInfoPacketToAll()
217 {
218 foreach (OpenSim.world.Avatar av in m_world.Avatars.Values)
219 {
220 this.sendRegionInfoPacket(av.ControllingClient);
221 }
222 }
223
224 public void sendRegionHandshakeToAll()
225 {
226 foreach (OpenSim.world.Avatar av in m_world.Avatars.Values)
227 {
228 this.sendRegionHandshake(av.ControllingClient);
229 }
230 }
231
232 public void sendRegionInfoPacket(IClientAPI remote_client)
233 {
234
235 AgentCircuitData circuitData = remote_client.RequestClientInfo();
236
237 RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
238 regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
239 regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
240 regionInfoPacket.RegionInfo.BillableFactor = m_world.m_regInfo.estateSettings.billableFactor;
241 regionInfoPacket.RegionInfo.EstateID = m_world.m_regInfo.estateSettings.estateID;
242 regionInfoPacket.RegionInfo.MaxAgents = m_world.m_regInfo.estateSettings.maxAgents;
243 regionInfoPacket.RegionInfo.ObjectBonusFactor = m_world.m_regInfo.estateSettings.objectBonusFactor;
244 regionInfoPacket.RegionInfo.ParentEstateID = m_world.m_regInfo.estateSettings.parentEstateID;
245 regionInfoPacket.RegionInfo.PricePerMeter = m_world.m_regInfo.estateSettings.pricePerMeter;
246 regionInfoPacket.RegionInfo.RedirectGridX = m_world.m_regInfo.estateSettings.redirectGridX;
247 regionInfoPacket.RegionInfo.RedirectGridY = m_world.m_regInfo.estateSettings.redirectGridY;
248 regionInfoPacket.RegionInfo.RegionFlags = (uint)m_world.m_regInfo.estateSettings.regionFlags;
249 regionInfoPacket.RegionInfo.SimAccess = (byte)m_world.m_regInfo.estateSettings.simAccess;
250 regionInfoPacket.RegionInfo.SimName = Helpers.StringToField(m_world.m_regInfo.RegionName);
251 regionInfoPacket.RegionInfo.SunHour = m_world.m_regInfo.estateSettings.sunHour;
252 regionInfoPacket.RegionInfo.TerrainLowerLimit = m_world.m_regInfo.estateSettings.terrainLowerLimit;
253 regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_world.m_regInfo.estateSettings.terrainRaiseLimit;
254 regionInfoPacket.RegionInfo.UseEstateSun = !m_world.m_regInfo.estateSettings.useFixedSun;
255 regionInfoPacket.RegionInfo.WaterHeight = m_world.m_regInfo.estateSettings.waterHeight;
256
257 remote_client.OutPacket(regionInfoPacket);
258 }
259
260 public void sendRegionHandshake(IClientAPI remote_client)
261 {
262 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
263 RegionHandshakePacket handshake = new RegionHandshakePacket();
264
265 handshake.RegionInfo.BillableFactor = m_world.m_regInfo.estateSettings.billableFactor;
266 handshake.RegionInfo.IsEstateManager = false;
267 handshake.RegionInfo.TerrainHeightRange00 = m_world.m_regInfo.estateSettings.terrainHeightRange0;
268 handshake.RegionInfo.TerrainHeightRange01 = m_world.m_regInfo.estateSettings.terrainHeightRange1;
269 handshake.RegionInfo.TerrainHeightRange10 = m_world.m_regInfo.estateSettings.terrainHeightRange2;
270 handshake.RegionInfo.TerrainHeightRange11 = m_world.m_regInfo.estateSettings.terrainHeightRange3;
271 handshake.RegionInfo.TerrainStartHeight00 = m_world.m_regInfo.estateSettings.terrainStartHeight0;
272 handshake.RegionInfo.TerrainStartHeight01 = m_world.m_regInfo.estateSettings.terrainStartHeight1;
273 handshake.RegionInfo.TerrainStartHeight10 = m_world.m_regInfo.estateSettings.terrainStartHeight2;
274 handshake.RegionInfo.TerrainStartHeight11 = m_world.m_regInfo.estateSettings.terrainStartHeight3;
275 handshake.RegionInfo.SimAccess = (byte)m_world.m_regInfo.estateSettings.simAccess;
276 handshake.RegionInfo.WaterHeight = m_world.m_regInfo.estateSettings.waterHeight;
277
278
279 handshake.RegionInfo.RegionFlags = (uint)m_world.m_regInfo.estateSettings.regionFlags;
280
281 handshake.RegionInfo.SimName = _enc.GetBytes(m_world.m_regInfo.estateSettings.waterHeight + "\0");
282 handshake.RegionInfo.SimOwner = m_world.m_regInfo.MasterAvatarAssignedUUID;
283 handshake.RegionInfo.TerrainBase0 = m_world.m_regInfo.estateSettings.terrainBase0;
284 handshake.RegionInfo.TerrainBase1 = m_world.m_regInfo.estateSettings.terrainBase1;
285 handshake.RegionInfo.TerrainBase2 = m_world.m_regInfo.estateSettings.terrainBase2;
286 handshake.RegionInfo.TerrainBase3 = m_world.m_regInfo.estateSettings.terrainBase3;
287 handshake.RegionInfo.TerrainDetail0 = m_world.m_regInfo.estateSettings.terrainDetail0;
288 handshake.RegionInfo.TerrainDetail1 = m_world.m_regInfo.estateSettings.terrainDetail1;
289 handshake.RegionInfo.TerrainDetail2 = m_world.m_regInfo.estateSettings.terrainDetail2;
290 handshake.RegionInfo.TerrainDetail3 = m_world.m_regInfo.estateSettings.terrainDetail3;
291 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting?
292
293 remote_client.OutPacket(handshake);
294 }
295 }
296}