diff options
author | Melanie | 2011-06-20 03:08:56 +0200 |
---|---|---|
committer | Melanie | 2011-06-20 03:08:56 +0200 |
commit | f4f55c4d6bdbe9a86b5343159916977b331fefe0 (patch) | |
tree | 08fb85f2aa0193bf8549e684b98501c2c52faa1a /OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs | |
parent | Add some flags to control content in search better (diff) | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
download | opensim-SC-f4f55c4d6bdbe9a86b5343159916977b331fefe0.zip opensim-SC-f4f55c4d6bdbe9a86b5343159916977b331fefe0.tar.gz opensim-SC-f4f55c4d6bdbe9a86b5343159916977b331fefe0.tar.bz2 opensim-SC-f4f55c4d6bdbe9a86b5343159916977b331fefe0.tar.xz |
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs | 98 |
1 files changed, 66 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index 5ab334f..0c60391 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
@@ -40,7 +41,10 @@ namespace OpenSim.Region.CoreModules.Hypergrid | |||
40 | { | 41 | { |
41 | public class HGWorldMapModule : WorldMapModule | 42 | public class HGWorldMapModule : WorldMapModule |
42 | { | 43 | { |
43 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | |||
46 | // Remember the map area that each client has been exposed to in this region | ||
47 | private Dictionary<UUID, List<MapBlockData>> m_SeenMapBlocks = new Dictionary<UUID, List<MapBlockData>>(); | ||
44 | 48 | ||
45 | #region INonSharedRegionModule Members | 49 | #region INonSharedRegionModule Members |
46 | 50 | ||
@@ -51,6 +55,13 @@ namespace OpenSim.Region.CoreModules.Hypergrid | |||
51 | m_Enabled = true; | 55 | m_Enabled = true; |
52 | } | 56 | } |
53 | 57 | ||
58 | public override void AddRegion(Scene scene) | ||
59 | { | ||
60 | base.AddRegion(scene); | ||
61 | |||
62 | scene.EventManager.OnClientClosed += new EventManager.ClientClosed(EventManager_OnClientClosed); | ||
63 | } | ||
64 | |||
54 | public override string Name | 65 | public override string Name |
55 | { | 66 | { |
56 | get { return "HGWorldMap"; } | 67 | get { return "HGWorldMap"; } |
@@ -58,47 +69,70 @@ namespace OpenSim.Region.CoreModules.Hypergrid | |||
58 | 69 | ||
59 | #endregion | 70 | #endregion |
60 | 71 | ||
61 | protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 72 | void EventManager_OnClientClosed(UUID clientID, Scene scene) |
62 | { | 73 | { |
63 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); | 74 | ScenePresence sp = scene.GetScenePresence(clientID); |
64 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 75 | if (sp != null) |
65 | minX * (int)Constants.RegionSize, maxX * (int)Constants.RegionSize, | ||
66 | minY * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize); | ||
67 | |||
68 | foreach (GridRegion r in regions) | ||
69 | { | 76 | { |
70 | MapBlockData block = new MapBlockData(); | 77 | if (m_SeenMapBlocks.ContainsKey(clientID)) |
71 | MapBlockFromGridRegion(block, r); | 78 | { |
72 | mapBlocks.Add(block); | 79 | List<MapBlockData> mapBlocks = m_SeenMapBlocks[clientID]; |
73 | } | 80 | foreach (MapBlockData b in mapBlocks) |
74 | 81 | { | |
75 | // Different from super | 82 | b.Name = string.Empty; |
76 | FillInMap(mapBlocks, minX, minY, maxX, maxY); | 83 | b.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's |
77 | // | 84 | } |
78 | 85 | ||
79 | remoteClient.SendMapBlock(mapBlocks, 0); | 86 | m_log.DebugFormat("[HG MAP]: Reseting {0} blocks", mapBlocks.Count); |
87 | sp.ControllingClient.SendMapBlock(mapBlocks, 0); | ||
88 | m_SeenMapBlocks.Remove(clientID); | ||
89 | } | ||
90 | } | ||
80 | } | 91 | } |
81 | 92 | ||
82 | 93 | protected override List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | |
83 | private void FillInMap(List<MapBlockData> mapBlocks, int minX, int minY, int maxX, int maxY) | ||
84 | { | 94 | { |
85 | for (int x = minX; x <= maxX; x++) | 95 | List<MapBlockData> mapBlocks = base.GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag); |
96 | lock (m_SeenMapBlocks) | ||
86 | { | 97 | { |
87 | for (int y = minY; y <= maxY; y++) | 98 | if (!m_SeenMapBlocks.ContainsKey(remoteClient.AgentId)) |
88 | { | 99 | { |
89 | MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); }); | 100 | m_SeenMapBlocks.Add(remoteClient.AgentId, mapBlocks); |
90 | if (mblock == null) | 101 | } |
91 | { | 102 | else |
92 | mblock = new MapBlockData(); | 103 | { |
93 | mblock.X = (ushort)x; | 104 | List<MapBlockData> seen = m_SeenMapBlocks[remoteClient.AgentId]; |
94 | mblock.Y = (ushort)y; | 105 | List<MapBlockData> newBlocks = new List<MapBlockData>(); |
95 | mblock.Name = ""; | 106 | foreach (MapBlockData b in mapBlocks) |
96 | mblock.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's | 107 | if (seen.Find(delegate(MapBlockData bdata) { return bdata.X == b.X && bdata.Y == b.Y; }) == null) |
97 | mblock.MapImageId = UUID.Zero; | 108 | newBlocks.Add(b); |
98 | mapBlocks.Add(mblock); | 109 | seen.AddRange(newBlocks); |
99 | } | ||
100 | } | 110 | } |
101 | } | 111 | } |
112 | |||
113 | return mapBlocks; | ||
114 | } | ||
115 | |||
116 | } | ||
117 | |||
118 | class MapArea | ||
119 | { | ||
120 | public int minX; | ||
121 | public int minY; | ||
122 | public int maxX; | ||
123 | public int maxY; | ||
124 | |||
125 | public MapArea(int mix, int miy, int max, int may) | ||
126 | { | ||
127 | minX = mix; | ||
128 | minY = miy; | ||
129 | maxX = max; | ||
130 | maxY = may; | ||
131 | } | ||
132 | |||
133 | public void Print() | ||
134 | { | ||
135 | Console.WriteLine(String.Format(" --> Area is minX={0} minY={1} minY={2} maxY={3}", minX, minY, maxY, maxY)); | ||
102 | } | 136 | } |
103 | } | 137 | } |
104 | } | 138 | } |