From 2a46f756d673f4caa2049f2ddda219fdba810eed Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 8 Jun 2011 16:38:25 -0700 Subject: Fixed a compilation problem. Also added a lengthy comment on the Map hack, so that it never goes unnoticed again. --- .../CoreModules/Hypergrid/HGWorldMapModule.cs | 3 +- .../CoreModules/World/WorldMap/WorldMapModule.cs | 83 +++++++++++++--------- 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index 0781de0..f066f83 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid #endregion - protected override List GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) + 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, @@ -96,7 +96,6 @@ namespace OpenSim.Region.CoreModules.Hypergrid remoteClient.SendMapBlock(mapBlocks, 0); - return mapBlocks; } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 0cacf2d..ed3677b 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -208,52 +208,65 @@ namespace OpenSim.Region.CoreModules.World.WorldMap //m_log.DebugFormat("[MAPLAYER]: path: {0}, param: {1}, agent:{2}", // path, param, agentID.ToString()); - // this is here because CAPS map requests work even beyond the 10,000 limit. - ScenePresence avatarPresence = null; - - m_scene.TryGetScenePresence(agentID, out avatarPresence); - - if (avatarPresence != null) + // There is a major hack going on in this method. The viewer doesn't request + // map blocks (RequestMapBlocks) above 4096. That means that if we don't hack, + // grids above that cell don't have a map at all. So, here's the hack: we wait + // for this CAP request to come, and we inject the map blocks at this point. + // In a normal scenario, this request simply sends back the MapLayer (the blue color). + // In the hacked scenario, it also sends the map blocks via UDP. + // + // 6/8/2011 -- I'm adding an explicit 4096 check, so that we never forget that there is + // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. + + if (m_scene.RegionInfo.RegionLocX >= 4096 || m_scene.RegionInfo.RegionLocY > 4096) { - bool lookup = false; + ScenePresence avatarPresence = null; - lock (cachedMapBlocks) - { - if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) - { - List mapBlocks; + m_scene.TryGetScenePresence(agentID, out avatarPresence); - mapBlocks = cachedMapBlocks; - avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); - } - else - { - lookup = true; - } - } - if (lookup) + if (avatarPresence != null) { - List mapBlocks = new List(); ; + bool lookup = false; - List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, - (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); - foreach (GridRegion r in regions) + lock (cachedMapBlocks) { - MapBlockData block = new MapBlockData(); - MapBlockFromGridRegion(block, r); - mapBlocks.Add(block); + if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) + { + List mapBlocks; + + mapBlocks = cachedMapBlocks; + avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); + } + else + { + lookup = true; + } } - avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); + if (lookup) + { + List mapBlocks = new List(); ; + + List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, + (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); + foreach (GridRegion r in regions) + { + MapBlockData block = new MapBlockData(); + MapBlockFromGridRegion(block, r); + mapBlocks.Add(block); + } + avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); - lock (cachedMapBlocks) - cachedMapBlocks = mapBlocks; + lock (cachedMapBlocks) + cachedMapBlocks = mapBlocks; - cachedTime = Util.UnixTimeSinceEpoch(); + cachedTime = Util.UnixTimeSinceEpoch(); + } } } + LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); return mapResponse.ToString(); -- cgit v1.1