Esempio n. 1
0
        //Find the correct WL settings to send to the client
        public void SendProfileToClient(IScenePresence presence)
        {
            if (presence == null)
            {
                return;
            }
            ILandObject             land             = null;
            IParcelManagementModule parcelManagement = presence.Scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                land = parcelManagement.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
            }
            OSDMap map = land != null ? land.LandData.GenericDataMap : 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));
            }
        }
        void AvatarEnteringParcel(IScenePresence avatar, ILandObject oldParcel)
        {
            ILandObject             obj = null;
            IParcelManagementModule parcelManagement = avatar.Scene.RequestModuleInterface <IParcelManagementModule> ();

            if (parcelManagement != null)
            {
                obj = parcelManagement.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
            }
            if (obj == null)
            {
                return;
            }

            try {
                if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0)
                {
                    ICombatPresence CP = avatar.RequestModuleInterface <ICombatPresence> ();
                    CP.Health           = MaximumHealth;
                    avatar.Invulnerable = false;
                }
                else
                {
                    avatar.Invulnerable = true;
                }
            } catch (Exception) {
            }
        }
Esempio n. 3
0
        public DateTime llRemoveFromLandBanList(string avatar)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(DateTime.Now);
            }

            IParcelManagementModule parcelManagement = World.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                LandData land =
                    parcelManagement.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData;
                if (land.OwnerID == m_host.OwnerID)
                {
                    UUID key;
                    if (UUID.TryParse(avatar, out key))
                    {
                        foreach (ParcelManager.ParcelAccessEntry entry in land.ParcelAccessList)
                        {
                            if (entry.AgentID == key && entry.Flags == AccessList.Ban)
                            {
                                land.ParcelAccessList.Remove(entry);
                                break;
                            }
                        }
                    }
                }
            }
            return(PScriptSleep(m_sleepMsOnRemoveFromLandBanList));
        }
Esempio n. 4
0
        public DateTime llResetLandPassList()
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(DateTime.Now);
            }

            IParcelManagementModule parcelManagement = World.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                LandData land =
                    parcelManagement.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData;
                if (land.OwnerID == m_host.OwnerID)
                {
                    foreach (ParcelManager.ParcelAccessEntry entry in land.ParcelAccessList)
                    {
                        if (entry.Flags == AccessList.Access)
                        {
                            land.ParcelAccessList.Remove(entry);
                        }
                    }
                }
            }
            return(PScriptSleep(m_sleepMsOnResetLandPassList));
        }
        bool EventManager_OnValidateBuyLand(EventManager.LandBuyArgs e)
        {
            IParcelManagementModule parcelManagement = GetSceneFor(e.agentId).RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement == null)
            {
                return(false);
            }
            ILandObject lob = parcelManagement.GetLandObject(e.parcelLocalID);

            if (lob != null)
            {
                UUID AuthorizedID = lob.LandData.AuthBuyerID;
                int  saleprice    = lob.LandData.SalePrice;
                UUID pOwnerID     = lob.LandData.OwnerID;

                bool landforsale = ((lob.LandData.Flags & (uint)(ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects)) != 0);
                if ((AuthorizedID == UUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice &&
                    landforsale)
                {
                    if (m_connector.UserCurrencyTransfer(lob.LandData.OwnerID, e.agentId, (uint)saleprice, "Land Buy", TransactionType.LandSale, UUID.Zero))
                    {
                        e.parcelOwnerID = pOwnerID;
                        e.landValidated = true;
                        return(true);
                    }

                    // not validated
                    e.landValidated = false;
                }
            }
            return(false);
        }
Esempio n. 6
0
        public DateTime llSetParcelMusicURL(string url)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(DateTime.Now);
            }

            IParcelManagementModule parcelManagement = World.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject land = parcelManagement.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);

                if (land == null)
                {
                    return(DateTime.Now);
                }

                if (!World.Permissions.CanEditParcel(m_host.OwnerID, land))
                {
                    return(DateTime.Now);
                }

                land.SetMusicUrl(url);
            }

            return(PScriptSleep(m_sleepMsOnSetParcelMusicURL));
        }
Esempio n. 7
0
 OSDMap m_syncMessageReceivedService_OnMessageReceived(OSDMap message)
 {
     if (!message.ContainsKey("Method"))
     {
         return(null);
     }
     if (message["Method"] == "SendGridMessage")
     {
         bool   result = m_currencyService.StarDustRegionService.SendGridMessage(message["AgentID"], message["Message"], false, message["TransactionID"]);
         OSDMap retVal = new OSDMap();
         retVal["Result"] = result;
         return(retVal);
     }
     if (message["Method"] == "SendGridMessage")
     {
         IScenePresence sp;
         if (m_currencyService.StarDustRegionService.Scene.TryGetScenePresence(message["AgentID"], out sp))
         {
             IParcelManagementModule parcelManagement = sp.Scene.RequestModuleInterface <IParcelManagementModule>();
             ILandObject             parcel           = parcelManagement.GetLandObject(sp.AbsolutePosition.X, sp.AbsolutePosition.Y);
             return(parcel.LandData.ToOSD());
         }
     }
     return(null);
 }
Esempio n. 8
0
        public DateTime llAddToLandBanList(string avatar, double hours)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(DateTime.Now);
            }

            IParcelManagementModule parcelManagement = World.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                LandData land =
                    parcelManagement.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData;
                if (land.OwnerID == m_host.OwnerID)
                {
                    ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
                    UUID key;
                    if (UUID.TryParse(avatar, out key))
                    {
                        entry.AgentID = key;
                        entry.Flags   = AccessList.Ban;
                        entry.Time    = DateTime.Now.AddHours(hours);
                        land.ParcelAccessList.Add(entry);
                    }
                }
            }
            return(PScriptSleep(m_sleepMsOnAddToLandBanList));
        }
Esempio n. 9
0
        public LSL_Integer llOverMyLand(string id)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(0);
            }

            UUID key = new UUID();

            if (UUID.TryParse(id, out key))
            {
                try {
                    IScenePresence          presence         = World.GetScenePresence(key);
                    IParcelManagementModule parcelManagement = World.RequestModuleInterface <IParcelManagementModule>();
                    if (presence != null)       // object is an avatar

                    {
                        if (parcelManagement != null)
                        {
                            if (m_host.OwnerID == parcelManagement.GetLandObject(presence.AbsolutePosition.X,
                                                                                 presence.AbsolutePosition.Y).LandData.OwnerID)
                            {
                                return(1);
                            }
                        }
                    }
                    else                        // object is not an avatar
                    {
                        ISceneChildEntity obj = World.GetSceneObjectPart(key);
                        if (obj != null && parcelManagement != null)
                        {
                            if (m_host.OwnerID == parcelManagement.GetLandObject(obj.AbsolutePosition.X,
                                                                                 obj.AbsolutePosition.Y).LandData.OwnerID)
                            {
                                return(1);
                            }
                        }
                    }
                } catch (NullReferenceException) {
                    // lots of places to get nulls
                    // eg, presence.AbsolutePosition
                    return(0);
                }
            }
            return(0);
        }
Esempio n. 10
0
        public void AuctionEnd(int localID)
        {
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject landObject = parcelManagement.GetLandObject(localID);
                if (landObject == null)
                {
                    return;
                }

                AuctionInfo info = GetAuctionInfo(localID);
                if (info == null)
                {
                    return; // cannot find this auction??
                }
                AuctionBid highestBid = new AuctionBid()
                {
                    Amount = 0
                };
                foreach (AuctionBid bid in info.AuctionBids)
                {
                    if (highestBid.Amount < bid.Amount)
                    {
                        highestBid = bid;
                    }
                }

                IOfflineMessagesConnector offlineMessages =
                    Framework.Utilities.DataManager.RequestPlugin <IOfflineMessagesConnector>();
                if (offlineMessages != null)
                {
                    offlineMessages.AddOfflineMessage(new GridInstantMessage()
                    {
                        BinaryBucket  = new byte[0],
                        Dialog        = (byte)InstantMessageDialog.MessageBox,
                        FromAgentID   = UUID.Zero,
                        FromAgentName = "System",
                        FromGroup     = false,
                        SessionID     = UUID.Random(),
                        Message       =
                            "You won the auction for the parcel " +
                            landObject.LandData.Name + ", paying " +
                            highestBid.Amount + " for it",
                        Offline        = 0,
                        ParentEstateID = 0,
                        Position       = Vector3.Zero,
                        RegionID       = m_scene.RegionInfo.RegionID,
                        Timestamp      = (uint)Util.UnixTimeSinceEpoch(),
                        ToAgentID      = highestBid.AuctionBidder
                    });
                }
                landObject.UpdateLandSold(highestBid.AuctionBidder, UUID.Zero, false, landObject.LandData.AuctionID,
                                          highestBid.Amount, landObject.LandData.Area);
            }
        }
Esempio n. 11
0
        private ILandObject GetLO()
        {
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                return(parcelManagement.GetLandObject(m_parcelID));
            }
            return(null);
        }
        public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name,
                                   string desc, UUID snapshotID, int sortOrder, bool enabled, Vector3d globalPos)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            UUID   parceluuid    = p.CurrentParcelUUID;
            string user          = "******";
            string OrigionalName = "(unknown)";

            Vector3 pos_global = new Vector3(globalPos);

            IParcelManagementModule parcelManagement =
                remoteClient.Scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject targetlandObj = parcelManagement.GetLandObject(pos_global.X / Constants.RegionSize,
                                                                           pos_global.Y / Constants.RegionSize);

                if (targetlandObj != null)
                {
                    UserAccount parcelOwner =
                        remoteClient.Scene.UserAccountService.GetUserAccount(remoteClient.AllScopeIDs,
                                                                             targetlandObj.LandData
                                                                             .OwnerID);
                    if (parcelOwner != null)
                    {
                        user = parcelOwner.Name;
                    }

                    parceluuid = targetlandObj.LandData.InfoUUID;

                    OrigionalName = targetlandObj.LandData.Name;
                }
            }

            ProfilePickInfo pick = new ProfilePickInfo
            {
                PickUUID     = pickID,
                CreatorUUID  = creatorID,
                TopPick      = topPick ? 1 : 0,
                ParcelUUID   = parceluuid,
                Name         = name,
                Description  = desc,
                SnapshotUUID = snapshotID,
                User         = user,
                OriginalName = OrigionalName,
                SimName      = remoteClient.Scene.RegionInfo.RegionName,
                GlobalPos    = pos_global,
                SortOrder    = sortOrder,
                Enabled      = enabled ? 1 : 0
            };

            ProfileFrontend.AddPick(pick);
        }
Esempio n. 13
0
        public void llUnSit(string id)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }


            UUID key = new UUID();

            if (UUID.TryParse(id, out key))
            {
                IScenePresence av = World.GetScenePresence(key);

                if (av != null)
                {
                    if (m_host.ParentEntity.SitTargetAvatar.Contains(key))
                    {
                        // if the avatar is sitting on this object, then
                        // we can unsit them.  We don't want random scripts unsitting random people
                        // Lets avoid the popcorn avatar scenario.
                        av.StandUp();
                    }
                    else
                    {
                        // If the object owner also owns the parcel
                        // or
                        // if the land is group owned and the object is group owned by the same group
                        // or
                        // if the object is owned by a person with estate access.

                        IParcelManagementModule parcelManagement = World.RequestModuleInterface <IParcelManagementModule>();
                        if (parcelManagement != null)
                        {
                            ILandObject parcel = parcelManagement.GetLandObject(av.AbsolutePosition.X,
                                                                                av.AbsolutePosition.Y);
                            if (parcel != null)
                            {
                                if (m_host.OwnerID == parcel.LandData.OwnerID ||
                                    (m_host.OwnerID == m_host.GroupID && m_host.GroupID == parcel.LandData.GroupID &&
                                     parcel.LandData.IsGroupOwned) || World.Permissions.IsGod(m_host.OwnerID))
                                {
                                    av.StandUp();
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 14
0
        private void SaveAuctionInfo(int LocalID, AuctionInfo info)
        {
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject landObject = parcelManagement.GetLandObject(LocalID);
                if (landObject == null)
                {
                    return;
                }
                landObject.LandData.AuctionInfo = info;
            }
        }
Esempio n. 15
0
        private AuctionInfo GetAuctionInfo(int LocalID)
        {
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject landObject = parcelManagement.GetLandObject(LocalID);
                if (landObject == null)
                {
                    return(null);
                }
                return(landObject.LandData.AuctionInfo);
            }
            return(null);
        }
Esempio n. 16
0
        public void StartAuction(int LocalID, UUID SnapshotID)
        {
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject landObject = parcelManagement.GetLandObject(LocalID);
                if (landObject == null)
                {
                    return;
                }
                landObject.LandData.SnapshotID = SnapshotID;
                landObject.LandData.AuctionID  = (uint)Util.RandomClass.Next(0, int.MaxValue);
                landObject.LandData.Status     = ParcelStatus.Abandoned;
                landObject.SendLandUpdateToAvatarsOverMe();
            }
        }
 bool EventManager_OnSceneGroupMove(UUID groupID, Vector3 pos)
 {
     Util.FireAndForget(delegate
     {
         IParcelManagementModule parcelManagment = m_Scene.RequestModuleInterface <IParcelManagementModule>();
         ILandObject landObject = parcelManagment.GetLandObject(pos.X, pos.Y) ?? parcelManagment.GetNearestAllowedParcel(UUID.Zero, pos.X, pos.Y);
         if (landObject == null)
         {
             return;
         }
         ParcelCounts parcelCounts;
         if ((m_ParcelCounts.TryGetValue(landObject.LandData.GlobalID, out parcelCounts)) && (!parcelCounts.Objects.ContainsKey(groupID)))
         {
             m_Tainted = true;
         }
     });
     return(true);
 }
Esempio n. 18
0
        private AuctionInfo GetAuctionInfo(int LocalID)
        {
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject landObject = parcelManagement.GetLandObject(LocalID);
                if (landObject == null)
                {
                    return(null);
                }
                OSDMap      map  = (OSDMap)landObject.LandData.GenericData["AuctionInfo"];
                AuctionInfo info = new AuctionInfo();
                info.FromOSD(map);
                return(info);
            }
            return(null);
        }
Esempio n. 19
0
        public DateTime llTeleportAgentHome(LSL_Key _agent)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(DateTime.Now);
            }

            string agent = _agent.ToString();

            UUID agentId = new UUID();

            if (UUID.TryParse(agent, out agentId))
            {
                IScenePresence presence = World.GetScenePresence(agentId);
                if (presence != null)
                {
                    // agent must be over the owners land
                    IParcelManagementModule parcelManagement = World.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        if (m_host.OwnerID != parcelManagement.GetLandObject(
                                presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID&&
                            !World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false))
                        {
                            return(PScriptSleep(m_sleepMsOnTeleportAgentHome));
                        }
                    }

                    //Send disable cancel so that the agent cannot attempt to stay in the region
                    presence.ControllingClient.SendTeleportStart((uint)TeleportFlags.DisableCancel);
                    IEntityTransferModule transferModule = World.RequestModuleInterface <IEntityTransferModule>();
                    if (transferModule != null)
                    {
                        transferModule.TeleportHome(agentId, presence.ControllingClient);
                    }
                    else
                    {
                        presence.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
                    }
                }
            }
            return(PScriptSleep(m_sleepMsOnTeleportAgentHome));
        }
Esempio n. 20
0
        public virtual void AddConeOfSilence(UUID objectID, Vector3 position, double Radius)
        {
            //Must have parcel owner permissions, too many places for abuse in this
            ISceneEntity            group            = m_scene.GetSceneObjectPart(objectID).ParentEntity;
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject land = parcelManagement.GetLandObject((int)position.X, (int)position.Y);
                if (!m_scene.Permissions.CanEditParcel(group.OwnerID, land))
                {
                    return;
                }
            }
            ConeOfSilence CS = new ConeOfSilence {
                Position = position, Radius = Radius
            };

            Cones.Add(objectID, CS);
        }
Esempio n. 21
0
        void client_OnViewerStartAuction(IClientAPI client, int LocalID, UUID SnapshotID)
        {
            if (!m_scene.Permissions.IsGod(client.AgentId))
            {
                return;
            }
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject landObject = parcelManagement.GetLandObject(LocalID);
                if (landObject == null)
                {
                    return;
                }
                landObject.LandData.SnapshotID = SnapshotID;
                landObject.LandData.AuctionID++;
                landObject.SendLandUpdateToAvatarsOverMe();
            }
        }
Esempio n. 22
0
        public void StartAuction(int localID, UUID snapshotID)
        {
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject landObject = parcelManagement.GetLandObject(localID);
                if (landObject == null)
                {
                    return;
                }
                landObject.LandData.SnapshotID = snapshotID;
                landObject.LandData.AuctionID  = (uint)Util.RandomClass.Next(0, int.MaxValue);

                // During an Auction, the Status of an parcel stays "Leased"
                // 20160204 -greythane- maybe this could be set to 'pending'?
                landObject.LandData.Status = ParcelStatus.Leased;
                landObject.SendLandUpdateToAvatarsOverMe();
            }
        }
Esempio n. 23
0
        public DateTime llEjectFromLand(string pest)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(DateTime.Now);
            }

            UUID agentId = new UUID();

            if (UUID.TryParse(pest, out agentId))
            {
                IScenePresence presence = World.GetScenePresence(agentId);
                if (presence != null)
                {
                    // agent must be over the owners land
                    IParcelManagementModule parcelManagement = World.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        if (m_host.OwnerID != parcelManagement.GetLandObject(
                                presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID&&
                            !World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false))
                        {
                            return(PScriptSleep(m_sleepMsOnEjectFromLand));
                        }
                    }
                    IEntityTransferModule transferModule = World.RequestModuleInterface <IEntityTransferModule>();
                    if (transferModule != null)
                    {
                        transferModule.TeleportHome(agentId, presence.ControllingClient);
                    }
                    else
                    {
                        presence.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
                    }
                }
            }
            return(PScriptSleep(m_sleepMsOnEjectFromLand));
        }
Esempio n. 24
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();
                }
            }
Esempio n. 25
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.InfoFormat("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 is not present in any region??");
                return(null);
            }

            MainConsole.Instance.Debug("Returning scene[0]: " + m_scenes [0].RegionInfo.RegionName);
            return(m_scenes[0]);
        }
Esempio n. 26
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. 27
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. 28
0
        /// <summary>
        /// Callback for a client request for ParcelVoiceInfo
        /// </summary>
        /// <param name="scene">current scene object of the client</param>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="param"></param>
        /// <param name="agentID"></param>
        /// <param name="caps"></param>
        /// <returns></returns>
        public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param,
                                             UUID agentID)
        {
            IScenePresence avatar     = scene.GetScenePresence(agentID);
            string         avatarName = avatar.Name;

            // - check whether we have a region channel in our cache
            // - if not:
            //       create it and cache it
            // - send it to the client
            // - send channel_uri: as "sip:regionID@m_sipDomain"
            try
            {
                string channelUri;

                IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>();
                if (parcelManagement == null)
                {
                    throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available",
                                                      scene.RegionInfo.RegionName, avatarName));
                }

                // get channel_uri: check first whether estate
                // settings allow voice, then whether parcel allows
                // voice, if all do retrieve or obtain the parcel
                // voice channel
                LandData land = parcelManagement.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y).LandData;

                m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}",
                                  scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param);

                if (!scene.RegionInfo.EstateSettings.AllowVoice)
                {
                    m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings",
                                      scene.RegionInfo.RegionName);
                    channelUri = String.Empty;
                }

                if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0)
                {
                    m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel",
                                      scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName);
                    channelUri = String.Empty;
                }
                else
                {
                    channelUri = ChannelUri(scene, land);
                }

                // fill in our response to the client
                OSDMap map = new OSDMap();
                map["region_name"]       = scene.RegionInfo.RegionName;
                map["parcel_local_id"]   = land.LocalID;
                map["voice_credentials"] = new OSDMap();
                ((OSDMap)map["voice_credentials"])["channel_uri"] = channelUri;
                string r = OSDParser.SerializeLLSDXmlString(map);

                m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}",
                                  scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r);
                return(r);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later",
                                  scene.RegionInfo.RegionName, avatarName, e.Message);
                m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed",
                                  scene.RegionInfo.RegionName, avatarName, e.ToString());

                return("<llsd>undef</llsd>");
            }
        }
Esempio n. 29
0
        private void DearchiveRegion0DotStar()
        {
            int      successfulAssetRestores = 0;
            int      failedAssetRestores     = 0;
            string   filePath = "NONE";
            DateTime start    = DateTime.Now;

            TarArchiveReader archive = new TarArchiveReader(m_loadStream);

            if (!m_skipAssets)
            {
                m_threadpool = new Aurora.Framework.AuroraThreadPool(new Aurora.Framework.AuroraThreadPoolStartInfo()
                {
                    Threads  = 1,
                    priority = System.Threading.ThreadPriority.BelowNormal
                });
            }

            IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();

            if (!m_merge)
            {
                DateTime before = DateTime.Now;
                MainConsole.Instance.Info("[ARCHIVER]: Clearing all existing scene objects");
                if (backup != null)
                {
                    backup.DeleteAllSceneObjects();
                }
                MainConsole.Instance.Info("[ARCHIVER]: Cleared all existing scene objects in " + (DateTime.Now - before).Minutes + ":" + (DateTime.Now - before).Seconds);
            }

            IScriptModule[] modules = m_scene.RequestModuleInterfaces <IScriptModule>();
            //Disable the script engine so that it doesn't load in the background and kill OAR loading
            foreach (IScriptModule module in modules)
            {
                module.Disabled = true;
            }
            //Disable backup for now as well
            if (backup != null)
            {
                backup.LoadingPrims = true;
            }

            IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface <IRegionSerialiserModule>();
            int sceneObjectsLoadedCount        = 0;

            //We save the groups so that we can back them up later
            List <SceneObjectGroup> groupsToBackup = new List <SceneObjectGroup>();
            List <LandData>         landData       = new List <LandData>();
            IUserFinder             UserManager    = m_scene.RequestModuleInterface <IUserFinder>();

            // must save off some stuff until after assets have been saved and recieved new uuids
            // keeping these collection local because I am sure they will get large and garbage collection is better that way
            List <byte[]>           seneObjectGroups        = new List <byte[]>();
            Dictionary <UUID, UUID> assetBinaryChangeRecord = new Dictionary <UUID, UUID>();
            Queue <UUID>            assets2Save             = new Queue <UUID>();

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

                    if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
                    {
                        seneObjectGroups.Add(data);
                    }
                    else if (!m_skipAssets && filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
                    {
                        AssetBase asset;
                        if (LoadAsset(filePath, data, out asset))
                        {
                            successfulAssetRestores++;
                            if (m_useAsync)
                            {
                                lock (AssetsToAdd) AssetsToAdd.Add(asset);
                            }
                            else
                            {
                                if (asset.IsBinaryAsset)
                                {
                                    UUID aid = asset.ID;
                                    asset.ID = m_scene.AssetService.Store(asset);
                                    if (asset.ID != aid && asset.ID != UUID.Zero)
                                    {
                                        assetBinaryChangeRecord.Add(aid, asset.ID);
                                    }
                                }
                                else
                                {
                                    if (!assetNonBinaryCollection.ContainsKey(asset.ID))
                                    {
                                        assetNonBinaryCollection.Add(asset.ID, asset);
                                        // I need something I can safely loop through
                                        assets2Save.Enqueue(asset.ID);
                                    }
                                }
                            }
                        }
                        else
                        {
                            failedAssetRestores++;
                        }

                        if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
                        {
                            MainConsole.Instance.Info("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets...");
                        }
                    }
                    else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
                    {
                        LoadTerrain(filePath, data);
                    }
                    else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH))
                    {
                        LoadRegionSettings(filePath, data);
                    }
                    else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
                    {
                        LandData parcel = LandDataSerializer.Deserialize(m_utf8Encoding.GetString(data));
                        parcel.OwnerID = ResolveUserUuid(parcel.OwnerID, UUID.Zero, "", Vector3.Zero, null);
                        landData.Add(parcel);
                    }
                    else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
                    {
                        LoadControlFile(data);
                    }
                }
                // Save Assets
                int savingAssetsCount = 0;
                while (assets2Save.Count > 0)
                {
                    try
                    {
                        UUID assetid = assets2Save.Dequeue();
                        SaveNonBinaryAssets(assetid, assetNonBinaryCollection[assetid], assetBinaryChangeRecord);
                        savingAssetsCount++;
                        if ((savingAssetsCount) % 250 == 0)
                        {
                            MainConsole.Instance.Info("[ARCHIVER]: Saving " + savingAssetsCount + " assets...");
                        }
                    }
                    catch (Exception ex)
                    {
                        MainConsole.Instance.Info("[ARCHIVER]: Exception in saving an asset: " + ex.ToString());
                    }
                }

                foreach (byte[] data2 in seneObjectGroups)
                {
                    byte[] data3 = data2;

                    string          stringData = Utils.BytesToString(data3);
                    MatchCollection mc         = Regex.Matches(stringData, sPattern);
                    bool            didChange  = false;
                    if (mc.Count >= 1)
                    {
                        foreach (Match match in mc)
                        {
                            UUID thematch = new UUID(match.Value);
                            UUID newvalue = thematch;
                            if (assetNonBinaryCollection.ContainsKey(thematch))
                            {
                                newvalue = assetNonBinaryCollection[thematch].ID;
                            }
                            else if (assetBinaryChangeRecord.ContainsKey(thematch))
                            {
                                newvalue = assetBinaryChangeRecord[thematch];
                            }
                            if (thematch == newvalue)
                            {
                                continue;
                            }
                            stringData = stringData.Replace(thematch.ToString().Trim(), newvalue.ToString().Trim());
                            didChange  = true;
                        }
                    }
                    if (didChange)
                    {
                        data3 = Utils.StringToBytes(stringData);
                    }

                    SceneObjectGroup sceneObject = (SceneObjectGroup)serialiser.DeserializeGroupFromXml2(data3, m_scene);

                    if (sceneObject == null)
                    {
                        //! big error!
                        MainConsole.Instance.Error("Error reading SOP XML (Please mantis this!): " + m_asciiEncoding.GetString(data3));
                        continue;
                    }

                    foreach (SceneObjectPart part in sceneObject.ChildrenList)
                    {
                        if (string.IsNullOrEmpty(part.CreatorData))
                        {
                            part.CreatorID = ResolveUserUuid(part.CreatorID, part.CreatorID, part.CreatorData, part.AbsolutePosition, landData);
                        }

                        if (UserManager != null)
                        {
                            UserManager.AddUser(part.CreatorID, part.CreatorData);
                        }

                        part.OwnerID = ResolveUserUuid(part.OwnerID, part.CreatorID, part.CreatorData, part.AbsolutePosition, landData);

                        part.LastOwnerID = ResolveUserUuid(part.LastOwnerID, part.CreatorID, part.CreatorData, part.AbsolutePosition, landData);

                        // And zap any troublesome sit target information
                        part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
                        part.SitTargetPosition    = new Vector3(0, 0, 0);

                        // Fix ownership/creator of inventory items
                        // Not doing so results in inventory items
                        // being no copy/no mod for everyone
                        lock (part.TaskInventory)
                        {
                            TaskInventoryDictionary inv = part.TaskInventory;
                            foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv)
                            {
                                kvp.Value.OwnerID = ResolveUserUuid(kvp.Value.OwnerID, kvp.Value.CreatorID, kvp.Value.CreatorData, part.AbsolutePosition, landData);
                                if (string.IsNullOrEmpty(kvp.Value.CreatorData))
                                {
                                    kvp.Value.CreatorID = ResolveUserUuid(kvp.Value.CreatorID, kvp.Value.CreatorID, kvp.Value.CreatorData, part.AbsolutePosition, landData);
                                }
                                if (UserManager != null)
                                {
                                    UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);
                                }
                            }
                        }
                    }

                    //Add the offsets of the region
                    Vector3 newPos = new Vector3(sceneObject.AbsolutePosition.X + m_offsetX,
                                                 sceneObject.AbsolutePosition.Y + m_offsetY,
                                                 sceneObject.AbsolutePosition.Z + m_offsetZ);
                    if (m_flipX)
                    {
                        newPos.X = m_scene.RegionInfo.RegionSizeX - newPos.X;
                    }
                    if (m_flipY)
                    {
                        newPos.Y = m_scene.RegionInfo.RegionSizeY - newPos.Y;
                    }
                    sceneObject.SetAbsolutePosition(false, newPos);

                    if (m_scene.SceneGraph.AddPrimToScene(sceneObject))
                    {
                        groupsToBackup.Add(sceneObject);
                        sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                        sceneObject.CreateScriptInstances(0, false, StateSource.RegionStart, UUID.Zero, true);
                    }
                    sceneObjectsLoadedCount++;
                    if (sceneObjectsLoadedCount % 250 == 0)
                    {
                        MainConsole.Instance.Info("[ARCHIVER]: Loaded " + sceneObjectsLoadedCount + " objects...");
                    }
                }
                assetNonBinaryCollection.Clear();
                assetBinaryChangeRecord.Clear();
                seneObjectGroups.Clear();
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat(
                    "[ARCHIVER]: Aborting load with error in archive file {0}.  {1}", filePath, e);
                m_errorMessage += e.ToString();
                m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage);
                return;
            }
            finally
            {
                archive.Close();
                m_loadStream.Close();
                m_loadStream.Dispose();

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

            //Now back up the prims
            foreach (SceneObjectGroup grp in groupsToBackup)
            {
                //Backup!
                grp.HasGroupChanged = true;
            }

            if (!m_skipAssets && m_useAsync && !AssetSaverIsRunning)
            {
                m_threadpool.QueueEvent(SaveAssets, 0);
            }

            if (!m_skipAssets)
            {
                MainConsole.Instance.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);

                if (failedAssetRestores > 0)
                {
                    MainConsole.Instance.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
                    m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
                }
            }

            // Try to retain the original creator/owner/lastowner if their uuid is present on this grid
            // otherwise, use the master avatar uuid instead

            // Reload serialized parcels
            MainConsole.Instance.InfoFormat("[ARCHIVER]: Loading {0} parcels.  Please wait.", landData.Count);

            IParcelManagementModule parcelManagementModule = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (!m_merge && parcelManagementModule != null)
            {
                parcelManagementModule.ClearAllParcels();
            }
            if (landData.Count > 0)
            {
                m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData, new Vector2(m_offsetX, m_offsetY));
                //Update the database as well!
                if (parcelManagementModule != null)
                {
                    foreach (LandData parcel in landData)
                    {
                        parcelManagementModule.UpdateLandObject(parcelManagementModule.GetLandObject(parcel.LocalID));
                    }
                }
            }
            else if (parcelManagementModule != null)
            {
                parcelManagementModule.ResetSimLandObjects();
            }

            MainConsole.Instance.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count);

            //Clean it out
            landData.Clear();

            MainConsole.Instance.InfoFormat("[ARCHIVER]: Successfully loaded archive in " + (DateTime.Now - start).Minutes + ":" + (DateTime.Now - start).Seconds);

            m_validUserUuids.Clear();
            m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage);
        }
Esempio n. 30
0
        private bool OnAllowedIncomingTeleport(UUID userID, IScene scene, Vector3 Position, out Vector3 newPosition, out string reason)
        {
            newPosition = Position;
            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID);

            IScenePresence Sp = scene.GetScenePresence(userID);

            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }

            //Make sure that this user is inside the region as well
            if (Position.X < -2f || Position.Y < -2f ||
                Position.X > scene.RegionInfo.RegionSizeX + 2 || Position.Y > scene.RegionInfo.RegionSizeY + 2)
            {
                m_log.DebugFormat(
                    "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping",
                    Position, Name, userID);
                bool changedX = false;
                bool changedY = false;
                while (Position.X < 0)
                {
                    Position.X += scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }
                while (Position.X > scene.RegionInfo.RegionSizeX)
                {
                    Position.X -= scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }

                while (Position.Y < 0)
                {
                    Position.Y += scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }
                while (Position.Y > scene.RegionInfo.RegionSizeY)
                {
                    Position.Y -= scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }

                if (changedX)
                {
                    Position.X = scene.RegionInfo.RegionSizeX - Position.X;
                }
                if (changedY)
                {
                    Position.Y = scene.RegionInfo.RegionSizeY - Position.Y;
                }
            }

            //Check that we are not underground as well
            float posZLimit = scene.RequestModuleInterface <ITerrainChannel>()[(int)Position.X, (int)Position.Y] + (float)1.25;

            if (posZLimit >= (Position.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
            {
                Position.Z = posZLimit;
            }

            IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;

            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(userID);
            }

            ILandObject             ILO = null;
            IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(Position.X, Position.Y);
            }

            if (ILO == null)
            {
                //Can't find land, give them the first parcel in the region and find a good position for them
                ILO      = parcelManagement.AllParcels()[0];
                Position = parcelManagement.GetParcelCenterAtGround(ILO);
            }

            //parcel permissions
            if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block
            {
                if (Sp == null)
                {
                    reason = "Banned from this parcel.";
                    return(true);
                }

                if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                {
                    //We found a place for them, but we don't need to check any further
                    return(true);
                }
            }
            //Move them out of banned parcels
            ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags;

            if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup &&
                (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList &&
                (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
            {
                //One of these is in play then
                if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID)
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    //All but the people on the access list are banned
                    if (ILO.IsRestrictedFromLand(userID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    //All but the people on the pass/access list are banned
                    if (ILO.IsRestrictedFromLand(Sp.UUID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            //Move them to the nearest landing point
            if (!ES.AllowDirectTeleport)
            {
                if (!scene.Permissions.IsGod(userID))
                {
                    Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle);
                    if (telehub != null)
                    {
                        if (telehub.SpawnPos.Count == 0)
                        {
                            Position = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        }
                        else
                        {
                            int LastTelehubNum = 0;
                            if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            {
                                LastTelehubNum = 0;
                            }
                            Position = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                            LastTelehubNum++;
                            if (LastTelehubNum == telehub.SpawnPos.Count)
                            {
                                LastTelehubNum = 0;
                            }
                            LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                        }
                    }
                }
            }
            if (!scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
            {
                if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land
                {
                    //Find a new parcel for them
                    List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
                    if (Parcels.Count == 0)
                    {
                        IScenePresence SP;
                        scene.TryGetScenePresence(userID, out SP);
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(SP);
                    }
                    else
                    {
                        bool found = false;
                        //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                        foreach (ILandObject Parcel in Parcels)
                        {
                            if (!Parcel.IsBannedFromLand(userID))
                            {
                                //Now we have to check their userloc
                                if (ILO.LandData.LandingType == 2)
                                {
                                    continue;                           //Blocked, check next one
                                }
                                else if (ILO.LandData.LandingType == 1) //Use their landing spot
                                {
                                    newPosition = Parcel.LandData.UserLocation;
                                }
                                else //They allow for anywhere, so dump them in the center at the ground
                                {
                                    newPosition = parcelManagement.GetParcelCenterAtGround(Parcel);
                                }
                                found = true;
                            }
                        }
                        if (!found) //Dump them at the edge
                        {
                            if (Sp != null)
                            {
                                newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                            }
                            else
                            {
                                reason = "Banned from this parcel.";
                                return(true);
                            }
                        }
                    }
                }
                else if (ILO.LandData.LandingType == 1) //Move to tp spot
                {
                    if (ILO.LandData.UserLocation != Vector3.Zero)
                    {
                        newPosition = ILO.LandData.UserLocation;
                    }
                    else // Dump them at the nearest region corner since they havn't set a landing point
                    {
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                    }
                }
            }

            //We assume that our own region isn't null....
            if (agentInfo != null)
            {
                //Can only enter prelude regions once!
                int flags = scene.GridService.GetRegionFlags(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionID);
                if (flags != -1 && ((flags & (int)Aurora.Framework.RegionFlags.Prelude) == (int)Aurora.Framework.RegionFlags.Prelude) && agentInfo != null)
                {
                    if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID))
                    {
                        reason = "You may not enter this region as you have already been to this prelude region.";
                        return(false);
                    }
                    else
                    {
                        agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID, OSD.FromInteger((int)IAgentFlags.PastPrelude));
                        AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok
                    }
                }
            }


            if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0)
            {
                if ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null)
            {
                if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            newPosition = Position;
            reason      = "";
            return(true);
        }