aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2011-06-10 17:22:17 -0700
committerDiva Canto2011-06-10 17:22:17 -0700
commit487cb51f69ac2f713797de03eb26a4b53afcfade (patch)
treefae27918edd3de1e5098e3f79d5f474c77ba730e /OpenSim/Region
parentIf the flotsam asset cache console command "fcache clear" is specified on its... (diff)
downloadopensim-SC-487cb51f69ac2f713797de03eb26a4b53afcfade.zip
opensim-SC-487cb51f69ac2f713797de03eb26a4b53afcfade.tar.gz
opensim-SC-487cb51f69ac2f713797de03eb26a4b53afcfade.tar.bz2
opensim-SC-487cb51f69ac2f713797de03eb26a4b53afcfade.tar.xz
3rd way of reseting the HG Map. This time, don't use the grid service; instead keep track of which map blocks each client has seen in the region, and reset exactly those when the client closes.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs25
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs121
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs4
3 files changed, 71 insertions, 79 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 8df89ad..4d77ef4 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -148,9 +148,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
148 base.AgentHasMovedAway(sp, logout); 148 base.AgentHasMovedAway(sp, logout);
149 if (logout) 149 if (logout)
150 { 150 {
151 // Reset the map
152 ResetMap(sp);
153
154 // Log them out of this grid 151 // Log them out of this grid
155 m_aScene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 152 m_aScene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
156 } 153 }
@@ -285,28 +282,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
285 282
286 } 283 }
287 284
288 protected void ResetMap(ScenePresence sp)
289 {
290 List<GridRegion> regions = m_Scenes[0].GridService.GetRegionRange(m_Scenes[0].RegionInfo.ScopeID, 0, 17000 * (int)Constants.RegionSize, 0, 17000 * (int)Constants.RegionSize);
291 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Resetting {0} tiles on the map", regions.Count);
292 if (regions != null)
293 {
294 List<MapBlockData> mapBlocks = new List<MapBlockData>();
295 foreach (GridRegion r in regions)
296 {
297 MapBlockData mblock = new MapBlockData();
298 mblock.X = (ushort)(r.RegionLocX / Constants.RegionSize);
299 mblock.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
300 mblock.Name = "";
301 mblock.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's
302 mblock.MapImageId = UUID.Zero;
303 mapBlocks.Add(mblock);
304 }
305 sp.ControllingClient.SendMapBlock(mapBlocks, 0);
306 }
307
308 }
309
310 #endregion 285 #endregion
311 286
312 #region IUserAgentVerificationModule 287 #region IUserAgentVerificationModule
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
index fd2cc20..0c60391 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
@@ -41,7 +41,10 @@ namespace OpenSim.Region.CoreModules.Hypergrid
41{ 41{
42 public class HGWorldMapModule : WorldMapModule 42 public class HGWorldMapModule : WorldMapModule
43 { 43 {
44 //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>>();
45 48
46 #region INonSharedRegionModule Members 49 #region INonSharedRegionModule Members
47 50
@@ -52,6 +55,13 @@ namespace OpenSim.Region.CoreModules.Hypergrid
52 m_Enabled = true; 55 m_Enabled = true;
53 } 56 }
54 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
55 public override string Name 65 public override string Name
56 { 66 {
57 get { return "HGWorldMap"; } 67 get { return "HGWorldMap"; }
@@ -59,65 +69,70 @@ namespace OpenSim.Region.CoreModules.Hypergrid
59 69
60 #endregion 70 #endregion
61 71
62 //protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 72 void EventManager_OnClientClosed(UUID clientID, Scene scene)
63 //{
64 // List<MapBlockData> mapBlocks = new List<MapBlockData>();
65 // List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
66 // minX * (int)Constants.RegionSize, maxX * (int)Constants.RegionSize,
67 // minY * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize);
68
69 // foreach (GridRegion r in regions)
70 // {
71 // uint x = 0, y = 0;
72 // long handle = 0;
73 // if (r.RegionSecret != null && r.RegionSecret != string.Empty)
74 // {
75 // if (long.TryParse(r.RegionSecret, out handle))
76 // {
77 // Utils.LongToUInts((ulong)handle, out x, out y);
78 // x = x / Constants.RegionSize;
79 // y = y / Constants.RegionSize;
80 // }
81 // }
82
83 // if (handle == 0 ||
84 // // Check the distance from the current region
85 // (handle != 0 && Math.Abs((int)(x - m_scene.RegionInfo.RegionLocX)) < 4096 && Math.Abs((int)(y - m_scene.RegionInfo.RegionLocY)) < 4096))
86 // {
87 // MapBlockData block = new MapBlockData();
88 // MapBlockFromGridRegion(block, r);
89 // mapBlocks.Add(block);
90 // }
91 // }
92
93 // // Different from super
94 // //FillInMap(mapBlocks, minX, minY, maxX, maxY);
95 // //
96
97 // remoteClient.SendMapBlock(mapBlocks, 0);
98
99 //}
100
101
102 private void FillInMap(List<MapBlockData> mapBlocks, int minX, int minY, int maxX, int maxY)
103 { 73 {
104 for (int x = minX; x <= maxX; x++) 74 ScenePresence sp = scene.GetScenePresence(clientID);
75 if (sp != null)
105 { 76 {
106 for (int y = minY; y <= maxY; y++) 77 if (m_SeenMapBlocks.ContainsKey(clientID))
107 { 78 {
108 MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); }); 79 List<MapBlockData> mapBlocks = m_SeenMapBlocks[clientID];
109 if (mblock == null) 80 foreach (MapBlockData b in mapBlocks)
110 { 81 {
111 mblock = new MapBlockData(); 82 b.Name = string.Empty;
112 mblock.X = (ushort)x; 83 b.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's
113 mblock.Y = (ushort)y;
114 mblock.Name = "";
115 mblock.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's
116 mblock.MapImageId = UUID.Zero;
117 mapBlocks.Add(mblock);
118 } 84 }
85
86 m_log.DebugFormat("[HG MAP]: Reseting {0} blocks", mapBlocks.Count);
87 sp.ControllingClient.SendMapBlock(mapBlocks, 0);
88 m_SeenMapBlocks.Remove(clientID);
119 } 89 }
120 } 90 }
121 } 91 }
92
93 protected override List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
94 {
95 List<MapBlockData> mapBlocks = base.GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag);
96 lock (m_SeenMapBlocks)
97 {
98 if (!m_SeenMapBlocks.ContainsKey(remoteClient.AgentId))
99 {
100 m_SeenMapBlocks.Add(remoteClient.AgentId, mapBlocks);
101 }
102 else
103 {
104 List<MapBlockData> seen = m_SeenMapBlocks[remoteClient.AgentId];
105 List<MapBlockData> newBlocks = new List<MapBlockData>();
106 foreach (MapBlockData b in mapBlocks)
107 if (seen.Find(delegate(MapBlockData bdata) { return bdata.X == b.X && bdata.Y == b.Y; }) == null)
108 newBlocks.Add(b);
109 seen.AddRange(newBlocks);
110 }
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));
136 }
122 } 137 }
123} 138}
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 69d3005..3553c9a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -845,7 +845,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
845 } 845 }
846 } 846 }
847 847
848 protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 848 protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
849 { 849 {
850 List<MapBlockData> mapBlocks = new List<MapBlockData>(); 850 List<MapBlockData> mapBlocks = new List<MapBlockData>();
851 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 851 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
@@ -860,6 +860,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
860 mapBlocks.Add(block); 860 mapBlocks.Add(block);
861 } 861 }
862 remoteClient.SendMapBlock(mapBlocks, 0); 862 remoteClient.SendMapBlock(mapBlocks, 0);
863
864 return mapBlocks;
863 } 865 }
864 866
865 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r) 867 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)