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); + } } } }