aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/EstateSettings.cs
diff options
context:
space:
mode:
authorDiva Canto2014-06-01 10:06:26 -0700
committerDiva Canto2014-06-01 10:06:26 -0700
commit2ff9ea3f8038653135c284cc0c93d88690db9a22 (patch)
tree34448f055a3577311e147503536260337a8d4719 /OpenSim/Framework/EstateSettings.cs
parentFix a bug where estate not found would result in a dummy estate record with e... (diff)
downloadopensim-SC-2ff9ea3f8038653135c284cc0c93d88690db9a22.zip
opensim-SC-2ff9ea3f8038653135c284cc0c93d88690db9a22.tar.gz
opensim-SC-2ff9ea3f8038653135c284cc0c93d88690db9a22.tar.bz2
opensim-SC-2ff9ea3f8038653135c284cc0c93d88690db9a22.tar.xz
Fixed a few things pertaining to interfacing with the estate service. Specifically, StoreEstateSettings was not being used anywhere; instead EstatSetting.Save was being called, but that method is a trigger to the DB-layer code directly, which, besides being wrong, was making it impossible to replace the service with a remote connector.
Also added more packing/unpacking code.
Diffstat (limited to 'OpenSim/Framework/EstateSettings.cs')
-rw-r--r--OpenSim/Framework/EstateSettings.cs101
1 files changed, 95 insertions, 6 deletions
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs
index dd3e195..328fca4 100644
--- a/OpenSim/Framework/EstateSettings.cs
+++ b/OpenSim/Framework/EstateSettings.cs
@@ -418,17 +418,106 @@ namespace OpenSim.Framework
418 Dictionary<string, object> map = new Dictionary<string, object>(); 418 Dictionary<string, object> map = new Dictionary<string, object>();
419 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); 419 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
420 foreach (PropertyInfo p in properties) 420 foreach (PropertyInfo p in properties)
421 map[p.Name] = p.GetValue(this, null); 421 {
422 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 Dictionary<string, object> bans = new Dictionary<string, object>();
447 int i = 0;
448 foreach (EstateBan ban in EstateBans)
449 bans["ban" + i++] = ban.ToMap();
450 map["EstateBans"] = bans;
423 return map; 451 return map;
424 } 452 }
425 453
426 public EstateSettings(Dictionary<string, object> map) 454 /// <summary>
455 /// For debugging
456 /// </summary>
457 /// <returns></returns>
458 public override string ToString()
427 { 459 {
428 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); 460 Dictionary<string, object> map = ToMap();
429 foreach (PropertyInfo p in properties) 461 String result = String.Empty;
430 p.SetValue(this, map[p.Name], null); 462
463 foreach (KeyValuePair<string, object> kvp in map)
464 {
465 if (kvp.Key == "EstateBans")
466 {
467 result += "EstateBans:" + Environment.NewLine;
468 foreach (KeyValuePair<string, object> ban in (Dictionary<string, object>)kvp.Value)
469 result += ban.Value.ToString();
470 }
471 else
472 result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value.ToString(), Environment.NewLine);
473 }
431 474
475 return result;
476 }
477
478 public EstateSettings(Dictionary<string, object> map)
479 {
480 foreach (KeyValuePair<string, object> kvp in map)
481 {
482 PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
483 if (p == null)
484 continue;
485
486 // EstateBans is a complex type, let's treat it as special
487 if (p.Name == "EstateBans")
488 continue;
489
490 if (p.PropertyType.IsArray)
491 {
492 string[] elements = ((string)map[p.Name]).Split(new char[] { ',' });
493 UUID[] uuids = new UUID[elements.Length];
494 int i = 0;
495 foreach (string e in elements)
496 uuids[i++] = new UUID(e);
497 p.SetValue(this, uuids, null);
498 }
499 else
500 {
501 object value = p.GetValue(this, null);
502 if (value is String)
503 p.SetValue(this, map[p.Name], null);
504 else if (value is UInt32)
505 p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
506 else if (value is Boolean)
507 p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
508 else if (value is UUID)
509 p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
510 }
511 }
512
513 // EstateBans are special
514 var banData = ((Dictionary<string, object>)map["EstateBans"]).Values;
515 EstateBan[] bans = new EstateBan[banData.Count];
516 int b = 0;
517 foreach (Dictionary<string, object> ban in banData)
518 bans[b++] = new EstateBan(ban);
519 PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
520 bansProperty.SetValue(this, bans, null);
432 } 521 }
433 } 522 }
434} 523}