Ejemplo n.º 1
0
        private void HandleMapNameRequest(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (MapNameRequest)m;

            if (req.CircuitAgentID != req.AgentID ||
                req.CircuitSessionID != req.SessionID)
            {
                return;
            }

#if DEBUG
            m_Log.InfoFormat("MapNameRequest for {0}", req.Name);
#endif
            var results = new List <MapBlockReply.DataEntry>();

            var regionAddress = new RegionAddress(req.Name);
            /* checking for targetting grid simplifies usability since user has not to think about from where */
            if (regionAddress.IsForeignGrid && !regionAddress.TargetsGatekeeperUri(scene.GatekeeperURI))
            {
#if DEBUG
                m_Log.InfoFormat("MapNameRequest for foreign at {0} region={1}", regionAddress.GatekeeperUri, regionAddress.RegionName);
#endif

                RegionInfo ri = null;
                var        foundRegionButWrongProtocol = false;
                var        foundProtocolName           = string.Empty;
                string     message;
                foreach (var foreignGrid in m_ForeignGridConnectorPlugins)
                {
#if DEBUG
                    m_Log.DebugFormat("Testing foreign grid protocol \"{0}\"", foreignGrid.DisplayName);
#endif
                    if (foreignGrid.IsProtocolSupported(regionAddress.GatekeeperUri))
                    {
                        try
                        {
                            if (!foreignGrid.Instantiate(regionAddress.GatekeeperUri).TryGetValue(regionAddress.RegionName, out ri, out message))
                            {
#if DEBUG
                                m_Log.DebugFormat("Foreign grid \"{0}\" does not have the region \"{1}\"", regionAddress.GatekeeperUri, regionAddress.RegionName);
#endif
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            m_Log.Error("Failed to connect to grid " + regionAddress.GatekeeperUri, e);
                            continue;
                        }

                        if (!foreignGrid.IsAgentSupported(agent.SupportedGridTypes))
                        {
                            foundRegionButWrongProtocol = true;
                            foundProtocolName           = agent.DisplayName;
                            ri = null;
                        }
                        else
                        {
#if DEBUG
                            m_Log.DebugFormat("Selected protocol \"{0}\" region => \"{1}\"", foreignGrid.Name, ri.Name);
#endif
                            break;
                        }
                    }
                    else
                    {
#if DEBUG
                        m_Log.DebugFormat("Foreign grid protocol \"{0}\" not supported for \"{1}\"", foreignGrid.DisplayName, regionAddress.GatekeeperUri);
#endif
                    }
                }

                if (ri == null && foundRegionButWrongProtocol)
                {
                    agent.SendAlertMessage(string.Format(this.GetLanguageString(agent.CurrentCulture, "YourHomeGridDoesNotSupportSelectedTargetGrid0", "Your home grid does not support the selected target grid (running {0})."), foundProtocolName), scene.ID);
                }
                else if (ri != null)
                {
                    var hgLoc = agent.CacheInterGridDestination(ri);
                    results.Add(new MapBlockReply.DataEntry
                    {
                        /* we map foreign grid locations in specific agent only */
                        X           = hgLoc.GridX,
                        Y           = hgLoc.GridY,
                        SizeX       = ri.Size.GridX,
                        SizeY       = ri.Size.GridY,
                        Name        = req.Name,
                        Access      = ri.Access,
                        RegionFlags = RegionOptionFlags.None, /* this is same region flags as seen on a sim */
                        WaterHeight = 21,
                        Agents      = 0,
                        MapImageID  = ri.RegionMapTexture
                    });
                }
            }
            else if (string.IsNullOrEmpty(regionAddress.RegionName))
            {
                agent.SendAlertMessage(this.GetLanguageString(agent.CurrentCulture, "PleaseEnterAString", "Please enter a string"), scene.ID);
            }
            else
            {
#if DEBUG
                m_Log.InfoFormat("MapNameRequest for {0} at local grid", regionAddress.RegionName);
#endif

                var service = scene.GridService;
                if (service != null)
                {
                    List <RegionInfo> ris;
                    try
                    {
                        ris = service.SearchRegionsByName(regionAddress.RegionName);
                    }
                    catch
                    {
                        ris = new List <RegionInfo>();
                    }

                    foreach (var ri in ris)
                    {
                        results.Add(new MapBlockReply.DataEntry
                        {
                            X     = ri.Location.GridX,
                            Y     = ri.Location.GridY,
                            SizeX = ri.Size.GridX,
                            SizeY = ri.Size.GridY,

                            Name        = ri.Name,
                            Access      = ri.Access,
                            RegionFlags = RegionOptionFlags.None, /* this is same region flags as seen on a sim */
                            WaterHeight = 21,
                            Agents      = 0,
                            MapImageID  = ri.RegionMapTexture
                        });
                    }
                }
            }

            SendMapBlocks(agent, scene, req.Flags, results);
        }
Ejemplo n.º 2
0
        private void HandleMapItemRequest(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (MapItemRequest)m;

            if (req.CircuitAgentID != req.AgentID ||
                req.CircuitSessionID != req.SessionID)
            {
                return;
            }

            var reply = new MapItemReply
            {
                AgentID  = agent.ID,
                Flags    = req.Flags,
                ItemType = req.ItemType
            };
            SceneInterface accessScene = null;

            if (req.Location.RegionHandle == 0 ||
                req.Location.Equals(scene.GridPosition))
            {
                accessScene = scene;
            }
            else
            {
                try
                {
                    accessScene = m_Scenes[req.Location];
                }
                catch
                {
                    accessScene = null; /* remote */
                }
            }

            switch (req.ItemType)
            {
            case MapItemType.AgentLocations:
                if (accessScene != null)
                {
                    /* local */
                    foreach (var sceneagent in accessScene.Agents)
                    {
                        if (sceneagent.IsInScene(accessScene) && !sceneagent.Owner.Equals(agent.Owner) && sceneagent is ViewerAgent)
                        {
                            var d = new MapItemReply.DataEntry
                            {
                                X      = (ushort)sceneagent.GlobalPosition.X,
                                Y      = (ushort)sceneagent.GlobalPosition.Y,
                                ID     = UUID.Zero,
                                Name   = sceneagent.NamedOwner.FullName,
                                Extra  = 1,
                                Extra2 = 0
                            };
                            reply.Data.Add(d);
                        }
                    }
                }
                else
                {
                    /* remote */
                }
                break;

            case MapItemType.LandForSale:
                if (accessScene != null)
                {
                    /* local */
                    foreach (var parcel in accessScene.Parcels)
                    {
                        if ((parcel.Flags & ParcelFlags.ForSale) != 0)
                        {
                            var    d = new MapItemReply.DataEntry();
                            double x = (parcel.AABBMin.X + parcel.AABBMax.X) / 2;
                            double y = (parcel.AABBMin.Y + parcel.AABBMax.Y) / 2;
                            d.X      = (ushort)x;
                            d.Y      = (ushort)y;
                            d.ID     = parcel.ID;
                            d.Name   = parcel.Name;
                            d.Extra  = parcel.Area;
                            d.Extra2 = parcel.SalePrice;
                            reply.Data.Add(d);
                        }
                    }
                }
                else
                {
                    /* remote */
                }
                break;

            case MapItemType.Telehub:
                if (accessScene != null)
                {
                    /* local */
                }
                else
                {
                    /* remote */
                }
                break;
            }
            agent.SendMessageAlways(reply, scene.ID);
        }
Ejemplo n.º 3
0
 public DispatchRegionInfo(ViewerAgent agent, SceneInterface scene, string remoteip)
 {
     m_Agent    = agent;
     m_Scene    = scene;
     m_RemoteIP = remoteip;
 }