diff options
author | Jeff Ames | 2008-11-06 02:11:51 +0000 |
---|---|---|
committer | Jeff Ames | 2008-11-06 02:11:51 +0000 |
commit | 397b608af51b638fd62ca7125208239223d4ede5 (patch) | |
tree | 39c69b716ac099f5940106837a0d7e70fb005ea6 /OpenSim/Region/Environment | |
parent | Update svn properties. (diff) | |
download | opensim-SC-397b608af51b638fd62ca7125208239223d4ede5.zip opensim-SC-397b608af51b638fd62ca7125208239223d4ede5.tar.gz opensim-SC-397b608af51b638fd62ca7125208239223d4ede5.tar.bz2 opensim-SC-397b608af51b638fd62ca7125208239223d4ede5.tar.xz |
Thanks Diva for a patch that makes WorldMapModule friendly to subclassing.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs | 75 |
1 files 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 | |||
64 | private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); | 64 | private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); |
65 | 65 | ||
66 | //private IConfig m_config; | 66 | //private IConfig m_config; |
67 | private Scene m_scene; | 67 | protected Scene m_scene; |
68 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); | 68 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); |
69 | private int cachedTime = 0; | 69 | private int cachedTime = 0; |
70 | private byte[] myMapImageJPEG; | 70 | private byte[] myMapImageJPEG; |
71 | private bool m_Enabled = false; | 71 | protected bool m_Enabled = false; |
72 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); | 72 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); |
73 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); | 73 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); |
74 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); | 74 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); |
@@ -81,7 +81,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
81 | 81 | ||
82 | #region IRegionModule Members | 82 | #region IRegionModule Members |
83 | 83 | ||
84 | public void Initialise(Scene scene, IConfigSource config) | 84 | public virtual void Initialise(Scene scene, IConfigSource config) |
85 | { | 85 | { |
86 | IConfig startupConfig = config.Configs["Startup"]; | 86 | IConfig startupConfig = config.Configs["Startup"]; |
87 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == | 87 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == |
@@ -91,35 +91,20 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
91 | if (!m_Enabled) | 91 | if (!m_Enabled) |
92 | return; | 92 | return; |
93 | 93 | ||
94 | myMapImageJPEG = new byte[0]; | ||
95 | |||
96 | m_scene = scene; | 94 | m_scene = scene; |
97 | string regionimage = "regionImage" + scene.RegionInfo.RegionID.ToString(); | ||
98 | regionimage = regionimage.Replace("-", ""); | ||
99 | m_log.Warn("[WEBMAP]: JPEG Map location: http://" + m_scene.RegionInfo.ExternalEndPoint.Address.ToString() + ":" + m_scene.RegionInfo.HttpPort.ToString() + "/index.php?method=" + regionimage); | ||
100 | |||
101 | |||
102 | m_scene.AddHTTPHandler(regionimage, OnHTTPGetMapImage); | ||
103 | m_scene.AddLLSDHandler("/MAP/MapItems/" + scene.RegionInfo.RegionHandle.ToString(),HandleRemoteMapItemRequest); | ||
104 | |||
105 | |||
106 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
107 | scene.EventManager.OnNewClient += OnNewClient; | ||
108 | scene.EventManager.OnClientClosed += ClientLoggedOut; | ||
109 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | ||
110 | scene.EventManager.OnMakeRootAgent += MakeRootAgent; | ||
111 | |||
112 | |||
113 | } | 95 | } |
114 | public void PostInitialise() | ||
115 | { | ||
116 | 96 | ||
97 | public virtual void PostInitialise() | ||
98 | { | ||
99 | if (m_Enabled) | ||
100 | AddHandlers(); | ||
117 | } | 101 | } |
118 | 102 | ||
119 | public void Close() | 103 | public virtual void Close() |
120 | { | 104 | { |
121 | } | 105 | } |
122 | public string Name | 106 | |
107 | public virtual string Name | ||
123 | { | 108 | { |
124 | get { return "WorldMapModule"; } | 109 | get { return "WorldMapModule"; } |
125 | } | 110 | } |
@@ -131,6 +116,24 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
131 | 116 | ||
132 | #endregion | 117 | #endregion |
133 | 118 | ||
119 | protected virtual void AddHandlers() | ||
120 | { | ||
121 | myMapImageJPEG = new byte[0]; | ||
122 | |||
123 | string regionimage = "regionImage" + m_scene.RegionInfo.RegionID.ToString(); | ||
124 | regionimage = regionimage.Replace("-", ""); | ||
125 | m_log.Warn("[WEBMAP]: JPEG Map location: http://" + m_scene.RegionInfo.ExternalEndPoint.Address.ToString() + ":" + m_scene.RegionInfo.HttpPort.ToString() + "/index.php?method=" + regionimage); | ||
126 | |||
127 | m_scene.AddHTTPHandler(regionimage, OnHTTPGetMapImage); | ||
128 | m_scene.AddLLSDHandler("/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest); | ||
129 | |||
130 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
131 | m_scene.EventManager.OnNewClient += OnNewClient; | ||
132 | m_scene.EventManager.OnClientClosed += ClientLoggedOut; | ||
133 | m_scene.EventManager.OnMakeChildAgent += MakeChildAgent; | ||
134 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; | ||
135 | } | ||
136 | |||
134 | public void OnRegisterCaps(UUID agentID, Caps caps) | 137 | public void OnRegisterCaps(UUID agentID, Caps caps) |
135 | { | 138 | { |
136 | m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 139 | m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
@@ -155,7 +158,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
155 | /// <param name="caps"></param> | 158 | /// <param name="caps"></param> |
156 | /// <returns></returns> | 159 | /// <returns></returns> |
157 | public string MapLayerRequest(string request, string path, string param, | 160 | public string MapLayerRequest(string request, string path, string param, |
158 | UUID agentID, Caps caps) | 161 | UUID agentID, Caps caps) |
159 | { | 162 | { |
160 | //try | 163 | //try |
161 | //{ | 164 | //{ |
@@ -249,7 +252,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
249 | /// <param name="AgentId">AgentID that logged out</param> | 252 | /// <param name="AgentId">AgentID that logged out</param> |
250 | private void ClientLoggedOut(UUID AgentId) | 253 | private void ClientLoggedOut(UUID AgentId) |
251 | { | 254 | { |
252 | |||
253 | List<ScenePresence> presences = m_scene.GetAvatars(); | 255 | List<ScenePresence> presences = m_scene.GetAvatars(); |
254 | int rootcount = 0; | 256 | int rootcount = 0; |
255 | for (int i=0;i<presences.Count;i++) | 257 | for (int i=0;i<presences.Count;i++) |
@@ -270,7 +272,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
270 | m_rootAgents.Remove(AgentId); | 272 | m_rootAgents.Remove(AgentId); |
271 | } | 273 | } |
272 | } | 274 | } |
273 | |||
274 | } | 275 | } |
275 | #endregion | 276 | #endregion |
276 | 277 | ||
@@ -310,11 +311,9 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
310 | requests.Enqueue(st); | 311 | requests.Enqueue(st); |
311 | } | 312 | } |
312 | 313 | ||
313 | |||
314 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, | 314 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, |
315 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 315 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
316 | { | 316 | { |
317 | |||
318 | lock (m_rootAgents) | 317 | lock (m_rootAgents) |
319 | { | 318 | { |
320 | if (!m_rootAgents.Contains(remoteClient.AgentId)) | 319 | if (!m_rootAgents.Contains(remoteClient.AgentId)) |
@@ -345,7 +344,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
345 | } | 344 | } |
346 | else | 345 | else |
347 | { | 346 | { |
348 | |||
349 | foreach (ScenePresence av in avatars) | 347 | foreach (ScenePresence av in avatars) |
350 | { | 348 | { |
351 | // Don't send a green dot for yourself | 349 | // Don't send a green dot for yourself |
@@ -368,7 +366,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
368 | { | 366 | { |
369 | // Remote Map Item Request | 367 | // Remote Map Item Request |
370 | 368 | ||
371 | |||
372 | // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. | 369 | // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. |
373 | // Note that we only start up a remote mapItem Request thread if there's users who could | 370 | // Note that we only start up a remote mapItem Request thread if there's users who could |
374 | // be making requests | 371 | // be making requests |
@@ -379,10 +376,8 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
379 | } | 376 | } |
380 | 377 | ||
381 | RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); | 378 | RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); |
382 | |||
383 | } | 379 | } |
384 | } | 380 | } |
385 | |||
386 | } | 381 | } |
387 | 382 | ||
388 | /// <summary> | 383 | /// <summary> |
@@ -441,7 +436,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
441 | /// <param name="response">The LLSDMap Response for the mapitem</param> | 436 | /// <param name="response">The LLSDMap Response for the mapitem</param> |
442 | private void RequestMapItemsCompleted(LLSDMap response) | 437 | private void RequestMapItemsCompleted(LLSDMap response) |
443 | { | 438 | { |
444 | |||
445 | UUID requestID = response["requestID"].AsUUID(); | 439 | UUID requestID = response["requestID"].AsUUID(); |
446 | 440 | ||
447 | if (requestID != UUID.Zero) | 441 | if (requestID != UUID.Zero) |
@@ -481,9 +475,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
481 | } | 475 | } |
482 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); | 476 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); |
483 | } | 477 | } |
484 | |||
485 | } | 478 | } |
486 | |||
487 | } | 479 | } |
488 | } | 480 | } |
489 | } | 481 | } |
@@ -509,7 +501,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
509 | st.itemtype = itemtype; | 501 | st.itemtype = itemtype; |
510 | st.regionhandle = regionhandle; | 502 | st.regionhandle = regionhandle; |
511 | EnqueueMapItemRequest(st); | 503 | EnqueueMapItemRequest(st); |
512 | |||
513 | } | 504 | } |
514 | 505 | ||
515 | /// <summary> | 506 | /// <summary> |
@@ -534,7 +525,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
534 | { | 525 | { |
535 | if (m_blacklistedregions.ContainsKey(regionhandle)) | 526 | if (m_blacklistedregions.ContainsKey(regionhandle)) |
536 | blacklisted = true; | 527 | blacklisted = true; |
537 | |||
538 | } | 528 | } |
539 | 529 | ||
540 | if (blacklisted) | 530 | if (blacklisted) |
@@ -645,7 +635,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
645 | } | 635 | } |
646 | catch (WebException) | 636 | catch (WebException) |
647 | { | 637 | { |
648 | |||
649 | responseMap["connect"] = LLSD.FromBoolean(false); | 638 | responseMap["connect"] = LLSD.FromBoolean(false); |
650 | lock (m_blacklistedurls) | 639 | lock (m_blacklistedurls) |
651 | { | 640 | { |
@@ -675,6 +664,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
675 | } | 664 | } |
676 | return responseMap; | 665 | return responseMap; |
677 | } | 666 | } |
667 | |||
678 | /// <summary> | 668 | /// <summary> |
679 | /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates | 669 | /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates |
680 | /// </summary> | 670 | /// </summary> |
@@ -789,6 +779,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
789 | 779 | ||
790 | return reply; | 780 | return reply; |
791 | } | 781 | } |
782 | |||
792 | // From msdn | 783 | // From msdn |
793 | private static ImageCodecInfo GetEncoderInfo(String mimeType) | 784 | private static ImageCodecInfo GetEncoderInfo(String mimeType) |
794 | { | 785 | { |
@@ -801,6 +792,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
801 | } | 792 | } |
802 | return null; | 793 | return null; |
803 | } | 794 | } |
795 | |||
804 | public LLSD HandleRemoteMapItemRequest(string path, LLSD request, string endpoint) | 796 | public LLSD HandleRemoteMapItemRequest(string path, LLSD request, string endpoint) |
805 | { | 797 | { |
806 | uint xstart = 0; | 798 | uint xstart = 0; |
@@ -858,11 +850,9 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
858 | } | 850 | } |
859 | return responsemap; | 851 | return responsemap; |
860 | } | 852 | } |
861 | |||
862 | 853 | ||
863 | private void MakeRootAgent(ScenePresence avatar) | 854 | private void MakeRootAgent(ScenePresence avatar) |
864 | { | 855 | { |
865 | |||
866 | // You may ask, why this is in a threadpool to start with.. | 856 | // You may ask, why this is in a threadpool to start with.. |
867 | // The reason is so we don't cause the thread to freeze waiting | 857 | // The reason is so we don't cause the thread to freeze waiting |
868 | // for the 1 second it costs to start a thread manually. | 858 | // for the 1 second it costs to start a thread manually. |
@@ -914,5 +904,4 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
914 | public uint itemtype; | 904 | public uint itemtype; |
915 | public ulong regionhandle; | 905 | public ulong regionhandle; |
916 | } | 906 | } |
917 | |||
918 | } | 907 | } |