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