Ejemplo n.º 1
0
        byte[] EnterAgent(string region, string name, IOSHttpRequest httpRequest, Dictionary <string, object> request, IOSHttpResponse httpResponse)
        {
            // Let's check if the region exists
            GridRegion gregion = null;

            if (string.IsNullOrEmpty(region) || region == "DEFAULT")
            {
                List <GridRegion> regions = m_GridService.GetDefaultRegions(UUID.Zero);
                if (regions.Count > 0)
                {
                    gregion = regions[0];
                }
                else
                {
                    return(BadRequest(httpResponse));
                }
            }
            else
            {
                gregion = m_GridService.GetRegionByName(UUID.Zero, region);
                if (gregion == null)
                {
                    return(BadRequest(httpResponse));
                }
            }

            // We found the region
            m_log.DebugFormat("[PotamOS]: Found requested region {0} at {1}", region, gregion.ServerURI);
            httpResponse.StatusCode  = (int)OSHttpStatusCode.SuccessOk;
            httpResponse.ContentType = "text/plain";
            string simUrl = string.Format("{0}={1}", region, HttpUtility.UrlEncode(gregion.ServerURI));

            return(PotamOSUtils.StringToBytes(simUrl));
        }
        public bool TryGet(string name, out GridRegion rinfo)
        {
            /*
             * if (disposed)
             * {
             *  rinfo = null;
             *  return false;
             * }
             */

            bool gotLock = false;

            try
            {
                try { }
                finally
                {
                    m_rwLock.EnterReadLock();
                    gotLock = true;
                }

                return(m_byName.TryGetValue(name.ToLowerInvariant(), out rinfo));
            }
            finally
            {
                if (gotLock)
                {
                    m_rwLock.ExitReadLock();
                }
            }
        }
Ejemplo n.º 3
0
        protected List <GridRegion> ParseQuery(List <string> query)
        {
            List <GridRegion> regionData = new List <GridRegion>();

            if ((query.Count % 14) == 0)
            {
                for (int i = 0; i < query.Count; i += 14)
                {
                    GridRegion data = new GridRegion();
                    OSDMap     map  = (OSDMap)OSDParser.DeserializeJson(query[i + 13]);
                    data.FromOSD(map);

                    //Check whether it should be down
                    if (data.LastSeen > (Util.UnixTimeSinceEpoch() + (1000 * 6)))
                    {
                        data.Access |= (int)SimAccess.Down;
                    }

                    if (!regionData.Contains(data))
                    {
                        regionData.Add(data);
                    }
                }
            }

            return(regionData);
        }
        public bool Contains(GridRegion rinfo)
        {
            //if (disposed)
            //    return false;

            bool gotLock = false;

            try
            {
                try { }
                finally
                {
                    m_rwLock.EnterReadLock();
                    gotLock = true;
                }

                if (!m_byHandler.TryGetValue(rinfo.RegionHandle & HANDLEMASK, out GridRegion rcur))
                {
                    return(false);
                }

                return(rcur.RegionID == rinfo.RegionID &&
                       rcur.RegionSizeX == rinfo.RegionSizeX &&
                       rcur.RegionSizeY == rinfo.RegionSizeY);
            }
            finally
            {
                if (gotLock)
                {
                    m_rwLock.ExitReadLock();
                }
            }
        }
Ejemplo n.º 5
0
        public void OnRegionHandleRequest(IClientAPI client, UUID regionID)
        {
            //m_log.DebugFormat("[SERVICE THROTTLE]: RegionHandleRequest {0}", regionID);
            Action action = delegate
            {
                if (!client.IsActive || m_scenes.Count == 0 || m_scenes[0] == null)
                {
                    client = null;
                    return;
                }

                Scene baseScene = m_scenes[0];
                if (baseScene.ShuttingDown)
                {
                    client = null;
                    return;
                }

                GridRegion r = baseScene.GridService.GetRegionByUUID(UUID.Zero, regionID);

                if (client.IsActive && r != null && r.RegionHandle != 0)
                {
                    client.SendRegionHandle(regionID, r.RegionHandle);
                }

                client = null;
            };

            m_processorJobEngine.QueueJob("regionHandle", action, regionID.ToString());
        }
Ejemplo n.º 6
0
 private void EventManager_OnMakeChildAgent(IScenePresence presence, GridRegion destination)
 {
     lock (scriptedcontrols)
     {
         scriptedcontrols.Clear(); //Remove all controls when we leave the region
     }
 }
 public void Cache(GridRegion rinfo)
 {
     if (rinfo != null)
     {
         this.Cache(rinfo.ScopeID, rinfo.RegionID, rinfo);
     }
 }
        private void removeFromInner(GridRegion region)
        {
            int rsx = region.RegionSizeX;
            int rsy = region.RegionSizeY;

            if (rsx < 257 && rsy < 257)
            {
                return;
            }

            rsx >>= 8;
            rsy >>= 8;
            ulong            handle = region.RegionHandle & HANDLEMASK;
            fastRegionHandle fh     = new fastRegionHandle(handle);
            uint             startY = fh.y;

            for (int i = 0; i < rsx; i++)
            {
                for (int j = 0; j < rsy; j++)
                {
                    m_innerHandles.Remove(fh.toHandle());
                    fh.y += 256;
                }

                fh.y  = startY;
                fh.x += 256;
            }
        }
Ejemplo n.º 9
0
        protected List <GridRegion> ParseQuery(List <UUID> scopeIDs, List <string> query)
        {
            List <GridRegion> regionData = new List <GridRegion>();

            if ((query.Count % 14) == 0)
            {
                for (int i = 0; i < query.Count; i += 14)
                {
                    GridRegion data = new GridRegion();
                    OSDMap     map  = (OSDMap)OSDParser.DeserializeJson(query[i + 13]);
                    map["owner_uuid"]  = (!map.ContainsKey("owner_uuid") || map["owner_uuid"].AsUUID() == UUID.Zero) ? OSD.FromUUID(UUID.Parse(query[i + 6])) : map["owner_uuid"];
                    map["EstateOwner"] = (!map.ContainsKey("EstateOwner") || map["EstateOwner"].AsUUID() == UUID.Zero) ? OSD.FromUUID(UUID.Parse(query[i + 6])) : map["EstateOwner"];
                    data.FromOSD(map);

                    //Check whether it should be down
                    if (data.LastSeen > (Util.UnixTimeSinceEpoch() + (1000 * 6)))
                    {
                        data.Access |= (int)SimAccess.Down;
                    }

                    if (!regionData.Contains(data))
                    {
                        regionData.Add(data);
                    }
                }
            }

            return(AllScopeIDImpl.CheckScopeIDs(scopeIDs, regionData));
        }
Ejemplo n.º 10
0
        public void OnRegionHandleRequest(IClientAPI client, UUID regionID)
        {
            //m_log.DebugFormat("[SERVICE THROTTLE]: RegionHandleRequest {0}", regionID);
            Action action = delegate
            {
                if (!client.IsActive)
                {
                    return;
                }

                GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID);

                if (!client.IsActive)
                {
                    return;
                }

                if (r != null && r.RegionHandle != 0)
                {
                    client.SendRegionHandle(regionID, r.RegionHandle);
                }
            };

            m_processorJobEngine.QueueJob("regionHandle", action, regionID.ToString());
        }
Ejemplo n.º 11
0
        protected MapBlockData TerrainBlockFromGridRegion(GridRegion r)
        {
            MapBlockData block = new MapBlockData();

            if (r == null)
            {
                block.Access     = (byte)SimAccess.Down;
                block.MapImageID = UUID.Zero;
                return(block);
            }
            block.Access     = r.Access;
            block.MapImageID = r.TerrainMapImage;
            if ((r.Access & (byte)SimAccess.Down) == (byte)SimAccess.Down)
            {
                block.Name = r.RegionName + " (offline)";
            }
            else
            {
                block.Name = r.RegionName;
            }
            block.X     = (ushort)(r.RegionLocX / Constants.RegionSize);
            block.Y     = (ushort)(r.RegionLocY / Constants.RegionSize);
            block.SizeX = (ushort)r.RegionSizeX;
            block.SizeY = (ushort)r.RegionSizeY;
            return(block);
        }
        public bool TryGet(UUID regionID, out GridRegion rinfo)
        {
            /*
             * if (disposed)
             * {
             *  rinfo = null;
             *  return false;
             * }
             */

            bool gotLock = false;

            try
            {
                try { }
                finally
                {
                    m_rwLock.EnterReadLock();
                    gotLock = true;
                }

                return(m_byUUID.TryGetValue(regionID, out rinfo));
            }
            finally
            {
                if (gotLock)
                {
                    m_rwLock.ExitReadLock();
                }
            }
        }
Ejemplo n.º 13
0
 protected void AgentIsLeaving(IScenePresence presence, OpenSim.Services.Interfaces.GridRegion destination)
 {
     //If its a root agent, we need to save all attachments as well
     if (!presence.IsChildAgent)
     {
         SuspendAvatar(presence, destination);
     }
 }
Ejemplo n.º 14
0
 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)
 {
     block.Access     = r.Access;
     block.MapImageId = r.TerrainImage;
     block.Name       = r.RegionName;
     block.X          = (ushort)(r.RegionLocX / Constants.RegionSize);
     block.Y          = (ushort)(r.RegionLocY / Constants.RegionSize);
 }
        private bool Call(GridRegion region, Dictionary <string, object> sendData)
        {
            string reqString = ServerUtils.BuildQueryString(sendData);

            //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString);
            if (region == null)
            {
                return(false);
            }

            string path = ServicePath();

            if (!region.ServerURI.EndsWith("/"))
            {
                path = "/" + path;
            }
            string uri = region.ServerURI + path;

//            m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri);

            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("RESULT"))
                    {
                        if (replyData["RESULT"].ToString().ToLower() == "true")
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field");
                    }
                }
                else
                {
                    m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message);
            }

            return(false);
        }
Ejemplo n.º 16
0
        protected List <MapBlockData> Map2BlockFromGridRegion(GridRegion r)
        {
            List <MapBlockData> blocks = new List <MapBlockData> ();
            MapBlockData        block  = new MapBlockData();

            if (r == null)
            {
                block.Access     = (byte)SimAccess.Down;
                block.MapImageID = UUID.Zero;
                blocks.Add(block);
                return(blocks);
            }
            block.Access     = r.Access;
            block.MapImageID = r.TerrainImage;
            if ((r.Access & (byte)SimAccess.Down) == (byte)SimAccess.Down)
            {
                block.Name = r.RegionName + " (offline)";
            }
            else
            {
                block.Name = r.RegionName;
            }
            block.X     = (ushort)(r.RegionLocX / Constants.RegionSize);
            block.Y     = (ushort)(r.RegionLocY / Constants.RegionSize);
            block.SizeX = (ushort)r.RegionSizeX;
            block.SizeY = (ushort)r.RegionSizeY;
            blocks.Add(block);
            if (r.RegionSizeX > Constants.RegionSize || r.RegionSizeY > Constants.RegionSize)
            {
                for (int x = 0; x < r.RegionSizeX / Constants.RegionSize; x++)
                {
                    for (int y = 0; y < r.RegionSizeY / Constants.RegionSize; y++)
                    {
                        if (x == 0 && y == 0)
                        {
                            continue;
                        }
                        block = new MapBlockData
                        {
                            Access     = r.Access,
                            MapImageID = r.TerrainImage,
                            Name       = r.RegionName,
                            X          = (ushort)((r.RegionLocX / Constants.RegionSize) + x),
                            Y          = (ushort)((r.RegionLocY / Constants.RegionSize) + y),
                            SizeX      = (ushort)r.RegionSizeX,
                            SizeY      = (ushort)r.RegionSizeY
                        };
                        //Child piece, so ignore it
                        blocks.Add(block);
                    }
                }
            }
            return(blocks);
        }
        private void SendToEstate(uint EstateID, Dictionary <string, object> sendData)
        {
            List <UUID> regions = m_EstateModule.Scenes[0].GetEstateRegions((int)EstateID);

            UUID ScopeID = UUID.Zero;

            // Handle local regions locally
            //
            lock (m_EstateModule.Scenes)
            {
                foreach (Scene s in m_EstateModule.Scenes)
                {
                    if (regions.Contains(s.RegionInfo.RegionID))
                    {
                        // All regions in one estate are in the same scope.
                        // Use that scope.
                        //
                        ScopeID = s.RegionInfo.ScopeID;
                        regions.Remove(s.RegionInfo.RegionID);
                    }
                }
            }

            // Our own region should always be in the above list.
            // In a standalone this would not be true. But then,
            // Scope ID is not relevat there. Use first scope.
            //
            if (ScopeID == UUID.Zero)
            {
                ScopeID = m_EstateModule.Scenes[0].RegionInfo.ScopeID;
            }

            // Don't send to the same instance twice
            //
            List <string> done = new List <string>();

            // Send to remote regions
            //
            foreach (UUID regionID in regions)
            {
                GridRegion region = m_EstateModule.Scenes[0].GridService.GetRegionByUUID(ScopeID, regionID);
                if (region != null)
                {
                    string url = "http://" + region.ExternalHostName + ":" + region.HttpPort;
                    if (done.Contains(url))
                    {
                        continue;
                    }

                    Call(region, sendData);
                    done.Add(url);
                }
            }
        }
Ejemplo n.º 18
0
        private void OnRegionUp(GridRegion otherRegion)
        {
            // This shouldn't happen
            if (otherRegion == null)
                return;

            m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
                m_scene.RegionInfo.RegionName, otherRegion.RegionName, Util.WorldToRegionLoc((uint)otherRegion.RegionLocX), Util.WorldToRegionLoc((uint)otherRegion.RegionLocY));

            m_neighbours[otherRegion.RegionHandle] = otherRegion;
        }
        public bool AddOrUpdate(GridRegion rinfo, int expire)
        {
            //if (rinfo == null || disposed)
            if (rinfo == null)
            {
                return(false);
            }

            bool gotLock = false;

            try
            {
                try { }
                finally
                {
                    m_rwLock.EnterWriteLock();
                    gotLock = true;
                }

                int newexpire = (int)(Util.GetTimeStamp() - starttimeS) + expire;

                ulong handle = rinfo.RegionHandle & HANDLEMASK;
                if (m_expireControl.ContainsKey(handle))
                {
                    if (m_expireControl[handle] < newexpire)
                    {
                        m_expireControl[handle] = newexpire;
                    }
                }
                else
                {
                    m_expireControl[handle] = newexpire;
                }

                if (m_innerHandles.TryGetValue(handle, out GridRegion oldr))
                {
                    removeFromInner(oldr);
                }
                addToInner(rinfo);

                m_byHandler[handle] = rinfo;
                m_byName[rinfo.RegionName.ToLowerInvariant()] = rinfo;
                m_byUUID[rinfo.RegionID] = rinfo;
                return(true);
            }
            finally
            {
                if (gotLock)
                {
                    m_rwLock.ExitWriteLock();
                }
            }
        }
Ejemplo n.º 20
0
        public void TestCreateChildScenePresence()
        {
            TestHelpers.InMethod();
            //            log4net.Config.XmlConfigurator.Configure();

            LocalSimulationConnectorModule lsc = new LocalSimulationConnectorModule();

            IConfigSource configSource = new IniConfigSource();
            IConfig       config       = configSource.AddConfig("Modules");

            config.Set("SimulationServices", "LocalSimulationConnectorModule");

            SceneHelpers sceneHelpers = new SceneHelpers();
            TestScene    scene        = sceneHelpers.SetupScene();

            SceneHelpers.SetupSceneModules(scene, configSource, lsc);

            UUID             agentId = TestHelpers.ParseTail(0x01);
            AgentCircuitData acd     = SceneHelpers.GenerateAgentData(agentId);

            acd.child = true;

            GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName);
            string     reason;

            // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and
            // establish a child scene presence.  We pass in the circuit code that the client has to connect with ***
            // XXX: ViaLogin may not be correct here.
            EntityTransferContext ctx = new EntityTransferContext();

            scene.SimulationService.CreateAgent(null, region, acd, (uint)TeleportFlags.ViaLogin, ctx, out reason);

            Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
            Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));

            // There's no scene presence yet since only an agent circuit has been established.
            Assert.That(scene.GetScenePresence(agentId), Is.Null);

            // *** This is the second stage, where the client established a child agent/scene presence using the
            // circuit code given to the scene in stage 1 ***
            TestClient client = new TestClient(acd, scene);

            scene.AddNewAgent(client, PresenceType.User);

            Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
            Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));

            ScenePresence sp = scene.GetScenePresence(agentId);

            Assert.That(sp, Is.Not.Null);
            Assert.That(sp.UUID, Is.EqualTo(agentId));
            Assert.That(sp.IsChildAgent, Is.True);
        }
Ejemplo n.º 21
0
        private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
        {
            GridRegion region = new GridRegion(xcell, ycell);

            region.RegionName       = name;
            region.RegionID         = UUID.Random();
            region.ExternalHostName = "127.0.0.1";
            region.HttpPort         = 9000;
            region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);

            return(region);
        }
Ejemplo n.º 22
0
        public static OSDMap CrossAgent(GridRegion crossingRegion, Vector3 pos,
                                        Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, ulong RequestingRegion)
        {
            OSDMap llsdBody = new OSDMap();

            llsdBody.Add("Pos", pos);
            llsdBody.Add("Vel", velocity);
            llsdBody.Add("Region", crossingRegion.ToOSD());
            llsdBody.Add("Circuit", circuit.PackAgentCircuitData());
            llsdBody.Add("AgentData", cAgent.Pack());
            return(buildEvent("CrossAgent", llsdBody, circuit.AgentID, RequestingRegion));
        }
Ejemplo n.º 23
0
        public static OSDMap CrossAgent(GridRegion crossingRegion, Vector3 pos,
            Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, ulong RequestingRegion)
        {
            OSDMap llsdBody = new OSDMap();

            llsdBody.Add("Pos", pos);
            llsdBody.Add("Vel", velocity);
            llsdBody.Add("Region", crossingRegion.ToOSD());
            llsdBody.Add("Circuit", circuit.PackAgentCircuitData());
            llsdBody.Add("AgentData", cAgent.Pack());
            return buildEvent("CrossAgent", llsdBody, circuit.AgentID, RequestingRegion);
        }
Ejemplo n.º 24
0
        public void SuspendAvatar(IScenePresence presence, OpenSim.Services.Interfaces.GridRegion destination)
        {
            presence.AttachmentsLoaded = false;
            ISceneEntity[] attachments = GetAttachmentsForAvatar(presence.UUID);
            foreach (ISceneEntity group in attachments)
            {
                if (group.RootChild.AttachedPos != group.RootChild.SavedAttachedPos ||
                    group.RootChild.SavedAttachmentPoint != group.RootChild.AttachmentPoint)
                {
                    group.RootChild.SavedAttachedPos     = group.RootChild.AttachedPos;
                    group.RootChild.SavedAttachmentPoint = group.RootChild.AttachmentPoint;
                    //Make sure we get updated
                    group.HasGroupChanged = true;
                }

                // If an item contains scripts, it's always changed.
                // This ensures script state is saved on detach
                foreach (ISceneChildEntity p in group.ChildrenEntities())
                {
                    if (p.Inventory.ContainsScripts())
                    {
                        group.HasGroupChanged = true;
                        break;
                    }
                }
                if (group.HasGroupChanged)
                {
                    UUID assetID = UpdateKnownItem(presence.ControllingClient, group,
                                                   group.RootChild.FromUserInventoryItemID, group.OwnerID);
                    group.RootChild.FromUserInventoryAssetID = assetID;
                }
            }
            IAvatarAppearanceModule appearance = presence.RequestModuleInterface <IAvatarAppearanceModule>();

            if (appearance != null)
            {
                appearance.Appearance.SetAttachments(attachments);
            }
            IBackupModule backup = presence.Scene.RequestModuleInterface <IBackupModule>();

            if (backup != null)
            {
                bool sendUpdates = destination == null;
                if (!sendUpdates)
                {
                    List <OpenSim.Services.Interfaces.GridRegion> regions = presence.Scene.RequestModuleInterface <IGridRegisterModule>().GetNeighbors(presence.Scene);
                    regions.RemoveAll((r) => r.RegionID != destination.RegionID);
                    sendUpdates = regions.Count == 0;
                }
                backup.DeleteSceneObjects(attachments, false, sendUpdates);
            }
        }
        private void Lure(IClientAPI client, uint teleportflags, GridInstantMessage im)
        {
            Scene      scene    = client.Scene as Scene;
            UUID       regionID = new UUID(im.RegionID);
            GridRegion region   = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, regionID);

            if (region != null)
            {
                scene.RequestTeleportLocation(client, region.RegionHandle, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags);
            }
            else // we don't have that region here. Check if it's HG
            {
                string[] parts = im.message.Split(new char[] { '@' });
                if (parts.Length > 1)
                {
                    string url = parts[parts.Length - 1]; // the last part
                    if (m_thisGridInfo.IsLocalGrid(url, true) == 0)
                    {
                        m_log.DebugFormat("[HG LURE MODULE]: Luring agent to grid {0} region {1} position {2}", url, im.RegionID, im.Position);
                        GatekeeperServiceConnector gConn = new GatekeeperServiceConnector();
                        GridRegion gatekeeper            = new GridRegion();
                        gatekeeper.ServerURI = url;
                        string homeURI = scene.GetAgentHomeURI(client.AgentId);

                        string     message;
                        GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, regionID, client.AgentId, homeURI, out message);
                        if (finalDestination != null)
                        {
                            ScenePresence         sp          = scene.GetScenePresence(client.AgentId);
                            IEntityTransferModule transferMod = scene.RequestModuleInterface <IEntityTransferModule>();

                            if (transferMod != null && sp != null)
                            {
                                if (message != null)
                                {
                                    sp.ControllingClient.SendAgentAlertMessage(message, true);
                                }

                                transferMod.DoTeleport(
                                    sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f),
                                    Vector3.UnitX, teleportflags);
                            }
                        }
                        else
                        {
                            m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message);
                            client.SendAgentAlertMessage(message, true);
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
        private void OnRegionUp(GridRegion otherRegion)
        {
            // This shouldn't happen
            if (otherRegion == null)
            {
                return;
            }

            m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
                              m_scene.RegionInfo.RegionName, otherRegion.RegionName, Util.WorldToRegionLoc((uint)otherRegion.RegionLocX), Util.WorldToRegionLoc((uint)otherRegion.RegionLocY));

            m_neighbours[otherRegion.RegionHandle] = otherRegion;
        }
        public bool FriendshipTerminated(GridRegion region, UUID userID, UUID friendID)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "friendship_terminated";

            sendData["FromID"] = userID.ToString();
            sendData["ToID"]   = friendID.ToString();

            return(Call(region, sendData));
        }
Ejemplo n.º 28
0
        public bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();
            //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "friendship_approved";

            sendData["FromID"] = userID.ToString();
            sendData["FromName"] = userName;
            sendData["ToID"] = friendID.ToString();

            return Call(region, sendData);
        }
Ejemplo n.º 29
0
        public static OSDMap TeleportAgent(int DrawDistance, AgentCircuitData circuit,
                                           AgentData data, uint TeleportFlags,
                                           GridRegion destination, ulong requestingRegion)
        {
            OSDMap llsdBody = new OSDMap();

            llsdBody.Add("DrawDistance", DrawDistance);
            llsdBody.Add("Circuit", circuit.PackAgentCircuitData());
            llsdBody.Add("TeleportFlags", TeleportFlags);
            llsdBody.Add("AgentData", data.Pack());
            llsdBody.Add("Region", destination.ToOSD());
            return(buildEvent("TeleportAgent", llsdBody, circuit.AgentID, requestingRegion));
        }
        public bool StatusNotify(GridRegion region, UUID userID, string friendID, bool online)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "status";

            sendData["FromID"] = userID.ToString();
            sendData["ToID"]   = friendID;
            sendData["Online"] = online.ToString();

            return(Call(region, sendData));
        }
Ejemplo n.º 31
0
        public List <GridRegion> GetNeighbours(UUID regionID, List <UUID> scopeIDs, uint squareRangeFromCenterInMeters)
        {
            List <GridRegion> regions = new List <GridRegion>(0);
            GridRegion        region  = Get(regionID, scopeIDs);

            if (region != null)
            {
                int centerX = region.RegionLocX + (region.RegionSizeX / 2); // calculate center of region
                int centerY = region.RegionLocY + (region.RegionSizeY / 2); // calculate center of region

                regions = Get(scopeIDs, region.RegionID, centerX, centerY, squareRangeFromCenterInMeters);
            }

            return(regions);
        }
Ejemplo n.º 32
0
        public virtual bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message, string userName)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();
            //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "friendship_offered";

            sendData["FromID"] = userID.ToString();
            sendData["ToID"] = friendID.ToString();
            sendData["Message"] = message;
            if (userName != String.Empty)
                sendData["FromName"] = userName;

            return Call(region, sendData);
        }
        public bool GrantRights(GridRegion region, UUID userID, UUID friendID, int userFlags, int rights)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "grant_rights";

            sendData["FromID"]    = userID.ToString();
            sendData["ToID"]      = friendID.ToString();
            sendData["UserFlags"] = userFlags.ToString();
            sendData["Rights"]    = rights.ToString();

            return(Call(region, sendData));
        }
        public GridRegion Get(UUID scopeID, UUID regionID, out bool inCache)
        {
            inCache = false;

            GridRegion       rinfo = null;
            ScopedRegionUUID id    = new ScopedRegionUUID(scopeID, regionID);

            if (m_UUIDCache.TryGetValue(id, out rinfo))
            {
                inCache = true;
                return(rinfo);
            }

            return(null);
        }
Ejemplo n.º 35
0
 protected void OnMakeChildAgent(IScenePresence presence, GridRegion destination)
 {
     //Switch child agent to root agent
     m_rootAgents--;
     m_childAgents++;
 }
Ejemplo n.º 36
0
 public List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag)
 {
     List<MapBlockData> blocks = new List<MapBlockData>();
     MapBlockData block = new MapBlockData();
     if (r == null)
     {
         block.Access = (byte)SimAccess.Down;
         block.MapImageId = UUID.Zero;
         blocks.Add(block);
     }
     else
     {
         block.Access = r.Access;
         switch (flag & 0xffff)
         {
             case 0:
                 block.MapImageId = r.TerrainImage;
                 break;
             case 2:
                 block.MapImageId = r.ParcelImage;
                 break;
             default:
                 block.MapImageId = UUID.Zero;
                 break;
         }
         block.Name = r.RegionName;
         block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
         block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
         block.SizeX = (ushort)r.RegionSizeX;
         block.SizeY = (ushort)r.RegionSizeY;
         blocks.Add(block);
     }
     return blocks;
 }
 private void EventManager_OnMakeChildAgent(IScenePresence presence, GridRegion destination)
 {
     lock (scriptedcontrols)
     {
         scriptedcontrols.Clear(); //Remove all controls when we leave the region
     }
 }
Ejemplo n.º 38
0
        protected MapBlockData MapBlockFromGridRegion(GridRegion r, int x, int y)
        {
            MapBlockData block = new MapBlockData();
            if (r == null)
            {
                block.Access = (byte)SimAccess.NonExistent;
                block.X = (ushort)x;
                block.Y = (ushort)y;
                block.MapImageID = UUID.Zero;
                return block;
            }
            if ((r.Flags & (int)Aurora.Framework.RegionFlags.RegionOnline) == (int)Aurora.Framework.RegionFlags.RegionOnline)
                block.Access = r.Access;
            else
                block.Access = (byte)OpenMetaverse.SimAccess.Down;
            block.MapImageID = r.TerrainImage;
            block.Name = r.RegionName;
            block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
            block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
            block.SizeX = (ushort)r.RegionSizeX;
            block.SizeY = (ushort)r.RegionSizeY;

            return block;
        }
Ejemplo n.º 39
0
        public static OSD EnableChildAgents(int DrawDistance, GridRegion[] neighbors,
            AgentCircuitData circuit, uint TeleportFlags, AgentData data, byte[] IPAddress, int Port)
        {
            OSDMap llsdBody = new OSDMap();

            llsdBody.Add("DrawDistance", DrawDistance);
            OSDArray regionsArray = new OSDArray();
            foreach (GridRegion r in neighbors)
            {
                regionsArray.Add(r.ToOSD());
            }
            llsdBody.Add("Regions", regionsArray);
            if(IPAddress != null)
                llsdBody.Add("IPAddress", IPAddress);
            if(Port != 0) //0 is the eqivilent of null
                llsdBody.Add("Port", Port);
            llsdBody.Add("Circuit", circuit.PackAgentCircuitData());
            llsdBody.Add("TeleportFlags", TeleportFlags);
            if(data != null)
                llsdBody.Add("AgentData", data.Pack());
            return buildEvent("EnableChildAgents", llsdBody);
        }
Ejemplo n.º 40
0
        private void Lure(IClientAPI client, uint teleportflags, GridInstantMessage im)
        {
            Scene scene = (Scene)(client.Scene);
            GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(im.RegionID));
            if (region != null)
                scene.RequestTeleportLocation(client, region.RegionHandle, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags);
            else // we don't have that region here. Check if it's HG
            {
                string[] parts = im.message.Split(new char[] { '@' });
                if (parts.Length > 1)
                {
                    string url = parts[parts.Length - 1]; // the last part
                    if (url.Trim(new char[] {'/'}) != m_ThisGridURL.Trim(new char[] {'/'}))
                    {
                        m_log.DebugFormat("[HG LURE MODULE]: Luring agent to grid {0} region {1} position {2}", url, im.RegionID, im.Position);
                        GatekeeperServiceConnector gConn = new GatekeeperServiceConnector();
                        GridRegion gatekeeper = new GridRegion();
                        gatekeeper.ServerURI = url;
                        string homeURI = scene.GetAgentHomeURI(client.AgentId);

                        string message;
                        GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID), client.AgentId, homeURI, out message);
                        if (finalDestination != null)
                        {
                            ScenePresence sp = scene.GetScenePresence(client.AgentId);
                            IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>();

                            if (transferMod != null && sp != null)
                            {
                                if (message != null)
                                    sp.ControllingClient.SendAgentAlertMessage(message, true);

                                transferMod.DoTeleport(
                                    sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f),
                                    Vector3.UnitX, teleportflags);
                            }
                        }
                        else
                        {
                            m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message);
                            client.SendAgentAlertMessage(message, true);
                        }
                    }
                }
            }
        }
Ejemplo n.º 41
0
 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag)
 {
     block.Access = r.Access;
     switch (flag & 0xffff)
     {
     case 0:
         block.MapImageId = r.TerrainImage;
         break;
     case 2:
         block.MapImageId = r.ParcelImage;
         break;
     default:
         block.MapImageId = UUID.Zero;
         break;
     }
     block.Name = r.RegionName;
     block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
     block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
 }
Ejemplo n.º 42
0
 public override void OtherRegionUp(GridRegion otherRegion)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 43
0
        private bool Call(GridRegion region, Dictionary<string, object> sendData)
        {
            string reqString = ServerUtils.BuildQueryString(sendData);
            // m_log.DebugFormat("[XESTATE CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string url = "http://" + region.ExternalHostName + ":" + region.HttpPort;
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                        url + "/estate",
                        reqString);
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("RESULT"))
                    {
                        if (replyData["RESULT"].ToString().ToLower() == "true")
                            return true;
                        else
                            return false;
                    }
                    else
                        m_log.DebugFormat("[XESTATE CONNECTOR]: reply data does not contain result field");

                }
                else
                    m_log.DebugFormat("[XESTATE CONNECTOR]: received empty reply");
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[XESTATE CONNECTOR]: Exception when contacting remote sim: {0}", e.Message);
            }

            return false;
        }
Ejemplo n.º 44
0
 public override void OtherRegionUp(GridRegion otherRegion) {  }
Ejemplo n.º 45
0
        public static OSDMap TeleportAgent(int DrawDistance, AgentCircuitData circuit,
            AgentData data, uint TeleportFlags,
            GridRegion destination, ulong requestingRegion)
        {
            OSDMap llsdBody = new OSDMap();

            llsdBody.Add("DrawDistance", DrawDistance);
            llsdBody.Add("Circuit", circuit.PackAgentCircuitData());
            llsdBody.Add("TeleportFlags", TeleportFlags);
            llsdBody.Add("AgentData", data.Pack());
            llsdBody.Add("Region", destination.ToOSD());
            return buildEvent("TeleportAgent", llsdBody, circuit.AgentID, requestingRegion);
        }
Ejemplo n.º 46
0
        public void TestRegisterRegion()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            // Create 4 regions
            GridRegion r1 = new GridRegion();
            r1.RegionName = "Test Region 1";
            r1.RegionID = new UUID(1);
            r1.RegionLocX = 1000 * (int)Constants.RegionSize;
            r1.RegionLocY = 1000 * (int)Constants.RegionSize;
            r1.ExternalHostName = "127.0.0.1";
            r1.HttpPort = 9001;
            r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
            Scene s = new Scene(new RegionInfo());
            s.RegionInfo.RegionID = r1.RegionID;
            m_LocalConnector.AddRegion(s);
            
            GridRegion r2 = new GridRegion();
            r2.RegionName = "Test Region 2";
            r2.RegionID = new UUID(2);
            r2.RegionLocX = 1001 * (int)Constants.RegionSize;
            r2.RegionLocY = 1000 * (int)Constants.RegionSize;
            r2.ExternalHostName = "127.0.0.1";
            r2.HttpPort = 9002;
            r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
            s = new Scene(new RegionInfo());
            s.RegionInfo.RegionID = r2.RegionID;
            m_LocalConnector.AddRegion(s);

            GridRegion r3 = new GridRegion();
            r3.RegionName = "Test Region 3";
            r3.RegionID = new UUID(3);
            r3.RegionLocX = 1005 * (int)Constants.RegionSize;
            r3.RegionLocY = 1000 * (int)Constants.RegionSize;
            r3.ExternalHostName = "127.0.0.1";
            r3.HttpPort = 9003;
            r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
            s = new Scene(new RegionInfo());
            s.RegionInfo.RegionID = r3.RegionID;
            m_LocalConnector.AddRegion(s);

            GridRegion r4 = new GridRegion();
            r4.RegionName = "Other Region 4";
            r4.RegionID = new UUID(4);
            r4.RegionLocX = 1004 * (int)Constants.RegionSize;
            r4.RegionLocY = 1002 * (int)Constants.RegionSize;
            r4.ExternalHostName = "127.0.0.1";
            r4.HttpPort = 9004;
            r4.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
            s = new Scene(new RegionInfo());
            s.RegionInfo.RegionID = r4.RegionID;
            m_LocalConnector.AddRegion(s);

            m_LocalConnector.RegisterRegion(UUID.Zero, r1);

            GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test");
            Assert.IsNull(result, "Retrieved GetRegionByName \"Test\" is not null");

            result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test Region 1");
            Assert.IsNotNull(result, "Retrieved GetRegionByName is null");
            Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match");

            m_LocalConnector.RegisterRegion(UUID.Zero, r2);
            m_LocalConnector.RegisterRegion(UUID.Zero, r3);
            m_LocalConnector.RegisterRegion(UUID.Zero, r4);

            result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1));
            Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
            Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");

            result = m_LocalConnector.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
            Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
            Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");

            List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1));
            Assert.IsNotNull(results, "Retrieved neighbours list is null");
            Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected");
            Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match");

            results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10);
            Assert.IsNotNull(results, "Retrieved GetRegionsByName collection is null");
            Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected");

            results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize,
                900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize);
            Assert.IsNotNull(results, "Retrieved GetRegionRange collection is null");
            Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");

            results = m_LocalConnector.GetDefaultRegions(UUID.Zero);
            Assert.IsNotNull(results, "Retrieved GetDefaultRegions collection is null");
            Assert.That(results.Count, Is.EqualTo(1), "Retrieved default regions collection has not the expected size");
            Assert.That(results[0].RegionID, Is.EqualTo(new UUID(1)), "Retrieved default region's UUID does not match");

            results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r1.RegionLocX, r1.RegionLocY);
            Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 1 is null");
            Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 1 has not the expected size");
            Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions for default region are not in the expected order 2-4-3");
            Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions for default region are not in the expected order 2-4-3");
            Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions for default region are not in the expected order 2-4-3");

            results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r2.RegionLocX, r2.RegionLocY);
            Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 2 is null");
            Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 2 has not the expected size");
            Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 2-4-3");
            Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 2-4-3");
            Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 2-4-3");

            results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r3.RegionLocX, r3.RegionLocY);
            Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 3 is null");
            Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 3 has not the expected size");
            Assert.That(results[0].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 3-4-2");
            Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 3-4-2");
            Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 3-4-2");

            results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r4.RegionLocX, r4.RegionLocY);
            Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 4 is null");
            Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 4 has not the expected size");
            Assert.That(results[0].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 4-3-2");
            Assert.That(results[1].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 4-3-2");
            Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 4-3-2");

            results = m_LocalConnector.GetHyperlinks(UUID.Zero);
            Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null");
            Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected");
        }
Ejemplo n.º 47
0
 protected List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag)
 {
     List<MapBlockData> blocks = new List<MapBlockData>();
     MapBlockData block = new MapBlockData();
     if (r == null)
     {
         block.Access = (byte)SimAccess.Down;
         block.MapImageId = UUID.Zero;
         blocks.Add(block);
     }
     else
     {
         block.Access = r.Access;
         switch (flag & 0xffff)
         {
             case 0:
                 block.MapImageId = r.TerrainImage;
                 break;
             case 2:
                 block.MapImageId = r.ParcelImage;
                 break;
             default:
                 block.MapImageId = UUID.Zero;
                 break;
         }
         block.Name = r.RegionName;
         block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
         block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
         block.SizeX = (ushort)r.RegionSizeX;
         block.SizeY = (ushort)r.RegionSizeY;
         blocks.Add(block);
         // If these are larger than legacy regions, create fake map entries for the covered
         //    regions. The map system only does legacy sized regions so we have to fake map
         //    entries for all the covered regions.
         if (r.RegionSizeX > Constants.RegionSize || r.RegionSizeY > Constants.RegionSize)
         {
             for (int x = 0; x < r.RegionSizeX / Constants.RegionSize; x++)
             {
                 for (int y = 0; y < r.RegionSizeY / Constants.RegionSize; y++)
                 {
                     if (x == 0 && y == 0)
                         continue;
                     block = new MapBlockData
                                 {
                                     Access = r.Access,
                                     MapImageId = r.TerrainImage,
                                     Name = r.RegionName,
                                     X = (ushort)((r.RegionLocX / Constants.RegionSize) + x),
                                     Y = (ushort)((r.RegionLocY / Constants.RegionSize) + y),
                                     SizeX = (ushort)r.RegionSizeX,
                                     SizeY = (ushort)r.RegionSizeY
                                 };
                     //Child piece, so ignore it
                     blocks.Add(block);
                 }
             }
         }
     }
     return blocks;
 }
Ejemplo n.º 48
0
 protected List<MapBlockData> Map2BlockFromGridRegion (GridRegion r)
 {
     List<MapBlockData> blocks = new List<MapBlockData> ();
     MapBlockData block = new MapBlockData ();
     if (r == null)
     {
         block.Access = (byte)SimAccess.Down;
         block.MapImageID = UUID.Zero;
         blocks.Add (block);
         return blocks;
     }
     block.Access = r.Access;
     block.MapImageID = r.TerrainImage;
     if ((r.Access & (byte)SimAccess.Down) == (byte)SimAccess.Down)
         block.Name = r.RegionName + " (offline)";
     else
         block.Name = r.RegionName;
     block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
     block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
     block.SizeX = (ushort)r.RegionSizeX;
     block.SizeY = (ushort)r.RegionSizeY;
     blocks.Add(block);
     if (r.RegionSizeX > Constants.RegionSize || r.RegionSizeY > Constants.RegionSize)
     {
         for (int x = 0; x < r.RegionSizeX / Constants.RegionSize; x++)
         {
             for (int y = 0; y < r.RegionSizeY / Constants.RegionSize; y++)
             {
                 if (x == 0 && y == 0)
                     continue;
                 block = new MapBlockData
                             {
                                 Access = r.Access,
                                 MapImageID = r.TerrainImage,
                                 Name = r.RegionName,
                                 X = (ushort) ((r.RegionLocX/Constants.RegionSize) + x),
                                 Y = (ushort) ((r.RegionLocY/Constants.RegionSize) + y),
                                 SizeX = (ushort) r.RegionSizeX,
                                 SizeY = (ushort) r.RegionSizeY
                             };
                 //Child piece, so ignore it
                 blocks.Add (block);
             }
         }
     }
     return blocks;
 }
Ejemplo n.º 49
0
 protected MapBlockData TerrainBlockFromGridRegion(GridRegion r)
 {
     MapBlockData block = new MapBlockData();
     if (r == null)
     {
         block.Access = (byte)SimAccess.Down;
         block.MapImageID = UUID.Zero;
         return block;
     }
     block.Access = r.Access;
     block.MapImageID = r.TerrainMapImage;
     if ((r.Access & (byte)SimAccess.Down) == (byte)SimAccess.Down)
         block.Name = r.RegionName + " (offline)";
     else
         block.Name = r.RegionName;
     block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
     block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
     block.SizeX = (ushort)r.RegionSizeX;
     block.SizeY = (ushort)r.RegionSizeY;
     return block;
 }
Ejemplo n.º 50
0
 public void TriggerOnRegionUp(GridRegion otherRegion)
 {
     handlerOnRegionUp = OnRegionUp;
     if (handlerOnRegionUp != null)
         handlerOnRegionUp(otherRegion);
 }
Ejemplo n.º 51
0
        public void OnRegionUp(GridRegion otherRegion)
        {
            ulong regionhandle = otherRegion.RegionHandle;
            string httpserver = otherRegion.ServerURI + "MAP/MapItems/" + regionhandle.ToString();

            lock (m_blacklistedregions)
            {
                if (!m_blacklistedregions.ContainsKey(regionhandle))
                    m_blacklistedregions.Remove(regionhandle);
            }

            lock (m_blacklistedurls)
            {
                if (m_blacklistedurls.ContainsKey(httpserver))
                    m_blacklistedurls.Remove(httpserver);
            }

            lock (m_cachedRegionMapItemsAddress)
            {
                if (!m_cachedRegionMapItemsAddress.ContainsKey(regionhandle))
                    m_cachedRegionMapItemsAddress.Remove(regionhandle);
            }
        }
        protected void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout)
        {
            if (gridLogout && m_RestrictInventoryAccessAbroad)
            {
                IUserManagement uMan = m_Scene.RequestModuleInterface<IUserManagement>();
                if (uMan != null && uMan.IsLocalGridUser(client.AgentId))
                {
                    // local grid user
                    ProcessInventoryForHypergriding(client);
                }
                else
                {
                    // Foreigner
                    ProcessInventoryForLeaving(client);
                }
            }

        }
Ejemplo n.º 53
0
 public void TriggerCrossAgentToNewRegion(ScenePresence agent, bool isFlying, GridRegion newRegion)
 {
     CrossAgentToNewRegion handlerCrossAgentToNewRegion = OnCrossAgentToNewRegion;
     if (handlerCrossAgentToNewRegion != null)
     {
         foreach (CrossAgentToNewRegion d in handlerCrossAgentToNewRegion.GetInvocationList())
         {
             try
             {
                 d(agent, isFlying, newRegion);
             }
             catch (Exception e)
             {
                 m_log.ErrorFormat(
                     "[EVENT MANAGER]: Delegate for TriggerCrossAgentToNewRegion failed - continuing.  {0} {1}",
                     e.Message, e.StackTrace);
             }
         }
     }
 }
Ejemplo n.º 54
0
 public void TriggerOnRegionUp(GridRegion otherRegion)
 {
     RegionUp handlerOnRegionUp = OnRegionUp;
     if (handlerOnRegionUp != null)
     {
         foreach (RegionUp d in handlerOnRegionUp.GetInvocationList())
         {
             try
             {
                 d(otherRegion);
             }
             catch (Exception e)
             {
                 m_log.ErrorFormat(
                     "[EVENT MANAGER]: Delegate for TriggerOnRegionUp failed - continuing.  {0} {1}", 
                     e.Message, e.StackTrace);
             }
         }
     }
 }
Ejemplo n.º 55
0
 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)
 {
     block.Access = r.Access;
     block.MapImageId = r.TerrainImage;
     block.Name = r.RegionName;
     block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
     block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
 }
Ejemplo n.º 56
0
        public void TestRegisterRegionV0_2()
        {
            SetUp();

            // Create 3 regions
            GridRegion r1 = new GridRegion();
            r1.RegionName = "Test Region 1";
            r1.RegionID = new UUID(1);
            r1.RegionLocX = 1000 * (int)Constants.RegionSize;
            r1.RegionLocY = 1000 * (int)Constants.RegionSize;
            r1.ExternalHostName = "127.0.0.1";
            r1.HttpPort = 9001;
            r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
            Scene s = new Scene(new RegionInfo());
            s.RegionInfo.RegionID = r1.RegionID;
            m_LocalConnector.AddRegion(s);
            

            GridRegion r2 = new GridRegion();
            r2.RegionName = "Test Region 2";
            r2.RegionID = new UUID(2);
            r2.RegionLocX = 1001 * (int)Constants.RegionSize;
            r2.RegionLocY = 1000 * (int)Constants.RegionSize;
            r2.ExternalHostName = "127.0.0.1";
            r2.HttpPort = 9002;
            r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
            s = new Scene(new RegionInfo());
            s.RegionInfo.RegionID = r1.RegionID;
            m_LocalConnector.AddRegion(s);

            GridRegion r3 = new GridRegion();
            r3.RegionName = "Test Region 3";
            r3.RegionID = new UUID(3);
            r3.RegionLocX = 1005 * (int)Constants.RegionSize;
            r3.RegionLocY = 1000 * (int)Constants.RegionSize;
            r3.ExternalHostName = "127.0.0.1";
            r3.HttpPort = 9003;
            r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
            s = new Scene(new RegionInfo());
            s.RegionInfo.RegionID = r1.RegionID;
            m_LocalConnector.AddRegion(s);

            m_LocalConnector.RegisterRegion(UUID.Zero, r1);
            GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test");
            Assert.IsNotNull(result, "Retrieved GetRegionByName is null");
            Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match");

            result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1));
            Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
            Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");

            result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize);
            Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
            Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");

            m_LocalConnector.RegisterRegion(UUID.Zero, r2);
            m_LocalConnector.RegisterRegion(UUID.Zero, r3);

            List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1));
            Assert.IsNotNull(results, "Retrieved neighbours list is null");
            Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected");
            Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match");

            results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10);
            Assert.IsNotNull(results, "Retrieved GetRegionsByName list is null");
            Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected");

            results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize,
                900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize);
            Assert.IsNotNull(results, "Retrieved GetRegionRange list is null");
            Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");
        }
Ejemplo n.º 57
0
        public void TriggerTeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout)
        {
            TeleportStart handler = OnTeleportStart;

            if (handler != null)
            {
                foreach (TeleportStart d in handler.GetInvocationList())
                {
                    try
                    {
                        d(client, destination, finalDestination, teleportFlags, gridLogout);
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TeleportStart failed - continuing {0} - {1}",
                            e.Message, e.StackTrace);
                    }
                }
            }
        }
Ejemplo n.º 58
0
 public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
 {
 }
Ejemplo n.º 59
0
        // Fill a passed MapBlockData from a GridRegion
        public MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag)
        {
            MapBlockData block = new MapBlockData();

            block.Access = r.Access;
            switch (flag & 0xffff)
            {
                case 0:
                    block.MapImageId = r.TerrainImage;
                    break;
                case 2:
                    block.MapImageId = r.ParcelImage;
                    break;
                default:
                    block.MapImageId = UUID.Zero;
                    break;
            }
            block.Name = r.RegionName;
            block.X = (ushort)Util.WorldToRegionLoc((uint)r.RegionLocX);
            block.Y = (ushort)Util.WorldToRegionLoc((uint)r.RegionLocY);
            block.SizeX = (ushort) r.RegionSizeX;
            block.SizeY = (ushort) r.RegionSizeY;

            return block;
        }
Ejemplo n.º 60
0
        public void OnRegionUp(GridRegion otherRegion)
        {
            ulong regionhandle = otherRegion.RegionHandle;
            string httpserver = otherRegion.ServerURI + "MAP/MapItems/" + regionhandle.ToString();

            m_blacklistedregions.Remove(regionhandle);

            m_blacklistedurls.Remove(httpserver);

            m_cachedRegionMapItemsAddress.Remove(regionhandle);
        }