From 98d1e7768af945d3516243f3e010cc4e1fc0788a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 10 Jun 2011 09:16:43 -0700 Subject: New method for resetting the map on HG: do it only once upon changing grids, and reset only exactly the map blocks that had regions in them. WARNING: this fetches all the regions from the Grid service, so there is a chance that this is a really bad idea in large grids. Pushing it for testing. --- .../EntityTransfer/HGEntityTransferModule.cs | 26 +++++++++ .../CoreModules/Hypergrid/HGWorldMapModule.cs | 66 +++++++++++----------- 2 files changed, 59 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 37d81a3..8df89ad 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -147,8 +147,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { base.AgentHasMovedAway(sp, logout); if (logout) + { + // Reset the map + ResetMap(sp); + // Log them out of this grid m_aScene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); + } } protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) @@ -280,6 +285,27 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } + protected void ResetMap(ScenePresence sp) + { + List regions = m_Scenes[0].GridService.GetRegionRange(m_Scenes[0].RegionInfo.ScopeID, 0, 17000 * (int)Constants.RegionSize, 0, 17000 * (int)Constants.RegionSize); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Resetting {0} tiles on the map", regions.Count); + if (regions != null) + { + List mapBlocks = new List(); + foreach (GridRegion r in regions) + { + MapBlockData mblock = new MapBlockData(); + mblock.X = (ushort)(r.RegionLocX / Constants.RegionSize); + mblock.Y = (ushort)(r.RegionLocY / Constants.RegionSize); + mblock.Name = ""; + mblock.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's + mblock.MapImageId = UUID.Zero; + mapBlocks.Add(mblock); + } + sp.ControllingClient.SendMapBlock(mapBlocks, 0); + } + + } #endregion diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index f066f83..fd2cc20 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs @@ -59,44 +59,44 @@ namespace OpenSim.Region.CoreModules.Hypergrid #endregion - protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) - { - List mapBlocks = new List(); - List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, - minX * (int)Constants.RegionSize, maxX * (int)Constants.RegionSize, - minY * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize); + //protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) + //{ + // List mapBlocks = new List(); + // List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, + // minX * (int)Constants.RegionSize, maxX * (int)Constants.RegionSize, + // minY * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize); - foreach (GridRegion r in regions) - { - uint x = 0, y = 0; - long handle = 0; - if (r.RegionSecret != null && r.RegionSecret != string.Empty) - { - if (long.TryParse(r.RegionSecret, out handle)) - { - Utils.LongToUInts((ulong)handle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - } - } + // foreach (GridRegion r in regions) + // { + // uint x = 0, y = 0; + // long handle = 0; + // if (r.RegionSecret != null && r.RegionSecret != string.Empty) + // { + // if (long.TryParse(r.RegionSecret, out handle)) + // { + // Utils.LongToUInts((ulong)handle, out x, out y); + // x = x / Constants.RegionSize; + // y = y / Constants.RegionSize; + // } + // } - if (handle == 0 || - // Check the distance from the current region - (handle != 0 && Math.Abs((int)(x - m_scene.RegionInfo.RegionLocX)) < 4096 && Math.Abs((int)(y - m_scene.RegionInfo.RegionLocY)) < 4096)) - { - MapBlockData block = new MapBlockData(); - MapBlockFromGridRegion(block, r); - mapBlocks.Add(block); - } - } + // if (handle == 0 || + // // Check the distance from the current region + // (handle != 0 && Math.Abs((int)(x - m_scene.RegionInfo.RegionLocX)) < 4096 && Math.Abs((int)(y - m_scene.RegionInfo.RegionLocY)) < 4096)) + // { + // MapBlockData block = new MapBlockData(); + // MapBlockFromGridRegion(block, r); + // mapBlocks.Add(block); + // } + // } - // Different from super - FillInMap(mapBlocks, minX, minY, maxX, maxY); - // + // // Different from super + // //FillInMap(mapBlocks, minX, minY, maxX, maxY); + // // - remoteClient.SendMapBlock(mapBlocks, 0); + // remoteClient.SendMapBlock(mapBlocks, 0); - } + //} private void FillInMap(List mapBlocks, int minX, int minY, int maxX, int maxY) -- cgit v1.1