29 using System.Collections.Generic;
30 using System.Reflection;
34 using OpenSim.Framework;
36 using OpenSim.Region.CoreModules.World.Land;
37 using OpenSim.Region.DataSnapshot.Interfaces;
38 using OpenSim.Region.Framework.Interfaces;
39 using OpenSim.Region.Framework.Scenes;
40 using OpenSim.Services.Interfaces;
42 namespace OpenSim.
Region.DataSnapshot.Providers
46 private Scene m_scene = null;
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 private bool m_stale =
true;
105 #region IDataSnapshotProvider members
113 m_scene.EventManager.OnNewClient += OnNewClient;
116 public Scene GetParentScene
118 get {
return m_scene; }
124 List<ILandObject> parcels = landChannel.AllParcels();
128 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element,
"parceldata",
"");
139 LandObject land = (LandObject)parcel_interface;
142 if (m_parent.ExposureLevel.Equals(
"all") ||
143 (m_parent.ExposureLevel.Equals(
"minimum") &&
144 (parcel.
Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory))
148 XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element,
"parcel",
"");
151 XmlAttribute scripts_attr = nodeFactory.CreateAttribute(
"scripts");
152 scripts_attr.Value = GetScriptsPermissions(parcel);
153 XmlAttribute build_attr = nodeFactory.CreateAttribute(
"build");
154 build_attr.Value = GetBuildPermissions(parcel);
155 XmlAttribute public_attr = nodeFactory.CreateAttribute(
"public");
156 public_attr.Value = GetPublicPermissions(parcel);
158 XmlAttribute category_attr = nodeFactory.CreateAttribute(
"category");
159 category_attr.Value = ((int)parcel.
Category).ToString();
161 XmlAttribute forsale_attr = nodeFactory.CreateAttribute(
"forsale");
162 forsale_attr.Value = CheckForSale(parcel);
163 XmlAttribute sales_attr = nodeFactory.CreateAttribute(
"salesprice");
164 sales_attr.Value = parcel.SalePrice.ToString();
166 XmlAttribute directory_attr = nodeFactory.CreateAttribute(
"showinsearch");
167 directory_attr.Value = GetShowInSearch(parcel);
170 xmlparcel.Attributes.Append(directory_attr);
171 xmlparcel.Attributes.Append(scripts_attr);
172 xmlparcel.Attributes.Append(build_attr);
173 xmlparcel.Attributes.Append(public_attr);
174 xmlparcel.Attributes.Append(category_attr);
175 xmlparcel.Attributes.Append(forsale_attr);
176 xmlparcel.Attributes.Append(sales_attr);
181 XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element,
"name",
"");
182 name.InnerText = parcel.Name;
183 xmlparcel.AppendChild(name);
185 XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element,
"description",
"");
186 desc.InnerText = parcel.Description;
187 xmlparcel.AppendChild(desc);
189 XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element,
"uuid",
"");
190 uuid.InnerText = parcel.GlobalID.ToString();
191 xmlparcel.AppendChild(uuid);
193 XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element,
"area",
"");
194 area.InnerText = parcel.Area.ToString();
195 xmlparcel.AppendChild(area);
198 XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element,
"location",
"");
199 Vector3 loc = parcel.UserLocation;
200 if (loc.Equals(Vector3.Zero))
201 loc =
new Vector3((parcel.
AABBMax.X + parcel.
AABBMin.X) / 2, (parcel.AABBMax.Y + parcel.AABBMin.Y) / 2, (parcel.
AABBMax.Z + parcel.
AABBMin.Z) / 2);
202 tpLocation.InnerText = loc.X.ToString() +
"/" + loc.Y.ToString() +
"/" + loc.Z.ToString();
203 xmlparcel.AppendChild(tpLocation);
205 XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element,
"infouuid",
"");
206 uint x = (uint)loc.X, y = (uint)loc.Y;
207 findPointInParcel(land, ref x, ref y);
208 infouuid.InnerText = Util.BuildFakeParcelID(
209 m_scene.RegionInfo.RegionHandle, x, y).ToString();
210 xmlparcel.AppendChild(infouuid);
212 XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element,
"dwell",
"");
213 if (dwellModule != null)
214 dwell.InnerText = dwellModule.GetDwell(parcel.GlobalID).ToString();
216 dwell.InnerText =
"0";
217 xmlparcel.AppendChild(dwell);
224 XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element,
"image",
"");
225 textureuuid.InnerText = parcel.SnapshotID.ToString();
226 xmlparcel.AppendChild(textureuuid);
229 string groupName = String.Empty;
234 XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element,
"group",
"");
235 XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element,
"groupuuid",
"");
236 groupuuid.InnerText = parcel.GroupID.ToString();
237 groupblock.AppendChild(groupuuid);
244 groupName = g.GroupName;
247 XmlNode groupname = nodeFactory.CreateNode(XmlNodeType.Element,
"groupname",
"");
248 groupname.InnerText = groupName;
249 groupblock.AppendChild(groupname);
251 xmlparcel.AppendChild(groupblock);
254 XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element,
"owner",
"");
256 UUID userOwnerUUID = parcel.OwnerID;
258 XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element,
"uuid",
"");
259 useruuid.InnerText = userOwnerUUID.ToString();
260 userblock.AppendChild(useruuid);
266 XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element,
"name",
"");
267 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID);
268 username.InnerText = account.FirstName +
" " + account.LastName;
269 userblock.AppendChild(username);
279 XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element,
"name",
"");
280 username.InnerText = groupName;
281 userblock.AppendChild(username);
284 xmlparcel.AppendChild(userblock);
286 parent.AppendChild(xmlparcel);
298 get {
return "LandSnapshot"; }
320 #region Helper functions
322 private string GetScriptsPermissions(
LandData parcel)
324 if ((parcel.
Flags & (uint)ParcelFlags.AllowOtherScripts) == (uint)ParcelFlags.AllowOtherScripts)
331 private string GetPublicPermissions(
LandData parcel)
333 if ((parcel.
Flags & (uint)ParcelFlags.UseAccessList) == (uint)ParcelFlags.UseAccessList)
340 private string GetBuildPermissions(
LandData parcel)
342 if ((parcel.
Flags & (uint)ParcelFlags.CreateObjects) == (uint)ParcelFlags.CreateObjects)
349 private string CheckForSale(
LandData parcel)
351 if ((parcel.
Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale)
357 private string GetShowInSearch(
LandData parcel)
359 if ((parcel.
Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)
368 #region Change detection hooks
373 client.OnParcelDivideRequest += delegate(
int west,
int south,
int east,
int north,
374 IClientAPI remote_client) { this.Stale =
true; };
375 client.OnParcelJoinRequest += delegate(
int west,
int south,
int east,
int north,
376 IClientAPI remote_client) { this.Stale =
true; };
377 client.OnParcelPropertiesUpdateRequest += delegate(
LandUpdateArgs args,
int local_id,
378 IClientAPI remote_client) { this.Stale =
true; };
379 client.OnParcelBuy += delegate(
UUID agentId,
UUID groupId,
bool final,
bool groupOwned,
380 bool removeContribution,
int parcelLocalID,
int parcelArea,
int parcelPrice,
bool authenticated)
381 { this.Stale =
true; };
398 private void findPointInParcel(
ILandObject land, ref uint refX, ref uint refY)
400 m_log.DebugFormat(
"[DATASNAPSHOT] trying {0}, {1}", refX, refY);
406 uint startY = (uint)land.LandData.AABBMin.Y;
408 uint endY = (uint)land.LandData.AABBMax.Y;
411 refX = (startX + endX) / 2;
412 refY = (startY + endY) / 2;
417 for (uint y = startY; y <= endY; ++y)
419 for (uint x = startX; x <= endX; ++x)
void ParcelPropsHook(LandUpdateArgs args, int local_id, IClientAPI remote_client)
void OnNewClient(IClientAPI client)
delegate void ProviderStale(IDataSnapshotProvider provider)
void Initialize(Scene scene, DataSnapshotManager parent)
Vector3 AABBMin
Lower corner of the AABB for the parcel
Keeps track of a specific piece of land's information
UUID GroupID
Unique ID of the Group that owns
UUID SnapshotID
ID of the snapshot used in the client parcel dialog of the parcel
Details of a Parcel of land
XmlNode RequestSnapshotData(XmlDocument nodeFactory)
bool ContainsPoint(int x, int y)
Vector3 AABBMax
Upper corner of the AABB for the parcel
ParcelCategory Category
Category of parcel. Used for classifying the parcel in classified listings
bool IsGroupOwned
Returns true if the Land Parcel is owned by a group
uint Flags
Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags ...
void ParcelSplitHook(int west, int south, int east, int north, IClientAPI remote_client)