示例#1
0
 public override void FromOSD(OpenMetaverse.StructuredData.OSDMap map)
 {
     GlobalPosX = map["GlobalPosX"];
     GlobalPosY = map["GlobalPosY"];
     LandData = new LandData();
     LandData.FromOSD((OSDMap)map["LandData"]);
     RegionName = map["RegionName"];
     RegionType = map["RegionType"];
 }
示例#2
0
 public void TriggerLandObjectAdded(LandData newParcel)
 {
     LandObjectAdded handlerLandObjectAdded = OnLandObjectAdded;
     if (handlerLandObjectAdded != null)
     {
         foreach (LandObjectAdded d in handlerLandObjectAdded.GetInvocationList())
         {
             try
             {
                 d(newParcel);
             }
             catch (Exception e)
             {
                 MainConsole.Instance.ErrorFormat(
                     "[EVENT MANAGER]: Delegate for TriggerLandObjectAdded failed - continuing.  {0} {1}",
                     e, e.StackTrace);
             }
         }
     }
 }
        protected virtual void ReadBackup(IScene scene)
        {
            MainConsole.Instance.Debug("[FileBasedSimulationData]: Reading file for " + scene.RegionInfo.RegionName);
            List<uint> foundLocalIDs = new List<uint>();
            var stream = ArchiveHelpers.GetStream((m_loadDirectory == "" || m_loadDirectory == "/")
                                                      ? m_fileName
                                                      : Path.Combine(m_loadDirectory, m_fileName));
            if(stream == null)
                return;

            GZipStream m_loadStream = new GZipStream(stream, CompressionMode.Decompress);
            TarArchiveReader reader = new TarArchiveReader(m_loadStream);

            byte[] data;
            string filePath;
            TarArchiveReader.TarEntryType entryType;
            System.Collections.Concurrent.ConcurrentQueue<byte[]> groups = new System.Collections.Concurrent.ConcurrentQueue<byte[]>();
            //Load the archive data that we need
            while ((data = reader.ReadEntry(out filePath, out entryType)) != null)
            {
                if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    continue;

                if (filePath.StartsWith("parcels/"))
                {
                    //Only use if we are not merging
                    LandData parcel = new LandData();
                    OSD parcelData = OSDParser.DeserializeLLSDBinary(data);
                    parcel.FromOSD((OSDMap) parcelData);
                    m_parcels.Add(parcel);
                }
                else if (filePath.StartsWith("terrain/"))
                {
                    m_oldstyleterrain = data;
                }
                else if (filePath.StartsWith("revertterrain/"))
                {
                    m_oldstylerevertTerrain = data;
                }
                else if (filePath.StartsWith("newstyleterrain/"))
                {
                    m_terrain = data;
                }
                else if (filePath.StartsWith("newstylerevertterrain/"))
                {
                    m_revertTerrain = data;
                }
                else if (filePath.StartsWith("newstylewater/"))
                {
                    m_water = data;
                }
                else if (filePath.StartsWith("newstylerevertwater/"))
                {
                    m_revertWater = data;
                }
                else if (filePath.StartsWith("entities/"))
                {
                    groups.Enqueue(data);
                }
                data = null;
            }
            m_loadStream.Close();
            m_loadStream = null;

            int threadCount = groups.Count > 16 ? 16 : groups.Count;
            System.Threading.Thread[] threads = new System.Threading.Thread[threadCount];
            for (int i = 0; i < threadCount; i++)
            {
                threads[i] = new System.Threading.Thread(() =>
                    {
                        byte[] groupData;
                        while(groups.TryDequeue(out groupData))
                        {
                            MemoryStream ms = new MemoryStream(groupData);
                            SceneObjectGroup sceneObject = SceneObjectSerializer.FromXml2Format(ref ms, scene);
                            ms.Close();
                            ms = null;
                            data = null;
                            if (sceneObject != null)
                            {
                                foreach (ISceneChildEntity part in sceneObject.ChildrenEntities())
                                {
                                    lock (foundLocalIDs)
                                    {
                                        if (!foundLocalIDs.Contains(part.LocalId))
                                            foundLocalIDs.Add(part.LocalId);
                                        else
                                            part.LocalId = 0; //Reset it! Only use it once!
                                    }
                                }
                                m_groups.Add(sceneObject);
                            }
                        }
                    });
                threads[i].Start();
            }
            for (int i = 0; i < threadCount; i++)
                threads[i].Join();


            foundLocalIDs.Clear();
            GC.Collect();
        }
示例#4
0
        /// <summary>
        ///   Make a new copy of the land data
        /// </summary>
        /// <returns></returns>
        public LandData Copy()
        {
            LandData landData = new LandData
                                    {
                                        _AABBMax = _AABBMax,
                                        _AABBMin = _AABBMin,
                                        _area = _area,
                                        _auctionID = _auctionID,
                                        _authBuyerID = _authBuyerID,
                                        _category = _category,
                                        _claimDate = _claimDate,
                                        _claimPrice = _claimPrice,
                                        _globalID = _globalID,
                                        _groupID = _groupID,
                                        _isGroupOwned = _isGroupOwned,
                                        _localID = _localID,
                                        _landingType = _landingType,
                                        _mediaAutoScale = _mediaAutoScale,
                                        _mediaID = _mediaID,
                                        _mediaURL = _mediaURL,
                                        _musicURL = _musicURL,
                                        _ownerID = _ownerID,
                                        _bitmap = (byte[]) _bitmap.Clone(),
                                        _description = _description,
                                        _flags = _flags,
                                        _name = _name,
                                        _status = _status,
                                        _passHours = _passHours,
                                        _passPrice = _passPrice,
                                        _salePrice = _salePrice,
                                        _snapshotID = _snapshotID,
                                        _userLocation = _userLocation,
                                        _userLookAt = _userLookAt,
                                        _otherCleanTime = _otherCleanTime,
                                        _dwell = _dwell,
                                        _mediaType = _mediaType,
                                        _mediaDescription = _mediaDescription,
                                        _mediaWidth = _mediaWidth,
                                        _mediaHeight = _mediaHeight,
                                        _mediaLoop = _mediaLoop,
                                        _MediaLoopSet = _MediaLoopSet,
                                        _obscureMusic = _obscureMusic,
                                        _obscureMedia = _obscureMedia,
                                        _regionID = _regionID,
                                        _regionHandle = _regionHandle,
                                        _infoUUID = _infoUUID,
                                        _Maturity = _Maturity,
                                        _private = _private
                                    };


            landData._parcelAccessList.Clear();
#if (!ISWIN)
            foreach (ParcelManager.ParcelAccessEntry entry in _parcelAccessList)
            {
                ParcelManager.ParcelAccessEntry newEntry = new ParcelManager.ParcelAccessEntry
                                                               {
                                                                   AgentID = entry.AgentID, Flags = entry.Flags, Time = entry.Time
                                                               };
                landData._parcelAccessList.Add(newEntry);
            }
#else
            foreach (ParcelManager.ParcelAccessEntry newEntry in _parcelAccessList.Select(entry => new ParcelManager.ParcelAccessEntry
                                                                                         {
                                                                                             AgentID = entry.AgentID,
                                                                                             Flags = entry.Flags,
                                                                                             Time = entry.Time
                                                                                         }))
            {
                landData._parcelAccessList.Add(newEntry);
            }
#endif

            return landData;
        }
        /// <summary>
        ///   Rebuild the access list from the database
        /// </summary>
        /// <param name = "LandData"></param>
        private void BuildParcelAccessList(LandData LandData)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["ParcelID"] = LandData.GlobalID;
            List<string> Query = GD.Query(new string[3]{
                "AccessID",
                "Flags",
                "Time"
            }, "parcelaccess", filter, null, null, null);

            ParcelManager.ParcelAccessEntry entry;
            for (int i = 0; i < Query.Count; i += 3)
            {
                entry = new ParcelManager.ParcelAccessEntry();
                entry.AgentID = UUID.Parse(Query[i]);
                entry.Flags = (AccessList) Enum.Parse(typeof (AccessList), Query[i + 1]);
                entry.Time = new DateTime(long.Parse(Query[i + 2]));
                LandData.ParcelAccessList.Add(entry);
            }
        }
        private string ChannelUri(IScene scene, LandData land)
        {
            string channelUri = null;

            string landUUID;
            string landName;

            // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same
            // as the directory ID. Otherwise, it reflects the parcel's ID.

            lock (m_ParcelAddress)
            {
                if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString()))
                {
                    m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}",
                                      land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]);
                    return m_ParcelAddress[land.GlobalID.ToString()];
                }
            }

            if (land.LocalID != 1 && (land.Flags & (uint)ParcelFlags.UseEstateVoiceChan) == 0)
            {
                landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name);
                landUUID = land.GlobalID.ToString();
                m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
                                  landName, land.LocalID, landUUID);
            }
            else
            {
                landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName);
                landUUID = scene.RegionInfo.RegionID.ToString();
                m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
                                  landName, land.LocalID, landUUID);
            }
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

            // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables
            // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator.
            channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm);

            lock (m_ParcelAddress)
            {
                if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString()))
                {
                    m_ParcelAddress.Add(land.GlobalID.ToString(), channelUri);
                }
            }

            return channelUri;
        }
        private static List<LandData> Query2LandData(List<string> Query)
        {
            List<LandData> Lands = new List<LandData>();

            LandData LandData;

            for (int i = 0; i < Query.Count; i += 23)
            {
                LandData = new LandData();
                LandData.RegionID = UUID.Parse(Query[i]);
                LandData.GlobalID = UUID.Parse(Query[i + 1]);
                LandData.LocalID = int.Parse(Query[i + 2]);
                LandData.UserLocation = new Vector3(float.Parse(Query[i + 3]), float.Parse(Query[i + 4]),
                                                    float.Parse(Query[i + 5]));
                LandData.Name = Query[i + 6];
                LandData.Description = Query[i + 7];
                LandData.Flags = uint.Parse(Query[i + 8]);
                LandData.Dwell = int.Parse(Query[i + 9]);
                LandData.InfoUUID = UUID.Parse(Query[i + 10]);
                LandData.AuctionID = uint.Parse(Query[i + 13]);
                LandData.Area = int.Parse(Query[i + 14]);
                LandData.Maturity = int.Parse(Query[i + 16]);
                LandData.OwnerID = UUID.Parse(Query[i + 17]);
                LandData.GroupID = UUID.Parse(Query[i + 18]);
                LandData.SnapshotID = UUID.Parse(Query[i + 20]);
                try
                {
                    LandData.Bitmap = OSDParser.DeserializeLLSDXml(Query[i + 21]);
                }
                catch
                {
                }
                LandData.Category = (Query[i + 22] == string.Empty) ? ParcelCategory.None : (ParcelCategory)int.Parse(Query[i + 22]);

                Lands.Add(LandData);
            }
            return Lands;
        }
        private string RegionGetOrCreateChannel(IScene scene, LandData land)
        {
            string channelUri = null;
            string channelId = null;

            string landUUID;
            string landName;
            string parentId;

               lock (m_parents) parentId = m_parents[scene.RegionInfo.RegionID.ToString()];

            // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same
            // as the directory ID. Otherwise, it reflects the parcel's ID.

            if (land.LocalID != 1 && (land.Flags & (uint)ParcelFlags.UseEstateVoiceChan) == 0)
            {
                landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name);
                landUUID = land.GlobalID.ToString();
                m_log.TraceFormat("[VivoxVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
                                  landName, land.LocalID, landUUID);
            }
            else
            {
                landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName);
                landUUID = scene.RegionInfo.RegionID.ToString();
                m_log.TraceFormat("[VivoxVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
                                  landName, land.LocalID, landUUID);
            }

            lock (vlock)
            {
                // Added by Adam to help debug channel not availible errors.
                if (VivoxTryGetChannel(parentId, landUUID, out channelId, out channelUri))
                    m_log.DebugFormat("[VivoxVoice] Found existing channel at " + channelUri);
                else if (VivoxTryCreateChannel(parentId, landUUID, landName, out channelUri))
                    m_log.DebugFormat("[VivoxVoice] Created new channel at " + channelUri);
                else
                    throw new Exception("vivox channel uri not available");

                m_log.TraceFormat("[VivoxVoice]: Region:Parcel \"{0}\": parent channel id {1}: retrieved parcel channel_uri {2} ",
                                  landName, parentId, channelUri);

            }

            return channelUri;
        }
 private string CheckForSale(LandData parcel)
 {
     if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale)
         return "true";
     else
         return "false";
 }
示例#10
0
文件: Backup.cs 项目: Gnu32/Silverfin
            public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene)
            {
                if (filePath.StartsWith("parcels/"))
                {
                    if (!m_merge)
                    {
                        //Only use if we are not merging
                        LandData parcel = new LandData();
                        OSD parcelData = OSDParser.DeserializeLLSDBinary(data);
                        parcel.FromOSD((OSDMap)parcelData);
                        m_parcels.Add(parcel);
                    }
                }
                #region New Style Terrain Loading
                else if (filePath.StartsWith ("newstyleterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylerevertterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainRevertMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylewater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainWaterMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylerevertwater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainWaterRevertMap = ReadTerrain(data, scene);
                }
                #endregion
                #region Old Style Terrain Loading
                else if (filePath.StartsWith ("terrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("revertterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadRevertMapFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("water/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadWaterFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("revertwater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadWaterRevertMapFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                #endregion
                else if (filePath.StartsWith ("entities/"))
                {
                    MemoryStream ms = new MemoryStream (data);
                    SceneObjectGroup sceneObject = OpenSim.Region.Framework.Scenes.Serialization.SceneObjectSerializer.FromXml2Format (ref ms, scene);
                    ms.Close ();
                    ms = null;
                    data = null;
                    m_groups.Add(sceneObject);
                }
                else if(filePath.StartsWith("assets/"))
                {
                    if(m_loadAssets)
                    {
                        AssetBase asset = new AssetBase();
                        asset.Unpack(OSDParser.DeserializeJson(Encoding.UTF8.GetString(data)));
                        scene.AssetService.Store(asset);
                    }
                }
            }
示例#11
0
        /// <summary>
        ///   Make a new copy of the land data
        /// </summary>
        /// <returns></returns>
        public LandData Copy()
        {
            LandData landData = new LandData
            {
                _AABBMax          = _AABBMax,
                _AABBMin          = _AABBMin,
                _area             = _area,
                _auctionID        = _auctionID,
                _authBuyerID      = _authBuyerID,
                _category         = _category,
                _claimDate        = _claimDate,
                _claimPrice       = _claimPrice,
                _globalID         = _globalID,
                _groupID          = _groupID,
                _isGroupOwned     = _isGroupOwned,
                _localID          = _localID,
                _landingType      = _landingType,
                _mediaAutoScale   = _mediaAutoScale,
                _mediaID          = _mediaID,
                _mediaURL         = _mediaURL,
                _musicURL         = _musicURL,
                _ownerID          = _ownerID,
                _bitmap           = (byte[])_bitmap.Clone(),
                _description      = _description,
                _flags            = _flags,
                _name             = _name,
                _status           = _status,
                _passHours        = _passHours,
                _passPrice        = _passPrice,
                _salePrice        = _salePrice,
                _snapshotID       = _snapshotID,
                _userLocation     = _userLocation,
                _userLookAt       = _userLookAt,
                _otherCleanTime   = _otherCleanTime,
                _dwell            = _dwell,
                _mediaType        = _mediaType,
                _mediaDescription = _mediaDescription,
                _mediaWidth       = _mediaWidth,
                _mediaHeight      = _mediaHeight,
                _mediaLoop        = _mediaLoop,
                _MediaLoopSet     = _MediaLoopSet,
                _obscureMusic     = _obscureMusic,
                _obscureMedia     = _obscureMedia,
                _regionID         = _regionID,
                _regionHandle     = _regionHandle,
                _infoUUID         = _infoUUID,
                _Maturity         = _Maturity,
                _private          = _private
            };


            landData._parcelAccessList.Clear();
#if (!ISWIN)
            foreach (ParcelManager.ParcelAccessEntry entry in _parcelAccessList)
            {
                ParcelManager.ParcelAccessEntry newEntry = new ParcelManager.ParcelAccessEntry
                {
                    AgentID = entry.AgentID, Flags = entry.Flags, Time = entry.Time
                };
                landData._parcelAccessList.Add(newEntry);
            }
#else
            foreach (ParcelManager.ParcelAccessEntry newEntry in _parcelAccessList.Select(entry => new ParcelManager.ParcelAccessEntry
            {
                AgentID = entry.AgentID,
                Flags = entry.Flags,
                Time = entry.Time
            }))
            {
                landData._parcelAccessList.Add(newEntry);
            }
#endif

            return(landData);
        }
 public LandData GetParcelInfo(UUID RegionID, UUID ScopeID, string ParcelName)
 {
     OSDMap mess = new OSDMap();
     mess["Method"] = "GetParcelInfo";
     mess["RegionID"] = RegionID;
     mess["ScopeID"] = ScopeID;
     mess["ParcelName"] = ParcelName;
     List<string> m_ServerURIs =
         m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("RemoteServerURI");
     foreach (string m_ServerURI in m_ServerURIs)
     {
         OSDMap results = WebUtils.PostToService(m_ServerURI + "osd", mess, true, false);
         OSDMap innerResults = (OSDMap)OSDParser.DeserializeJson(results["_RawResult"]);
         if (innerResults["Success"])
         {
             LandData result = new LandData(innerResults);
             return result;
         }
     }
     return null;
 }
示例#13
0
            public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene)
            {
                if (filePath.StartsWith("parcels/"))
                {
                    if (!m_merge)
                    {
                        //Only use if we are not merging
                        LandData parcel = new LandData();
                        OSD parcelData = OSDParser.DeserializeLLSDBinary(data);
                        parcel.FromOSD((OSDMap)parcelData);
                        m_parcels.Add(parcel);
                    }
                }
                #region New Style Terrain Loading
                else if (filePath.StartsWith ("newstyleterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylerevertterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainRevertMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylewater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainWaterMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith ("newstylerevertwater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
                    terrainModule.TerrainWaterRevertMap = ReadTerrain(data, scene);
                }
                #endregion
                else if (filePath.StartsWith ("terrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("revertterrain/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadRevertMapFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("water/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadWaterFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("revertwater/"))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

                    MemoryStream ms = new MemoryStream (data);
                    terrainModule.LoadWaterRevertMapFromStream (filePath, ms, 0, 0);
                    ms.Close ();
                }
                else if (filePath.StartsWith ("entities/"))
                {
                    MemoryStream ms = new MemoryStream (data);
                    SceneObjectGroup sceneObject = OpenSim.Region.Framework.Scenes.Serialization.SceneObjectSerializer.FromXml2Format (ref ms, scene);
                    ms.Close ();
                    ms = null;
                    data = null;
                    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);
                    }
                }
                else if(filePath.StartsWith("assets/"))
                {
                    if(m_loadAssets)
                    {
                        AssetBase asset = new AssetBase();
                        asset.Unpack(OSDParser.DeserializeJson(Encoding.UTF8.GetString(data)));
                        bool exists = scene.AssetService.Get(asset.IDString) != null;
                        if(!exists)
                            scene.AssetService.Store(asset);
                    }
                }
            }
        /// <summary>
        ///   Build a Land Data from the persisted data.
        /// </summary>
        /// <param name = "row"></param>
        /// <returns></returns>
        private LandData buildLandData(DataRow row)
        {
            LandData newData = new LandData
                                   {
                                       GlobalID = new UUID((String) row["UUID"]),
                                       LocalID = Convert.ToInt32(row["LocalLandID"]),
                                       Bitmap = (Byte[]) row["Bitmap"],
                                       Name = (String) row["Name"],
                                       Description = (String) row["Desc"],
                                       OwnerID = (UUID) (String) row["OwnerUUID"],
                                       IsGroupOwned = (Boolean) row["IsGroupOwned"],
                                       Area = Convert.ToInt32(row["Area"]),
                                       AuctionID = Convert.ToUInt32(row["AuctionID"]),
                                       Category = (ParcelCategory) Convert.ToInt32(row["Category"]),
                                       ClaimDate = Convert.ToInt32(row["ClaimDate"]),
                                       ClaimPrice = Convert.ToInt32(row["ClaimPrice"]),
                                       GroupID = new UUID((String) row["GroupUUID"]),
                                       SalePrice = Convert.ToInt32(row["SalePrice"]),
                                       Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]),
                                       Flags = Convert.ToUInt32(row["LandFlags"]),
                                       LandingType = (Byte) row["LandingType"],
                                       MediaAutoScale = (Byte) row["MediaAutoScale"],
                                       MediaID = new UUID((String) row["MediaTextureUUID"]),
                                       MediaURL = (String) row["MediaURL"],
                                       MusicURL = (String) row["MusicURL"],
                                       PassHours = Convert.ToSingle(row["PassHours"]),
                                       PassPrice = Convert.ToInt32(row["PassPrice"]),
                                       SnapshotID = (UUID) (String) row["SnapshotUUID"]
                                   };


            // Bitmap is a byte[512]

            //Unemplemented
            //Enum OpenMetaverse.Parcel.ParcelCategory
            //Enum. OpenMetaverse.Parcel.ParcelStatus
            try
            {
                newData.UserLocation =
                    new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]),
                                Convert.ToSingle(row["UserLocationZ"]));
                newData.UserLookAt =
                    new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]),
                                Convert.ToSingle(row["UserLookAtZ"]));
            }
            catch (InvalidCastException)
            {
                MainConsole.Instance.ErrorFormat(":[SQLite REGION DB]: unable to get parcel telehub settings for {1}", newData.Name);
                newData.UserLocation = Vector3.Zero;
                newData.UserLookAt = Vector3.Zero;
            }
            newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
            UUID authBuyerID = UUID.Zero;

            UUID.TryParse((string) row["AuthbuyerID"], out authBuyerID);

            newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]);
            newData.Dwell = Convert.ToInt32(row["Dwell"]);

            return newData;
        }
 private string GetBuildPermissions(LandData parcel)
 {
     if ((parcel.Flags & (uint)ParcelFlags.CreateObjects) == (uint)ParcelFlags.CreateObjects)
         return "true";
     else
         return "false";
 }
        /// <summary>
        ///   Builds the land data from a datarecord.
        /// </summary>
        /// <param name = "row">datarecord with land data</param>
        /// <returns></returns>
        private static LandData BuildLandData(IDataRecord row)
        {
            LandData newData = new LandData
                                   {
                                       GlobalID = new UUID((Guid) row["UUID"]),
                                       LocalID = Convert.ToInt32(row["LocalLandID"]),
                                       Bitmap = (Byte[]) row["Bitmap"],
                                       Name = (string) row["Name"],
                                       Description = (string) row["Description"],
                                       OwnerID = new UUID((Guid) row["OwnerUUID"]),
                                       IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]),
                                       Area = Convert.ToInt32(row["Area"]),
                                       AuctionID = Convert.ToUInt32(row["AuctionID"]),
                                       Category = (ParcelCategory) Convert.ToInt32(row["Category"]),
                                       ClaimDate = Convert.ToInt32(row["ClaimDate"]),
                                       ClaimPrice = Convert.ToInt32(row["ClaimPrice"]),
                                       GroupID = new UUID((Guid) row["GroupUUID"]),
                                       SalePrice = Convert.ToInt32(row["SalePrice"]),
                                       Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]),
                                       Flags = Convert.ToUInt32(row["LandFlags"]),
                                       LandingType = Convert.ToByte(row["LandingType"]),
                                       MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]),
                                       MediaID = new UUID((Guid) row["MediaTextureUUID"]),
                                       MediaURL = (string) row["MediaURL"],
                                       MusicURL = (string) row["MusicURL"],
                                       PassHours = Convert.ToSingle(row["PassHours"]),
                                       PassPrice = Convert.ToInt32(row["PassPrice"]),
                                       AuthBuyerID = new UUID((Guid) row["AuthBuyerID"]),
                                       SnapshotID = new UUID((Guid) row["SnapshotUUID"]),
                                       OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"])
                                   };


            // Bitmap is a byte[512]

            //Unemplemented
            //Enum libsecondlife.Parcel.ParcelCategory
            //Enum. libsecondlife.Parcel.ParcelStatus

            //            UUID authedbuyer;
            //            UUID snapshotID;
            //
            //            if (UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer))
            //                newData.AuthBuyerID = authedbuyer;
            //
            //            if (UUID.TryParse((string)row["SnapshotUUID"], out snapshotID))
            //                newData.SnapshotID = snapshotID;


            try
            {
                newData.UserLocation =
                    new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]),
                                Convert.ToSingle(row["UserLocationZ"]));
                newData.UserLookAt =
                    new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]),
                                Convert.ToSingle(row["UserLookAtZ"]));
            }
            catch (InvalidCastException)
            {
                newData.UserLocation = Vector3.Zero;
                newData.UserLookAt = Vector3.Zero;
            }

            newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();

            return newData;
        }
 private string GetPublicPermissions(LandData parcel)
 {
     if ((parcel.Flags & (uint)ParcelFlags.UseAccessList) == (uint)ParcelFlags.UseAccessList)
         return "false";
     else
         return "true";
 }
示例#18
0
        protected virtual void ReadBackup(IScene scene)
        {
            MainConsole.Instance.Info("[FileBasedSimulationData]: Reading file for " + scene.RegionInfo.RegionName);
            List<uint> foundLocalIDs = new List<uint>();
            GZipStream m_loadStream;
            try
            {
                m_loadStream =
                    new GZipStream(
                        ArchiveHelpers.GetStream(((m_loadDirectory == "" || m_loadDirectory == "/")
                                                      ? m_fileName
                                                      : Path.Combine(m_loadDirectory, m_fileName))),
                        CompressionMode.Decompress);
            }
            catch
            {
                if (CheckForOldDataBase())
                    SaveBackup(m_saveDirectory, false);
                return;
            }
            TarArchiveReader reader = new TarArchiveReader(m_loadStream);

            byte[] data;
            string filePath;
            TarArchiveReader.TarEntryType entryType;
            //Load the archive data that we need
            while ((data = reader.ReadEntry(out filePath, out entryType)) != null)
            {
                if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    continue;

                if (filePath.StartsWith("parcels/"))
                {
                    //Only use if we are not merging
                    LandData parcel = new LandData();
                    OSD parcelData = OSDParser.DeserializeLLSDBinary(data);
                    parcel.FromOSD((OSDMap) parcelData);
                    m_parcels.Add(parcel);
                }
                else if (filePath.StartsWith("terrain/"))
                {
                    m_oldstyleterrain = data;
                }
                else if (filePath.StartsWith("revertterrain/"))
                {
                    m_oldstylerevertTerrain = data;
                }
                else if (filePath.StartsWith("newstyleterrain/"))
                {
                    m_terrain = data;
                }
                else if (filePath.StartsWith("newstylerevertterrain/"))
                {
                    m_revertTerrain = data;
                }
                else if (filePath.StartsWith("newstylewater/"))
                {
                    m_water = data;
                }
                else if (filePath.StartsWith("newstylerevertwater/"))
                {
                    m_revertWater = data;
                }
                else if (filePath.StartsWith("entities/"))
                {
                    MemoryStream ms = new MemoryStream(data);
                    SceneObjectGroup sceneObject = SceneObjectSerializer.FromXml2Format(ref ms, scene);
                    ms.Close();
                    ms = null;
                    data = null;
                    foreach (ISceneChildEntity part in sceneObject.ChildrenEntities())
                    {
                        if (!foundLocalIDs.Contains(part.LocalId))
                            foundLocalIDs.Add(part.LocalId);
                        else
                            part.LocalId = 0; //Reset it! Only use it once!
                    }
                    m_groups.Add(sceneObject);
                }
                data = null;
            }
            m_loadStream.Close();
            m_loadStream = null;
            foundLocalIDs.Clear();
            GC.Collect();
        }
 private string GetScriptsPermissions(LandData parcel)
 {
     if ((parcel.Flags & (uint)ParcelFlags.AllowOtherScripts) == (uint)ParcelFlags.AllowOtherScripts)
         return "true";
     else
         return "false";
 }
 /// <summary>
 ///   Save this parcel's access list
 /// </summary>
 /// <param name = "data"></param>
 private void SaveParcelAccessList(LandData data)
 {
     //Clear out all old parcel bans and access list entries
     QueryFilter filter = new QueryFilter();
     filter.andFilters["ParcelID"] = data.GlobalID;
     GD.Delete("parcelaccess", filter);
     foreach (ParcelManager.ParcelAccessEntry entry in data.ParcelAccessList)
     {
         Dictionary<string, object> row = new Dictionary<string, object>(4);
         row["ParcelID"] = data.GlobalID;
         row["AccessID"] = entry.AgentID;
         row["Flags"] = entry.Flags;
         row["Time"] = entry.Time.Ticks;
         //Replace all the old ones
         GD.Replace("parcelaccess", row);
     }
 }
 private string GetShowInSearch(LandData parcel)
 {
     if ((parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)
         return "true";
     else
         return "false";
 }
 /// <summary>
 ///   Save this parcel's access list
 /// </summary>
 /// <param name = "data"></param>
 private void SaveParcelAccessList(LandData data)
 {
     //Clear out all old parcel bans and access list entries
     GD.Delete("parcelaccess", new[] {"ParcelID"}, new object[] {data.GlobalID});
     foreach (ParcelManager.ParcelAccessEntry entry in data.ParcelAccessList)
     {
         //Replace all the old ones
         GD.Replace("parcelaccess", new[]
                                        {
                                            "ParcelID",
                                            "AccessID",
                                            "Flags",
                                            "Time"
                                        }
                    ,
                    new object[]
                        {
                            data.GlobalID,
                            entry.AgentID,
                            entry.Flags,
                            entry.Time.Ticks
                        });
     }
 }
 private static OSDMap LandData2WebOSD(LandData parcel)
 {
     OSDMap parcelOSD = parcel.ToOSD();
     parcelOSD["GenericData"] = parcelOSD.ContainsKey("GenericData") ? (parcelOSD["GenericData"].Type == OSDType.Map ? parcelOSD["GenericData"] : (OSDMap)OSDParser.DeserializeLLSDXml(parcelOSD["GenericData"].ToString())) : new OSDMap();
     parcelOSD["Bitmap"] = OSD.FromBinary(parcelOSD["Bitmap"]).ToString();
     return parcelOSD;
 }
 /// <summary>
 ///   This also updates the parcel, not for just adding a new one
 /// </summary>
 /// <param name = "args"></param>
 public void StoreLandObject(LandData args)
 {
     GenericUtils.AddGeneric(args.RegionID, "LandData", args.GlobalID.ToString(), args.ToOSD(), GD);
     //Parcel access is saved seperately
     SaveParcelAccessList(args);
 }
 public bool PreprocessIncomingLandObjectFromStorage(LandData data, Vector2 parcelOffset)
 {
     ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
     new_land.LandData = data;
     return SetLandBitmapFromByteArray(new_land, false, parcelOffset);
 }
示例#26
0
 private bool ContainsPoint(LandData data, int checkx, int checky)
 {
     int x = 0, y = 0, i = 0;
     for (i = 0; i < data.Bitmap.Length; i++)
     {
         byte tempByte = 0;
         if (i < data.Bitmap.Length)
             tempByte = data.Bitmap[i];
         else
             break;//All the rest are false then
         int bitNum = 0;
         for (bitNum = 0; bitNum < 8; bitNum++)
         {
             if (x == checkx / 4 && y == checky / 4)
                 return Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & 1);
             x++;
             //Remove the offset so that we get a calc from the beginning of the array, not the offset array
             if (x > ((m_scene.RegionInfo.RegionSizeX / 4) - 1))
             {
                 x = 0;//Back to the beginning
                 y++;
             }
         }
     }
     return false;
 }
示例#27
0
        private void OnLandObjectAdded(LandData newParcel)
        {
            //If a new land object is added or updated, we need to redo the check for the avatars invulnerability
#if (!ISWIN)
            m_scene.ForEachScenePresence(delegate(IScenePresence sp)
            {
                AvatarEnteringParcel(sp, null);
            });
#else
            m_scene.ForEachScenePresence(sp => AvatarEnteringParcel(sp, null));
#endif
        }
        private static List<LandData> Query2LandData(List<string> Query)
        {
            List<LandData> Lands = new List<LandData>();

            for (int i = 0; i < Query.Count; i += 24)
            {
                LandData LandData = new LandData
                                        {
                                            RegionID = UUID.Parse(Query[i]),
                                            GlobalID = UUID.Parse(Query[i + 1]),
                                            LocalID = int.Parse(Query[i + 2]),
                                            UserLocation =
                                                new Vector3(float.Parse(Query[i + 3]), float.Parse(Query[i + 4]),
                                                            float.Parse(Query[i + 5])),
                                            Name = Query[i + 6],
                                            Description = Query[i + 7],
                                            Flags = uint.Parse(Query[i + 8]),
                                            Dwell = int.Parse(Query[i + 9]),
                                            InfoUUID = UUID.Parse(Query[i + 10]),
                                            AuctionID = uint.Parse(Query[i + 13]),
                                            Area = int.Parse(Query[i + 14]),
                                            Maturity = int.Parse(Query[i + 16]),
                                            OwnerID = UUID.Parse(Query[i + 17]),
                                            GroupID = UUID.Parse(Query[i + 18]),
                                            SnapshotID = UUID.Parse(Query[i + 20])
                                        };
                try
                {
                    LandData.Bitmap = OSDParser.DeserializeLLSDXml(Query[i + 21]);
                }
                catch
                {
                }
                LandData.Category = (string.IsNullOrEmpty(Query[i + 22])) ? ParcelCategory.None : (ParcelCategory)int.Parse(Query[i + 22]);
                LandData.ScopeID = UUID.Parse(Query[i + 23]);

                Lands.Add(LandData);
            }
            return Lands;
        }
 private void OnLandObjectAdded(LandData newParcel)
 {
     //Taint it!
     TaintPrimCount(m_Scene.RequestModuleInterface<IParcelManagementModule>().GetLandObject(newParcel.GlobalID));
 }
示例#30
0
 private static OSDMap LandData2WebOSD(LandData parcel)
 {
     OSDMap parcelOSD = parcel.ToOSD();
     parcelOSD["GenericData"] = parcelOSD.ContainsKey("GenericData") ? (parcelOSD["GenericData"].Type == OSDType.Map ? parcelOSD["GenericData"] : (OSDMap)OSDParser.DeserializeLLSDXml(parcelOSD["GenericData"].ToString())) : new OSDMap();
     parcelOSD["Bitmap"] = OSD.FromBinary(parcelOSD["Bitmap"]).ToString();
     parcelOSD["RegionHandle"] = OSD.FromString((parcelOSD["RegionHandle"].AsULong()).ToString());
     parcelOSD["AuctionID"] = OSD.FromInteger((int)parcelOSD["AuctionID"].AsUInteger());
     return parcelOSD;
 }
 private string ChannelName(IScene scene, LandData land)
 {
     // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same
     // as the directory ID. Otherwise, it reflects the parcel's ID.
     if (land.LocalID != 1 && (land.Flags & (uint)ParcelFlags.UseEstateVoiceChan) == 0)
     {
         m_log.DebugFormat("[MurmurVoice] Region:Parcel \"{0}:{1}\": parcel id {2}",
                           scene.RegionInfo.RegionName, land.Name, land.LocalID);
         return land.GlobalID.ToString().Replace("-", "");
     }
     m_log.DebugFormat("[MurmurVoice] Region:Parcel \"{0}:{1}\": parcel id {2}",
                       scene.RegionInfo.RegionName, scene.RegionInfo.RegionName, land.LocalID);
     return scene.RegionInfo.RegionName;
 }