aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Hypergrid
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/CoreModules/Hypergrid
parentIf the flotsam asset cache console command "fcache clear" is specified on its... (diff)
downloadopensim-SC_OLD-487cb51f69ac2f713797de03eb26a4b53afcfade.zip
opensim-SC_OLD-487cb51f69ac2f713797de03eb26a4b53afcfade.tar.gz
opensim-SC_OLD-487cb51f69ac2f713797de03eb26a4b53afcfade.tar.bz2
opensim-SC_OLD-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/CoreModules/Hypergrid')
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs121
1 files changed, 68 insertions, 53 deletions
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}