public LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess) { // m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {1}", // regionHandle, m_Scenes.Count); uint rx = 0, ry = 0; Util.RegionHandleToWorldLoc(regionHandle, out rx, out ry); rx += x; ry += y; foreach (Scene s in m_Scenes) { uint t = s.RegionInfo.WorldLocX; if (rx < t) { continue; } t += s.RegionInfo.RegionSizeX; if (rx >= t) { continue; } t = s.RegionInfo.WorldLocY; if (ry < t) { continue; } t += s.RegionInfo.RegionSizeY; if (ry < t) { // m_log.Debug("[LAND IN CONNECTOR]: Found region to GetLandData from"); x = rx - s.RegionInfo.WorldLocX; y = ry - s.RegionInfo.WorldLocY; regionAccess = s.RegionInfo.AccessLevel; LandData land = s.GetLandData(x, y); IDwellModule dwellModule = s.RequestModuleInterface <IDwellModule>(); if (dwellModule != null) { land.Dwell = dwellModule.GetDwell(land); } return(land); } } m_log.DebugFormat("[LAND IN CONNECTOR]: region handle {0} not found", regionHandle); regionAccess = 42; return(null); }
public LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess) { regionAccess = 2; // m_log.DebugFormat("[LAND CONNECTOR]: request for land data in {0} at {1}, {2}", // regionHandle, x, y); uint rx = 0, ry = 0; Util.RegionHandleToWorldLoc(regionHandle, out rx, out ry); foreach (Scene s in m_Scenes) { uint t = s.RegionInfo.WorldLocX; if (rx < t) { continue; } t += s.RegionInfo.RegionSizeX; if (rx >= t) { continue; } t = s.RegionInfo.WorldLocY; if (ry < t) { continue; } t += s.RegionInfo.RegionSizeY; if (ry < t) { LandData land = s.GetLandData(x, y); regionAccess = s.RegionInfo.AccessLevel; IDwellModule dwellModule = s.RequestModuleInterface <IDwellModule>(); if (dwellModule != null) { land.Dwell = dwellModule.GetDwell(land); } return(land); } } //m_log.Debug("[LAND CONNECTOR]: didn't find land data locally."); return(null); }
public XmlNode RequestSnapshotData(XmlDocument nodeFactory) { XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", ""); ILandChannel landChannel = m_scene.LandChannel; if (landChannel == null) { return(parent); } List <ILandObject> parcels = landChannel.AllParcels(); IDwellModule dwellModule = m_scene.RequestModuleInterface <IDwellModule>(); if (parcels != null) { //foreach (KeyValuePair<int, Land> curParcel in m_landIndexed) foreach (ILandObject parcel_interface in parcels) { // Play it safe if (!(parcel_interface is LandObject)) { continue; } LandObject land = (LandObject)parcel_interface; LandData parcel = land.LandData; if (m_parent.ExposureLevel.Equals("all") || (m_parent.ExposureLevel.Equals("minimum") && (parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)) { //TODO: make better method of marshalling data from LandData to XmlNode XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", ""); // Attributes of the parcel node XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts"); scripts_attr.Value = GetScriptsPermissions(parcel); XmlAttribute build_attr = nodeFactory.CreateAttribute("build"); build_attr.Value = GetBuildPermissions(parcel); XmlAttribute public_attr = nodeFactory.CreateAttribute("public"); public_attr.Value = GetPublicPermissions(parcel); // Check the category of the Parcel XmlAttribute category_attr = nodeFactory.CreateAttribute("category"); category_attr.Value = ((int)parcel.Category).ToString(); // Check if the parcel is for sale XmlAttribute forsale_attr = nodeFactory.CreateAttribute("forsale"); forsale_attr.Value = CheckForSale(parcel); XmlAttribute sales_attr = nodeFactory.CreateAttribute("salesprice"); sales_attr.Value = parcel.SalePrice.ToString(); XmlAttribute directory_attr = nodeFactory.CreateAttribute("showinsearch"); directory_attr.Value = GetShowInSearch(parcel); //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities"); //entities_attr.Value = land.primsOverMe.Count.ToString(); xmlparcel.Attributes.Append(directory_attr); xmlparcel.Attributes.Append(scripts_attr); xmlparcel.Attributes.Append(build_attr); xmlparcel.Attributes.Append(public_attr); xmlparcel.Attributes.Append(category_attr); xmlparcel.Attributes.Append(forsale_attr); xmlparcel.Attributes.Append(sales_attr); //xmlparcel.Attributes.Append(entities_attr); //name, description, area, and UUID XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); name.InnerText = parcel.Name; xmlparcel.AppendChild(name); XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); desc.InnerText = parcel.Description; xmlparcel.AppendChild(desc); XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); uuid.InnerText = parcel.GlobalID.ToString(); xmlparcel.AppendChild(uuid); XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", ""); area.InnerText = parcel.Area.ToString(); xmlparcel.AppendChild(area); //default location XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); Vector3 loc = parcel.UserLocation; if (loc.Equals(Vector3.Zero)) // This test is moot at this point: the location is wrong by default { loc = new Vector3((parcel.AABBMax.X + parcel.AABBMin.X) / 2, (parcel.AABBMax.Y + parcel.AABBMin.Y) / 2, (parcel.AABBMax.Z + parcel.AABBMin.Z) / 2); } tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); xmlparcel.AppendChild(tpLocation); XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", ""); uint x = (uint)loc.X, y = (uint)loc.Y; findPointInParcel(land, ref x, ref y); // find a suitable spot infouuid.InnerText = Util.BuildFakeParcelID( m_scene.RegionInfo.RegionHandle, x, y).ToString(); xmlparcel.AppendChild(infouuid); XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", ""); if (dwellModule != null) { dwell.InnerText = dwellModule.GetDwell(parcel.GlobalID).ToString(); } else { dwell.InnerText = "0"; } xmlparcel.AppendChild(dwell); //TODO: figure how to figure out teleport system landData.landingType //land texture snapshot uuid if (parcel.SnapshotID != UUID.Zero) { XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); textureuuid.InnerText = parcel.SnapshotID.ToString(); xmlparcel.AppendChild(textureuuid); } string groupName = String.Empty; //attached user and group if (parcel.GroupID != UUID.Zero) { XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", ""); XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element, "groupuuid", ""); groupuuid.InnerText = parcel.GroupID.ToString(); groupblock.AppendChild(groupuuid); IGroupsModule gm = m_scene.RequestModuleInterface <IGroupsModule>(); if (gm != null) { GroupRecord g = gm.GetGroupRecord(parcel.GroupID); if (g != null) { groupName = g.GroupName; } } XmlNode groupname = nodeFactory.CreateNode(XmlNodeType.Element, "groupname", ""); groupname.InnerText = groupName; groupblock.AppendChild(groupname); xmlparcel.AppendChild(groupblock); } XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", ""); UUID userOwnerUUID = parcel.OwnerID; XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); useruuid.InnerText = userOwnerUUID.ToString(); userblock.AppendChild(useruuid); if (!parcel.IsGroupOwned) { try { XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID); if (account != null) { username.InnerText = account.FirstName + " " + account.LastName; } else { username.InnerText = "UnKnown"; } userblock.AppendChild(username); } catch (Exception) { //m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel"); } } else { XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); username.InnerText = groupName; userblock.AppendChild(username); } xmlparcel.AppendChild(userblock); parent.AppendChild(xmlparcel); } } //snap.AppendChild(parent); } this.Stale = false; return(parent); }