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