diff options
Merge branch 'grid-service-redux'
Diffstat (limited to 'OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 98 |
1 files changed, 72 insertions, 26 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 1f25f28..05ed70a 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -48,6 +48,7 @@ using OpenSim.Region.Framework.Scenes; | |||
48 | using Caps=OpenSim.Framework.Capabilities.Caps; | 48 | using Caps=OpenSim.Framework.Capabilities.Caps; |
49 | using OSDArray=OpenMetaverse.StructuredData.OSDArray; | 49 | using OSDArray=OpenMetaverse.StructuredData.OSDArray; |
50 | using OSDMap=OpenMetaverse.StructuredData.OSDMap; | 50 | using OSDMap=OpenMetaverse.StructuredData.OSDMap; |
51 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
51 | 52 | ||
52 | namespace OpenSim.Region.CoreModules.World.WorldMap | 53 | namespace OpenSim.Region.CoreModules.World.WorldMap |
53 | { | 54 | { |
@@ -232,10 +233,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
232 | } | 233 | } |
233 | if (lookup) | 234 | if (lookup) |
234 | { | 235 | { |
235 | List<MapBlockData> mapBlocks; | 236 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; |
236 | 237 | ||
237 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); | 238 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
238 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0); | 239 | (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, |
240 | (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, | ||
241 | (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, | ||
242 | (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); | ||
243 | foreach (GridRegion r in regions) | ||
244 | { | ||
245 | MapBlockData block = new MapBlockData(); | ||
246 | MapBlockFromGridRegion(block, r); | ||
247 | mapBlocks.Add(block); | ||
248 | } | ||
249 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); | ||
239 | 250 | ||
240 | lock (cachedMapBlocks) | 251 | lock (cachedMapBlocks) |
241 | cachedMapBlocks = mapBlocks; | 252 | cachedMapBlocks = mapBlocks; |
@@ -579,7 +590,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
579 | } | 590 | } |
580 | if (httpserver.Length == 0) | 591 | if (httpserver.Length == 0) |
581 | { | 592 | { |
582 | RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); | 593 | uint x = 0, y = 0; |
594 | Utils.LongToUInts(regionhandle, out x, out y); | ||
595 | GridRegion mreg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); | ||
583 | 596 | ||
584 | if (mreg != null) | 597 | if (mreg != null) |
585 | { | 598 | { |
@@ -719,15 +732,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
719 | { | 732 | { |
720 | List<MapBlockData> response = new List<MapBlockData>(); | 733 | List<MapBlockData> response = new List<MapBlockData>(); |
721 | 734 | ||
722 | // this should return one mapblock at most. But make sure: Look whether the one we requested is in there | 735 | // this should return one mapblock at most. |
723 | List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | 736 | // (diva note: why?? in that case we should GetRegionByPosition) |
724 | if (mapBlocks != null) | 737 | // But make sure: Look whether the one we requested is in there |
738 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | ||
739 | minX * (int)Constants.RegionSize, | ||
740 | maxX * (int)Constants.RegionSize, | ||
741 | minY * (int)Constants.RegionSize, | ||
742 | maxY * (int)Constants.RegionSize); | ||
743 | |||
744 | if (regions != null) | ||
725 | { | 745 | { |
726 | foreach (MapBlockData block in mapBlocks) | 746 | foreach (GridRegion r in regions) |
727 | { | 747 | { |
728 | if (block.X == minX && block.Y == minY) | 748 | if ((r.RegionLocX == minX * (int)Constants.RegionSize) && |
749 | (r.RegionLocY == minY * (int)Constants.RegionSize)) | ||
729 | { | 750 | { |
730 | // found it => add it to response | 751 | // found it => add it to response |
752 | MapBlockData block = new MapBlockData(); | ||
753 | MapBlockFromGridRegion(block, r); | ||
731 | response.Add(block); | 754 | response.Add(block); |
732 | break; | 755 | break; |
733 | } | 756 | } |
@@ -754,10 +777,30 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
754 | 777 | ||
755 | protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 778 | protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
756 | { | 779 | { |
757 | List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); | 780 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); |
781 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | ||
782 | (minX - 4) * (int)Constants.RegionSize, | ||
783 | (maxX + 4) * (int)Constants.RegionSize, | ||
784 | (minY - 4) * (int)Constants.RegionSize, | ||
785 | (maxY + 4) * (int)Constants.RegionSize); | ||
786 | foreach (GridRegion r in regions) | ||
787 | { | ||
788 | MapBlockData block = new MapBlockData(); | ||
789 | MapBlockFromGridRegion(block, r); | ||
790 | mapBlocks.Add(block); | ||
791 | } | ||
758 | remoteClient.SendMapBlock(mapBlocks, flag); | 792 | remoteClient.SendMapBlock(mapBlocks, flag); |
759 | } | 793 | } |
760 | 794 | ||
795 | protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r) | ||
796 | { | ||
797 | block.Access = r.Access; | ||
798 | block.MapImageId = r.TerrainImage; | ||
799 | block.Name = r.RegionName; | ||
800 | block.X = (ushort)(r.RegionLocX / Constants.RegionSize); | ||
801 | block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); | ||
802 | } | ||
803 | |||
761 | public Hashtable OnHTTPGetMapImage(Hashtable keysvals) | 804 | public Hashtable OnHTTPGetMapImage(Hashtable keysvals) |
762 | { | 805 | { |
763 | m_log.Debug("[WORLD MAP]: Sending map image jpeg"); | 806 | m_log.Debug("[WORLD MAP]: Sending map image jpeg"); |
@@ -874,31 +917,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
874 | m_log.InfoFormat( | 917 | m_log.InfoFormat( |
875 | "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); | 918 | "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); |
876 | 919 | ||
877 | List<MapBlockData> mapBlocks = | 920 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); |
878 | m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( | 921 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
879 | (int)(m_scene.RegionInfo.RegionLocX - 9), | 922 | (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize, |
880 | (int)(m_scene.RegionInfo.RegionLocY - 9), | 923 | (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize, |
881 | (int)(m_scene.RegionInfo.RegionLocX + 9), | 924 | (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize, |
882 | (int)(m_scene.RegionInfo.RegionLocY + 9)); | 925 | (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize); |
883 | List<AssetBase> textures = new List<AssetBase>(); | 926 | List<AssetBase> textures = new List<AssetBase>(); |
884 | List<Image> bitImages = new List<Image>(); | 927 | List<Image> bitImages = new List<Image>(); |
885 | 928 | ||
886 | foreach (MapBlockData mapBlock in mapBlocks) | 929 | foreach (GridRegion r in regions) |
887 | { | 930 | { |
931 | MapBlockData mapBlock = new MapBlockData(); | ||
932 | MapBlockFromGridRegion(mapBlock, r); | ||
888 | AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); | 933 | AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); |
889 | 934 | ||
890 | if (texAsset != null) | 935 | if (texAsset != null) |
891 | { | 936 | { |
892 | textures.Add(texAsset); | 937 | textures.Add(texAsset); |
893 | } | 938 | } |
894 | else | 939 | //else |
895 | { | 940 | //{ |
896 | texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); | 941 | // // WHAT?!? This doesn't seem right. Commenting (diva) |
897 | if (texAsset != null) | 942 | // texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); |
898 | { | 943 | // if (texAsset != null) |
899 | textures.Add(texAsset); | 944 | // { |
900 | } | 945 | // textures.Add(texAsset); |
901 | } | 946 | // } |
947 | //} | ||
902 | } | 948 | } |
903 | 949 | ||
904 | foreach (AssetBase asset in textures) | 950 | foreach (AssetBase asset in textures) |