Example #1
0
        private static void ReadLinkFromConfig(IConfig config, Scene scene)
        {
            RegionInfo regInfo;
            uint       xloc, yloc;
            uint       externalPort;
            string     externalHostName;
            uint       realXLoc, realYLoc;

            xloc             = Convert.ToUInt32(config.GetString("xloc", "0"));
            yloc             = Convert.ToUInt32(config.GetString("yloc", "0"));
            externalPort     = Convert.ToUInt32(config.GetString("externalPort", "0"));
            externalHostName = config.GetString("externalHostName", "");
            realXLoc         = Convert.ToUInt32(config.GetString("real-xloc", "0"));
            realYLoc         = Convert.ToUInt32(config.GetString("real-yloc", "0"));

            if (m_enableAutoMapping)
            {
                xloc = (uint)((xloc % 100) + m_autoMappingX);
                yloc = (uint)((yloc % 100) + m_autoMappingY);
            }

            if (((realXLoc == 0) && (realYLoc == 0)) ||
                (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
                 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
            {
                if (HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
                {
                    regInfo.RegionName = config.GetString("localName", "");
                }
            }
        }
Example #2
0
        private void OnMapNameRequest(IClientAPI remoteClient, string mapName)
        {
            if (mapName.Length < 3)
            {
                remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
                return;
            }

            // try to fetch from GridServer
            List <RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20);

            if (regionInfos == null)
            {
                m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?");
                // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
                regionInfos = new List <RegionInfo>();
                RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
                if (info != null)
                {
                    regionInfos.Add(info);
                }
            }

            if ((regionInfos.Count == 0) && IsHypergridOn())
            {
                // OK, we tried but there are no regions matching that name.
                // Let's check quickly if this is a domain name, and if so link to it
                if (mapName.Contains(".") && mapName.Contains(":"))
                {
                    // It probably is a domain name. Try to link to it.
                    RegionInfo regInfo;
                    Scene      cScene = GetClientScene(remoteClient);
                    regInfo = HGHyperlink.TryLinkRegion(cScene, remoteClient, mapName);
                    if (regInfo != null)
                    {
                        regionInfos.Add(regInfo);
                    }
                }
            }

            List <MapBlockData> blocks = new List <MapBlockData>();

            MapBlockData data;

            if (regionInfos.Count > 0)
            {
                foreach (RegionInfo info in regionInfos)
                {
                    data             = new MapBlockData();
                    data.Agents      = 0;
                    data.Access      = info.AccessLevel;
                    data.MapImageId  = info.RegionSettings.TerrainImageID;
                    data.Name        = info.RegionName;
                    data.RegionFlags = 0; // TODO not used?
                    data.WaterHeight = 0; // not used
                    data.X           = (ushort)info.RegionLocX;
                    data.Y           = (ushort)info.RegionLocY;
                    blocks.Add(data);
                }
            }

            // final block, closing the search result
            data             = new MapBlockData();
            data.Agents      = 0;
            data.Access      = 255;
            data.MapImageId  = UUID.Zero;
            data.Name        = mapName;
            data.RegionFlags = 0;
            data.WaterHeight = 0; // not used
            data.X           = 0;
            data.Y           = 0;
            blocks.Add(data);

            remoteClient.SendMapBlock(blocks, 0);
        }
Example #3
0
        public static void RunHGCommand(string command, string[] cmdparams, Scene scene)
        {
            if (command.Equals("link-mapping"))
            {
                if (cmdparams.Length == 2)
                {
                    try
                    {
                        m_autoMappingX      = Convert.ToUInt32(cmdparams[0]);
                        m_autoMappingY      = Convert.ToUInt32(cmdparams[1]);
                        m_enableAutoMapping = true;
                    }

                    catch (Exception)
                    {
                        m_autoMappingX      = 0;
                        m_autoMappingY      = 0;
                        m_enableAutoMapping = false;
                    }
                }
            }
            else if (command.Equals("link-region"))
            {
                if (cmdparams.Length < 3)
                {
                    if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
                    {
                        LoadXmlLinkFile(cmdparams, scene);
                    }
                    else
                    {
                        LinkRegionCmdUsage();
                    }

                    return;
                }

                if (cmdparams[2].Contains(":"))
                {
                    // New format
                    uint   xloc, yloc;
                    string mapName;

                    try
                    {
                        xloc    = Convert.ToUInt32(cmdparams[0]);
                        yloc    = Convert.ToUInt32(cmdparams[1]);
                        mapName = cmdparams[2];

                        if (cmdparams.Length > 3)
                        {
                            for (int i = 3; i < cmdparams.Length; i++)
                            {
                                mapName += " " + cmdparams[i];
                            }
                        }

                        m_log.Info(">> MapName: " + mapName);
                    }

                    catch (Exception e)
                    {
                        m_log.Warn("[Hyper Grid]: Wrong format for link-region command: " + e.Message);
                        LinkRegionCmdUsage();
                        return;
                    }

                    HGHyperlink.TryLinkRegionToCoords(scene, null, mapName, xloc, yloc);
                }
                else
                {
                    // old format
                    RegionInfo regInfo;
                    uint       xloc, yloc;
                    uint       externalPort;
                    string     externalHostName;

                    try
                    {
                        xloc             = Convert.ToUInt32(cmdparams[0]);
                        yloc             = Convert.ToUInt32(cmdparams[1]);
                        externalPort     = Convert.ToUInt32(cmdparams[3]);
                        externalHostName = cmdparams[2];
                    }
                    catch (Exception e)
                    {
                        m_log.Warn("[Hyper Grid]: Wrong format for link-region command: " + e.Message);
                        LinkRegionCmdUsage();
                        return;
                    }

                    if (HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
                    {
                        if (cmdparams.Length >= 5)
                        {
                            regInfo.RegionName = "";

                            for (int i = 4; i < cmdparams.Length; i++)
                            {
                                regInfo.RegionName += cmdparams[i] + " ";
                            }
                        }
                    }
                }

                return;
            }
            else if (command.Equals("unlink-region"))
            {
                if (cmdparams.Length < 1)
                {
                    UnlinkRegionCmdUsage();
                    return;
                }

                if (HGHyperlink.TryUnlinkRegion(scene, cmdparams[0]))
                {
                    m_log.InfoFormat("[Hyper Grid]: Successfully unlinked {0}", cmdparams[0]);
                }
                else
                {
                    m_log.InfoFormat("[Hyper Grid]: Unable to unlink {0}, region not found", cmdparams[0]);
                }
            }
        }