/// <summary> /// The client wants to buy a pass for a parcel /// </summary> /// <param name="client"></param> /// <param name="fromID"></param> /// <param name="parcelLocalId"></param> private void ClientOnParcelBuyPass(IClientAPI client, UUID fromID, int parcelLocalId) { MainConsole.Instance.InfoFormat("[StarDustCurrency]: ClientOnParcelBuyPass {0}, {1}, {2}", client.Name, fromID, parcelLocalId); IScenePresence agentSp = Scene.GetScenePresence(client.AgentId); IParcelManagementModule parcelManagement = agentSp.Scene.RequestModuleInterface <IParcelManagementModule>(); ILandObject landParcel = null; List <ILandObject> land = parcelManagement.AllParcels(); foreach (ILandObject landObject in land) { if (landObject.LandData.LocalID == parcelLocalId) { landParcel = landObject; } } if (landParcel != null) { MainConsole.Instance.Debug("[StarDustCurrency]: Base account: " + landParcel.LandData.OwnerID + " Agent ID: " + fromID + " Price:" + landParcel.LandData.PassPrice); bool giveResult = m_connector.UserCurrencyTransfer(landParcel.LandData.OwnerID, fromID, UUID.Zero, UUID.Zero, (uint)landParcel.LandData.PassPrice, "Parcel Pass", TransactionType.LandPassSale, UUID.Random()); if (giveResult) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry { AgentID = fromID, Flags = AccessList.Access, Time = DateTime.Now.AddHours(landParcel.LandData.PassHours) }; landParcel.LandData.ParcelAccessList.Add(entry); agentSp.ControllingClient.SendAgentAlertMessage("You have been added to the parcel access list.", false); } } else { MainConsole.Instance.ErrorFormat("[StarDustCurrency]: No parcel found for parcel id {0}", parcelLocalId); agentSp.ControllingClient.SendAgentAlertMessage("Opps, the internet blew up! Unable to find parcel.", false); } }
/// <summary> /// The client wants to buy a pass for a parcel /// </summary> /// <param name="client"></param> /// <param name="fromID"></param> /// <param name="parcelLocalId"></param> private void ClientOnParcelBuyPass(IClientAPI client, UUID fromID, int parcelLocalId) { IScenePresence agentSp = m_scene.GetScenePresence(client.AgentId); IParcelManagementModule parcelManagement = agentSp.Scene.RequestModuleInterface <IParcelManagementModule>(); ILandObject landParcel = null; List <ILandObject> land = parcelManagement.AllParcels(); foreach (ILandObject landObject in land) { if (landObject.LandData.LocalID == parcelLocalId) { landParcel = landObject; } } if (landParcel != null) { bool giveResult = m_connector.UserCurrencyTransfer(landParcel.LandData.OwnerID, fromID, UUID.Zero, UUID.Zero, (uint)landParcel.LandData.PassPrice, "Parcel Pass", TransactionType.LandPassSale, UUID.Random()); if (giveResult) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry { AgentID = fromID, Flags = AccessList.Access, Time = DateTime.Now.AddHours(landParcel.LandData.PassHours) }; landParcel.LandData.ParcelAccessList.Add(entry); agentSp.ControllingClient.SendAgentAlertMessage("You have been added to the parcel access list.", false); } } else { agentSp.ControllingClient.SendAgentAlertMessage("Unable to find parcel.", false); } }
/// <summary> /// Save a backup of the sim /// </summary> /// <param name = "appendedFilePath">The file path where the backup will be saved</param> protected virtual void SaveBackup(string appendedFilePath, bool saveAssets) { if (appendedFilePath == "/") { appendedFilePath = ""; } if (m_scene.RegionInfo.HasBeenDeleted) { return; } IBackupModule backupModule = m_scene.RequestModuleInterface <IBackupModule>(); if (backupModule != null && backupModule.LoadingPrims) //Something is changing lots of prims { MainConsole.Instance.Info("[Backup]: Not saving backup because the backup module is loading prims"); return; } //Save any script state saves that might be around IScriptModule[] engines = m_scene.RequestModuleInterfaces <IScriptModule>(); try { if (engines != null) { #if (!ISWIN) foreach (IScriptModule engine in engines) { if (engine != null) { engine.SaveStateSaves(); } } #else foreach (IScriptModule engine in engines.Where(engine => engine != null)) { engine.SaveStateSaves(); } #endif } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } MainConsole.Instance.Info("[FileBasedSimulationData]: Saving backup for region " + m_scene.RegionInfo.RegionName); string fileName = appendedFilePath + m_scene.RegionInfo.RegionName + m_saveAppendedFileName + ".abackup"; if (File.Exists(fileName)) { //Do new style saving here! GZipStream m_saveStream = new GZipStream(new FileStream(fileName + ".tmp", FileMode.Create), CompressionMode.Compress); TarArchiveWriter writer = new TarArchiveWriter(m_saveStream); GZipStream m_loadStream = new GZipStream(new FileStream(fileName, FileMode.Open), CompressionMode.Decompress); TarArchiveReader reader = new TarArchiveReader(m_loadStream); writer.WriteDir("parcels"); IParcelManagementModule module = m_scene.RequestModuleInterface <IParcelManagementModule>(); if (module != null) { List <ILandObject> landObject = module.AllParcels(); foreach (ILandObject parcel in landObject) { OSDMap parcelMap = parcel.LandData.ToOSD(); var binary = OSDParser.SerializeLLSDBinary(parcelMap); writer.WriteFile("parcels/" + parcel.LandData.GlobalID.ToString(), binary); binary = null; parcelMap = null; } } writer.WriteDir("newstyleterrain"); writer.WriteDir("newstylerevertterrain"); writer.WriteDir("newstylewater"); writer.WriteDir("newstylerevertwater"); ITerrainModule tModule = m_scene.RequestModuleInterface <ITerrainModule>(); if (tModule != null) { try { byte[] sdata = WriteTerrainToStream(tModule.TerrainMap); writer.WriteFile("newstyleterrain/" + m_scene.RegionInfo.RegionID.ToString() + ".terrain", sdata); sdata = null; sdata = WriteTerrainToStream(tModule.TerrainRevertMap); writer.WriteFile( "newstylerevertterrain/" + m_scene.RegionInfo.RegionID.ToString() + ".terrain", sdata); sdata = null; if (tModule.TerrainWaterMap != null) { sdata = WriteTerrainToStream(tModule.TerrainWaterMap); writer.WriteFile("newstylewater/" + m_scene.RegionInfo.RegionID.ToString() + ".terrain", sdata); sdata = null; sdata = WriteTerrainToStream(tModule.TerrainWaterRevertMap); writer.WriteFile( "newstylerevertwater/" + m_scene.RegionInfo.RegionID.ToString() + ".terrain", sdata); sdata = null; } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } } IDictionary <UUID, AssetType> assets = new Dictionary <UUID, AssetType>(); UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService); ISceneEntity[] saveentities = m_scene.Entities.GetEntities(); List <UUID> entitiesToSave = new List <UUID>(); foreach (ISceneEntity entity in saveentities) { try { if (entity.IsAttachment || ((entity.RootChild.Flags & PrimFlags.Temporary) == PrimFlags.Temporary) || ((entity.RootChild.Flags & PrimFlags.TemporaryOnRez) == PrimFlags.TemporaryOnRez)) { continue; } if (entity.HasGroupChanged) { entity.HasGroupChanged = false; //Write all entities byte[] xml = ((ISceneObject)entity).ToBinaryXml2(); writer.WriteFile("entities/" + entity.UUID.ToString(), xml); xml = null; } else { entitiesToSave.Add(entity.UUID); } if (saveAssets) { assetGatherer.GatherAssetUuids(entity, assets, m_scene); } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); entitiesToSave.Add(entity.UUID); } } byte[] data; string filePath; TarArchiveReader.TarEntryType entryType; //Load the archive data that we need try { while ((data = reader.ReadEntry(out filePath, out entryType)) != null) { if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) { continue; } if (filePath.StartsWith("entities/")) { UUID entityID = UUID.Parse(filePath.Remove(0, 9)); if (entitiesToSave.Contains(entityID)) { writer.WriteFile(filePath, data); entitiesToSave.Remove(entityID); } } data = null; } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } if (entitiesToSave.Count > 0) { MainConsole.Instance.Fatal(entitiesToSave.Count + " PRIMS WERE NOT GOING TO BE SAVED! FORCE SAVING NOW! "); foreach (ISceneEntity entity in saveentities) { if (entitiesToSave.Contains(entity.UUID)) { if (entity.IsAttachment || ((entity.RootChild.Flags & PrimFlags.Temporary) == PrimFlags.Temporary) || ((entity.RootChild.Flags & PrimFlags.TemporaryOnRez) == PrimFlags.TemporaryOnRez)) { continue; } //Write all entities byte[] xml = ((ISceneObject)entity).ToBinaryXml2(); writer.WriteFile("entities/" + entity.UUID.ToString(), xml); xml = null; } } } if (saveAssets) { foreach (UUID assetID in new List <UUID>(assets.Keys)) { try { WriteAsset(assetID.ToString(), m_scene.AssetService.Get(assetID.ToString()), writer); } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } } } reader.Close(); writer.Close(); m_loadStream.Close(); m_saveStream.Close(); GC.Collect(); if (m_keepOldSave && !m_oldSaveHasBeenSaved) { //Havn't moved it yet, so make sure the directory exists, then move it m_oldSaveHasBeenSaved = true; if (!Directory.Exists(m_oldSaveDirectory)) { Directory.CreateDirectory(m_oldSaveDirectory); } File.Copy(fileName + ".tmp", Path.Combine(m_oldSaveDirectory, m_scene.RegionInfo.RegionName + SerializeDateTime() + m_saveAppendedFileName + ".abackup")); } //Just remove the file File.Delete(fileName); } else { //Add the .temp since we might need to make a backup and so that if something goes wrong, we don't corrupt the main backup GZipStream m_saveStream = new GZipStream(new FileStream(fileName + ".tmp", FileMode.Create), CompressionMode.Compress); TarArchiveWriter writer = new TarArchiveWriter(m_saveStream); IAuroraBackupArchiver archiver = m_scene.RequestModuleInterface <IAuroraBackupArchiver>(); //Turn off prompting so that we don't ask the user questions every time we need to save the backup archiver.AllowPrompting = false; archiver.SaveRegionBackup(writer, m_scene); archiver.AllowPrompting = true; m_saveStream.Close(); writer.Close(); GC.Collect(); } File.Move(fileName + ".tmp", fileName); ISceneEntity[] entities = m_scene.Entities.GetEntities(); try { #if (!ISWIN) foreach (ISceneEntity entity in entities) { if (entity.HasGroupChanged) { entity.HasGroupChanged = false; } } #else foreach (ISceneEntity entity in entities.Where(entity => entity.HasGroupChanged)) { entity.HasGroupChanged = false; } #endif } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } //Now make it the full file again MapTileNeedsGenerated = true; MainConsole.Instance.Info("[FileBasedSimulationData]: Saved Backup for region " + m_scene.RegionInfo.RegionName); }
/// <summary> /// Save a backup of the sim /// </summary> /// <param name="isOldSave"></param> protected virtual void SaveBackup(bool isOldSave) { if (m_scene == null || m_scene.RegionInfo.HasBeenDeleted) { return; } IBackupModule backupModule = m_scene.RequestModuleInterface <IBackupModule>(); if (backupModule != null && backupModule.LoadingPrims) //Something is changing lots of prims { MainConsole.Instance.Info("[Backup]: Not saving backup because the backup module is loading prims"); return; } //Save any script state saves that might be around IScriptModule[] engines = m_scene.RequestModuleInterfaces <IScriptModule>(); try { if (engines != null) { foreach (IScriptModule engine in engines.Where(engine => engine != null)) { engine.SaveStateSaves(); } } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } MainConsole.Instance.Info("[FileBasedSimulationData]: Saving backup for region " + m_scene.RegionInfo.RegionName); RegionData regiondata = new RegionData(); regiondata.Init(); regiondata.RegionInfo = m_scene.RegionInfo; IParcelManagementModule module = m_scene.RequestModuleInterface <IParcelManagementModule>(); if (module != null) { List <ILandObject> landObject = module.AllParcels(); foreach (ILandObject parcel in landObject) { regiondata.Parcels.Add(parcel.LandData); } } ITerrainModule tModule = m_scene.RequestModuleInterface <ITerrainModule>(); if (tModule != null) { try { regiondata.Terrain = WriteTerrainToStream(tModule.TerrainMap); regiondata.RevertTerrain = WriteTerrainToStream(tModule.TerrainRevertMap); if (tModule.TerrainWaterMap != null) { regiondata.Water = WriteTerrainToStream(tModule.TerrainWaterMap); regiondata.RevertWater = WriteTerrainToStream(tModule.TerrainWaterRevertMap); } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } } ISceneEntity[] entities = m_scene.Entities.GetEntities(); regiondata.Groups = new List <SceneObjectGroup>(entities.Cast <SceneObjectGroup>().Where((entity) => { return (!(entity .IsAttachment || ((entity .RootChild .Flags & PrimFlags .Temporary) == PrimFlags .Temporary) || ((entity .RootChild .Flags & PrimFlags .TemporaryOnRez) == PrimFlags .TemporaryOnRez))); })); try { foreach (ISceneEntity entity in regiondata.Groups.Where(ent => ent.HasGroupChanged)) { entity.HasGroupChanged = false; } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } string filename = isOldSave ? BuildOldSaveFileName() : BuildSaveFileName(); if (File.Exists(filename + (isOldSave ? "" : ".tmp"))) { File.Delete(filename + (isOldSave ? "" : ".tmp")); //Remove old tmp files } if (!_regionLoader.SaveBackup(filename + (isOldSave ? "" : ".tmp"), regiondata)) { if (File.Exists(filename + (isOldSave ? "" : ".tmp"))) { File.Delete(filename + (isOldSave ? "" : ".tmp")); //Remove old tmp files } MainConsole.Instance.Error("[FileBasedSimulationData]: Failed to save backup for region " + m_scene.RegionInfo.RegionName + "!"); return; } //RegionData data = _regionLoader.LoadBackup(filename + ".tmp"); if (!isOldSave) { if (File.Exists(filename)) { File.Delete(filename); } File.Move(filename + ".tmp", filename); if (m_keepOldSave && !m_oldSaveHasBeenSaved) { //Havn't moved it yet, so make sure the directory exists, then move it m_oldSaveHasBeenSaved = true; if (!Directory.Exists(m_oldSaveDirectory)) { Directory.CreateDirectory(m_oldSaveDirectory); } File.Copy(filename, BuildOldSaveFileName()); } } regiondata.Dispose(); //Now make it the full file again MapTileNeedsGenerated = true; MainConsole.Instance.Info("[FileBasedSimulationData]: Saved Backup for region " + m_scene.RegionInfo.RegionName); }
protected internal void Save(ICollection <UUID> assetsFoundUuids, ICollection <UUID> assetsNotFoundUuids) { foreach (UUID uuid in assetsNotFoundUuids) { MainConsole.Instance.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid); } // MainConsole.Instance.InfoFormat( // "[ARCHIVER]: Received {0} of {1} assets requested", // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); MainConsole.Instance.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); // Write out control file m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); MainConsole.Instance.InfoFormat("[ARCHIVER]: Added control file to archive."); // Write out region settings string settingsPath = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings)); MainConsole.Instance.InfoFormat("[ARCHIVER]: Added region settings to archive."); // Write out land data (aka parcel) settings IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>(); if (parcelManagement != null) { List <ILandObject> landObjects = parcelManagement.AllParcels(); foreach (ILandObject lo in landObjects) { LandData landData = lo.LandData; string landDataPath = String.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH, landData.GlobalID.ToString()); m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData)); } } MainConsole.Instance.InfoFormat("[ARCHIVER]: Added parcel settings to archive."); // Write out terrain string terrainPath = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_scene.RegionInfo.RegionName); MemoryStream ms = new MemoryStream(); m_terrainModule.SaveToStream(m_terrainModule.TerrainMap, terrainPath, ms); m_archiveWriter.WriteFile(terrainPath, ms.ToArray()); ms.Close(); MainConsole.Instance.InfoFormat("[ARCHIVER]: Added terrain information to archive."); // Write out scene object metadata foreach (ISceneEntity sceneObject in m_sceneObjects) { //MainConsole.Instance.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject); m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); } MainConsole.Instance.InfoFormat("[ARCHIVER]: Added scene objects to archive."); }
private bool OnAllowedIncomingTeleport(UUID userID, IScene scene, Vector3 Position, out Vector3 newPosition, out string reason) { newPosition = Position; UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID); IScenePresence Sp = scene.GetScenePresence(userID); if (account == null) { reason = "Failed authentication."; return(false); //NO! } //Make sure that this user is inside the region as well if (Position.X < -2f || Position.Y < -2f || Position.X > scene.RegionInfo.RegionSizeX + 2 || Position.Y > scene.RegionInfo.RegionSizeY + 2) { m_log.DebugFormat( "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping", Position, Name, userID); bool changedX = false; bool changedY = false; while (Position.X < 0) { Position.X += scene.RegionInfo.RegionSizeX; changedX = true; } while (Position.X > scene.RegionInfo.RegionSizeX) { Position.X -= scene.RegionInfo.RegionSizeX; changedX = true; } while (Position.Y < 0) { Position.Y += scene.RegionInfo.RegionSizeY; changedY = true; } while (Position.Y > scene.RegionInfo.RegionSizeY) { Position.Y -= scene.RegionInfo.RegionSizeY; changedY = true; } if (changedX) { Position.X = scene.RegionInfo.RegionSizeX - Position.X; } if (changedY) { Position.Y = scene.RegionInfo.RegionSizeY - Position.Y; } } //Check that we are not underground as well float posZLimit = scene.RequestModuleInterface <ITerrainChannel>()[(int)Position.X, (int)Position.Y] + (float)1.25; if (posZLimit >= (Position.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit))) { Position.Z = posZLimit; } IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin <IAgentConnector>(); IAgentInfo agentInfo = null; if (AgentConnector != null) { agentInfo = AgentConnector.GetAgent(userID); } ILandObject ILO = null; IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>(); if (parcelManagement != null) { ILO = parcelManagement.GetLandObject(Position.X, Position.Y); } if (ILO == null) { //Can't find land, give them the first parcel in the region and find a good position for them ILO = parcelManagement.AllParcels()[0]; Position = parcelManagement.GetParcelCenterAtGround(ILO); } //parcel permissions if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block { if (Sp == null) { reason = "Banned from this parcel."; return(true); } if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { //We found a place for them, but we don't need to check any further return(true); } } //Move them out of banned parcels ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags; if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup && (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList && (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { //One of these is in play then if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup) { if (Sp == null) { reason = "Banned from this parcel."; return(true); } if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { //We found a place for them, but we don't need to check any further return(true); } } } else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList) { if (Sp == null) { reason = "Banned from this parcel."; return(true); } //All but the people on the access list are banned if (ILO.IsRestrictedFromLand(userID)) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { //We found a place for them, but we don't need to check any further return(true); } } } else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { if (Sp == null) { reason = "Banned from this parcel."; return(true); } //All but the people on the pass/access list are banned if (ILO.IsRestrictedFromLand(Sp.UUID)) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { //We found a place for them, but we don't need to check any further return(true); } } } } EstateSettings ES = scene.RegionInfo.EstateSettings; //Move them to the nearest landing point if (!ES.AllowDirectTeleport) { if (!scene.Permissions.IsGod(userID)) { Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); if (telehub != null) { if (telehub.SpawnPos.Count == 0) { Position = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); } else { int LastTelehubNum = 0; if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum)) { LastTelehubNum = 0; } Position = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); LastTelehubNum++; if (LastTelehubNum == telehub.SpawnPos.Count) { LastTelehubNum = 0; } LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum; } } } } if (!scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None)) { if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land { //Find a new parcel for them List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position); if (Parcels.Count == 0) { IScenePresence SP; scene.TryGetScenePresence(userID, out SP); newPosition = parcelManagement.GetNearestRegionEdgePosition(SP); } else { bool found = false; //We need to check here as well for bans, can't toss someone into a parcel they are banned from foreach (ILandObject Parcel in Parcels) { if (!Parcel.IsBannedFromLand(userID)) { //Now we have to check their userloc if (ILO.LandData.LandingType == 2) { continue; //Blocked, check next one } else if (ILO.LandData.LandingType == 1) //Use their landing spot { newPosition = Parcel.LandData.UserLocation; } else //They allow for anywhere, so dump them in the center at the ground { newPosition = parcelManagement.GetParcelCenterAtGround(Parcel); } found = true; } } if (!found) //Dump them at the edge { if (Sp != null) { newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp); } else { reason = "Banned from this parcel."; return(true); } } } } else if (ILO.LandData.LandingType == 1) //Move to tp spot { if (ILO.LandData.UserLocation != Vector3.Zero) { newPosition = ILO.LandData.UserLocation; } else // Dump them at the nearest region corner since they havn't set a landing point { newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp); } } } //We assume that our own region isn't null.... if (agentInfo != null) { //Can only enter prelude regions once! int flags = scene.GridService.GetRegionFlags(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionID); if (flags != -1 && ((flags & (int)Aurora.Framework.RegionFlags.Prelude) == (int)Aurora.Framework.RegionFlags.Prelude) && agentInfo != null) { if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID)) { reason = "You may not enter this region as you have already been to this prelude region."; return(false); } else { agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID, OSD.FromInteger((int)IAgentFlags.PastPrelude)); AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok } } } if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0) { if ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) { reason = "You may not enter this region."; return(false); } } if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null) { if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "You may not enter this region."; return(false); } } newPosition = Position; reason = ""; return(true); }
private Hashtable RetrieveWindLightSettings(Hashtable m_dhttpMethod, UUID agentID) { Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = ""; IScenePresence SP = m_scene.GetScenePresence(agentID); if (SP == null) { return(responsedata); //They don't exist } IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>(); OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml((string)m_dhttpMethod["requestbody"]); OSDMap retVal = new OSDMap(); if (rm.ContainsKey("RegionID")) { //For the region, just add all of them OSDArray array = new OSDArray(); foreach (RegionLightShareData rlsd in m_WindlightSettings.Values) { OSDMap m = rlsd.ToOSD(); m.Add("Name", OSD.FromString("(Region Settings), Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude)); array.Add(m); } retVal.Add("WindLight", array); retVal.Add("Type", OSD.FromInteger(1)); } else if (rm.ContainsKey("ParcelID")) { OSDArray retVals = new OSDArray(); //-1 is all parcels if (rm["ParcelID"].AsInteger() == -1) { //All parcels if (parcelManagement != null) { foreach (ILandObject land in parcelManagement.AllParcels()) { OSDMap map = land.LandData.GenericDataMap; if (map.ContainsKey("WindLight")) { OSDMap parcelWindLight = (OSDMap)map["WindLight"]; foreach (OSD innerMap in parcelWindLight.Values) { RegionLightShareData rlsd = new RegionLightShareData(); rlsd.FromOSD((OSDMap)innerMap); OSDMap imap = new OSDMap(); imap = rlsd.ToOSD(); imap.Add("Name", OSD.FromString(land.LandData.Name + ", Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude)); retVals.Add(imap); } } } } } else { //Only the given parcel parcel given by localID if (parcelManagement != null) { ILandObject land = parcelManagement.GetLandObject(rm["ParcelID"].AsInteger()); OSDMap map = land.LandData.GenericDataMap; if (map.ContainsKey("WindLight")) { OSDMap parcelWindLight = (OSDMap)map["WindLight"]; foreach (OSD innerMap in parcelWindLight.Values) { RegionLightShareData rlsd = new RegionLightShareData(); rlsd.FromOSD((OSDMap)innerMap); OSDMap imap = new OSDMap(); imap = rlsd.ToOSD(); imap.Add("Name", OSD.FromString(land.LandData.Name + ", Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude)); retVals.Add(imap); } } } } retVal.Add("WindLight", retVals); retVal.Add("Type", OSD.FromInteger(2)); } responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(retVal); return(responsedata); }
public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene) { m_isArchiving = true; MainConsole.Instance.Info("[Archive]: Writing parcels to archive"); writer.WriteDir("parcels"); IParcelManagementModule module = scene.RequestModuleInterface <IParcelManagementModule> (); if (module != null) { List <ILandObject> landObject = module.AllParcels(); foreach (ILandObject parcel in landObject) { OSDMap parcelMap = parcel.LandData.ToOSD(); writer.WriteFile("parcels/" + parcel.LandData.GlobalID, OSDParser.SerializeLLSDBinary(parcelMap)); } } MainConsole.Instance.Info("[Archive]: Finished writing parcels to archive"); MainConsole.Instance.Info("[Archive]: Writing terrain to archive"); writer.WriteDir("newstyleterrain"); writer.WriteDir("newstylerevertterrain"); writer.WriteDir("newstylewater"); writer.WriteDir("newstylerevertwater"); ITerrainModule tModule = scene.RequestModuleInterface <ITerrainModule> (); if (tModule != null) { try { byte [] sdata = WriteTerrainToStream(tModule.TerrainMap); writer.WriteFile("newstyleterrain/" + scene.RegionInfo.RegionID + ".terrain", sdata); sdata = WriteTerrainToStream(tModule.TerrainRevertMap); writer.WriteFile("newstylerevertterrain/" + scene.RegionInfo.RegionID + ".terrain", sdata); sdata = null; if (tModule.TerrainWaterMap != null) { sdata = WriteTerrainToStream(tModule.TerrainWaterMap); writer.WriteFile("newstylewater/" + scene.RegionInfo.RegionID + ".terrain", sdata); sdata = WriteTerrainToStream(tModule.TerrainWaterRevertMap); writer.WriteFile( "newstylerevertwater/" + scene.RegionInfo.RegionID + ".terrain", sdata); sdata = null; } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } } MainConsole.Instance.Info("[Archive]: Finished writing terrain to archive"); MainConsole.Instance.Info("[Archive]: Writing entities to archive"); ISceneEntity [] entities = scene.Entities.GetEntities(); //Get all entities, then start writing them to the database writer.WriteDir("entities"); IDictionary <UUID, AssetType> assets = new Dictionary <UUID, AssetType> (); UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService); IWhiteCoreBackupArchiver archiver = m_scene.RequestModuleInterface <IWhiteCoreBackupArchiver> (); bool saveAssets = false; if (archiver.AllowPrompting) { saveAssets = MainConsole.Instance.Prompt("Save assets? (Will not be able to load on other grids if not saved)", "false") .Equals("true", StringComparison.CurrentCultureIgnoreCase); } int count = 0; foreach (ISceneEntity entity in entities) { try { if (entity.IsAttachment || ((entity.RootChild.Flags & PrimFlags.Temporary) == PrimFlags.Temporary) || ((entity.RootChild.Flags & PrimFlags.TemporaryOnRez) == PrimFlags.TemporaryOnRez)) { continue; } //Write all entities byte [] xml = entity.ToBinaryXml2(); writer.WriteFile("entities/" + entity.UUID, xml); xml = null; count++; if (count % 3 == 0) { Thread.Sleep(5); } //Get all the assets too if (saveAssets) { assetGatherer.GatherAssetUuids(entity, assets); } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } } entities = null; MainConsole.Instance.Info("[Archive]: Finished writing entities to archive"); MainConsole.Instance.Info("[Archive]: Writing assets for entities to archive"); bool foundAllAssets = true; foreach (UUID assetID in new List <UUID> (assets.Keys)) { try { foundAllAssets = false; //Not all are cached m_scene.AssetService.Get(assetID.ToString(), writer, RetrievedAsset); m_missingAssets.Add(assetID); } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex); } } if (foundAllAssets) { m_isArchiving = false; //We're done if all the assets were found } MainConsole.Instance.Info("[Archive]: Finished writing assets for entities to archive"); }
// NOTE: Call under Taint Lock private void RemoveObject(ISceneEntity obj) { if (obj.IsAttachment) { return; } if (((obj.RootChild.Flags & PrimFlags.TemporaryOnRez) != 0)) { return; } IParcelManagementModule parcelManagment = m_Scene.RequestModuleInterface <IParcelManagementModule>(); Vector3 pos = obj.AbsolutePosition; ILandObject landObject = parcelManagment.GetLandObject(pos.X, pos.Y) ?? parcelManagment.GetNearestAllowedParcel(UUID.Zero, pos.X, pos.Y); if (landObject == null) { return; } LandData landData = landObject.LandData; ParcelCounts parcelCounts; if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) { UUID landOwner = landData.OwnerID; foreach (ISceneChildEntity child in obj.ChildrenEntities()) { bool foundit = false; if (!parcelCounts.Objects.ContainsKey(child.UUID)) { //was not found, lets look through all the parcels foreach (ILandObject parcel in parcelManagment.AllParcels()) { landData = parcel.LandData; if (!m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) { continue; } landOwner = landData.OwnerID; if (!parcelCounts.Objects.ContainsKey(child.UUID)) { continue; } foundit = true; break; } } else { foundit = true; } if (!foundit) { continue; } parcelCounts.Objects.Remove(child.UUID); if (m_SimwideCounts.ContainsKey(landOwner)) { m_SimwideCounts[landOwner] -= 1; } if (parcelCounts.Users.ContainsKey(obj.OwnerID)) { parcelCounts.Users[obj.OwnerID] -= 1; } if (landData.IsGroupOwned) { if (obj.OwnerID == landData.GroupID) { parcelCounts.Owner -= 1; } else if (obj.GroupID == landData.GroupID) { parcelCounts.Group -= 1; } else { parcelCounts.Others -= 1; } } else { if (obj.OwnerID == landData.OwnerID) { parcelCounts.Owner -= 1; } else if (obj.GroupID == landData.GroupID) { parcelCounts.Group -= 1; } else { parcelCounts.Others -= 1; } } } } }
public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene) { m_isArchiving = true; m_log.Info("[Archive]: Writing parcels to archive"); writer.WriteDir("parcels"); IParcelManagementModule module = scene.RequestModuleInterface <IParcelManagementModule>(); if (module != null) { List <ILandObject> landObject = module.AllParcels(); foreach (ILandObject parcel in landObject) { OSDMap parcelMap = parcel.LandData.ToOSD(); writer.WriteFile("parcels/" + parcel.LandData.GlobalID.ToString(), OSDParser.SerializeLLSDBinary(parcelMap)); } } m_log.Info("[Archive]: Finished writing parcels to archive"); m_log.Info("[Archive]: Writing terrain to archive"); writer.WriteDir("terrain"); ITerrainModule tModule = scene.RequestModuleInterface <ITerrainModule>(); if (tModule != null) { MemoryStream s = new MemoryStream(); tModule.SaveToStream(scene.RegionInfo.RegionID.ToString() + ".r32", s); writer.WriteFile("terrain/" + scene.RegionInfo.RegionID.ToString() + ".r32", s.ToArray()); s.Close(); } m_log.Info("[Archive]: Finished writing terrain to archive"); m_log.Info("[Archive]: Writing entities to archive"); ISceneEntity[] entities = scene.Entities.GetEntities(); //Get all entities, then start writing them to the database writer.WriteDir("entities"); IDictionary <UUID, AssetType> assets = new Dictionary <UUID, AssetType>(); UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService); foreach (ISceneEntity entity in entities) { //Write all entities writer.WriteFile("entities/" + entity.UUID.ToString(), ((ISceneObject)entity).ToXml2()); //Get all the assets too assetGatherer.GatherAssetUuids(entity, assets, scene); } m_log.Info("[Archive]: Finished writing entities to archive"); m_log.Info("[Archive]: Writing assets for entities to archive"); bool foundAllAssets = true; foreach (UUID assetID in new List <UUID>(assets.Keys)) { AssetBase asset = m_scene.AssetService.GetCached(assetID.ToString()); if (asset != null) { WriteAsset(asset, writer); //Write it syncronously since we havn't } else { foundAllAssets = false; //Not all are cached m_missingAssets.Add(assetID); m_scene.AssetService.Get(assetID.ToString(), writer, RetrievedAsset); } } if (foundAllAssets) { m_isArchiving = false; //We're done if all the assets were found } m_log.Info("[Archive]: Finished writing assets for entities to archive"); }
private bool OnAllowedIncomingTeleport(UUID userID, IScene scene, Vector3 Position, uint TeleportFlags, out Vector3 newPosition, out string reason) { newPosition = Position; UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, userID); IScenePresence Sp = scene.GetScenePresence(userID); if (account == null) { reason = "Failed authentication."; return(false); //NO! } //Make sure that this user is inside the region as well if (Position.X < -2f || Position.Y < -2f || Position.X > scene.RegionInfo.RegionSizeX + 2 || Position.Y > scene.RegionInfo.RegionSizeY + 2) { MainConsole.Instance.DebugFormat( "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping", Position, Name, userID); bool changedX = false; bool changedY = false; while (Position.X < 0) { Position.X += scene.RegionInfo.RegionSizeX; changedX = true; } while (Position.X > scene.RegionInfo.RegionSizeX) { Position.X -= scene.RegionInfo.RegionSizeX; changedX = true; } while (Position.Y < 0) { Position.Y += scene.RegionInfo.RegionSizeY; changedY = true; } while (Position.Y > scene.RegionInfo.RegionSizeY) { Position.Y -= scene.RegionInfo.RegionSizeY; changedY = true; } if (changedX) { Position.X = scene.RegionInfo.RegionSizeX - Position.X; } if (changedY) { Position.Y = scene.RegionInfo.RegionSizeY - Position.Y; } } IAgentConnector AgentConnector = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>(); IAgentInfo agentInfo = null; if (AgentConnector != null) { agentInfo = AgentConnector.GetAgent(userID); } ILandObject ILO = null; IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>(); if (parcelManagement != null) { ILO = parcelManagement.GetLandObject(Position.X, Position.Y); } if (ILO == null) { if (Sp != null) { Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity } //Can't find land, give them the first parcel in the region and find a good position for them ILO = parcelManagement.AllParcels()[0]; Position = parcelManagement.GetParcelCenterAtGround(ILO); } //parcel permissions if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block { if (Sp != null) { Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity } if (Sp == null) { reason = "Banned from this parcel."; return(false); } if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { } } //Move them out of banned parcels ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags; if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup && (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList && (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { if (Sp != null) { Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity } //One of these is in play then if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup) { if (Sp == null) { reason = "Banned from this parcel."; return(false); } if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { } } } else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList) { if (Sp == null) { reason = "Banned from this parcel."; return(false); } //All but the people on the access list are banned if (ILO.IsRestrictedFromLand(userID)) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { } } } else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { if (Sp == null) { reason = "Banned from this parcel."; return(false); } //All but the people on the pass/access list are banned if (ILO.IsRestrictedFromLand(Sp.UUID)) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { } } } } EstateSettings ES = scene.RegionInfo.EstateSettings; TeleportFlags tpflags = (TeleportFlags)TeleportFlags; const TeleportFlags allowableFlags = OpenMetaverse.TeleportFlags.ViaLandmark | OpenMetaverse.TeleportFlags.ViaHome | OpenMetaverse.TeleportFlags.ViaLure | OpenMetaverse.TeleportFlags.ForceRedirect | OpenMetaverse.TeleportFlags.Godlike | OpenMetaverse.TeleportFlags.NineOneOne; //If the user wants to force landing points on crossing, we act like they are not crossing, otherwise, check the child property and that the ViaRegionID is set bool isCrossing = !ForceLandingPointsOnCrossing && (Sp != null && Sp.IsChildAgent && ((tpflags & OpenMetaverse.TeleportFlags.ViaRegionID) == OpenMetaverse.TeleportFlags.ViaRegionID)); //Move them to the nearest landing point if (!((tpflags & allowableFlags) != 0) && !isCrossing && !ES.AllowDirectTeleport) { if (Sp != null) { Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity } if (!scene.Permissions.IsGod(userID)) { Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); if (telehub != null) { if (telehub.SpawnPos.Count == 0) { Position = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); } else { int LastTelehubNum = 0; if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum)) { LastTelehubNum = 0; } Position = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); LastTelehubNum++; if (LastTelehubNum == telehub.SpawnPos.Count) { LastTelehubNum = 0; } LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum; } } } } else if (!((tpflags & allowableFlags) != 0) && !isCrossing && !scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None)) //Telehubs override parcels { if (Sp != null) { Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity } if (ILO.LandData.LandingType == (int)LandingType.None) //Blocked, force this person off this land { //Find a new parcel for them List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position); if (Parcels.Count > 1) { newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp); } else { bool found = false; //We need to check here as well for bans, can't toss someone into a parcel they are banned from foreach (ILandObject Parcel in Parcels.Where(Parcel => !Parcel.IsBannedFromLand(userID))) { //Now we have to check their userloc if (ILO.LandData.LandingType == (int)LandingType.None) { continue; //Blocked, check next one } else if (ILO.LandData.LandingType == (int)LandingType.LandingPoint) { //Use their landing spot newPosition = Parcel.LandData.UserLocation; } else //They allow for anywhere, so dump them in the center at the ground { newPosition = parcelManagement.GetParcelCenterAtGround(Parcel); } found = true; } if (!found) //Dump them at the edge { if (Sp != null) { newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp); } else { reason = "Banned from this parcel."; return(false); } } } } else if (ILO.LandData.LandingType == (int)LandingType.LandingPoint) //Move to tp spot { newPosition = ILO.LandData.UserLocation != Vector3.Zero ? ILO.LandData.UserLocation : parcelManagement.GetNearestRegionEdgePosition(Sp); } } //We assume that our own region isn't null.... if (agentInfo != null) { //Can only enter prelude regions once! if (scene.RegionInfo.RegionFlags != -1 && ((scene.RegionInfo.RegionFlags & (int)RegionFlags.Prelude) == (int)RegionFlags.Prelude) && agentInfo != null) { if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID)) { reason = "You may not enter this region as you have already been to this prelude region."; return(false); } else { agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID, OSD.FromInteger((int)IAgentFlags.PastPrelude)); AgentConnector.UpdateAgent(agentInfo); } } if (agentInfo.OtherAgentInformation.ContainsKey("LimitedToEstate")) { int LimitedToEstate = agentInfo.OtherAgentInformation["LimitedToEstate"]; if (scene.RegionInfo.EstateSettings.EstateID != LimitedToEstate) { reason = "You may not enter this reason, as it is outside of the estate you are limited to."; return(false); } } } if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0) { if (account != null && (account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) { reason = "You may not enter this region."; return(false); } } if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null) { if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "You may not enter this region."; return(false); } } //Check that we are not underground as well ITerrainChannel chan = scene.RequestModuleInterface <ITerrainChannel>(); if (chan != null) { float posZLimit = chan[(int)newPosition.X, (int)newPosition.Y] + (float)1.25; if (posZLimit >= (newPosition.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit))) { newPosition.Z = posZLimit; } } reason = ""; return(true); }
public XmlNode RequestSnapshotData(XmlDocument nodeFactory) { IParcelManagementModule landChannel = m_scene.RequestModuleInterface <IParcelManagementModule>(); List <ILandObject> parcels = landChannel.AllParcels(); XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", ""); 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)) { 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", ""); dwell.InnerText = parcel.Dwell.ToString(); xmlparcel.AppendChild(dwell); //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); username.InnerText = account.FirstName + " " + account.LastName; 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); }
private byte[] RetrieveWindLightSettings(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID agentID) { IScenePresence SP = m_scene.GetScenePresence(agentID); if (SP == null) { return(new byte[0]); //They don't exist } IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>(); OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap retVal = new OSDMap(); if (rm.ContainsKey("RegionID")) { //For the region, just add all of them OSDArray array = new OSDArray(); foreach (RegionLightShareData rlsd in m_WindlightSettings.Values) { OSDMap m = rlsd.ToOSD(); m.Add("Name", OSD.FromString("(Region Settings), Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude)); array.Add(m); } retVal.Add("WindLight", array); retVal.Add("Type", OSD.FromInteger(1)); } else if (rm.ContainsKey("ParcelID")) { OSDArray retVals = new OSDArray(); //-1 is all parcels if (rm["ParcelID"].AsInteger() == -1) { //All parcels if (parcelManagement != null) { foreach (ILandObject land in parcelManagement.AllParcels()) { OSDMap map = land.LandData.GenericData; if (map.ContainsKey("WindLight")) { OSDMap parcelWindLight = (OSDMap)map["WindLight"]; foreach (OSD innerMap in parcelWindLight.Values) { RegionLightShareData rlsd = new RegionLightShareData(); rlsd.FromOSD((OSDMap)innerMap); OSDMap imap = new OSDMap(); imap = rlsd.ToOSD(); imap.Add("Name", OSD.FromString(land.LandData.Name + ", Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude)); retVals.Add(imap); } } } } } else { //Only the given parcel parcel given by localID if (parcelManagement != null) { ILandObject land = parcelManagement.GetLandObject(rm["ParcelID"].AsInteger()); OSDMap map = land.LandData.GenericData; if (map.ContainsKey("WindLight")) { OSDMap parcelWindLight = (OSDMap)map["WindLight"]; foreach (OSD innerMap in parcelWindLight.Values) { RegionLightShareData rlsd = new RegionLightShareData(); rlsd.FromOSD((OSDMap)innerMap); OSDMap imap = new OSDMap(); imap = rlsd.ToOSD(); imap.Add("Name", OSD.FromString(land.LandData.Name + ", Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude)); retVals.Add(imap); } } } } retVal.Add("WindLight", retVals); retVal.Add("Type", OSD.FromInteger(2)); } return(OSDParser.SerializeLLSDXmlBytes(retVal)); }