public virtual void Teleport (IScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) { int x = 0, y = 0; Util.UlongToInts (regionHandle, out x, out y); GridRegion reg = sp.Scene.GridService.GetRegionByPosition (sp.ControllingClient.AllScopeIDs, x, y); if (reg == null) { List<GridRegion> regions = sp.Scene.GridService.GetRegionRange ( sp.ControllingClient.AllScopeIDs, x - (sp.Scene.GridService.GetRegionViewSize () * sp.Scene.RegionInfo.RegionSizeX), x + (sp.Scene.GridService.GetRegionViewSize () * sp.Scene.RegionInfo.RegionSizeX), y - (sp.Scene.GridService.GetRegionViewSize () * sp.Scene.RegionInfo.RegionSizeY), y + (sp.Scene.GridService.GetRegionViewSize () * sp.Scene.RegionInfo.RegionSizeY) ); foreach (GridRegion r in regions) { if (r.RegionLocX <= x && r.RegionLocX + r.RegionSizeX > x && r.RegionLocY <= y && r.RegionLocY + r.RegionSizeY > y) { reg = r; position.X += x - reg.RegionLocX; position.Y += y - reg.RegionLocY; break; } } if (reg == null) { // TP to a place that doesn't exist (anymore) // Inform the viewer about that sp.ControllingClient.SendTeleportFailed ("The region you tried to teleport to doesn't exist anymore"); // and set the map-tile to '(Offline)' int regX, regY; Util.UlongToInts (regionHandle, out regX, out regY); MapBlockData block = new MapBlockData { X = (ushort)(regX / Constants.RegionSize), Y = (ushort)(regY / Constants.RegionSize), Access = 254 }; // == not there List<MapBlockData> blocks = new List<MapBlockData> { block }; sp.ControllingClient.SendMapBlock (blocks, 0); return; } } Teleport (sp, reg, position, lookAt, teleportFlags); }
private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) { if (mapName.Length < 1) { remoteClient.SendAlertMessage("Use a search string with at least 1 character"); return; } bool TryCoordsSearch = false; int XCoord = 0; int YCoord = 0; string[] splitSearch = mapName.Split(','); if (splitSearch.Length != 1) { if (splitSearch[1].StartsWith(" ")) splitSearch[1] = splitSearch[1].Remove(0, 1); if (int.TryParse(splitSearch[0], out XCoord) && int.TryParse(splitSearch[1], out YCoord)) TryCoordsSearch = true; } List<MapBlockData> blocks = new List<MapBlockData>(); List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(remoteClient.AllScopeIDs, mapName, 0, 20); if (TryCoordsSearch) { GridRegion region = m_scene.GridService.GetRegionByPosition(remoteClient.AllScopeIDs, XCoord*Constants.RegionSize, YCoord*Constants.RegionSize); if (region != null) { region.RegionName = mapName + " - " + region.RegionName; regionInfos.Add(region); } } List<GridRegion> allRegions = new List<GridRegion>(); if (regionInfos != null) { foreach (GridRegion region in regionInfos) { //Add the found in search region first if (!allRegions.Contains(region)) { allRegions.Add(region); blocks.Add(SearchMapBlockFromGridRegion(region)); } //Then send surrounding regions List<GridRegion> regions = m_scene.GridService.GetRegionRange(remoteClient.AllScopeIDs, (region.RegionLocX - (4*Constants.RegionSize)), (region.RegionLocX + (4*Constants.RegionSize)), (region.RegionLocY - (4*Constants.RegionSize)), (region.RegionLocY + (4*Constants.RegionSize))); if (regions != null) { foreach (GridRegion r in regions) { if (!allRegions.Contains(region)) { allRegions.Add(region); blocks.Add(SearchMapBlockFromGridRegion(r)); } } } } } // final block, closing the search result MapBlockData data = new MapBlockData { Agents = 0, Access = 255, MapImageID = UUID.Zero, Name = mapName, RegionFlags = 0, WaterHeight = 0, X = 0, Y = 0, SizeX = 256, SizeY = 256 }; // not used blocks.Add(data); remoteClient.SendMapBlock(blocks, flags); }
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.Flags & (int)RegionFlags.RegionOnline) != (int)RegionFlags.RegionOnline) 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; }
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) RegionFlags.RegionOnline) == (int) 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; }
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; } if ((r.Flags & (int) RegionFlags.RegionOnline) == (int) 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; 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; }
protected MapBlockData MapBlockFromGridRegion (GridRegion r, int flag) { MapBlockData block = new MapBlockData (); if (r == null) { block.Access = (byte)SimAccess.Down; block.MapImageID = UUID.Zero; return block; } block.Access = r.Access; if ((flag & 0xffff) == 0) block.MapImageID = r.TerrainImage; if ((flag & 0xffff) == 1) block.MapImageID = r.TerrainMapImage; if ((flag & 0xffff) == 2) block.MapImageID = r.ParcelMapImage; 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; }