29 using System.Collections.Generic;
30 using System.Reflection;
34 using OpenMetaverse.StructuredData;
36 using OpenSim.Framework;
37 using OpenSim.Region.CoreModules.World.WorldMap;
38 using OpenSim.Region.Framework.Interfaces;
39 using OpenSim.Region.Framework.Scenes;
40 using OpenSim.Services.Interfaces;
45 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"HGWorldMapModule")]
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 private Dictionary<UUID, List<MapBlockData>> m_SeenMapBlocks =
new Dictionary<UUID, List<MapBlockData>>();
53 private string m_MapImageServerURL = string.Empty;
57 #region INonSharedRegionModule Members
61 if (Util.GetConfigVarFromSections<
string>(
62 source,
"WorldMapModule",
new string[] {
"Map",
"Startup" },
"WorldMap") ==
"HGWorldMap")
66 m_MapImageServerURL = Util.GetConfigVarFromSections<
string>(source,
"MapTileURL",
new string[] {
"LoginService",
"HGWorldMap",
"SimulatorFeatures"});
68 if (!
string.IsNullOrEmpty(m_MapImageServerURL))
70 m_MapImageServerURL = m_MapImageServerURL.Trim();
71 if (!m_MapImageServerURL.EndsWith(
"/"))
72 m_MapImageServerURL = m_MapImageServerURL +
"/";
84 base.AddRegion(scene);
86 scene.EventManager.OnClientClosed += EventManager_OnClientClosed;
94 base.RegionLoaded(scene);
97 if (featuresModule != null)
98 featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
109 scene.EventManager.OnClientClosed -= EventManager_OnClientClosed;
112 public override string Name
114 get {
return "HGWorldMap"; }
119 void EventManager_OnClientClosed(UUID clientID,
Scene scene)
124 if (m_SeenMapBlocks.ContainsKey(clientID))
126 List<MapBlockData> mapBlocks = m_SeenMapBlocks[clientID];
129 b.Name = string.Empty;
131 b.Access = (byte)SimAccess.Down;
134 m_log.DebugFormat(
"[HG MAP]: Resetting {0} blocks", mapBlocks.Count);
135 sp.ControllingClient.SendMapBlock(mapBlocks, 0);
136 m_SeenMapBlocks.Remove(clientID);
143 List<MapBlockData> mapBlocks = base.GetAndSendBlocksInternal(remoteClient, minX, minY, maxX, maxY, flag);
144 lock (m_SeenMapBlocks)
146 if (!m_SeenMapBlocks.ContainsKey(remoteClient.AgentId))
148 m_SeenMapBlocks.Add(remoteClient.AgentId, mapBlocks);
152 List<MapBlockData> seen = m_SeenMapBlocks[remoteClient.AgentId];
153 List<MapBlockData> newBlocks =
new List<MapBlockData>();
155 if (seen.Find(delegate(
MapBlockData bdata) {
return bdata.X == b.X && bdata.Y == b.Y; }) == null)
157 seen.AddRange(newBlocks);
164 private void OnSimulatorFeaturesRequest(UUID agentID, ref
OSDMap features)
166 if (m_UserManagement != null && !
string.IsNullOrEmpty(m_MapImageServerURL) && !m_UserManagement.IsLocalGridUser(agentID))
169 if (features.ContainsKey(
"OpenSimExtras"))
170 extras = features[
"OpenSimExtras"];
172 features[
"OpenSimExtras"] = extras;
174 ((
OSDMap)extras)[
"map-server-url"] = m_MapImageServerURL;
187 public MapArea(
int mix,
int miy,
int max,
int may)
197 Console.WriteLine(String.Format(
" --> Area is minX={0} minY={1} minY={2} maxY={3}", minX, minY, maxY, maxY));
override void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
OpenMetaverse.StructuredData.OSDMap OSDMap
Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures ca...
override void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
OpenMetaverse.StructuredData.OSD OSD
Interactive OpenSim region server
override void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
override List< MapBlockData > GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
OpenSim.Services.Interfaces.GridRegion GridRegion
override void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
This maintains the relationship between a UUID and a user name.
MapArea(int mix, int miy, int max, int may)