public void EndLoadModuleFromArchive(IScene scene) { IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>(); IScriptModule[] modules = m_scene.RequestModuleInterfaces <IScriptModule>(); //Reeanble now that we are done foreach (IScriptModule module in modules) { module.Disabled = false; } //Reset backup too if (backup != null) { backup.LoadingPrims = false; } //Update the database as well! IParcelManagementModule parcelManagementModule = m_scene.RequestModuleInterface <IParcelManagementModule>(); if (parcelManagementModule != null && !m_merge) //Only if we are not merging { m_scene.EventManager.TriggerIncomingLandDataFromStorage(m_parcels); foreach (LandData parcel in m_parcels) { parcelManagementModule.UpdateLandObject(parcel.LocalID, parcel); } m_parcels.Clear(); } m_validUserUuids.Clear(); }
private void DearchiveRegion0DotStar() { int successfulAssetRestores = 0; int failedAssetRestores = 0; string filePath = "NONE"; DateTime start = DateTime.Now; TarArchiveReader archive = new TarArchiveReader(m_loadStream); if (!m_skipAssets) { m_threadpool = new Aurora.Framework.AuroraThreadPool(new Aurora.Framework.AuroraThreadPoolStartInfo() { Threads = 1, priority = System.Threading.ThreadPriority.BelowNormal }); } IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>(); if (!m_merge) { DateTime before = DateTime.Now; MainConsole.Instance.Info("[ARCHIVER]: Clearing all existing scene objects"); if (backup != null) { backup.DeleteAllSceneObjects(); } MainConsole.Instance.Info("[ARCHIVER]: Cleared all existing scene objects in " + (DateTime.Now - before).Minutes + ":" + (DateTime.Now - before).Seconds); } IScriptModule[] modules = m_scene.RequestModuleInterfaces <IScriptModule>(); //Disable the script engine so that it doesn't load in the background and kill OAR loading foreach (IScriptModule module in modules) { module.Disabled = true; } //Disable backup for now as well if (backup != null) { backup.LoadingPrims = true; } IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface <IRegionSerialiserModule>(); int sceneObjectsLoadedCount = 0; //We save the groups so that we can back them up later List <SceneObjectGroup> groupsToBackup = new List <SceneObjectGroup>(); List <LandData> landData = new List <LandData>(); IUserFinder UserManager = m_scene.RequestModuleInterface <IUserFinder>(); // must save off some stuff until after assets have been saved and recieved new uuids // keeping these collection local because I am sure they will get large and garbage collection is better that way List <byte[]> seneObjectGroups = new List <byte[]>(); Dictionary <UUID, UUID> assetBinaryChangeRecord = new Dictionary <UUID, UUID>(); Queue <UUID> assets2Save = new Queue <UUID>(); try { byte[] data; TarArchiveReader.TarEntryType entryType; while ((data = archive.ReadEntry(out filePath, out entryType)) != null) { if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) { continue; } if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) { seneObjectGroups.Add(data); } else if (!m_skipAssets && filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { AssetBase asset; if (LoadAsset(filePath, data, out asset)) { successfulAssetRestores++; if (m_useAsync) { lock (AssetsToAdd) AssetsToAdd.Add(asset); } else { if (asset.IsBinaryAsset) { UUID aid = asset.ID; asset.ID = m_scene.AssetService.Store(asset); if (asset.ID != aid && asset.ID != UUID.Zero) { assetBinaryChangeRecord.Add(aid, asset.ID); } } else { if (!assetNonBinaryCollection.ContainsKey(asset.ID)) { assetNonBinaryCollection.Add(asset.ID, asset); // I need something I can safely loop through assets2Save.Enqueue(asset.ID); } } } } else { failedAssetRestores++; } if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) { MainConsole.Instance.Info("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); } } else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) { LoadTerrain(filePath, data); } else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) { LoadRegionSettings(filePath, data); } else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) { LandData parcel = LandDataSerializer.Deserialize(m_utf8Encoding.GetString(data)); parcel.OwnerID = ResolveUserUuid(parcel.OwnerID, UUID.Zero, "", Vector3.Zero, null); landData.Add(parcel); } else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) { LoadControlFile(data); } } // Save Assets int savingAssetsCount = 0; while (assets2Save.Count > 0) { try { UUID assetid = assets2Save.Dequeue(); SaveNonBinaryAssets(assetid, assetNonBinaryCollection[assetid], assetBinaryChangeRecord); savingAssetsCount++; if ((savingAssetsCount) % 250 == 0) { MainConsole.Instance.Info("[ARCHIVER]: Saving " + savingAssetsCount + " assets..."); } } catch (Exception ex) { MainConsole.Instance.Info("[ARCHIVER]: Exception in saving an asset: " + ex.ToString()); } } foreach (byte[] data2 in seneObjectGroups) { byte[] data3 = data2; string stringData = Utils.BytesToString(data3); MatchCollection mc = Regex.Matches(stringData, sPattern); bool didChange = false; if (mc.Count >= 1) { foreach (Match match in mc) { UUID thematch = new UUID(match.Value); UUID newvalue = thematch; if (assetNonBinaryCollection.ContainsKey(thematch)) { newvalue = assetNonBinaryCollection[thematch].ID; } else if (assetBinaryChangeRecord.ContainsKey(thematch)) { newvalue = assetBinaryChangeRecord[thematch]; } if (thematch == newvalue) { continue; } stringData = stringData.Replace(thematch.ToString().Trim(), newvalue.ToString().Trim()); didChange = true; } } if (didChange) { data3 = Utils.StringToBytes(stringData); } SceneObjectGroup sceneObject = (SceneObjectGroup)serialiser.DeserializeGroupFromXml2(data3, m_scene); if (sceneObject == null) { //! big error! MainConsole.Instance.Error("Error reading SOP XML (Please mantis this!): " + m_asciiEncoding.GetString(data3)); continue; } foreach (SceneObjectPart part in sceneObject.ChildrenList) { if (string.IsNullOrEmpty(part.CreatorData)) { part.CreatorID = ResolveUserUuid(part.CreatorID, part.CreatorID, part.CreatorData, part.AbsolutePosition, landData); } if (UserManager != null) { UserManager.AddUser(part.CreatorID, part.CreatorData); } part.OwnerID = ResolveUserUuid(part.OwnerID, part.CreatorID, part.CreatorData, part.AbsolutePosition, landData); part.LastOwnerID = ResolveUserUuid(part.LastOwnerID, part.CreatorID, part.CreatorData, part.AbsolutePosition, landData); // And zap any troublesome sit target information part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); part.SitTargetPosition = new Vector3(0, 0, 0); // Fix ownership/creator of inventory items // Not doing so results in inventory items // being no copy/no mod for everyone lock (part.TaskInventory) { TaskInventoryDictionary inv = part.TaskInventory; foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv) { kvp.Value.OwnerID = ResolveUserUuid(kvp.Value.OwnerID, kvp.Value.CreatorID, kvp.Value.CreatorData, part.AbsolutePosition, landData); if (string.IsNullOrEmpty(kvp.Value.CreatorData)) { kvp.Value.CreatorID = ResolveUserUuid(kvp.Value.CreatorID, kvp.Value.CreatorID, kvp.Value.CreatorData, part.AbsolutePosition, landData); } if (UserManager != null) { UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); } } } } //Add the offsets of the region Vector3 newPos = new Vector3(sceneObject.AbsolutePosition.X + m_offsetX, sceneObject.AbsolutePosition.Y + m_offsetY, sceneObject.AbsolutePosition.Z + m_offsetZ); if (m_flipX) { newPos.X = m_scene.RegionInfo.RegionSizeX - newPos.X; } if (m_flipY) { newPos.Y = m_scene.RegionInfo.RegionSizeY - newPos.Y; } sceneObject.SetAbsolutePosition(false, newPos); if (m_scene.SceneGraph.AddPrimToScene(sceneObject)) { groupsToBackup.Add(sceneObject); sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate); sceneObject.CreateScriptInstances(0, false, StateSource.RegionStart, UUID.Zero, true); } sceneObjectsLoadedCount++; if (sceneObjectsLoadedCount % 250 == 0) { MainConsole.Instance.Info("[ARCHIVER]: Loaded " + sceneObjectsLoadedCount + " objects..."); } } assetNonBinaryCollection.Clear(); assetBinaryChangeRecord.Clear(); seneObjectGroups.Clear(); } catch (Exception e) { MainConsole.Instance.ErrorFormat( "[ARCHIVER]: Aborting load with error in archive file {0}. {1}", filePath, e); m_errorMessage += e.ToString(); m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage); return; } finally { archive.Close(); m_loadStream.Close(); m_loadStream.Dispose(); //Reeanble now that we are done foreach (IScriptModule module in modules) { module.Disabled = false; } //Reset backup too if (backup != null) { backup.LoadingPrims = false; } } //Now back up the prims foreach (SceneObjectGroup grp in groupsToBackup) { //Backup! grp.HasGroupChanged = true; } if (!m_skipAssets && m_useAsync && !AssetSaverIsRunning) { m_threadpool.QueueEvent(SaveAssets, 0); } if (!m_skipAssets) { MainConsole.Instance.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); if (failedAssetRestores > 0) { MainConsole.Instance.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); } } // Try to retain the original creator/owner/lastowner if their uuid is present on this grid // otherwise, use the master avatar uuid instead // Reload serialized parcels MainConsole.Instance.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", landData.Count); IParcelManagementModule parcelManagementModule = m_scene.RequestModuleInterface <IParcelManagementModule>(); if (!m_merge && parcelManagementModule != null) { parcelManagementModule.ClearAllParcels(); } if (landData.Count > 0) { m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData, new Vector2(m_offsetX, m_offsetY)); //Update the database as well! if (parcelManagementModule != null) { foreach (LandData parcel in landData) { parcelManagementModule.UpdateLandObject(parcelManagementModule.GetLandObject(parcel.LocalID)); } } } else if (parcelManagementModule != null) { parcelManagementModule.ResetSimLandObjects(); } MainConsole.Instance.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); //Clean it out landData.Clear(); MainConsole.Instance.InfoFormat("[ARCHIVER]: Successfully loaded archive in " + (DateTime.Now - start).Minutes + ":" + (DateTime.Now - start).Seconds); m_validUserUuids.Clear(); m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage); }
public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client) { if (m_scene.RegionInfo.EstateSettings.AllowParcelChanges) { try { bool snap_selection = false; if (args.AuthBuyerID != LandData.AuthBuyerID || args.SalePrice != LandData.SalePrice) { if (m_scene.Permissions.CanSellParcel(remote_client.AgentId, this) && m_scene.RegionInfo.RegionSettings.AllowLandResell) { LandData.AuthBuyerID = args.AuthBuyerID; LandData.SalePrice = args.SalePrice; snap_selection = true; } else { remote_client.SendAlertMessage("Permissions: You cannot set this parcel for sale"); args.ParcelFlags &= ~(uint)ParcelFlags.ForSale; args.ParcelFlags &= ~(uint)ParcelFlags.ForSaleObjects; args.ParcelFlags &= ~(uint)ParcelFlags.SellParcelObjects; } } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandSetSale)) { if (!LandData.IsGroupOwned) { LandData.GroupID = args.GroupID; } } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.FindPlaces)) { LandData.Category = args.Category; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.ChangeMedia)) { LandData.MediaAutoScale = args.MediaAutoScale; LandData.MediaID = args.MediaID; LandData.MediaURL = args.MediaURL; LandData.MusicURL = args.MusicURL; LandData.MediaType = args.MediaType; LandData.MediaDescription = args.MediaDescription; LandData.MediaWidth = args.MediaWidth; LandData.MediaHeight = args.MediaHeight; LandData.MediaLoop = args.MediaLoop; LandData.ObscureMusic = args.ObscureMusic; LandData.ObscureMedia = args.ObscureMedia; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) { if (m_scene.RegionInfo.RegionSettings.BlockFly && ((args.ParcelFlags & (uint)ParcelFlags.AllowFly) == (uint)ParcelFlags.AllowFly)) { //Vanquish flying as per estate settings! args.ParcelFlags &= ~(uint)ParcelFlags.AllowFly; } if (m_scene.RegionInfo.RegionSettings.RestrictPushing && ((args.ParcelFlags & (uint)ParcelFlags.RestrictPushObject) == (uint)ParcelFlags.RestrictPushObject)) { //Vanquish pushing as per estate settings! args.ParcelFlags &= ~(uint)ParcelFlags.RestrictPushObject; } if (!m_scene.RegionInfo.EstateSettings.AllowLandmark && ((args.ParcelFlags & (uint)ParcelFlags.AllowLandmark) == (uint)ParcelFlags.AllowLandmark)) { //Vanquish landmarks as per estate settings! args.ParcelFlags &= ~(uint)ParcelFlags.AllowLandmark; } if (m_scene.RegionInfo.RegionSettings.BlockShowInSearch && ((args.ParcelFlags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)) { //Vanquish show in search as per estate settings! args.ParcelFlags &= ~(uint)ParcelFlags.ShowDirectory; } if ((args.ParcelFlags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory && (LandData.Flags & (uint)ParcelFlags.ShowDirectory) != (uint)ParcelFlags.ShowDirectory) { //If the flags have changed, we need to charge them.. maybe // We really need to check per month or whatever IScheduledMoneyModule scheduledMoneyModule = m_scene.RequestModuleInterface <IScheduledMoneyModule>(); IMoneyModule moneyModule = m_scene.RequestModuleInterface <IMoneyModule>(); if (scheduledMoneyModule != null) { if ((args.ParcelFlags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory) { //Flag is set if (!scheduledMoneyModule.Charge(remote_client.AgentId, moneyModule.DirectoryFeeCharge, "Parcel Show in Search Fee - " + LandData.GlobalID, 7, TransactionType.ParcelDirFee, "[ShowInDirectory: " + LandData.GlobalID.ToString() + "]", false))// was true { remote_client.SendAlertMessage( "You don't have enough money to set this parcel in search."); args.ParcelFlags &= (uint)ParcelFlags.ShowDirectory; } } else { scheduledMoneyModule.RemoveFromScheduledCharge("[ShowInDirectory: " + LandData.GlobalID.ToString() + "]"); } } } LandData.Flags = args.ParcelFlags; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.SetLandingPoint)) { LandData.LandingType = args.LandingType; LandData.UserLocation = args.UserLocation; LandData.UserLookAt = args.UserLookAt; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandChangeIdentity)) { LandData.Description = args.Desc; LandData.Name = args.Name; LandData.SnapshotID = args.SnapshotID; LandData.Private = args.Privacy; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManagePasses)) { LandData.PassHours = args.PassHours; LandData.PassPrice = args.PassPrice; } // 141031 Greythane, this is an example of where the check needs to go LandData.Status = LandData.OwnerID == m_parcelManagementModule.GodParcelOwner ? ParcelStatus.Abandoned : LandData.AuthBuyerID != UUID.Zero ? ParcelStatus.LeasePending : ParcelStatus.Leased; m_parcelManagementModule.UpdateLandObject(this); SendLandUpdateToAvatarsOverMe(snap_selection); } catch (Exception ex) { MainConsole.Instance.Warn("[LAND]: Error updating land object " + this.LandData.Name + " in region " + this.m_scene.RegionInfo.RegionName + " : " + ex); } } }
public void EndLoadModuleFromArchive(IScene scene) { IBackupModule backup = scene.RequestModuleInterface <IBackupModule> (); IScriptModule [] modules = scene.RequestModuleInterfaces <IScriptModule> (); //Reeanble now that we are done foreach (IScriptModule module in modules) { module.Disabled = false; } //Reset backup too if (backup != null) { backup.LoadingPrims = false; } //Update the database as well! IParcelManagementModule parcelManagementModule = scene.RequestModuleInterface <IParcelManagementModule> (); if (parcelManagementModule != null && !m_merge) //Only if we are not merging { if (m_parcels.Count > 0) { scene.EventManager.TriggerIncomingLandDataFromStorage(m_parcels, Vector2.Zero); //Update the database as well! foreach (LandData parcel in m_parcels) { parcelManagementModule.UpdateLandObject(parcelManagementModule.GetLandObject(parcel.LocalID)); } } else { parcelManagementModule.ResetSimLandObjects(); } m_parcels.Clear(); } foreach (ISceneEntity sceneObject in m_groups) { foreach (ISceneChildEntity part in sceneObject.ChildrenEntities()) { if (!ResolveUserUuid(part.CreatorID)) { part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; } if (!ResolveUserUuid(part.OwnerID)) { part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; } if (!ResolveUserUuid(part.LastOwnerID)) { part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; } // Fix ownership/creator of inventory items // Not doing so results in inventory items // being no copy/no mod for everyone lock (part.TaskInventory) { TaskInventoryDictionary inv = part.TaskInventory; foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv) { if (!ResolveUserUuid(kvp.Value.OwnerID)) { kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner; } if (!ResolveUserUuid(kvp.Value.CreatorID)) { kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner; } } } } if (scene.SceneGraph.AddPrimToScene(sceneObject)) { sceneObject.HasGroupChanged = true; sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate); sceneObject.CreateScriptInstances(0, false, StateSource.RegionStart, UUID.Zero, false); } } }
private void DearchiveRegion0DotStar() { int successfulAssetRestores = 0; int failedAssetRestores = 0; //List<string> serialisedSceneObjects = new List<string>(); List <string> serialisedParcels = new List <string>(); string filePath = "NONE"; DateTime start = DateTime.Now; TarArchiveReader archive = new TarArchiveReader(m_loadStream); byte[] data; TarArchiveReader.TarEntryType entryType; if (!m_skipAssets) { m_threadpool = new Aurora.Framework.AuroraThreadPool(new Aurora.Framework.AuroraThreadPoolStartInfo() { Threads = 1, priority = System.Threading.ThreadPriority.BelowNormal }); } IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>(); if (!m_merge) { DateTime before = DateTime.Now; m_log.Info("[ARCHIVER]: Clearing all existing scene objects"); if (backup != null) { backup.DeleteAllSceneObjects(); } m_log.Info("[ARCHIVER]: Cleared all existing scene objects in " + (DateTime.Now - before).Minutes + ":" + (DateTime.Now - before).Seconds); } IScriptModule[] modules = m_scene.RequestModuleInterfaces <IScriptModule>(); //Disable the script engine so that it doesn't load in the background and kill OAR loading foreach (IScriptModule module in modules) { module.Disabled = true; } //Disable backup for now as well if (backup != null) { backup.LoadingPrims = true; } IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface <IRegionSerialiserModule>(); int sceneObjectsLoadedCount = 0; //We save the groups so that we can back them up later List <SceneObjectGroup> groupsToBackup = new List <SceneObjectGroup>(); try { while ((data = archive.ReadEntry(out filePath, out entryType)) != null) { //m_log.DebugFormat( // "[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length); if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) { continue; } if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) { string sogdata = m_utf8Encoding.GetString(data); //serialisedSceneObjects.Add(m_utf8Encoding.GetString(data)); /* * m_log.DebugFormat("[ARCHIVER]: Loading xml with raw size {0}", serialisedSceneObject.Length); * * // Really large xml files (multi megabyte) appear to cause * // memory problems * // when loading the xml. But don't enable this check yet * * if (serialisedSceneObject.Length > 5000000) * { * m_log.Error("[ARCHIVER]: Ignoring xml since size > 5000000);"); * continue; * } */ string serialisedSceneObject = sogdata; SceneObjectGroup sceneObject = (SceneObjectGroup)serialiser.DeserializeGroupFromXml2(serialisedSceneObject, m_scene); if (sceneObject == null) { //! big error! m_log.Error("Error reading SOP XML (Please mantis this!): " + serialisedSceneObject); continue; } foreach (SceneObjectPart part in sceneObject.ChildrenList) { if (!ResolveUserUuid(part.CreatorID)) { part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; } if (!ResolveUserUuid(part.OwnerID)) { part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; } if (!ResolveUserUuid(part.LastOwnerID)) { part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; } // And zap any troublesome sit target information part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); part.SitTargetPosition = new Vector3(0, 0, 0); // Fix ownership/creator of inventory items // Not doing so results in inventory items // being no copy/no mod for everyone lock (part.TaskInventory) { TaskInventoryDictionary inv = part.TaskInventory; foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv) { if (!ResolveUserUuid(kvp.Value.OwnerID)) { kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; } if (!ResolveUserUuid(kvp.Value.CreatorID)) { kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; } } } } //Add the offsets of the region Vector3 newPos = new Vector3(sceneObject.AbsolutePosition.X + m_offsetX, sceneObject.AbsolutePosition.Y + m_offsetY, sceneObject.AbsolutePosition.Z + m_offsetZ); if (m_flipX) { newPos.X = m_scene.RegionInfo.RegionSizeX - newPos.X; } if (m_flipY) { newPos.Y = m_scene.RegionInfo.RegionSizeY - newPos.Y; } sceneObject.SetAbsolutePosition(false, newPos); if (m_scene.SceneGraph.AddPrimToScene(sceneObject)) { groupsToBackup.Add(sceneObject); sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.FullUpdate); sceneObjectsLoadedCount++; sceneObject.CreateScriptInstances(0, false, 0, UUID.Zero); sceneObject.ResumeScripts(); } sceneObjectsLoadedCount++; if (sceneObjectsLoadedCount % 250 == 0) { m_log.Debug("[ARCHIVER]: Loaded " + sceneObjectsLoadedCount + " objects..."); } } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { if (!m_skipAssets) { if (LoadAsset(filePath, data)) { successfulAssetRestores++; } else { failedAssetRestores++; } if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) { m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); } } } else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) { LoadTerrain(filePath, data); } else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) { LoadRegionSettings(filePath, data); } else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) { serialisedParcels.Add(m_utf8Encoding.GetString(data)); } else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) { LoadControlFile(filePath, data); } else { m_log.Debug("[ARCHIVER]:UNKNOWN PATH: " + filePath); } } //m_log.Debug("[ARCHIVER]: Reached end of archive"); } catch (Exception e) { m_log.ErrorFormat( "[ARCHIVER]: Aborting load with error in archive file {0}. {1}", filePath, e); m_errorMessage += e.ToString(); m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage); return; } finally { archive.Close(); m_loadStream.Close(); m_loadStream.Dispose(); } //Reeanble now that we are done foreach (IScriptModule module in modules) { module.Disabled = false; } //Reset backup too if (backup != null) { backup.LoadingPrims = false; } //Now back up the prims foreach (SceneObjectGroup grp in groupsToBackup) { //Backup! grp.HasGroupChanged = true; } if (!m_skipAssets) { if (m_useAsync && !AssetSaverIsRunning) { m_threadpool.QueueEvent(SaveAssets, 0); } else if (!AssetSaverIsRunning) { SaveAssets(); } } if (!m_skipAssets) { m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); if (failedAssetRestores > 0) { m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); } } // Try to retain the original creator/owner/lastowner if their uuid is present on this grid // otherwise, use the master avatar uuid instead // Reload serialized parcels m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); List <LandData> landData = new List <LandData>(); foreach (string serialisedParcel in serialisedParcels) { LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); if (!ResolveUserUuid(parcel.OwnerID)) { parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; } landData.Add(parcel); } m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData); //Update the database as well! IParcelManagementModule parcelManagementModule = m_scene.RequestModuleInterface <IParcelManagementModule>(); if (parcelManagementModule != null) { foreach (LandData parcel in landData) { parcelManagementModule.UpdateLandObject(parcel.LocalID, parcel); } } m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); //Clean it out landData.Clear(); serialisedParcels.Clear(); m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive in " + (DateTime.Now - start).Minutes + ":" + (DateTime.Now - start).Seconds); m_validUserUuids.Clear(); m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage); }
public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client) { if (m_scene.RegionInfo.EstateSettings.AllowParcelChanges) { try { bool snap_selection = false; if (args.AuthBuyerID != LandData.AuthBuyerID || args.SalePrice != LandData.SalePrice) { if (m_scene.Permissions.CanSellParcel(remote_client.AgentId, this) && m_scene.RegionInfo.RegionSettings.AllowLandResell) { LandData.AuthBuyerID = args.AuthBuyerID; LandData.SalePrice = args.SalePrice; snap_selection = true; } else { remote_client.SendAlertMessage("Permissions: You cannot set this parcel for sale"); args.ParcelFlags &= ~(uint)ParcelFlags.ForSale; args.ParcelFlags &= ~(uint)ParcelFlags.ForSaleObjects; args.ParcelFlags &= ~(uint)ParcelFlags.SellParcelObjects; } } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandSetSale)) { if (!LandData.IsGroupOwned) { LandData.GroupID = args.GroupID; } } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.FindPlaces)) { LandData.Category = args.Category; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.ChangeMedia)) { LandData.MediaAutoScale = args.MediaAutoScale; LandData.MediaID = args.MediaID; LandData.MediaURL = args.MediaURL; LandData.MusicURL = args.MusicURL; LandData.MediaType = args.MediaType; LandData.MediaDescription = args.MediaDescription; LandData.MediaWidth = args.MediaWidth; LandData.MediaHeight = args.MediaHeight; LandData.MediaLoop = args.MediaLoop; LandData.ObscureMusic = args.ObscureMusic; LandData.ObscureMedia = args.ObscureMedia; // 25062016 Added for LibOMV update 0.9.4.5 LandData.AnyAVSounds = args.AnyAVSounds; LandData.GroupAVSounds = args.GroupAVSounds; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) { // check for allowed settings and clear if necessary if (m_scene.RegionInfo.RegionSettings.BlockFly && ((args.ParcelFlags & (uint)ParcelFlags.AllowFly) == (uint)ParcelFlags.AllowFly)) { //Vanquish flying as per estate settings! args.ParcelFlags &= ~(uint)ParcelFlags.AllowFly; } if (m_scene.RegionInfo.RegionSettings.RestrictPushing && ((args.ParcelFlags & (uint)ParcelFlags.RestrictPushObject) == (uint)ParcelFlags.RestrictPushObject)) { //Vanquish pushing as per estate settings! args.ParcelFlags &= ~(uint)ParcelFlags.RestrictPushObject; } if (!m_scene.RegionInfo.EstateSettings.AllowLandmark && ((args.ParcelFlags & (uint)ParcelFlags.AllowLandmark) == (uint)ParcelFlags.AllowLandmark)) { //Vanquish landmarks as per estate settings! args.ParcelFlags &= ~(uint)ParcelFlags.AllowLandmark; } if (m_scene.RegionInfo.RegionSettings.BlockShowInSearch && ((args.ParcelFlags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)) { //Vanquish show in search as per estate settings! args.ParcelFlags &= ~(uint)ParcelFlags.ShowDirectory; } // Check if ShowDirectory has changed var updShowInDir = (args.ParcelFlags & (uint)ParcelFlags.ShowDirectory); if ((LandData.Flags & (uint)ParcelFlags.ShowDirectory) != updShowInDir) { IScheduledMoneyModule scheduledMoneyModule = m_scene.RequestModuleInterface <IScheduledMoneyModule> (); if (scheduledMoneyModule != null) { if ((args.ParcelFlags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory) { //Flag is set var payOk = scheduledMoneyModule.Charge(remote_client.AgentId, // who to charge scheduledMoneyModule.DirectoryFeeCharge, // how much "Parcel Show in Search Fee - " + LandData.GlobalID, // description (needs UUID) TransactionType.ParcelDirFee, // transaction type "[ShowInDirectory: " + LandData.GlobalID + "]", // scheduler identifier false, // charge immediately false); // run once if (!payOk) { // Payment was not processed remote_client.SendAlertMessage("You don't have enough money to set this parcel in search."); args.ParcelFlags &= (uint)ParcelFlags.ShowDirectory; } } else { scheduledMoneyModule.RemoveDirFeeScheduledCharge("[ShowInDirectory: " + LandData.GlobalID + "]"); } } } LandData.Flags = args.ParcelFlags; // 25062016 Added for LibOMV update 0.9.4.5 LandData.SeeAVS = args.SeeAVs; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.SetLandingPoint)) { LandData.LandingType = args.LandingType; LandData.UserLocation = args.UserLocation; LandData.UserLookAt = args.UserLookAt; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandChangeIdentity)) { LandData.Description = args.Desc; LandData.Name = args.Name; LandData.SnapshotID = args.SnapshotID; LandData.Private = args.Privacy; } if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManagePasses)) { LandData.PassHours = args.PassHours; LandData.PassPrice = args.PassPrice; } // 20160203 -greythane- the only time we should play with the ParcelStatus is // if it is being sold to a specified buyer if (LandData.AuthBuyerID != UUID.Zero) { LandData.Status = ParcelStatus.LeasePending; } // 141031 Greythane, this is an example of where the check needs to go /* LandData.Status = LandData.OwnerID == m_parcelManagementModule.GodParcelOwner * ? ParcelStatus.Abandoned * : LandData.AuthBuyerID != UUID.Zero * ? ParcelStatus.LeasePending * : ParcelStatus.Leased; */ m_parcelManagementModule.UpdateLandObject(this); SendLandUpdateToAvatarsOverMe(snap_selection); } catch (Exception ex) { MainConsole.Instance.Warn("[LAND]: Error updating land object " + LandData.Name + " in region " + m_scene.RegionInfo.RegionName + " : " + ex); } } }