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