public RegionCombinerLargeLandChannel(RegionData regData, IParcelManagementModule rootRegionLandChannel,
                                       List<RegionData> regionConnections)
 {
     RegData = regData;
     RootRegionLandChannel = rootRegionLandChannel;
     RegionConnections = regionConnections;
 }
        public LandObject(UUID owner_id, bool is_group_owned, IScene scene)
        {
            m_scene = scene;

            LandData.Maturity = m_scene.RegionInfo.RegionSettings.Maturity;
            LandData.OwnerID = owner_id;
            LandData.GroupID = is_group_owned ? owner_id : UUID.Zero;
            LandData.IsGroupOwned = is_group_owned;

            LandData.RegionID = scene.RegionInfo.RegionID;
            LandData.ScopeID = scene.RegionInfo.ScopeID;
            LandData.RegionHandle = scene.RegionInfo.RegionHandle;

            m_parcelManagementModule = scene.RequestModuleInterface<IParcelManagementModule>();

            //We don't set up the InfoID here... it will just be overwriten
        }
Esempio n. 3
0
        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))
                {
                    //We found a place for them, but we don't need to check any further on positions here
                    //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)
            {
                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))
                        {
                            //We found a place for them, but we don't need to check any further on positions here
                            //return true;
                        }
                    }
                }
                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))
                        {
                            //We found a place for them, but we don't need to check any further on positions here
                            //return true;
                        }
                    }
                }
                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))
                        {
                            //We found a place for them, but we don't need to check any further on positions here
                            //return true;
                        }
                    }
                }
            }

            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;
                }
            }

            //newPosition = Position;
            reason = "";
            return(true);
        }
        /// <summary>
        /// Creates the estate info for a region.
        /// </summary>
        /// <returns>The estate info.</returns>
        /// <param name="scene">Scene.</param>
        EstateSettings CreateEstateInfo(IScene scene)
        {
            // check for regionType to determine if this is 'Mainland' or an 'Estate'
            string regType = scene.RegionInfo.RegionType.ToLower();

            if (regType.StartsWith("m", System.StringComparison.Ordinal))
            {
                return(LinkSystemEstate(scene.RegionInfo.RegionID, Constants.MainlandEstateID));
            }

            // we are linking to a user estate
            IEstateConnector      estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            ISystemAccountService sysAccounts     = m_registry.RequestModuleInterface <ISystemAccountService> ();

            string sysEstateOwnerName;
            var    sysAccount = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, sysAccounts.SystemEstateOwnerUUID);

            if (sysAccount == null)
            {
                sysEstateOwnerName = sysAccounts.SystemEstateOwnerName;
            }
            else
            {
                sysEstateOwnerName = sysAccount.Name;
            }


            // This is an 'Estate' so get some details....
            var    LastEstateOwner = sysEstateOwnerName;
            string LastEstateName;

            while (true)
            {
                UserAccount account;
                string      estateOwner;

                estateOwner = MainConsole.Instance.Prompt("Estate owner name (" + sysEstateOwnerName + "/User Name)", LastEstateOwner);

                // we have a prospective estate owner...
                List <EstateSettings> ownerEstates = null;
                account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, estateOwner);
                if (account != null)
                {
                    // we have a user account...
                    LastEstateOwner = account.Name;

                    ownerEstates = estateConnector.GetEstates(account.PrincipalID);
                }

                if (account == null || ownerEstates == null || ownerEstates.Count == 0)
                {
                    if (account == null)
                    {
                        MainConsole.Instance.Warn("[Estate]: Unable to locate the user " + estateOwner);
                    }
                    else
                    {
                        MainConsole.Instance.WarnFormat("[Estate]: The user, {0}, has no estates currently.", account.Name);
                    }

                    string joinSystemland = MainConsole.Instance.Prompt(
                        "Do you want to 'park' the region with the system owner/estate? (yes/no)", "yes");
                    if (joinSystemland.ToLower().StartsWith("y", System.StringComparison.Ordinal))                        // joining 'Systemland'
                    {
                        return(LinkSystemEstate(scene.RegionInfo.RegionID, Constants.SystemEstateID));
                    }

                    continue;
                }

                if (ownerEstates.Count > 1)
                {
                    MainConsole.Instance.InfoFormat("[Estate]: User {0} has {1} estates currently. {2}",
                                                    account.Name, ownerEstates.Count, "These estates are the following:");
                    foreach (EstateSettings t in ownerEstates)
                    {
                        MainConsole.Instance.CleanInfo("         " + t.EstateName);
                    }

                    LastEstateName = ownerEstates [0].EstateName;

                    List <string> responses = ownerEstates.Select(settings => settings.EstateName).ToList();
                    responses.Add("Cancel");

                    do
                    {
                        //TODO: This could be a problem if we have a lot of estates
                        string response = MainConsole.Instance.Prompt("Estate name to join", LastEstateName, responses);
                        if (response == "None" || response == "Cancel")
                        {
                            LastEstateName = "";
                            break;
                        }
                        LastEstateName = response;
                    } while (LastEstateName == "");
                    if (LastEstateName == "")
                    {
                        continue;
                    }
                }
                else
                {
                    LastEstateName = ownerEstates [0].EstateName;
                }


                // we should have a user account and estate name by now
                int estateID = estateConnector.GetEstate(account.PrincipalID, LastEstateName);
                if (estateID == 0)
                {
                    MainConsole.Instance.Warn("[Estate]: The name you have entered matches no known estate. Please try again");
                    continue;
                }

                // link up the region
                EstateSettings ES;
                UUID           oldOwnerID = UUID.Zero;
                if (scene.RegionInfo.EstateSettings != null)
                {
                    oldOwnerID = scene.RegionInfo.EstateSettings.EstateOwner;
                }

                if (!estateConnector.LinkRegion(scene.RegionInfo.RegionID, estateID))
                {
                    MainConsole.Instance.WarnFormat("[Estate]: Joining the {0} estate failed. Please try again.", LastEstateName);
                    continue;
                }

                // make sure that the region is fully set up
                if ((ES = estateConnector.GetRegionEstateSettings(scene.RegionInfo.RegionID)) == null || ES.EstateID == 0)
                {
                    MainConsole.Instance.Warn("[Estate]: Unable to verify region update (possible server connection error), please try again.");
                    continue;
                }

                // Linking was successful, change any previously owned parcels to the new owner
                if (oldOwnerID != UUID.Zero)
                {
                    IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule> ();
                    if (parcelManagement != null)
                    {
                        parcelManagement.ReclaimParcels(oldOwnerID, ES.EstateOwner);
                    }
                }

                MainConsole.Instance.InfoFormat("[Estate]: Successfully joined the {0} estate!", LastEstateName);
                return(ES);
            }
        }
Esempio n. 5
0
        public void RegionLoaded(IScene scene)
        {
            //if (m_friendsModule == null)
            //    MainConsole.Instance.Warn("[PERMISSIONS]: Friends module not found, friend permissions will not work");

            m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();

            //if (m_groupsModule == null)
            //    MainConsole.Instance.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work");

            m_moapModule = m_scene.RequestModuleInterface<IMoapModule>();

            // This log line will be commented out when no longer required for debugging
//            if (m_moapModule == null)
//                MainConsole.Instance.Warn("[PERMISSIONS]: Media on a prim module not found, media on a prim permissions will not work");

            m_parcelManagement = m_scene.RequestModuleInterface<IParcelManagementModule>();
        }
        /// <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;
            }

            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);
        }
        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 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);
        }
Esempio n. 9
0
        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();

            // Reload serialized prims
            //m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects.  Please wait.", serialisedSceneObjects.Count);

            //m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjectsLoadedCount);

            //int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount;

            //if (ignoredObjects > 0)
            //    m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects);

            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);
        }
Esempio n. 10
0
        /// <summary>
        ///     Updates the AABBMin and AABBMax values after area/shape modification of the land object
        /// </summary>
        void UpdateAABBAndAreaValues()
        {
            ITerrainChannel         heightmap       = m_scene.RequestModuleInterface <ITerrainChannel> ();
            IParcelManagementModule parcelManModule = m_scene.RequestModuleInterface <IParcelManagementModule> ();
            int min_x = m_scene.RegionInfo.RegionSizeX / 4;
            int min_y = m_scene.RegionInfo.RegionSizeY / 4;
            int max_x = 0;
            int max_y = 0;
            int tempArea = 0;
            int x, y;

            for (x = 0; x < m_scene.RegionInfo.RegionSizeX / 4; x++)
            {
                for (y = 0; y < m_scene.RegionInfo.RegionSizeY / 4; y++)
                {
                    if (parcelManModule.LandIDList [x, y] == LandData.LocalID)
                    {
                        if (min_x > x)
                        {
                            min_x = x;
                        }
                        if (min_y > y)
                        {
                            min_y = y;
                        }
                        if (max_x < x)
                        {
                            max_x = x;
                        }
                        if (max_y < y)
                        {
                            max_y = y;
                        }
                        tempArea += 16; //16sqm peice of land (4x4)
                    }
                }
            }
            int tx = min_x * 4;

            if (tx > (m_scene.RegionInfo.RegionSizeX - 1))
            {
                tx = (m_scene.RegionInfo.RegionSizeX - 1);
            }
            int ty = min_y * 4;

            if (ty > (m_scene.RegionInfo.RegionSizeY - 1))
            {
                ty = (m_scene.RegionInfo.RegionSizeY - 1);
            }
            float min;

            min = heightmap == null ? 0 : heightmap [tx, ty];
            LandData.AABBMin = new Vector3((min_x * 4), (min_y * 4), 0);

            tx = max_x * 4;
            if (tx > (m_scene.RegionInfo.RegionSizeX - 1))
            {
                tx = (m_scene.RegionInfo.RegionSizeX - 1);
            }
            ty = max_y * 4;
            if (ty > (m_scene.RegionInfo.RegionSizeY - 1))
            {
                ty = (m_scene.RegionInfo.RegionSizeY - 1);
            }
            min = heightmap == null ? 0 : heightmap [tx, ty];
            LandData.AABBMax = new Vector3((max_x * 4), (max_y * 4), min);
            LandData.Area    = tempArea;
        }
Esempio n. 11
0
        OSDMap syncRecievedService_OnMessageReceived(OSDMap message)
        {
            string method = message ["Method"];

            if (method == "UpdateMoneyBalance")
            {
                UUID           agentID       = message ["AgentID"];
                int            Amount        = message ["Amount"];
                string         Message       = message ["Message"];
                UUID           TransactionID = message ["TransactionID"];
                IDialogModule  dialogModule  = GetSceneFor(agentID).RequestModuleInterface <IDialogModule> ();
                IScenePresence sp            = GetSceneFor(agentID).GetScenePresence(agentID);
                if (sp != null)
                {
                    if (dialogModule != null && !string.IsNullOrEmpty(Message))
                    {
                        dialogModule.SendAlertToUser(agentID, Message);
                    }

                    sp.ControllingClient.SendMoneyBalance(TransactionID, true, Utils.StringToBytes(Message), Amount);
                }
            }
            else if (method == "GetLandData")
            {
                MainConsole.Instance.Info(message);

                UUID   agentID = message["AgentID"];
                IScene region  = GetSceneFor(agentID);
                MainConsole.Instance.Info("Region: " + region.RegionInfo.RegionName);

                IParcelManagementModule parcelManagement = region.RequestModuleInterface <IParcelManagementModule> ();
                if (parcelManagement != null)
                {
                    IScenePresence sp = region.GetScenePresence(agentID);
                    if (sp != null)
                    {
                        MainConsole.Instance.DebugFormat("sp parcel UUID: {0} Pos: {1}, {2}",
                                                         sp.CurrentParcelUUID, sp.AbsolutePosition.X, sp.AbsolutePosition.Y);

                        ILandObject lo = sp.CurrentParcel;
                        if (lo == null)
                        {
                            // try for a position fix
                            lo = parcelManagement.GetLandObject((int)sp.AbsolutePosition.X, (int)sp.AbsolutePosition.Y);
                        }

                        if (lo != null)
                        {
                            if ((lo.LandData.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale)
                            {
                                if (lo.LandData.AuthBuyerID != UUID.Zero && lo.LandData.AuthBuyerID != agentID)
                                {
                                    return new OSDMap {
                                               new KeyValuePair <string, OSD> ("Success", false)
                                    }
                                }
                                ;
                                OSDMap map = lo.LandData.ToOSD();
                                map ["Success"] = true;
                                return(map);
                            }
                        }
                    }
                }
                return(new OSDMap {
                    new KeyValuePair <string, OSD>("Success", false)
                });
            }
            return(null);
        }

        IScene GetSceneFor(UUID userID)
        {
            foreach (IScene scene in m_scenes)
            {
                var sp = scene.GetScenePresence(userID);
                if (sp != null && !sp.IsChildAgent)
                {
                    return(scene);
                }
            }
            if (m_scenes.Count == 0)
            {
                MainConsole.Instance.Debug("User not present in any regions??");
                return(null);
            }

            MainConsole.Instance.Debug("Returning scene[0]: " + m_scenes [0].RegionInfo.RegionName);
            return(m_scenes[0]);
        }
Esempio n. 12
0
        public virtual void PlayAttachedSound(
            UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius)
        {
            ISceneChildEntity part = m_scene.GetSceneObjectPart(objectID);

            if (part == null)
            {
                return;
            }

            bool                    LocalOnly        = false;
            ILandObject             ILO              = null;
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(position.X, position.Y);
                if (ILO != null)
                {
                    LocalOnly = (ILO.LandData.Flags & (uint)ParcelFlags.SoundLocal) == (uint)ParcelFlags.SoundLocal;
                }
            }

            m_scene.ForEachScenePresence(delegate(IScenePresence sp)
            {
                if (Cones.Count != 0)
                {
                    foreach (ConeOfSilence CS in Cones.Values)
                    {
                        if (Util.GetDistanceTo(sp.AbsolutePosition, CS.Position) >
                            CS.Radius)
                        {
                            // Presence is outside of the Cone of silence
                            if (Util.GetDistanceTo(CS.Position, position) < CS.Radius)
                            {
                                //Sound was triggered inside the cone, but avatar is outside
                                continue;
                            }
                        }
                        else
                        {
                            // Avatar is inside the cone of silence
                            if (Util.GetDistanceTo(CS.Position, position) > CS.Radius)
                            {
                                //Sound was triggered outside of the cone, but avatar is inside of the cone.
                                continue;
                            }
                        }
                    }
                }
                if (sp.IsChildAgent)
                {
                    return;
                }

                double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
                if (dis > 100.0)                                  // Max audio distance
                {
                    return;
                }

                if (part.IsAttachment)
                {
                    if (part.ParentEntity.GetAttachmentPoint() >=
                        (uint)OpenMetaverse.AttachmentPoint.HUDCenter2 &&
                        part.ParentEntity.GetAttachmentPoint() <=
                        (uint)OpenMetaverse.AttachmentPoint.HUDBottomRight)                                   // HUD
                    {
                        if (sp.ControllingClient.AgentId != part.OwnerID)
                        {
                            return;
                        }
                    }

                    if (sp.ControllingClient.AgentId == part.OwnerID)
                    {
                        dis = 0;
                    }
                }

                //Check to see if the person is local and the av is in the same parcel
                if (LocalOnly && sp.CurrentParcelUUID != ILO.LandData.GlobalID)
                {
                    return;
                }

                if ((sp.CurrentParcelUUID != ILO.LandData.GlobalID &&
                     (sp.CurrentParcel.LandData.Private || ILO.LandData.Private)))
                {
                    return;
                }
                //If one of them is in a private parcel, and the other isn't in the same parcel, don't send the chat message

                float thisSpGain;

                // Scale by distance
                if (radius == 0)
                {
                    thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
                }
                else
                {
                    thisSpGain = (float)((double)gain * ((radius - dis) / radius));
                }

                if (sp.Scene.GetSceneObjectPart(objectID).UseSoundQueue == 1 &&
                    (flags & (int)SoundFlags.Queue) == 0)
                {
                    flags |= (int)SoundFlags.Queue;
                }

                sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID,
                                                           thisSpGain, flags);
            });
        }
Esempio n. 13
0
        public virtual void TriggerSound(
            UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle,
            float radius)
        {
            bool                    LocalOnly        = false;
            ILandObject             ILO              = null;
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(position.X, position.Y);
                if (ILO != null) //Check only if null, otherwise this breaks mega-regions
                {
                    LocalOnly = (ILO.LandData.Flags & (uint)ParcelFlags.SoundLocal) == (uint)ParcelFlags.SoundLocal;
                }
            }
            ISceneChildEntity part = m_scene.GetSceneObjectPart(objectID);

            if (part == null)
            {
                IScenePresence sp;
                if (!m_scene.TryGetScenePresence(objectID, out sp))
                {
                    return;
                }
            }
            else
            {
                ISceneEntity grp = part.ParentEntity;

                if (grp.IsAttachment && grp.GetAttachmentPoint() > 30)
                {
                    objectID = ownerID;
                    parentID = ownerID;
                }
            }

            m_scene.ForEachScenePresence(delegate(IScenePresence sp)
            {
                if (Cones.Count != 0)
                {
                    foreach (ConeOfSilence CS in Cones.Values)
                    {
                        if (Util.GetDistanceTo(sp.AbsolutePosition, CS.Position) >
                            CS.Radius)
                        {
                            // Presence is outside of the Cone of silence

                            if (Util.GetDistanceTo(CS.Position, position) < CS.Radius)
                            {
                                //Sound was triggered inside the cone, but avatar is outside
                                continue;
                            }
                        }
                        else
                        {
                            // Avatar is inside the cone of silence
                            if (Util.GetDistanceTo(CS.Position, position) > CS.Radius)
                            {
                                //Sound was triggered outside of the cone, but avatar is inside of the cone.
                                continue;
                            }
                        }
                    }
                }
                if (sp.IsChildAgent)
                {
                    return;
                }

                float dis = (float)Util.GetDistanceTo(sp.AbsolutePosition, position);
                if (dis > 100.0f)                                  // Max audio distance
                {
                    return;
                }

                //Check to see if the person is local and the av is in the same parcel
                if (LocalOnly && sp.CurrentParcelUUID != ILO.LandData.GlobalID)
                {
                    return;
                }

                // Scale by distance
                float thisSPGain;
                if (radius == 0)
                {
                    thisSPGain = (float)(gain * ((100.0f - dis) / 100.0f));
                }
                else
                {
                    thisSPGain = (float)(gain * ((radius - dis) / radius));
                }

                sp.ControllingClient.SendTriggeredSound(
                    soundId, ownerID, objectID, parentID, handle, position,
                    thisSPGain);
            });
        }
        bool DearchiveRegion0DotStar()
        {
            if (m_loadStream == null)
            {
                return(false);
            }

            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 WhiteCoreThreadPool(
                    new WhiteCoreThreadPoolStartInfo()
                {
                    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 <ISceneEntity> groupsToBackup = new List <ISceneEntity> ();
            List <LandData>     landData       = new List <LandData> ();

            // must save off some stuff until after assets have been saved and received 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> ();

            MainConsole.Instance.Info("[Archiver]: Commencing load from archive");
            int ticker = 0;

            try {
                byte [] data;
                TarArchiveReader.TarEntryType entryType;
                while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
                {
                    if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    {
                        continue;
                    }

                    if (TarArchiveReader.TarEntryType.TYPE_NORMAL_FILE == entryType)
                    {
                        string fName;
                        try {
                            fName = Path.GetFileName(filePath);
                            if (fName.StartsWith(".", StringComparison.Ordinal))                  // ignore hidden files
                            {
                                continue;
                            }
                        } catch {
                            MainConsole.Instance.ErrorFormat("[Archiver]: Invalid file name in archive: {0}", filePath);
                            continue;
                        }
                    }

                    ticker++;
                    if (ticker % 10 == 0)
                    {
                        MainConsole.Instance.Ticker();
                    }

                    if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH, StringComparison.Ordinal))
                    {
                        seneObjectGroups.Add(data);
                        if (seneObjectGroups.Count % 100 == 0)
                        {
                            MainConsole.Instance.Ticker(
                                string.Format("[Archiver]: Found {0} scene object groups...", seneObjectGroups.Count), true);
                        }
                    }
                    else if (!m_skipAssets && filePath.StartsWith(ArchiveConstants.ASSETS_PATH, StringComparison.Ordinal))
                    {
                        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) % 100 == 0)
                        {
                            MainConsole.Instance.Ticker(
                                string.Format("[Archiver]: Loaded {0} assets, with {1} failures...",
                                              successfulAssetRestores, failedAssetRestores),
                                true);
                        }
                    }
                    else if (!m_skipTerrain && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH, StringComparison.Ordinal))
                    {
                        LoadTerrain(filePath, data);
                    }
                    else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH, StringComparison.Ordinal))
                    {
                        LoadRegionSettings(filePath, data);
                    }
                    else if (!m_skipTerrain && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH, StringComparison.Ordinal))
                    {
                        var parcel = LoadLandData(data);
                        landData.Add(parcel);
                    }
                    else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
                    {
                        LoadControlFile(data);
                    }
                }

                MainConsole.Instance.CleanInfo("");
                MainConsole.Instance.Info("[Archiver]: Saving non binary assets");
                ticker = 0;

                // Save Assets
                int savingAssetsCount = 0;
                while (assets2Save.Count > 0)
                {
                    ticker++;
                    if (ticker % 10 == 0)
                    {
                        MainConsole.Instance.Ticker();
                    }

                    try {
                        UUID assetid = assets2Save.Dequeue();
                        SaveNonBinaryAssets(assetid, assetNonBinaryCollection [assetid], assetBinaryChangeRecord);
                        savingAssetsCount++;
                        if ((savingAssetsCount) % 100 == 0)
                        {
                            MainConsole.Instance.Ticker(
                                string.Format("[Archiver]: Saved {0} assets...", savingAssetsCount), true);
                        }
                    } catch (Exception ex) {
                        MainConsole.Instance.Info("[Archiver]: Exception in saving an asset: " + ex);
                    }
                }

                MainConsole.Instance.CleanInfo("");
                MainConsole.Instance.Info("[Archiver]: Saving loaded objects");
                ticker = 0;
                foreach (byte [] data2 in seneObjectGroups)
                {
                    ticker++;
                    if (ticker % 10 == 0)
                    {
                        MainConsole.Instance.Ticker();
                    }

                    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);
                    }

                    ISceneEntity sceneObject = 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;
                    }

                    // check sceneObject ownership
                    sceneObject.OwnerID = ResolveUserUuid(sceneObject.OwnerID, sceneObject.LastSignificantPosition, landData);
                    //... and children
                    foreach (ISceneChildEntity part in sceneObject.ChildrenEntities())
                    {
                        // check user ID's
                        part.CreatorID   = ResolveUserUuid(part.CreatorID, part.AbsolutePosition, landData);
                        part.OwnerID     = ResolveUserUuid(part.OwnerID, part.AbsolutePosition, landData);
                        part.LastOwnerID = ResolveUserUuid(part.LastOwnerID, part.AbsolutePosition, landData);

                        //check group ID's
                        part.GroupID = ResolveGroupUuid(part.GroupID);

                        // 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)
                            {
                                // check user ID's
                                kvp.Value.OwnerID = ResolveUserUuid(
                                    kvp.Value.OwnerID,
                                    part.AbsolutePosition,
                                    landData
                                    );

                                kvp.Value.LastOwnerID = ResolveUserUuid(
                                    kvp.Value.LastOwnerID,
                                    part.AbsolutePosition,
                                    landData
                                    );

                                kvp.Value.CreatorID = ResolveUserUuid(
                                    kvp.Value.CreatorID,
                                    part.AbsolutePosition,
                                    landData
                                    );

                                // ..and possible group ID's
                                kvp.Value.GroupID = ResolveGroupUuid(kvp.Value.GroupID);
                            }
                        }
                    }

                    //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 % 100 == 0)
                    {
                        MainConsole.Instance.Ticker(
                            string.Format("[Archiver]: Saved {0} objects...", sceneObjectsLoadedCount), true);
                    }
                }
                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(false);
            } finally {
                archive.Close();
                m_loadStream.Close();
                m_loadStream.Dispose();

                assets2Save.Clear();
                assetNonBinaryCollection.Clear();

                // Re-enable scripts now that we are done
                foreach (IScriptModule module in modules)
                {
                    module.Disabled = false;
                }
                // Reset backup too
                if (backup != null)
                {
                    backup.LoadingPrims = false;
                }
            }

            // finished with the ticker
            MainConsole.Instance.CleanInfo("");

            // Now back up the prims
            foreach (ISceneEntity 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);
                }
            }

            // Reload serialized parcels
            if (!m_skipTerrain)
            {
                MainConsole.Instance.InfoFormat("[Archiver]: Loading {0} parcels.", landData.Count);

                IParcelManagementModule parcelManagementModule = m_scene.RequestModuleInterface <IParcelManagementModule> ();
                if (parcelManagementModule != null)
                {
                    parcelManagementModule.IncomingLandDataFromOAR(landData, m_merge, new Vector2(m_offsetX, m_offsetY));
                }

                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_validGroupUuids.Clear();
            m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage);

            return(true);    // all good
        }
        /// <summary>
        /// Changes the region estate.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd parameters.</param>
        protected void ChangeRegionEstate(IScene scene, string [] cmd)
        {
            var    conScenes = MainConsole.Instance.ConsoleScenes;
            IScene regScene  = scene;

            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            if (estateConnector == null)
            {
                MainConsole.Instance.Error("[Estate]: Unable to obtain estate connector for update");
                return;
            }

            string regionName;

            if (regScene == null)
            {
                regionName = cmd.Length > 2 ? cmd [2] : MainConsole.Instance.Prompt("The region you wish to change?");
                if (string.IsNullOrEmpty(regionName))
                {
                    return;
                }

                // find the required region/scene
                regionName = regionName.ToLower();
                foreach (IScene scn in conScenes)
                {
                    if (scn.RegionInfo.RegionName.ToLower() == regionName)
                    {
                        regScene = scn;
                        break;
                    }
                }

                if (regScene == null)
                {
                    MainConsole.Instance.Error("[Estate]: The region '" + regionName + "' could not be found.");
                    return;
                }
            }
            else
            {
                regionName = regScene.RegionInfo.RegionName;
            }

            // check for mainland regions
            if (regScene.RegionInfo.RegionType.ToLower().StartsWith("m", System.StringComparison.Ordinal))
            {
                var sysEstates     = regScene.RequestModuleInterface <ISystemEstateService> ();
                var mainlandEstate = sysEstates.MainlandEstateName;
                MainConsole.Instance.InfoFormat("[Estate]: {0} is a Mainland region and is automatically part of the '{1}' estate",
                                                regionName, mainlandEstate);
                return;
            }

            var regionID   = regScene.RegionInfo.RegionID;
            var oldOwnerID = regScene.RegionInfo.EstateSettings.EstateOwner;

            // get the new estate name
            string estateName = cmd.Length > 3
                ? cmd [3]
                : MainConsole.Instance.Prompt("The new estate for " + regionName + " (? for more options)");

            if (string.IsNullOrEmpty(estateName))
            {
                return;
            }

            int newEstateId = 0;

            if (estateName != "?")
            {
                newEstateId = estateConnector.GetEstateID(estateName);
            }

            if (newEstateId == 0)
            {
                if (estateName != "?")
                {
                    MainConsole.Instance.Warn("[Estate]: The estate '" + estateName + "' matches no known estate.");
                }

                // try the long way...
                newEstateId = GetUserEstateID(regScene, estateConnector);
                if (newEstateId == 0)
                {
                    return;
                }
                var estate = estateConnector.GetEstateIDSettings(newEstateId);
                if (estate != null)
                {
                    estateName = estate.EstateName;
                }
            }

            // we have a region & estate name
            bool deLinkEstate = true;

            if (cmd.Length == 3)
            {
                var resp = MainConsole.Instance.Prompt(
                    "Are you sure you want to change '" + regionName + "' to the '" + estateName + "' estate? (yes/no)", "yes");
                deLinkEstate = (resp.StartsWith("y", System.StringComparison.Ordinal));
            }
            if (!deLinkEstate)
            {
                return;
            }

            // good to go
            if (!estateConnector.DelinkRegion(regionID))
            {
                MainConsole.Instance.Warn("[Estate]: Aborting - Unable to remove this region from the current estate.");
                return;
            }

            // check for'Mainland'
            string regType = regScene.RegionInfo.RegionType.ToLower();

            if (regType.StartsWith("m", System.StringComparison.Ordinal))
            {
                if (newEstateId == Constants.MainlandEstateID)
                {
                    MainConsole.Instance.Info("[Estate]: This region is already part of the Mainland estate");
                    return;
                }

                // link this region to the mainland
                MainConsole.Instance.Info("[Estate]: Mainland type regions must be part of the Mainland estate");
                LinkSystemEstate(regionID, Constants.MainlandEstateID);
                return;
            }

            var newEstate = LinkRegionEstate(regionID, newEstateId);

            if (newEstate != null)
            {
                regScene.RegionInfo.EstateSettings = newEstate;

                // Linking was successful, change any previously owned parcels to the new owner
                if (oldOwnerID != UUID.Zero)
                {
                    IParcelManagementModule parcelManagement = regScene.RequestModuleInterface <IParcelManagementModule> ();
                    if (parcelManagement != null)
                    {
                        parcelManagement.ReclaimParcels(oldOwnerID, newEstate.EstateOwner);
                    }
                }
            }
        }
Esempio n. 16
0
            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.ToString(),
                                         OSDParser.SerializeLLSDBinary(parcelMap));
                        parcelMap = null;
                    }
                }

                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 = null;

                            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);
                IUniverseBackupArchiver archiver      = m_scene.RequestModuleInterface <IUniverseBackupArchiver>();
                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");
            }
Esempio n. 17
0
            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);
                    }
                }
            }
Esempio n. 18
0
        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));
        }
        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);
                    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);
                if (serializedObject != null)
                {
                    m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject);
                }
            }

            MainConsole.Instance.InfoFormat("[Archiver]: Added scene objects to archive.");
        }
Esempio n. 20
0
        private byte[] DispatchWindLightSettings(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
            }
            MainConsole.Instance.Info("[WindLightSettings]: Got a request to update WindLight from " + SP.Name);

            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(request);

            RegionLightShareData lsd = new RegionLightShareData();

            lsd.FromOSD(rm);
            lsd.regionID = SP.Scene.RegionInfo.RegionID;
            bool remove = false;

            if (rm.ContainsKey("remove"))
            {
                remove = rm["remove"].AsBoolean();
            }

            if (remove)
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                    {
                        return(new byte[0]); // No permissions
                    }
#if (!ISWIN)
                    bool found = false;
                    foreach (RegionLightShareData regionLsd in m_WindlightSettings.Values)
                    {
                        if (lsd.minEffectiveAltitude == regionLsd.minEffectiveAltitude && lsd.maxEffectiveAltitude == regionLsd.maxEffectiveAltitude)
                        {
                            found = true;
                            break;
                        }
                    }
#else
                    bool found = m_WindlightSettings.Values.Any(regionLSD => lsd.minEffectiveAltitude == regionLSD.minEffectiveAltitude && lsd.maxEffectiveAltitude == regionLSD.maxEffectiveAltitude);
#endif

                    //Set to default
                    if (found)
                    {
                        SaveWindLightSettings(lsd.minEffectiveAltitude, new RegionLightShareData());
                    }
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement =
                        SP.Scene.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int)SP.AbsolutePosition.X,
                                                                          (int)SP.AbsolutePosition.Y);
                        if (SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        {
                            return(new byte[0]); // No permissions
                        }
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return(new byte[0]);
                        }

                        OSDMap map = land.LandData.GenericData;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericData.ContainsKey("WindLight"))
                        {
                            innerMap = (OSDMap)map["WindLight"];
                        }

                        if (innerMap.ContainsKey(lsd.minEffectiveAltitude.ToString()))
                        {
                            innerMap.Remove(lsd.minEffectiveAltitude.ToString());
                        }

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP, false);
                    }
                }
            }
            else
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                    {
                        return(new byte[0]); // No permissions
                    }
                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        string message = "";
                        if (checkAltitude(lsd, regionLSD, out message))
                        {
                            SP.ControllingClient.SendAlertMessage(message);
                            return(new byte[0]);
                        }
                    }
                    SaveWindLightSettings(lsd.minEffectiveAltitude, lsd);
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement =
                        SP.Scene.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int)SP.AbsolutePosition.X,
                                                                          (int)SP.AbsolutePosition.Y);
                        if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        {
                            return(new byte[0]); // No permissions
                        }
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return(new byte[0]);
                        }

                        OSDMap map = land.LandData.GenericData;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericData.ContainsKey("WindLight"))
                        {
                            innerMap = (OSDMap)map["WindLight"];
                        }

                        foreach (KeyValuePair <string, OSD> kvp in innerMap)
                        {
                            OSDMap lsdMap = (OSDMap)kvp.Value;
                            RegionLightShareData parcelLSD = new RegionLightShareData();
                            parcelLSD.FromOSD(lsdMap);

                            string message = "";
                            if (checkAltitude(lsd, parcelLSD, out message))
                            {
                                SP.ControllingClient.SendAlertMessage(message);
                                return(new byte[0]);
                            }
                        }

                        innerMap[lsd.minEffectiveAltitude.ToString()] = lsd.ToOSD();

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP, lsd);
                    }
                }
            }
            SP.ControllingClient.SendAlertMessage("WindLight Settings updated.");
            return(new byte[0]);
        }
Esempio n. 21
0
        private Hashtable DispatchWindLightSettings(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
            }
            m_log.Info("[WindLightSettings]: Got a request to update WindLight from " + SP.Name);

            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml((string)m_dhttpMethod["requestbody"]);

            RegionLightShareData lsd = new RegionLightShareData();

            lsd.FromOSD(rm);
            lsd.regionID = SP.Scene.RegionInfo.RegionID;
            bool remove = false;

            if (rm.ContainsKey("remove"))
            {
                remove = rm["remove"].AsBoolean();
            }

            if (remove)
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                    {
                        return(responsedata); // No permissions
                    }
                    bool found = false;
                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        if (lsd.minEffectiveAltitude == regionLSD.minEffectiveAltitude &&
                            lsd.maxEffectiveAltitude == regionLSD.maxEffectiveAltitude)
                        {
                            //it exists
                            found = true;
                            break;
                        }
                    }

                    //Set to default
                    if (found)
                    {
                        SaveWindLightSettings(lsd.minEffectiveAltitude, new RegionLightShareData());
                    }
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement = SP.Scene.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int)SP.AbsolutePosition.X, (int)SP.AbsolutePosition.Y);
                        if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        {
                            return(responsedata); // No permissions
                        }
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return(responsedata);
                        }

                        OSDMap map = land.LandData.GenericDataMap;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericDataMap.ContainsKey("WindLight"))
                        {
                            innerMap = (OSDMap)map["WindLight"];
                        }

                        if (innerMap.ContainsKey(lsd.minEffectiveAltitude.ToString()))
                        {
                            innerMap.Remove(lsd.minEffectiveAltitude.ToString());
                        }

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP);
                    }
                }
            }
            else
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                    {
                        return(responsedata); // No permissions
                    }
                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        string message = "";
                        if (checkAltitude(lsd, regionLSD, out message))
                        {
                            SP.ControllingClient.SendAlertMessage(message);
                            return(responsedata);
                        }
                    }
                    SaveWindLightSettings(lsd.minEffectiveAltitude, lsd);
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement = SP.Scene.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int)SP.AbsolutePosition.X, (int)SP.AbsolutePosition.Y);
                        if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        {
                            return(responsedata); // No permissions
                        }
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return(responsedata);
                        }

                        OSDMap map = land.LandData.GenericDataMap;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericDataMap.ContainsKey("WindLight"))
                        {
                            innerMap = (OSDMap)map["WindLight"];
                        }

                        string removeThisMap = "";

                        foreach (KeyValuePair <string, OSD> kvp in innerMap)
                        {
                            OSDMap lsdMap = (OSDMap)kvp.Value;
                            RegionLightShareData parcelLSD = new RegionLightShareData();
                            parcelLSD.FromOSD(lsdMap);

                            string message = "";
                            if (checkAltitude(lsd, parcelLSD, out message))
                            {
                                SP.ControllingClient.SendAlertMessage(message);
                                return(responsedata);
                            }
                        }

                        if (removeThisMap != "")
                        {
                            innerMap.Remove(removeThisMap);
                        }

                        innerMap[lsd.minEffectiveAltitude.ToString()] = lsd.ToOSD();

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP, lsd);
                    }
                }
            }
            SP.ControllingClient.SendAlertMessage("WindLight Settings updated.");
            return(responsedata);
        }
Esempio n. 22
0
        //Find the correct WL settings to send to the client
        public void SendProfileToClient(IScenePresence presence, bool checkAltitudesOnly)
        {
            if (presence == null)
            {
                return;
            }
            ILandObject land = null;

            if (!checkAltitudesOnly)
            {
                IParcelManagementModule parcelManagement =
                    presence.Scene.RequestModuleInterface <IParcelManagementModule>();
                if (parcelManagement != null)
                {
                    land = parcelManagement.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
                }
                OSDMap map = land != null ? land.LandData.GenericData : new OSDMap();
                if (map.ContainsKey("WindLight"))
                {
                    IOpenRegionSettingsModule ORSM = presence.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                    if (ORSM != null && ORSM.AllowParcelWindLight)
                    {
                        if (CheckOverRideParcels(presence))
                        {
                            //Overrides all
                            SendProfileToClient(presence, FindRegionWindLight(presence));
                        }
                        else
                        {
                            OSDMap innerMap = (OSDMap)map["WindLight"];
                            foreach (KeyValuePair <string, OSD> kvp in innerMap)
                            {
                                int minEffectiveAltitude = int.Parse(kvp.Key);
                                if (presence.AbsolutePosition.Z > minEffectiveAltitude)
                                {
                                    OSDMap lsdMap = (OSDMap)kvp.Value;
                                    RegionLightShareData parcelLSD = new RegionLightShareData();
                                    parcelLSD.FromOSD(lsdMap);
                                    if (presence.AbsolutePosition.Z < parcelLSD.maxEffectiveAltitude)
                                    {
                                        //They are between both altitudes
                                        SendProfileToClient(presence, parcelLSD);
                                        return; //End it
                                    }
                                }
                            }
                            //Send region since no parcel claimed the user
                            SendProfileToClient(presence, FindRegionWindLight(presence));
                        }
                    }
                    else
                    {
                        //Only region allowed
                        SendProfileToClient(presence, FindRegionWindLight(presence));
                    }
                }
                else
                {
                    //Send the region by default to override any previous settings
                    SendProfileToClient(presence, FindRegionWindLight(presence));
                }
            }
            else
            {
                //Send the region by default to override any previous settings
                SendProfileToClient(presence, FindRegionWindLight(presence));
            }
        }
        public void RegionLoaded(IScene scene)
        {
            m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();

            m_moapModule = m_scene.RequestModuleInterface<IMoapModule>();

            m_parcelManagement = m_scene.RequestModuleInterface<IParcelManagementModule>();
        }
Esempio n. 24
0
        // 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;
                        }
                    }
                }
            }
        }
Esempio n. 25
0
        public void ClassifiedInfoUpdate(UUID queryClassifiedID, uint queryCategory, string queryName,
                                         string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos,
                                         byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            if (p == null)
            {
                return; //Just fail
            }
            IScheduledMoneyModule scheduledMoneyModule = p.Scene.RequestModuleInterface <IScheduledMoneyModule> ();
            IMoneyModule          moneyModule          = p.Scene.RequestModuleInterface <IMoneyModule> ();
            Classified            classcheck           = ProfileFrontend.GetClassified(queryClassifiedID);

            if (((queryclassifiedFlags & 32) != 32) && moneyModule != null)
            {
                //Single week
                if (!moneyModule.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified", TransactionType.ClassifiedCharge))
                {
                    remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                    return;
                }
            }
            else if (scheduledMoneyModule != null)
            {
                //Auto-renew
                if (classcheck != null)
                {
                    scheduledMoneyModule.RemoveFromScheduledCharge("[Classified: " + queryClassifiedID + "]");
                }

                var payOK = scheduledMoneyModule.Charge(
                    remoteClient.AgentId,                                                       // who to charge
                    queryclassifiedPrice,                                                       // how much
                    "Add Reoccurring Classified (" + queryClassifiedID + ")",                   // description
                    TransactionType.ClassifiedCharge,                                           // transaction type
                    "[Classified: " + queryClassifiedID + "]",                                  // scheduler identifier
                    true,                                                                       // charger immediately
                    false);                                                                     // run once
                if (!payOK)
                {
                    remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                    return;
                }
            }

            UUID    creatorUUID     = remoteClient.AgentId;
            UUID    classifiedUUID  = queryClassifiedID;
            uint    category        = queryCategory;
            string  name            = queryName;
            string  description     = queryDescription;
            uint    parentestate    = queryParentEstate;
            UUID    snapshotUUID    = querySnapshotID;
            string  simname         = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos       = queryGlobalPos;
            byte    classifiedFlags = queryclassifiedFlags;
            int     classifiedPrice = queryclassifiedPrice;

            UUID   parceluuid = p.CurrentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement = remoteClient.Scene.RequestModuleInterface <IParcelManagementModule> ();

            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.GlobalID;
                }
            }

            uint creationdate = (uint)Util.UnixTimeSinceEpoch();

            uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60);

            Classified classified = new Classified {
                ClassifiedUUID  = classifiedUUID,
                CreatorUUID     = creatorUUID,
                CreationDate    = creationdate,
                ExpirationDate  = expirationdate,
                Category        = category,
                Name            = name,
                Description     = description,
                ParcelUUID      = parceluuid,
                ParentEstate    = parentestate,
                SnapshotUUID    = snapshotUUID,
                SimName         = simname,
                GlobalPos       = globalpos,
                ParcelName      = parcelname,
                ClassifiedFlags = classifiedFlags,
                PriceForListing = classifiedPrice,
                ScopeID         = remoteClient.ScopeID
            };

            ProfileFrontend.AddClassified(classified);
        }
Esempio n. 26
0
        /// <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);
        }
Esempio n. 27
0
        public LandObject(UUID owner_id, bool is_group_owned, Scene scene)
        {
            m_scene = scene;

            m_landBitmap = new bool[m_scene.RegionInfo.RegionSizeX / 4, m_scene.RegionInfo.RegionSizeY / 4];

            LandData.Maturity = m_scene.RegionInfo.RegionSettings.Maturity;
            LandData.OwnerID = owner_id;
            if (is_group_owned)
                LandData.GroupID = owner_id;
            else
                LandData.GroupID = UUID.Zero;
            LandData.IsGroupOwned = is_group_owned;

            LandData.RegionID = scene.RegionInfo.RegionID;
            LandData.RegionHandle = scene.RegionInfo.RegionHandle;

            m_parcelManagementModule = scene.RequestModuleInterface<IParcelManagementModule>();

            //We don't set up the InfoID here... it will just be overwriten
        }
Esempio n. 28
0
        public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName,
                                         string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos,
                                         byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            if (p == null)
            {
                return; //Just fail
            }
            IMoneyModule money = p.Scene.RequestModuleInterface <IMoneyModule>();

            if (money != null)
            {
                Classified classcheck = ProfileFrontend.GetClassified(queryclassifiedID);
                if (classcheck == null)
                {
                    if (!money.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified"))
                    {
                        remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                        return;
                    }
                }
            }

            UUID    creatorUUID     = remoteClient.AgentId;
            UUID    classifiedUUID  = queryclassifiedID;
            uint    category        = queryCategory;
            string  name            = queryName;
            string  description     = queryDescription;
            uint    parentestate    = queryParentEstate;
            UUID    snapshotUUID    = querySnapshotID;
            string  simname         = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos       = queryGlobalPos;
            byte    classifiedFlags = queryclassifiedFlags;
            int     classifiedPrice = queryclassifiedPrice;

            UUID   parceluuid = p.CurrentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement =
                remoteClient.Scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.InfoUUID;
                }
            }

            uint creationdate = (uint)Util.UnixTimeSinceEpoch();

            uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60);

            Classified classified = new Classified
            {
                ClassifiedUUID  = classifiedUUID,
                CreatorUUID     = creatorUUID,
                CreationDate    = creationdate,
                ExpirationDate  = expirationdate,
                Category        = category,
                Name            = name,
                Description     = description,
                ParcelUUID      = parceluuid,
                ParentEstate    = parentestate,
                SnapshotUUID    = snapshotUUID,
                SimName         = simname,
                GlobalPos       = globalpos,
                ParcelName      = parcelname,
                ClassifiedFlags = classifiedFlags,
                PriceForListing = classifiedPrice,
                ScopeID         = remoteClient.ScopeID
            };

            ProfileFrontend.AddClassified(classified);
        }