From eaf595c008998047eaa754696f8b1bec70faa65c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 31 May 2014 11:40:54 -0700 Subject: Fix a bug where estate not found would result in a dummy estate record with erroneous information. Also, added conversion of EstateSettings from/to key-value pairs in preparation for robust net work connectors. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 11 +++++++++-- OpenSim/Framework/EstateSettings.cs | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3dd46cb..69c89d4 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -145,7 +145,11 @@ namespace OpenSim.Data.MySQL cmd.CommandText = sql; cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - return DoLoad(cmd, regionID, create); + EstateSettings e = DoLoad(cmd, regionID, create); + if (!create && e.EstateID == 0) // Not found + return null; + + return e; } } @@ -427,7 +431,10 @@ namespace OpenSim.Data.MySQL cmd.CommandText = sql; cmd.Parameters.AddWithValue("?EstateID", estateID); - return DoLoad(cmd, UUID.Zero, false); + EstateSettings e = DoLoad(cmd, UUID.Zero, false); + if (e.EstateID != estateID) + return null; + return e; } } diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index a02993d..dd3e195 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Reflection; using OpenMetaverse; namespace OpenSim.Framework @@ -411,5 +412,23 @@ namespace OpenSim.Framework { return l_EstateGroups.Contains(groupID); } + + public Dictionary ToMap() + { + Dictionary map = new Dictionary(); + PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); + foreach (PropertyInfo p in properties) + map[p.Name] = p.GetValue(this, null); + + return map; + } + + public EstateSettings(Dictionary map) + { + PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); + foreach (PropertyInfo p in properties) + p.SetValue(this, map[p.Name], null); + + } } } -- cgit v1.1