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