aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs744
1 files changed, 744 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
new file mode 100644
index 0000000..daabd9b
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
@@ -0,0 +1,744 @@
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 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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes;
36using OpenSim.Framework;
37using Nini.Config;
38using log4net;
39
40namespace OpenSim.Region.Environment.Modules.World.Estate
41{
42 public class EstateManagementModule : IRegionModule
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45
46 private Scene m_scene;
47
48 public enum EstateAccessCodex : uint
49 {
50 AccessOptions = 17,
51 AllowedGroups = 18,
52 EstateBans = 20,
53 EstateManagers = 24
54 }
55
56
57 #region Helper Functions
58
59 private bool convertParamStringToBool(byte[] field)
60 {
61 string s = Helpers.FieldToUTF8String(field);
62 if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
63 {
64 return true;
65 }
66 return false;
67 }
68
69 /// <summary>
70 /// Sets terrain texture heights for each of the four corners of the region - textures are distributed as a linear range between the two heights.
71 /// </summary>
72 /// <param name="corner">Which corner</param>
73 /// <param name="lowValue">Minimum height that texture range should cover</param>
74 /// <param name="highValue">Maximum height that texture range should cover</param>
75 public void setEstateTextureRange(Int16 corner, float lowValue, float highValue)
76 {
77 switch (corner)
78 {
79 case 0:
80 m_scene.RegionInfo.EstateSettings.terrainStartHeight0 = lowValue;
81 m_scene.RegionInfo.EstateSettings.terrainHeightRange0 = highValue;
82 break;
83 case 1:
84 m_scene.RegionInfo.EstateSettings.terrainStartHeight1 = lowValue;
85 m_scene.RegionInfo.EstateSettings.terrainHeightRange1 = highValue;
86 break;
87 case 2:
88 m_scene.RegionInfo.EstateSettings.terrainStartHeight2 = lowValue;
89 m_scene.RegionInfo.EstateSettings.terrainHeightRange2 = highValue;
90 break;
91 case 3:
92 m_scene.RegionInfo.EstateSettings.terrainStartHeight3 = lowValue;
93 m_scene.RegionInfo.EstateSettings.terrainHeightRange3 = highValue;
94 break;
95 }
96 }
97
98 /// <summary>
99 /// Sets the 'detail' terrain texture on each of the bands.
100 /// </summary>
101 /// <param name="band">Which texture band</param>
102 /// <param name="textureUUID">The UUID of the texture</param>
103 public void setTerrainTexture(Int16 band, LLUUID textureUUID)
104 {
105 switch (band)
106 {
107 case 0:
108 m_scene.RegionInfo.EstateSettings.terrainDetail0 = textureUUID;
109 break;
110 case 1:
111 m_scene.RegionInfo.EstateSettings.terrainDetail1 = textureUUID;
112 break;
113 case 2:
114 m_scene.RegionInfo.EstateSettings.terrainDetail2 = textureUUID;
115 break;
116 case 3:
117 m_scene.RegionInfo.EstateSettings.terrainDetail3 = textureUUID;
118 break;
119 }
120 }
121
122 /// <summary>
123 /// Sets common region settings
124 /// </summary>
125 /// <param name="WaterHeight">Water height of the waterplane (may not nessecarily be one value)</param>
126 /// <param name="TerrainRaiseLimit">Maximum amount terrain can be raised from previous baking</param>
127 /// <param name="TerrainLowerLimit">Minimum amount terrain can be lowered from previous baking</param>
128 /// <param name="UseFixedSun">Use a fixed time of day on the sun?</param>
129 /// <param name="SunHour">The offset hour of the day</param>
130 public void setRegionSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit,
131 bool UseFixedSun, float SunHour)
132 {
133 // Water Height
134 m_scene.RegionInfo.EstateSettings.waterHeight = WaterHeight;
135
136 // Terraforming limits
137 m_scene.RegionInfo.EstateSettings.terrainRaiseLimit = TerrainRaiseLimit;
138 m_scene.RegionInfo.EstateSettings.terrainLowerLimit = TerrainLowerLimit;
139
140 // Time of day / fixed sun
141 m_scene.RegionInfo.EstateSettings.useFixedSun = UseFixedSun;
142 m_scene.RegionInfo.EstateSettings.sunHour = SunHour;
143 }
144 #endregion
145
146 #region Packet Handlers
147
148 public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
149 {
150 switch (Helpers.FieldToUTF8String(packet.MethodData.Method))
151 {
152 case "getinfo":
153
154 //System.Console.WriteLine("[ESTATE]: CLIENT--->" + packet.ToString());
155 //sendRegionInfoPacketToAll();
156 if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
157 {
158 sendDetailedEstateData(remote_client, packet);
159 }
160 break;
161 case "setregioninfo":
162 if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
163 estateSetRegionInfoHandler(packet);
164 break;
165 case "texturebase":
166 if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
167 estateTextureBaseHandler(packet);
168 break;
169 case "texturedetail":
170 if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
171 estateTextureDetailHandler(packet);
172 break;
173 case "textureheights":
174 if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
175 estateTextureHeightsHandler(packet);
176 break;
177 case "texturecommit":
178 sendRegionHandshakeToAll();
179 break;
180 case "setregionterrain":
181 if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
182 estateSetRegionTerrainHandler(packet);
183 break;
184 case "restart":
185 if (m_scene.PermissionsMngr.CanRestartSim(remote_client.AgentId))
186 {
187 estateRestartSim(packet);
188 }
189 break;
190 case "estatechangecovenantid":
191 if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
192 {
193 EstateChangeCovenant(packet);
194 }
195 break;
196 case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
197 if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
198 {
199 estateAccessDelta(remote_client, packet);
200 }
201 break;
202 case "simulatormessage":
203 if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
204 {
205 SendSimulatorBlueBoxMessage(remote_client, packet);
206 }
207 break;
208 case "instantmessage":
209 if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
210 {
211 SendEstateBlueBoxMessage(remote_client, packet);
212 }
213 break;
214 case "setregiondebug":
215 if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
216 {
217 SetRegionDebug(remote_client, packet);
218 }
219 break;
220 case "teleporthomeuser":
221 if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
222 {
223 TeleportOneUserHome(remote_client, packet);
224 }
225 break;
226 default:
227 m_log.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
228 break;
229 }
230
231
232 }
233
234 private void TeleportOneUserHome(object remove_client, EstateOwnerMessagePacket packet)
235 {
236 LLUUID invoice = packet.MethodData.Invoice;
237 LLUUID SenderID = packet.AgentData.AgentID;
238 LLUUID Prey = LLUUID.Zero;
239
240 Helpers.TryParse(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter), out Prey);
241 if (Prey != LLUUID.Zero)
242 {
243 ScenePresence s = m_scene.GetScenePresence(Prey);
244 if (s != null)
245 {
246 m_scene.TeleportClientHome(Prey, s.ControllingClient);
247 }
248 }
249 }
250
251 private void SetRegionDebug(IClientAPI remote_client, EstateOwnerMessagePacket packet)
252 {
253 LLUUID invoice = packet.MethodData.Invoice;
254 LLUUID SenderID = packet.AgentData.AgentID;
255 bool scripted = convertParamStringToBool(packet.ParamList[0].Parameter);
256 bool collisionEvents = convertParamStringToBool(packet.ParamList[1].Parameter);
257 bool physics = convertParamStringToBool(packet.ParamList[2].Parameter);
258
259 if (physics)
260 {
261 m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipPhysics;
262 }
263 else
264 {
265 m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipPhysics;
266 }
267
268 if (scripted)
269 {
270 m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipScripts;
271 }
272 else
273 {
274 m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipScripts;
275 }
276
277
278 m_scene.SetSceneCoreDebug(scripted, collisionEvents, physics);
279 }
280
281 private void SendSimulatorBlueBoxMessage(IClientAPI remote_client, EstateOwnerMessagePacket packet)
282 {
283 LLUUID invoice = packet.MethodData.Invoice;
284 LLUUID SenderID = new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
285 string SenderName = Helpers.FieldToUTF8String(packet.ParamList[3].Parameter);
286 string Message = Helpers.FieldToUTF8String(packet.ParamList[4].Parameter);
287 m_scene.SendRegionMessageFromEstateTools(SenderID, packet.AgentData.SessionID, SenderName, Message);
288
289 }
290 private void SendEstateBlueBoxMessage(IClientAPI remote_client, EstateOwnerMessagePacket packet)
291 {
292 LLUUID invoice = packet.MethodData.Invoice;
293 LLUUID SenderID = packet.AgentData.AgentID;
294 string SenderName = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter);
295 string Message = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter);
296 m_scene.SendEstateMessageFromEstateTools(SenderID, packet.AgentData.SessionID, SenderName, Message);
297
298 }
299 private void sendDetailedEstateData(IClientAPI remote_client, EstateOwnerMessagePacket packet)
300 {
301
302 LLUUID invoice = packet.MethodData.Invoice;
303 packet.AgentData.TransactionID = LLUUID.Random();
304 packet.MethodData.Method = Helpers.StringToField("estateupdateinfo");
305 EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[9];
306
307 for (int i = 0; i < 9; i++)
308 {
309 returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
310 }
311
312 //Sending Estate Settings
313 returnblock[0].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateName);
314 returnblock[1].Parameter = Helpers.StringToField(m_scene.RegionInfo.MasterAvatarAssignedUUID.ToString());
315 returnblock[2].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateID.ToString());
316
317 // TODO: Resolve Magic numbers here
318 returnblock[3].Parameter = Helpers.StringToField("269516800");
319 returnblock[4].Parameter = Helpers.StringToField("0");
320 returnblock[5].Parameter = Helpers.StringToField("1");
321 returnblock[6].Parameter = Helpers.StringToField(m_scene.RegionInfo.RegionID.ToString());
322 returnblock[7].Parameter = Helpers.StringToField("1160895077");
323 returnblock[8].Parameter = Helpers.StringToField("1");
324
325 packet.ParamList = returnblock;
326 packet.Header.Reliable = false;
327 //System.Console.WriteLine("[ESTATE]: SIM--->" + packet.ToString());
328 remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
329
330 sendEstateManagerList(remote_client, packet);
331
332 }
333
334 private void sendEstateManagerList(IClientAPI remote_client, EstateOwnerMessagePacket packet)
335 {
336 LLUUID invoice = packet.MethodData.Invoice;
337
338 //Sending Estate Managers
339 packet = new EstateOwnerMessagePacket();
340 packet.AgentData.TransactionID = LLUUID.Random();
341 packet.AgentData.AgentID = remote_client.AgentId;
342 packet.AgentData.SessionID = remote_client.SessionId;
343 packet.MethodData.Invoice = invoice;
344 packet.MethodData.Method = Helpers.StringToField("setaccess");
345
346 LLUUID[] EstateManagers = m_scene.RegionInfo.EstateSettings.estateManagers;
347
348 EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + EstateManagers.Length];
349
350 for (int i = 0; i < (6 + EstateManagers.Length); i++)
351 {
352 returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
353 }
354 int j = 0;
355
356 returnblock[j].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateID.ToString()); j++;
357 returnblock[j].Parameter = Helpers.StringToField(((int)EstateAccessCodex.EstateManagers).ToString()); j++;
358 returnblock[j].Parameter = Helpers.StringToField("0"); j++;
359 returnblock[j].Parameter = Helpers.StringToField("0"); j++;
360 returnblock[j].Parameter = Helpers.StringToField("0"); j++;
361 returnblock[j].Parameter = Helpers.StringToField(EstateManagers.Length.ToString()); j++;
362 for (int i = 0; i < EstateManagers.Length; i++)
363 {
364 returnblock[j].Parameter = EstateManagers[i].GetBytes(); j++;
365 }
366 packet.ParamList = returnblock;
367 packet.Header.Reliable = false;
368 //System.Console.WriteLine("[ESTATE]: SIM--->" + packet.ToString());
369 remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
370 }
371
372 private void estateAccessDelta(IClientAPI remote_client, EstateOwnerMessagePacket packet)
373 {
374 // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
375 int estateAccessType = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
376
377 switch (estateAccessType)
378 {
379 case 256:
380
381 // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml
382 // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates
383 if (packet.AgentData.AgentID == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions)
384 {
385 m_scene.RegionInfo.EstateSettings.AddEstateManager(new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)));
386 sendEstateManagerList(remote_client, packet);
387 }
388 else
389 {
390 remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
391 }
392
393 break;
394 case 512:
395 // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml
396 // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates
397 if (packet.AgentData.AgentID == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions)
398 {
399 m_scene.RegionInfo.EstateSettings.RemoveEstateManager(new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)));
400 sendEstateManagerList(remote_client, packet);
401 }
402 else
403 {
404 remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
405 }
406 break;
407
408 default:
409
410 m_log.Error("EstateOwnerMessage: Unknown EstateAccessType requested in estateAccessDelta\n" + packet.ToString());
411 break;
412 }
413 //m_log.Error("EstateOwnerMessage: estateAccessDelta\n" + packet.ToString());
414
415
416 }
417 private void estateSetRegionInfoHandler(EstateOwnerMessagePacket packet)
418 {
419 if (packet.ParamList.Length != 9)
420 {
421 m_log.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length");
422 }
423 else
424 {
425 m_scene.RegionInfo.EstateSettings.regionFlags = Simulator.RegionFlags.None;
426
427 if (convertParamStringToBool(packet.ParamList[0].Parameter))
428 {
429 m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
430 Simulator.RegionFlags.BlockTerraform;
431 }
432
433 if (convertParamStringToBool(packet.ParamList[1].Parameter))
434 {
435 m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
436 Simulator.RegionFlags.NoFly;
437 }
438
439 if (convertParamStringToBool(packet.ParamList[2].Parameter))
440 {
441 m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
442 Simulator.RegionFlags.AllowDamage;
443 }
444
445 if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
446 {
447 m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
448 Simulator.RegionFlags.BlockLandResell;
449 }
450
451
452 int tempMaxAgents =
453 Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
454 m_scene.RegionInfo.EstateSettings.maxAgents = (byte)tempMaxAgents;
455
456 float tempObjectBonusFactor =
457 (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
458 m_scene.RegionInfo.EstateSettings.objectBonusFactor = tempObjectBonusFactor;
459
460 int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
461 m_scene.RegionInfo.EstateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel;
462
463
464 if (convertParamStringToBool(packet.ParamList[7].Parameter))
465 {
466 m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
467 Simulator.RegionFlags.RestrictPushObject;
468 }
469
470 if (convertParamStringToBool(packet.ParamList[8].Parameter))
471 {
472 m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
473 Simulator.RegionFlags.AllowParcelChanges;
474 }
475
476 sendRegionInfoPacketToAll();
477 }
478 }
479
480 private void estateSetRegionTerrainHandler(EstateOwnerMessagePacket packet)
481 {
482 if (packet.ParamList.Length != 9)
483 {
484 m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
485 }
486 else
487 {
488 try
489 {
490 string tmp;
491 tmp = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter);
492 if (!tmp.Contains(".")) tmp += ".00";
493 float WaterHeight = (float)Convert.ToDecimal(tmp);
494 tmp = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter);
495 if (!tmp.Contains(".")) tmp += ".00";
496 float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp);
497 tmp = Helpers.FieldToUTF8String(packet.ParamList[2].Parameter);
498 if (!tmp.Contains(".")) tmp += ".00";
499 float TerrainLowerLimit = (float)Convert.ToDecimal(tmp);
500 bool UseFixedSun = convertParamStringToBool(packet.ParamList[4].Parameter);
501 float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
502
503 setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour);
504
505 sendRegionInfoPacketToAll();
506 }
507 catch (Exception ex)
508 {
509 m_log.Error("EstateManager: Exception while setting terrain settings: \n" + packet.ToString() + "\n" + ex.ToString());
510 }
511 }
512 }
513
514 private void estateTextureHeightsHandler(EstateOwnerMessagePacket packet)
515 {
516 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
517 {
518 string s = Helpers.FieldToUTF8String(block.Parameter);
519 string[] splitField = s.Split(' ');
520 if (splitField.Length == 3)
521 {
522 Int16 corner = Convert.ToInt16(splitField[0]);
523 float lowValue = (float)Convert.ToDecimal(splitField[1]);
524 float highValue = (float)Convert.ToDecimal(splitField[2]);
525
526 setEstateTextureRange(corner, lowValue, highValue);
527 }
528 }
529 }
530
531 private void estateTextureDetailHandler(EstateOwnerMessagePacket packet)
532 {
533 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
534 {
535 string s = Helpers.FieldToUTF8String(block.Parameter);
536 string[] splitField = s.Split(' ');
537 if (splitField.Length == 2)
538 {
539 Int16 corner = Convert.ToInt16(splitField[0]);
540 LLUUID textureUUID = new LLUUID(splitField[1]);
541
542 setTerrainTexture(corner, textureUUID);
543 }
544 }
545 }
546
547 private void estateTextureBaseHandler(EstateOwnerMessagePacket packet)
548 {
549 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
550 {
551 string s = Helpers.FieldToUTF8String(block.Parameter);
552 string[] splitField = s.Split(' ');
553 if (splitField.Length == 2)
554 {
555 LLUUID tempUUID = new LLUUID(splitField[1]);
556 switch (Convert.ToInt16(splitField[0]))
557 {
558 case 0:
559 m_scene.RegionInfo.EstateSettings.terrainBase0 = tempUUID;
560 break;
561 case 1:
562 m_scene.RegionInfo.EstateSettings.terrainBase1 = tempUUID;
563 break;
564 case 2:
565 m_scene.RegionInfo.EstateSettings.terrainBase2 = tempUUID;
566 break;
567 case 3:
568 m_scene.RegionInfo.EstateSettings.terrainBase3 = tempUUID;
569 break;
570 }
571 }
572 }
573 }
574
575 private void estateRestartSim(EstateOwnerMessagePacket packet)
576 {
577 // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
578 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
579 {
580 float timeSeconds = 0;
581 Helpers.TryParse(Helpers.FieldToUTF8String(block.Parameter), out timeSeconds);
582 timeSeconds = (int)timeSeconds;
583 m_scene.Restart(timeSeconds);
584
585 }
586 }
587
588 private void EstateChangeCovenant(EstateOwnerMessagePacket packet)
589 {
590 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
591 {
592 LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter));
593 m_scene.RegionInfo.CovenantID = newCovenantID;
594 m_scene.RegionInfo.SaveEstatecovenantUUID(newCovenantID);
595 }
596 }
597
598 public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID)
599 {
600 RegionInfoPacket rinfopack = new RegionInfoPacket();
601 RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
602 rinfopack.AgentData.AgentID = client.AgentId;
603 rinfopack.AgentData.SessionID = client.SessionId;
604 rinfoblk.BillableFactor = m_scene.RegionInfo.EstateSettings.billableFactor;
605 rinfoblk.EstateID = m_scene.RegionInfo.EstateSettings.estateID;
606 rinfoblk.MaxAgents = m_scene.RegionInfo.EstateSettings.maxAgents;
607 rinfoblk.ObjectBonusFactor = m_scene.RegionInfo.EstateSettings.objectBonusFactor;
608 rinfoblk.ParentEstateID = m_scene.RegionInfo.EstateSettings.parentEstateID;
609 rinfoblk.PricePerMeter = m_scene.RegionInfo.EstateSettings.pricePerMeter;
610 rinfoblk.RedirectGridX = m_scene.RegionInfo.EstateSettings.redirectGridX;
611 rinfoblk.RedirectGridY = m_scene.RegionInfo.EstateSettings.redirectGridY;
612 rinfoblk.RegionFlags = (uint)(m_scene.RegionInfo.EstateSettings.regionFlags);
613 rinfoblk.SimAccess = (byte)m_scene.RegionInfo.EstateSettings.simAccess;
614 rinfoblk.SunHour = m_scene.RegionInfo.EstateSettings.sunHour;
615 rinfoblk.TerrainLowerLimit = m_scene.RegionInfo.EstateSettings.terrainLowerLimit;
616 rinfoblk.TerrainRaiseLimit = m_scene.RegionInfo.EstateSettings.terrainRaiseLimit;
617 rinfoblk.UseEstateSun = !m_scene.RegionInfo.EstateSettings.useFixedSun;
618 rinfoblk.WaterHeight = m_scene.RegionInfo.EstateSettings.waterHeight;
619 rinfoblk.SimName = Helpers.StringToField(m_scene.RegionInfo.RegionName);
620
621 rinfopack.RegionInfo = rinfoblk;
622
623 client.OutPacket(rinfopack, ThrottleOutPacketType.Task);
624 }
625
626 public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID)
627 {
628 EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
629 EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
630 edata.CovenantID = m_scene.RegionInfo.CovenantID;
631 edata.CovenantTimestamp = 0;
632 edata.EstateOwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
633 edata.EstateName =
634 Helpers.StringToField(m_scene.RegionInfo.MasterAvatarFirstName + " " + m_scene.RegionInfo.MasterAvatarLastName);
635 einfopack.Data = edata;
636 client.OutPacket(einfopack, ThrottleOutPacketType.Task);
637 }
638
639 #endregion
640
641 #region Outgoing Packets
642
643 public void sendRegionInfoPacketToAll()
644 {
645 List<ScenePresence> avatars = m_scene.GetAvatars();
646
647 for (int i = 0; i < avatars.Count; i++)
648 {
649 sendRegionInfoPacket(avatars[i].ControllingClient);
650 }
651 }
652
653 public void sendRegionHandshakeToAll()
654 {
655 m_scene.Broadcast(
656 sendRegionHandshake
657 );
658 }
659
660 public void sendRegionInfoPacket(IClientAPI remote_client)
661 {
662 AgentCircuitData circuitData = remote_client.RequestClientInfo();
663
664 RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
665 regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
666 regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
667 regionInfoPacket.RegionInfo.BillableFactor = m_scene.RegionInfo.EstateSettings.billableFactor;
668 regionInfoPacket.RegionInfo.EstateID = m_scene.RegionInfo.EstateSettings.estateID;
669 regionInfoPacket.RegionInfo.MaxAgents = m_scene.RegionInfo.EstateSettings.maxAgents;
670 regionInfoPacket.RegionInfo.ObjectBonusFactor = m_scene.RegionInfo.EstateSettings.objectBonusFactor;
671 regionInfoPacket.RegionInfo.ParentEstateID = m_scene.RegionInfo.EstateSettings.parentEstateID;
672 regionInfoPacket.RegionInfo.PricePerMeter = m_scene.RegionInfo.EstateSettings.pricePerMeter;
673 regionInfoPacket.RegionInfo.RedirectGridX = m_scene.RegionInfo.EstateSettings.redirectGridX;
674 regionInfoPacket.RegionInfo.RedirectGridY = m_scene.RegionInfo.EstateSettings.redirectGridY;
675 regionInfoPacket.RegionInfo.RegionFlags = (uint)(m_scene.RegionInfo.EstateSettings.regionFlags);
676 regionInfoPacket.RegionInfo.SimAccess = (byte)m_scene.RegionInfo.EstateSettings.simAccess;
677 regionInfoPacket.RegionInfo.SimName = Helpers.StringToField(m_scene.RegionInfo.RegionName);
678 regionInfoPacket.RegionInfo.SunHour = m_scene.RegionInfo.EstateSettings.sunHour;
679 regionInfoPacket.RegionInfo.TerrainLowerLimit = m_scene.RegionInfo.EstateSettings.terrainLowerLimit;
680 regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_scene.RegionInfo.EstateSettings.terrainRaiseLimit;
681 regionInfoPacket.RegionInfo.UseEstateSun = !m_scene.RegionInfo.EstateSettings.useFixedSun;
682 regionInfoPacket.RegionInfo.WaterHeight = m_scene.RegionInfo.EstateSettings.waterHeight;
683
684
685 remote_client.OutPacket(regionInfoPacket, ThrottleOutPacketType.Task);
686 }
687
688 public void sendRegionHandshake(IClientAPI remoteClient)
689 {
690 remoteClient.SendRegionHandshake(m_scene.RegionInfo);
691 }
692
693 #endregion
694
695 #region IRegionModule Members
696
697 public void Initialise(Scene scene, IConfigSource source)
698 {
699 m_scene = scene;
700 m_scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
701 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
702
703 }
704
705 void EventManager_OnNewClient(IClientAPI client)
706 {
707 client.OnEstateOwnerMessage += handleEstateOwnerMessage;
708 client.OnRegionInfoRequest += HandleRegionInfoRequest;
709 client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
710 sendRegionHandshake(client);
711 }
712
713
714 public void PostInitialise()
715 {
716 }
717
718 public void Close()
719 {
720 }
721
722 public string Name
723 {
724 get { return "EstateManagementModule"; }
725 }
726
727 public bool IsSharedModule
728 {
729 get { return false; }
730 }
731
732 #endregion
733
734 #region Other Functions
735
736 public void changeWaterHeight(float height)
737 {
738 setRegionSettings(height, m_scene.RegionInfo.EstateSettings.terrainRaiseLimit, m_scene.RegionInfo.EstateSettings.terrainLowerLimit, m_scene.RegionInfo.EstateSettings.useFixedSun, m_scene.RegionInfo.EstateSettings.sunHour);
739 sendRegionInfoPacketToAll();
740 }
741 #endregion
742
743 }
744}