Thanks Diva for a patch that makes WorldMapModule friendly to subclassing.

0.6.0-stable
Jeff Ames 2008-11-06 02:11:51 +00:00
parent 1c4d6544d5
commit 397b608af5
1 changed files with 32 additions and 43 deletions

View File

@ -64,11 +64,11 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>();
//private IConfig m_config; //private IConfig m_config;
private Scene m_scene; protected Scene m_scene;
private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
private int cachedTime = 0; private int cachedTime = 0;
private byte[] myMapImageJPEG; private byte[] myMapImageJPEG;
private bool m_Enabled = false; protected bool m_Enabled = false;
private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>();
private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>();
private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>();
@ -81,7 +81,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
#region IRegionModule Members #region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config) public virtual void Initialise(Scene scene, IConfigSource config)
{ {
IConfig startupConfig = config.Configs["Startup"]; IConfig startupConfig = config.Configs["Startup"];
if (startupConfig.GetString("WorldMapModule", "WorldMap") == if (startupConfig.GetString("WorldMapModule", "WorldMap") ==
@ -91,35 +91,20 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
if (!m_Enabled) if (!m_Enabled)
return; return;
myMapImageJPEG = new byte[0];
m_scene = scene; 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"; } get { return "WorldMapModule"; }
} }
@ -131,6 +116,24 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
#endregion #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) public void OnRegisterCaps(UUID agentID, Caps caps)
{ {
m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
@ -155,7 +158,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
/// <param name="caps"></param> /// <param name="caps"></param>
/// <returns></returns> /// <returns></returns>
public string MapLayerRequest(string request, string path, string param, public string MapLayerRequest(string request, string path, string param,
UUID agentID, Caps caps) UUID agentID, Caps caps)
{ {
//try //try
//{ //{
@ -249,7 +252,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
/// <param name="AgentId">AgentID that logged out</param> /// <param name="AgentId">AgentID that logged out</param>
private void ClientLoggedOut(UUID AgentId) private void ClientLoggedOut(UUID AgentId)
{ {
List<ScenePresence> presences = m_scene.GetAvatars(); List<ScenePresence> presences = m_scene.GetAvatars();
int rootcount = 0; int rootcount = 0;
for (int i=0;i<presences.Count;i++) for (int i=0;i<presences.Count;i++)
@ -270,7 +272,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
m_rootAgents.Remove(AgentId); m_rootAgents.Remove(AgentId);
} }
} }
} }
#endregion #endregion
@ -310,11 +311,9 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
requests.Enqueue(st); requests.Enqueue(st);
} }
public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
uint EstateID, bool godlike, uint itemtype, ulong regionhandle) uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
{ {
lock (m_rootAgents) lock (m_rootAgents)
{ {
if (!m_rootAgents.Contains(remoteClient.AgentId)) if (!m_rootAgents.Contains(remoteClient.AgentId))
@ -345,7 +344,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
} }
else else
{ {
foreach (ScenePresence av in avatars) foreach (ScenePresence av in avatars)
{ {
// Don't send a green dot for yourself // Don't send a green dot for yourself
@ -368,7 +366,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
{ {
// Remote Map Item Request // Remote Map Item Request
// ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
// Note that we only start up a remote mapItem Request thread if there's users who could // Note that we only start up a remote mapItem Request thread if there's users who could
// be making requests // be making requests
@ -379,10 +376,8 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
} }
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
} }
} }
} }
/// <summary> /// <summary>
@ -441,7 +436,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
/// <param name="response">The LLSDMap Response for the mapitem</param> /// <param name="response">The LLSDMap Response for the mapitem</param>
private void RequestMapItemsCompleted(LLSDMap response) private void RequestMapItemsCompleted(LLSDMap response)
{ {
UUID requestID = response["requestID"].AsUUID(); UUID requestID = response["requestID"].AsUUID();
if (requestID != UUID.Zero) if (requestID != UUID.Zero)
@ -481,9 +475,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
} }
av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags);
} }
} }
} }
} }
} }
@ -509,7 +501,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
st.itemtype = itemtype; st.itemtype = itemtype;
st.regionhandle = regionhandle; st.regionhandle = regionhandle;
EnqueueMapItemRequest(st); EnqueueMapItemRequest(st);
} }
/// <summary> /// <summary>
@ -534,7 +525,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
{ {
if (m_blacklistedregions.ContainsKey(regionhandle)) if (m_blacklistedregions.ContainsKey(regionhandle))
blacklisted = true; blacklisted = true;
} }
if (blacklisted) if (blacklisted)
@ -645,7 +635,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
} }
catch (WebException) catch (WebException)
{ {
responseMap["connect"] = LLSD.FromBoolean(false); responseMap["connect"] = LLSD.FromBoolean(false);
lock (m_blacklistedurls) lock (m_blacklistedurls)
{ {
@ -675,6 +664,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
} }
return responseMap; return responseMap;
} }
/// <summary> /// <summary>
/// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
/// </summary> /// </summary>
@ -789,6 +779,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
return reply; return reply;
} }
// From msdn // From msdn
private static ImageCodecInfo GetEncoderInfo(String mimeType) private static ImageCodecInfo GetEncoderInfo(String mimeType)
{ {
@ -801,6 +792,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
} }
return null; return null;
} }
public LLSD HandleRemoteMapItemRequest(string path, LLSD request, string endpoint) public LLSD HandleRemoteMapItemRequest(string path, LLSD request, string endpoint)
{ {
uint xstart = 0; uint xstart = 0;
@ -858,11 +850,9 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
} }
return responsemap; return responsemap;
} }
private void MakeRootAgent(ScenePresence avatar) private void MakeRootAgent(ScenePresence avatar)
{ {
// You may ask, why this is in a threadpool to start with.. // 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 // The reason is so we don't cause the thread to freeze waiting
// for the 1 second it costs to start a thread manually. // 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 uint itemtype;
public ulong regionhandle; public ulong regionhandle;
} }
} }