Remove the cruft of accessing a private member of another module's class
from DataSnapshot and replace it with a best practices approach, making it much less dependent on the land module's internal structure and types.0.6.0-stable
parent
e45db5917b
commit
91e3463582
|
@ -119,28 +119,22 @@ namespace OpenSim.Region.DataSnapshot.Providers
|
||||||
|
|
||||||
public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
|
public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
|
||||||
{
|
{
|
||||||
ILandChannel landChannel = (LandChannel)m_scene.LandChannel;
|
ILandChannel landChannel = m_scene.LandChannel;
|
||||||
Dictionary<int, ILandObject> landList = null;
|
List<ILandObject> parcels = landChannel.AllParcels();
|
||||||
try
|
|
||||||
{
|
|
||||||
Type landChannelType = typeof(LandChannel);
|
|
||||||
FieldInfo landListField = landChannelType.GetField("landList", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
if (landListField != null)
|
|
||||||
{
|
|
||||||
landList = (Dictionary<int, ILandObject>)landListField.GetValue(landChannel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString());
|
|
||||||
}
|
|
||||||
XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", "");
|
XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", "");
|
||||||
if (landList != null)
|
if (parcels != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
//foreach (KeyValuePair<int, Land> curParcel in m_landIndexed)
|
//foreach (KeyValuePair<int, Land> curParcel in m_landIndexed)
|
||||||
foreach (LandObject land in landList.Values)
|
foreach (ILandObject parcel_interface in parcels)
|
||||||
{
|
{
|
||||||
|
// Play it safe
|
||||||
|
if (!(parcel_interface is LandObject))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
LandObject land = (LandObject)parcel_interface;
|
||||||
|
|
||||||
LandData parcel = land.landData;
|
LandData parcel = land.landData;
|
||||||
if ((parcel.Flags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory)
|
if ((parcel.Flags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace OpenSim.Region.Environment.Interfaces
|
||||||
{
|
{
|
||||||
|
|
||||||
List<ILandObject> ParcelsNearPoint(Vector3 position);
|
List<ILandObject> ParcelsNearPoint(Vector3 position);
|
||||||
|
List<ILandObject> AllParcels();
|
||||||
ILandObject GetLandObject(int x, int y);
|
ILandObject GetLandObject(int x, int y);
|
||||||
ILandObject GetLandObject(float x, float y);
|
ILandObject GetLandObject(float x, float y);
|
||||||
bool IsLandPrimCountTainted();
|
bool IsLandPrimCountTainted();
|
||||||
|
|
|
@ -105,6 +105,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ILandObject> AllParcels()
|
||||||
|
{
|
||||||
|
if (m_landManagementModule != null)
|
||||||
|
{
|
||||||
|
return m_landManagementModule.AllParcels();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new List<ILandObject>();
|
||||||
|
}
|
||||||
|
|
||||||
public List<ILandObject> ParcelsNearPoint(Vector3 position)
|
public List<ILandObject> ParcelsNearPoint(Vector3 position)
|
||||||
{
|
{
|
||||||
if (m_landManagementModule != null)
|
if (m_landManagementModule != null)
|
||||||
|
|
|
@ -175,6 +175,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||||
AddLandObject(fullSimParcel);
|
AddLandObject(fullSimParcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ILandObject> AllParcels()
|
||||||
|
{
|
||||||
|
return new List<ILandObject>(landList.Values);
|
||||||
|
}
|
||||||
|
|
||||||
public List<ILandObject> ParcelsNearPoint(Vector3 position)
|
public List<ILandObject> ParcelsNearPoint(Vector3 position)
|
||||||
{
|
{
|
||||||
List<ILandObject> parcelsNear = new List<ILandObject>();
|
List<ILandObject> parcelsNear = new List<ILandObject>();
|
||||||
|
|
Loading…
Reference in New Issue