aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/EstateSettings.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/EstateSettings.cs147
1 files changed, 147 insertions, 0 deletions
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs
index a92abbf..4df7860 100644
--- a/OpenSim/Framework/EstateSettings.cs
+++ b/OpenSim/Framework/EstateSettings.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection;
31using OpenMetaverse; 32using OpenMetaverse;
32 33
33namespace OpenSim.Framework 34namespace OpenSim.Framework
@@ -58,6 +59,30 @@ namespace OpenSim.Framework
58 set { m_EstateName = value; } 59 set { m_EstateName = value; }
59 } 60 }
60 61
62 private bool m_AllowLandmark = true;
63
64 public bool AllowLandmark
65 {
66 get { return m_AllowLandmark; }
67 set { m_AllowLandmark = value; }
68 }
69
70 private bool m_AllowParcelChanges = true;
71
72 public bool AllowParcelChanges
73 {
74 get { return m_AllowParcelChanges; }
75 set { m_AllowParcelChanges = value; }
76 }
77
78 private bool m_AllowSetHome = true;
79
80 public bool AllowSetHome
81 {
82 get { return m_AllowSetHome; }
83 set { m_AllowSetHome = value; }
84 }
85
61 private uint m_ParentEstateID = 1; 86 private uint m_ParentEstateID = 1;
62 87
63 public uint ParentEstateID 88 public uint ParentEstateID
@@ -374,10 +399,132 @@ namespace OpenSim.Framework
374 return l_EstateAccess.Contains(user); 399 return l_EstateAccess.Contains(user);
375 } 400 }
376 401
402 public void SetFromFlags(ulong regionFlags)
403 {
404 ResetHomeOnTeleport = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport) == (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport);
405 BlockDwell = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.BlockDwell) == (ulong)OpenMetaverse.RegionFlags.BlockDwell);
406 AllowLandmark = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowLandmark) == (ulong)OpenMetaverse.RegionFlags.AllowLandmark);
407 AllowParcelChanges = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges) == (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges);
408 AllowSetHome = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowSetHome) == (ulong)OpenMetaverse.RegionFlags.AllowSetHome);
409 }
410
377 public bool GroupAccess(UUID groupID) 411 public bool GroupAccess(UUID groupID)
378 { 412 {
379 return l_EstateGroups.Contains(groupID); 413 return l_EstateGroups.Contains(groupID);
380 } 414 }
381 415
416 public Dictionary<string, object> ToMap()
417 {
418 Dictionary<string, object> map = new Dictionary<string, object>();
419 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
420 foreach (PropertyInfo p in properties)
421 {
422 // EstateBans is a complex type, let's treat it as special
423 if (p.Name == "EstateBans")
424 continue;
425
426 object value = p.GetValue(this, null);
427 if (value != null)
428 {
429 if (p.PropertyType.IsArray) // of UUIDs
430 {
431 if (((Array)value).Length > 0)
432 {
433 string[] args = new string[((Array)value).Length];
434 int index = 0;
435 foreach (object o in (Array)value)
436 args[index++] = o.ToString();
437 map[p.Name] = String.Join(",", args);
438 }
439 }
440 else // simple types
441 map[p.Name] = value;
442 }
443 }
444
445 // EstateBans are special
446 if (EstateBans.Length > 0)
447 {
448 Dictionary<string, object> bans = new Dictionary<string, object>();
449 int i = 0;
450 foreach (EstateBan ban in EstateBans)
451 bans["ban" + i++] = ban.ToMap();
452 map["EstateBans"] = bans;
453 }
454
455 return map;
456 }
457
458 /// <summary>
459 /// For debugging
460 /// </summary>
461 /// <returns></returns>
462 public override string ToString()
463 {
464 Dictionary<string, object> map = ToMap();
465 String result = String.Empty;
466
467 foreach (KeyValuePair<string, object> kvp in map)
468 {
469 if (kvp.Key == "EstateBans")
470 {
471 result += "EstateBans:" + Environment.NewLine;
472 foreach (KeyValuePair<string, object> ban in (Dictionary<string, object>)kvp.Value)
473 result += ban.Value.ToString();
474 }
475 else
476 result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value.ToString(), Environment.NewLine);
477 }
478
479 return result;
480 }
481
482 public EstateSettings(Dictionary<string, object> map)
483 {
484 foreach (KeyValuePair<string, object> kvp in map)
485 {
486 PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
487 if (p == null)
488 continue;
489
490 // EstateBans is a complex type, let's treat it as special
491 if (p.Name == "EstateBans")
492 continue;
493
494 if (p.PropertyType.IsArray)
495 {
496 string[] elements = ((string)map[p.Name]).Split(new char[] { ',' });
497 UUID[] uuids = new UUID[elements.Length];
498 int i = 0;
499 foreach (string e in elements)
500 uuids[i++] = new UUID(e);
501 p.SetValue(this, uuids, null);
502 }
503 else
504 {
505 object value = p.GetValue(this, null);
506 if (value is String)
507 p.SetValue(this, map[p.Name], null);
508 else if (value is UInt32)
509 p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
510 else if (value is Boolean)
511 p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
512 else if (value is UUID)
513 p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
514 }
515 }
516
517 // EstateBans are special
518 if (map.ContainsKey("EstateBans"))
519 {
520 var banData = ((Dictionary<string, object>)map["EstateBans"]).Values;
521 EstateBan[] bans = new EstateBan[banData.Count];
522 int b = 0;
523 foreach (Dictionary<string, object> ban in banData)
524 bans[b++] = new EstateBan(ban);
525 PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
526 bansProperty.SetValue(this, bans, null);
527 }
528 }
382 } 529 }
383} 530}