From 14a31c3e9b868cb29c55bcfb6c5b8555bf9aae9f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 1 Jun 2014 12:01:49 -0700 Subject: [PATCH] Correct minor bug regarding packing of estate bans --- OpenSim/Framework/EstateSettings.cs | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 328fca4477..4df7860e04 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -443,11 +443,15 @@ namespace OpenSim.Framework } // EstateBans are special - Dictionary bans = new Dictionary(); - int i = 0; - foreach (EstateBan ban in EstateBans) - bans["ban" + i++] = ban.ToMap(); - map["EstateBans"] = bans; + if (EstateBans.Length > 0) + { + Dictionary bans = new Dictionary(); + int i = 0; + foreach (EstateBan ban in EstateBans) + bans["ban" + i++] = ban.ToMap(); + map["EstateBans"] = bans; + } + return map; } @@ -511,13 +515,16 @@ namespace OpenSim.Framework } // EstateBans are special - var banData = ((Dictionary)map["EstateBans"]).Values; - EstateBan[] bans = new EstateBan[banData.Count]; - int b = 0; - foreach (Dictionary ban in banData) - bans[b++] = new EstateBan(ban); - PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); - bansProperty.SetValue(this, bans, null); + if (map.ContainsKey("EstateBans")) + { + var banData = ((Dictionary)map["EstateBans"]).Values; + EstateBan[] bans = new EstateBan[banData.Count]; + int b = 0; + foreach (Dictionary ban in banData) + bans[b++] = new EstateBan(ban); + PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); + bansProperty.SetValue(this, bans, null); + } } } }