From 397b608af51b638fd62ca7125208239223d4ede5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 6 Nov 2008 02:11:51 +0000 Subject: Thanks Diva for a patch that makes WorldMapModule friendly to subclassing. --- .../Modules/World/WorldMap/WorldMapModule.cs | 75 +++++++++------------- 1 file changed, 32 insertions(+), 43 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs index b277626..c51a314 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs @@ -64,11 +64,11 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap private OpenSim.Framework.BlockingQueue requests = new OpenSim.Framework.BlockingQueue(); //private IConfig m_config; - private Scene m_scene; + protected Scene m_scene; private List cachedMapBlocks = new List(); private int cachedTime = 0; private byte[] myMapImageJPEG; - private bool m_Enabled = false; + protected bool m_Enabled = false; private Dictionary m_openRequests = new Dictionary(); private Dictionary m_blacklistedurls = new Dictionary(); private Dictionary m_blacklistedregions = new Dictionary(); @@ -81,7 +81,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap #region IRegionModule Members - public void Initialise(Scene scene, IConfigSource config) + public virtual void Initialise(Scene scene, IConfigSource config) { IConfig startupConfig = config.Configs["Startup"]; if (startupConfig.GetString("WorldMapModule", "WorldMap") == @@ -91,35 +91,20 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap if (!m_Enabled) return; - myMapImageJPEG = new byte[0]; - m_scene = scene; - string regionimage = "regionImage" + scene.RegionInfo.RegionID.ToString(); - regionimage = regionimage.Replace("-", ""); - m_log.Warn("[WEBMAP]: JPEG Map location: http://" + m_scene.RegionInfo.ExternalEndPoint.Address.ToString() + ":" + m_scene.RegionInfo.HttpPort.ToString() + "/index.php?method=" + regionimage); - - - m_scene.AddHTTPHandler(regionimage, OnHTTPGetMapImage); - m_scene.AddLLSDHandler("/MAP/MapItems/" + scene.RegionInfo.RegionHandle.ToString(),HandleRemoteMapItemRequest); - - - scene.EventManager.OnRegisterCaps += OnRegisterCaps; - scene.EventManager.OnNewClient += OnNewClient; - scene.EventManager.OnClientClosed += ClientLoggedOut; - scene.EventManager.OnMakeChildAgent += MakeChildAgent; - scene.EventManager.OnMakeRootAgent += MakeRootAgent; - - } - public void PostInitialise() - { + public virtual void PostInitialise() + { + if (m_Enabled) + AddHandlers(); } - public void Close() + public virtual void Close() { } - public string Name + + public virtual string Name { get { return "WorldMapModule"; } } @@ -131,6 +116,24 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap #endregion + protected virtual void AddHandlers() + { + myMapImageJPEG = new byte[0]; + + string regionimage = "regionImage" + m_scene.RegionInfo.RegionID.ToString(); + regionimage = regionimage.Replace("-", ""); + m_log.Warn("[WEBMAP]: JPEG Map location: http://" + m_scene.RegionInfo.ExternalEndPoint.Address.ToString() + ":" + m_scene.RegionInfo.HttpPort.ToString() + "/index.php?method=" + regionimage); + + m_scene.AddHTTPHandler(regionimage, OnHTTPGetMapImage); + m_scene.AddLLSDHandler("/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest); + + m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; + m_scene.EventManager.OnNewClient += OnNewClient; + m_scene.EventManager.OnClientClosed += ClientLoggedOut; + m_scene.EventManager.OnMakeChildAgent += MakeChildAgent; + m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; + } + public void OnRegisterCaps(UUID agentID, Caps caps) { m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); @@ -155,7 +158,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap /// /// public string MapLayerRequest(string request, string path, string param, - UUID agentID, Caps caps) + UUID agentID, Caps caps) { //try //{ @@ -249,7 +252,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap /// AgentID that logged out private void ClientLoggedOut(UUID AgentId) { - List presences = m_scene.GetAvatars(); int rootcount = 0; for (int i=0;i @@ -441,7 +436,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap /// The LLSDMap Response for the mapitem private void RequestMapItemsCompleted(LLSDMap response) { - UUID requestID = response["requestID"].AsUUID(); if (requestID != UUID.Zero) @@ -481,9 +475,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap } av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); } - } - } } } @@ -509,7 +501,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap st.itemtype = itemtype; st.regionhandle = regionhandle; EnqueueMapItemRequest(st); - } /// @@ -534,7 +525,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap { if (m_blacklistedregions.ContainsKey(regionhandle)) blacklisted = true; - } if (blacklisted) @@ -645,7 +635,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap } catch (WebException) { - responseMap["connect"] = LLSD.FromBoolean(false); lock (m_blacklistedurls) { @@ -675,6 +664,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap } return responseMap; } + /// /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates /// @@ -789,6 +779,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap return reply; } + // From msdn private static ImageCodecInfo GetEncoderInfo(String mimeType) { @@ -801,6 +792,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap } return null; } + public LLSD HandleRemoteMapItemRequest(string path, LLSD request, string endpoint) { uint xstart = 0; @@ -858,11 +850,9 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap } return responsemap; } - private void MakeRootAgent(ScenePresence avatar) { - // You may ask, why this is in a threadpool to start with.. // The reason is so we don't cause the thread to freeze waiting // for the 1 second it costs to start a thread manually. @@ -914,5 +904,4 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap public uint itemtype; public ulong regionhandle; } - } -- cgit v1.1