diff options
author | Melanie Thielker | 2008-09-13 17:50:02 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-09-13 17:50:02 +0000 |
commit | 91e346358283e43644ef9a28483d9fac0b159e45 (patch) | |
tree | aa81e60a0bc02c39b16b803e015d170849e4328d | |
parent | Fix a typo in the DataSnapshot module (diff) | |
download | opensim-SC-91e346358283e43644ef9a28483d9fac0b159e45.zip opensim-SC-91e346358283e43644ef9a28483d9fac0b159e45.tar.gz opensim-SC-91e346358283e43644ef9a28483d9fac0b159e45.tar.bz2 opensim-SC-91e346358283e43644ef9a28483d9fac0b159e45.tar.xz |
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.
4 files changed, 27 insertions, 17 deletions
diff --git a/OpenSim/Region/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/DataSnapshot/LandSnapshot.cs index b0ba29d..dc7ef8c 100644 --- a/OpenSim/Region/DataSnapshot/LandSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/LandSnapshot.cs | |||
@@ -119,28 +119,22 @@ namespace OpenSim.Region.DataSnapshot.Providers | |||
119 | 119 | ||
120 | public XmlNode RequestSnapshotData(XmlDocument nodeFactory) | 120 | public XmlNode RequestSnapshotData(XmlDocument nodeFactory) |
121 | { | 121 | { |
122 | ILandChannel landChannel = (LandChannel)m_scene.LandChannel; | 122 | ILandChannel landChannel = m_scene.LandChannel; |
123 | Dictionary<int, ILandObject> landList = null; | 123 | List<ILandObject> parcels = landChannel.AllParcels(); |
124 | try | 124 | |
125 | { | ||
126 | Type landChannelType = typeof(LandChannel); | ||
127 | FieldInfo landListField = landChannelType.GetField("landList", BindingFlags.NonPublic | BindingFlags.Instance); | ||
128 | if (landListField != null) | ||
129 | { | ||
130 | landList = (Dictionary<int, ILandObject>)landListField.GetValue(landChannel); | ||
131 | } | ||
132 | } | ||
133 | catch (Exception e) | ||
134 | { | ||
135 | m_log.Error("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString()); | ||
136 | } | ||
137 | XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", ""); | 125 | XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", ""); |
138 | if (landList != null) | 126 | if (parcels != null) |
139 | { | 127 | { |
140 | 128 | ||
141 | //foreach (KeyValuePair<int, Land> curParcel in m_landIndexed) | 129 | //foreach (KeyValuePair<int, Land> curParcel in m_landIndexed) |
142 | foreach (LandObject land in landList.Values) | 130 | foreach (ILandObject parcel_interface in parcels) |
143 | { | 131 | { |
132 | // Play it safe | ||
133 | if (!(parcel_interface is LandObject)) | ||
134 | continue; | ||
135 | |||
136 | LandObject land = (LandObject)parcel_interface; | ||
137 | |||
144 | LandData parcel = land.landData; | 138 | LandData parcel = land.landData; |
145 | if ((parcel.Flags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory) | 139 | if ((parcel.Flags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory) |
146 | { | 140 | { |
diff --git a/OpenSim/Region/Environment/Interfaces/ILandChannel.cs b/OpenSim/Region/Environment/Interfaces/ILandChannel.cs index 4a74949..98998f7 100644 --- a/OpenSim/Region/Environment/Interfaces/ILandChannel.cs +++ b/OpenSim/Region/Environment/Interfaces/ILandChannel.cs | |||
@@ -36,6 +36,7 @@ namespace OpenSim.Region.Environment.Interfaces | |||
36 | { | 36 | { |
37 | 37 | ||
38 | List<ILandObject> ParcelsNearPoint(Vector3 position); | 38 | List<ILandObject> ParcelsNearPoint(Vector3 position); |
39 | List<ILandObject> AllParcels(); | ||
39 | ILandObject GetLandObject(int x, int y); | 40 | ILandObject GetLandObject(int x, int y); |
40 | ILandObject GetLandObject(float x, float y); | 41 | ILandObject GetLandObject(float x, float y); |
41 | bool IsLandPrimCountTainted(); | 42 | bool IsLandPrimCountTainted(); |
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs index 1e1291a..8747bd4 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs | |||
@@ -105,6 +105,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
105 | return obj; | 105 | return obj; |
106 | } | 106 | } |
107 | 107 | ||
108 | public List<ILandObject> AllParcels() | ||
109 | { | ||
110 | if (m_landManagementModule != null) | ||
111 | { | ||
112 | return m_landManagementModule.AllParcels(); | ||
113 | } | ||
114 | |||
115 | return new List<ILandObject>(); | ||
116 | } | ||
117 | |||
108 | public List<ILandObject> ParcelsNearPoint(Vector3 position) | 118 | public List<ILandObject> ParcelsNearPoint(Vector3 position) |
109 | { | 119 | { |
110 | if (m_landManagementModule != null) | 120 | if (m_landManagementModule != null) |
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs index f4ba9a3..bf51edb 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs | |||
@@ -175,6 +175,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
175 | AddLandObject(fullSimParcel); | 175 | AddLandObject(fullSimParcel); |
176 | } | 176 | } |
177 | 177 | ||
178 | public List<ILandObject> AllParcels() | ||
179 | { | ||
180 | return new List<ILandObject>(landList.Values); | ||
181 | } | ||
182 | |||
178 | public List<ILandObject> ParcelsNearPoint(Vector3 position) | 183 | public List<ILandObject> ParcelsNearPoint(Vector3 position) |
179 | { | 184 | { |
180 | List<ILandObject> parcelsNear = new List<ILandObject>(); | 185 | List<ILandObject> parcelsNear = new List<ILandObject>(); |