diff options
author | Homer Horwitz | 2009-04-24 20:37:15 +0000 |
---|---|---|
committer | Homer Horwitz | 2009-04-24 20:37:15 +0000 |
commit | 6a08accde0887a95da4d9ac129e25af5c4800863 (patch) | |
tree | 63554d88f073f5846557d993141898a4ecdea94c /OpenSim | |
parent | * Write separate unit test for replicating iar structure to a user inventory (diff) | |
download | opensim-SC-6a08accde0887a95da4d9ac129e25af5c4800863.zip opensim-SC-6a08accde0887a95da4d9ac129e25af5c4800863.tar.gz opensim-SC-6a08accde0887a95da4d9ac129e25af5c4800863.tar.bz2 opensim-SC-6a08accde0887a95da4d9ac129e25af5c4800863.tar.xz |
- Moved WorldMapModule and HGWorldMapModule to the new region-module system
- Cleaned up some whitespace
Diffstat (limited to 'OpenSim')
3 files changed, 125 insertions, 70 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index e37cb59..6143c87 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs | |||
@@ -37,30 +37,51 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 37 | ||
38 | namespace OpenSim.Region.CoreModules.Hypergrid | 38 | namespace OpenSim.Region.CoreModules.Hypergrid |
39 | { | 39 | { |
40 | public class HGWorldMapModule : WorldMapModule, IRegionModule | 40 | public class HGWorldMapModule : WorldMapModule |
41 | { | 41 | { |
42 | private static readonly ILog m_log = | 42 | private static readonly ILog m_log = |
43 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 44 | ||
45 | #region IRegionModule Members | 45 | #region INonSharedRegionModule Members |
46 | 46 | ||
47 | public override void Initialise(Scene scene, IConfigSource config) | 47 | public override void Initialise(IConfigSource config) |
48 | { | 48 | { |
49 | IConfig startupConfig = config.Configs["Startup"]; | 49 | IConfig startupConfig = config.Configs["Startup"]; |
50 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") | 50 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") |
51 | m_Enabled = true; | 51 | m_Enabled = true; |
52 | } | ||
52 | 53 | ||
54 | public override void AddRegion(Scene scene) | ||
55 | { | ||
53 | if (!m_Enabled) | 56 | if (!m_Enabled) |
54 | return; | 57 | return; |
58 | |||
55 | m_log.Info("[HGMap] Initializing..."); | 59 | m_log.Info("[HGMap] Initializing..."); |
56 | m_scene = scene; | 60 | lock (scene) |
61 | { | ||
62 | m_scene = scene; | ||
57 | 63 | ||
58 | m_scene.RegisterModuleInterface<IWorldMapModule>(this); | 64 | m_scene.RegisterModuleInterface<IWorldMapModule>(this); |
65 | |||
66 | m_scene.AddCommand( | ||
67 | this, "export-map", | ||
68 | "export-map [<path>]", | ||
69 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); | ||
70 | } | ||
71 | } | ||
59 | 72 | ||
60 | m_scene.AddCommand( | 73 | public override void RemoveRegion(Scene scene) |
61 | this, "export-map", | 74 | { |
62 | "export-map [<path>]", | 75 | if (!m_Enabled) |
63 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); | 76 | return; |
77 | |||
78 | lock (m_scene) | ||
79 | { | ||
80 | m_Enabled = false; | ||
81 | m_scene.UnregisterModuleInterface<IWorldMapModule>(this); | ||
82 | // TODO: m_scene.RemoveCommand(this, "export-map"); | ||
83 | m_scene = null; | ||
84 | } | ||
64 | } | 85 | } |
65 | 86 | ||
66 | public override string Name | 87 | public override string Name |
@@ -158,5 +179,5 @@ namespace OpenSim.Region.CoreModules.Hypergrid | |||
158 | } | 179 | } |
159 | } | 180 | } |
160 | } | 181 | } |
161 | } | 182 | } |
162 | } | 183 | } |
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 8b5f26f..2920a96 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | |||
@@ -9,6 +9,8 @@ | |||
9 | 9 | ||
10 | <Extension path = "/OpenSim/RegionModules"> | 10 | <Extension path = "/OpenSim/RegionModules"> |
11 | <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" /> | 11 | <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" /> |
12 | <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> | ||
13 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> | ||
12 | </Extension> | 14 | </Extension> |
13 | 15 | ||
14 | <Extension path = "/OpenSim/WindModule"> | 16 | <Extension path = "/OpenSim/WindModule"> |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 4f98e8b..75b5a85 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -50,11 +50,11 @@ using OSDMap=OpenMetaverse.StructuredData.OSDMap; | |||
50 | 50 | ||
51 | namespace OpenSim.Region.CoreModules.World.WorldMap | 51 | namespace OpenSim.Region.CoreModules.World.WorldMap |
52 | { | 52 | { |
53 | public class WorldMapModule : IRegionModule, IWorldMapModule | 53 | public class WorldMapModule : INonSharedRegionModule, IWorldMapModule |
54 | { | 54 | { |
55 | private static readonly ILog m_log = | 55 | private static readonly ILog m_log = |
56 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
57 | 57 | ||
58 | private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg"; | 58 | private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg"; |
59 | 59 | ||
60 | private static readonly string m_mapLayerPath = "0001/"; | 60 | private static readonly string m_mapLayerPath = "0001/"; |
@@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
66 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); | 66 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); |
67 | private int cachedTime = 0; | 67 | private int cachedTime = 0; |
68 | private byte[] myMapImageJPEG; | 68 | private byte[] myMapImageJPEG; |
69 | protected bool m_Enabled = false; | 69 | protected volatile bool m_Enabled = false; |
70 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); | 70 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); |
71 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); | 71 | private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); |
72 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); | 72 | private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); |
@@ -77,49 +77,64 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
77 | 77 | ||
78 | //private int CacheRegionsDistance = 256; | 78 | //private int CacheRegionsDistance = 256; |
79 | 79 | ||
80 | #region IRegionModule Members | 80 | #region INonSharedRegionModule Members |
81 | 81 | public virtual void Initialise (IConfigSource config) | |
82 | public virtual void Initialise(Scene scene, IConfigSource config) | ||
83 | { | 82 | { |
84 | IConfig startupConfig = config.Configs["Startup"]; | 83 | IConfig startupConfig = config.Configs["Startup"]; |
85 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap") | 84 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap") |
86 | m_Enabled = true; | 85 | m_Enabled = true; |
86 | } | ||
87 | 87 | ||
88 | public virtual void AddRegion (Scene scene) | ||
89 | { | ||
88 | if (!m_Enabled) | 90 | if (!m_Enabled) |
89 | return; | 91 | return; |
90 | 92 | ||
91 | m_scene = scene; | 93 | lock (scene) |
92 | 94 | { | |
93 | m_scene.RegisterModuleInterface<IWorldMapModule>(this); | 95 | m_scene = scene; |
96 | |||
97 | m_scene.RegisterModuleInterface<IWorldMapModule>(this); | ||
98 | |||
99 | m_scene.AddCommand( | ||
100 | this, "export-map", | ||
101 | "export-map [<path>]", | ||
102 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); | ||
94 | 103 | ||
95 | m_scene.AddCommand( | 104 | AddHandlers(); |
96 | this, "export-map", | 105 | } |
97 | "export-map [<path>]", | ||
98 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); | ||
99 | } | 106 | } |
100 | 107 | ||
101 | public virtual void PostInitialise() | 108 | public virtual void RemoveRegion (Scene scene) |
102 | { | 109 | { |
103 | if (m_Enabled) | 110 | if (!m_Enabled) |
104 | AddHandlers(); | 111 | return; |
112 | |||
113 | lock (m_scene) | ||
114 | { | ||
115 | m_Enabled = false; | ||
116 | RemoveHandlers(); | ||
117 | m_scene = null; | ||
118 | } | ||
105 | } | 119 | } |
106 | 120 | ||
107 | public virtual void Close() | 121 | public virtual void RegionLoaded (Scene scene) |
108 | { | 122 | { |
109 | } | 123 | } |
110 | 124 | ||
111 | public virtual string Name | 125 | |
126 | public virtual void Close() | ||
112 | { | 127 | { |
113 | get { return "WorldMapModule"; } | ||
114 | } | 128 | } |
115 | 129 | ||
116 | public bool IsSharedModule | 130 | public virtual string Name |
117 | { | 131 | { |
118 | get { return false; } | 132 | get { return "WorldMapModule"; } |
119 | } | 133 | } |
120 | 134 | ||
121 | #endregion | 135 | #endregion |
122 | 136 | ||
137 | // this has to be called with a lock on m_scene | ||
123 | protected virtual void AddHandlers() | 138 | protected virtual void AddHandlers() |
124 | { | 139 | { |
125 | myMapImageJPEG = new byte[0]; | 140 | myMapImageJPEG = new byte[0]; |
@@ -139,6 +154,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
139 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; | 154 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; |
140 | } | 155 | } |
141 | 156 | ||
157 | // this has to be called with a lock on m_scene | ||
158 | protected virtual void RemoveHandlers() | ||
159 | { | ||
160 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; | ||
161 | m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; | ||
162 | m_scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
163 | m_scene.EventManager.OnNewClient -= OnNewClient; | ||
164 | m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | ||
165 | |||
166 | string regionimage = "regionImage" + m_scene.RegionInfo.RegionID.ToString(); | ||
167 | regionimage = regionimage.Replace("-", ""); | ||
168 | m_scene.CommsManager.HttpServer.RemoveLLSDHandler("/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), | ||
169 | HandleRemoteMapItemRequest); | ||
170 | m_scene.CommsManager.HttpServer.RemoveHTTPHandler("", regionimage); | ||
171 | } | ||
172 | |||
142 | public void OnRegisterCaps(UUID agentID, Caps caps) | 173 | public void OnRegisterCaps(UUID agentID, Caps caps) |
143 | { | 174 | { |
144 | //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 175 | //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
@@ -246,7 +277,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
246 | private void OnNewClient(IClientAPI client) | 277 | private void OnNewClient(IClientAPI client) |
247 | { | 278 | { |
248 | client.OnRequestMapBlocks += RequestMapBlocks; | 279 | client.OnRequestMapBlocks += RequestMapBlocks; |
249 | client.OnMapItemRequest += HandleMapItemRequest; | 280 | client.OnMapItemRequest += HandleMapItemRequest; |
250 | } | 281 | } |
251 | 282 | ||
252 | /// <summary> | 283 | /// <summary> |
@@ -269,7 +300,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
269 | } | 300 | } |
270 | if (rootcount <= 1) | 301 | if (rootcount <= 1) |
271 | StopThread(); | 302 | StopThread(); |
272 | 303 | ||
273 | lock (m_rootAgents) | 304 | lock (m_rootAgents) |
274 | { | 305 | { |
275 | if (m_rootAgents.Contains(AgentId)) | 306 | if (m_rootAgents.Contains(AgentId)) |
@@ -316,7 +347,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
316 | requests.Enqueue(st); | 347 | requests.Enqueue(st); |
317 | } | 348 | } |
318 | 349 | ||
319 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, | 350 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, |
320 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 351 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
321 | { | 352 | { |
322 | lock (m_rootAgents) | 353 | lock (m_rootAgents) |
@@ -330,7 +361,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
330 | if (itemtype == 6) // we only sevice 6 right now (avatar green dots) | 361 | if (itemtype == 6) // we only sevice 6 right now (avatar green dots) |
331 | { | 362 | { |
332 | if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) | 363 | if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) |
333 | { | 364 | { |
334 | // Local Map Item Request | 365 | // Local Map Item Request |
335 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 366 | List<ScenePresence> avatars = m_scene.GetAvatars(); |
336 | int tc = Environment.TickCount; | 367 | int tc = Environment.TickCount; |
@@ -372,7 +403,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
372 | // Remote Map Item Request | 403 | // Remote Map Item Request |
373 | 404 | ||
374 | // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. | 405 | // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. |
375 | // Note that we only start up a remote mapItem Request thread if there's users who could | 406 | // Note that we only start up a remote mapItem Request thread if there's users who could |
376 | // be making requests | 407 | // be making requests |
377 | if (!threadrunning) | 408 | if (!threadrunning) |
378 | { | 409 | { |
@@ -395,14 +426,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
395 | while (true) | 426 | while (true) |
396 | { | 427 | { |
397 | MapRequestState st = requests.Dequeue(); | 428 | MapRequestState st = requests.Dequeue(); |
398 | 429 | ||
399 | // end gracefully | 430 | // end gracefully |
400 | if (st.agentID == UUID.Zero) | 431 | if (st.agentID == UUID.Zero) |
401 | { | 432 | { |
402 | ThreadTracker.Remove(mapItemReqThread); | 433 | ThreadTracker.Remove(mapItemReqThread); |
403 | break; | 434 | break; |
404 | } | 435 | } |
405 | 436 | ||
406 | bool dorequest = true; | 437 | bool dorequest = true; |
407 | lock (m_rootAgents) | 438 | lock (m_rootAgents) |
408 | { | 439 | { |
@@ -421,7 +452,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
421 | { | 452 | { |
422 | m_log.ErrorFormat("[WORLD MAP]: Map item request thread terminated abnormally with exception {0}", e); | 453 | m_log.ErrorFormat("[WORLD MAP]: Map item request thread terminated abnormally with exception {0}", e); |
423 | } | 454 | } |
424 | 455 | ||
425 | threadrunning = false; | 456 | threadrunning = false; |
426 | } | 457 | } |
427 | 458 | ||
@@ -498,11 +529,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
498 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 529 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
499 | { | 530 | { |
500 | MapRequestState st = new MapRequestState(); | 531 | MapRequestState st = new MapRequestState(); |
501 | st.agentID = id; | 532 | st.agentID = id; |
502 | st.flags = flags; | 533 | st.flags = flags; |
503 | st.EstateID = EstateID; | 534 | st.EstateID = EstateID; |
504 | st.godlike = godlike; | 535 | st.godlike = godlike; |
505 | st.itemtype = itemtype; | 536 | st.itemtype = itemtype; |
506 | st.regionhandle = regionhandle; | 537 | st.regionhandle = regionhandle; |
507 | EnqueueMapItemRequest(st); | 538 | EnqueueMapItemRequest(st); |
508 | } | 539 | } |
@@ -510,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
510 | /// <summary> | 541 | /// <summary> |
511 | /// Does the actual remote mapitem request | 542 | /// Does the actual remote mapitem request |
512 | /// This should be called from an asynchronous thread | 543 | /// This should be called from an asynchronous thread |
513 | /// Request failures get blacklisted until region restart so we don't | 544 | /// Request failures get blacklisted until region restart so we don't |
514 | /// continue to spend resources trying to contact regions that are down. | 545 | /// continue to spend resources trying to contact regions that are down. |
515 | /// </summary> | 546 | /// </summary> |
516 | /// <param name="httpserver">blank string, we discover this in the process</param> | 547 | /// <param name="httpserver">blank string, we discover this in the process</param> |
@@ -543,7 +574,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
543 | if (httpserver.Length == 0) | 574 | if (httpserver.Length == 0) |
544 | { | 575 | { |
545 | RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); | 576 | RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); |
546 | 577 | ||
547 | if (mreg != null) | 578 | if (mreg != null) |
548 | { | 579 | { |
549 | httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString(); | 580 | httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString(); |
@@ -682,7 +713,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
682 | if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible | 713 | if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible |
683 | { | 714 | { |
684 | List<MapBlockData> response = new List<MapBlockData>(); | 715 | List<MapBlockData> response = new List<MapBlockData>(); |
685 | 716 | ||
686 | // this should return one mapblock at most. But make sure: Look whether the one we requested is in there | 717 | // this should return one mapblock at most. But make sure: Look whether the one we requested is in there |
687 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | 718 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); |
688 | if (mapBlocks != null) | 719 | if (mapBlocks != null) |
@@ -697,7 +728,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
697 | } | 728 | } |
698 | } | 729 | } |
699 | } | 730 | } |
700 | 731 | ||
701 | if (response.Count == 0) | 732 | if (response.Count == 0) |
702 | { | 733 | { |
703 | // response still empty => couldn't find the map-tile the user clicked on => tell the client | 734 | // response still empty => couldn't find the map-tile the user clicked on => tell the client |
@@ -796,13 +827,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
796 | } | 827 | } |
797 | return null; | 828 | return null; |
798 | } | 829 | } |
799 | 830 | ||
800 | /// <summary> | 831 | /// <summary> |
801 | /// Export the world map | 832 | /// Export the world map |
802 | /// </summary> | 833 | /// </summary> |
803 | /// <param name="fileName"></param> | 834 | /// <param name="fileName"></param> |
804 | public void HandleExportWorldMapConsoleCommand(string module, string[] cmdparams) | 835 | public void HandleExportWorldMapConsoleCommand(string module, string[] cmdparams) |
805 | { | 836 | { |
806 | if (m_scene.ConsoleScene() == null) | 837 | if (m_scene.ConsoleScene() == null) |
807 | { | 838 | { |
808 | // FIXME: If console region is root then this will be printed by every module. Currently, there is no | 839 | // FIXME: If console region is root then this will be printed by every module. Currently, there is no |
@@ -811,20 +842,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
811 | m_log.InfoFormat("[WORLD MAP]: Please change to a specific region in order to export its world map"); | 842 | m_log.InfoFormat("[WORLD MAP]: Please change to a specific region in order to export its world map"); |
812 | return; | 843 | return; |
813 | } | 844 | } |
814 | 845 | ||
815 | if (m_scene.ConsoleScene() != m_scene) | 846 | if (m_scene.ConsoleScene() != m_scene) |
816 | return; | 847 | return; |
817 | 848 | ||
818 | string exportPath; | 849 | string exportPath; |
819 | 850 | ||
820 | if (cmdparams.Length > 1) | 851 | if (cmdparams.Length > 1) |
821 | exportPath = cmdparams[1]; | 852 | exportPath = cmdparams[1]; |
822 | else | 853 | else |
823 | exportPath = DEFAULT_WORLD_MAP_EXPORT_PATH; | 854 | exportPath = DEFAULT_WORLD_MAP_EXPORT_PATH; |
824 | 855 | ||
825 | m_log.InfoFormat( | 856 | m_log.InfoFormat( |
826 | "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); | 857 | "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); |
827 | 858 | ||
828 | List<MapBlockData> mapBlocks = | 859 | List<MapBlockData> mapBlocks = |
829 | m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( | 860 | m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( |
830 | (int)(m_scene.RegionInfo.RegionLocX - 9), | 861 | (int)(m_scene.RegionInfo.RegionLocX - 9), |
@@ -872,19 +903,19 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
872 | ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.RegionLocY) + 10); | 903 | ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.RegionLocY) + 10); |
873 | g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); | 904 | g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); |
874 | } | 905 | } |
875 | 906 | ||
876 | mapTexture.Save(exportPath, ImageFormat.Jpeg); | 907 | mapTexture.Save(exportPath, ImageFormat.Jpeg); |
877 | 908 | ||
878 | m_log.InfoFormat( | 909 | m_log.InfoFormat( |
879 | "[WORLD MAP]: Successfully exported world map for {0} to {1}", | 910 | "[WORLD MAP]: Successfully exported world map for {0} to {1}", |
880 | m_scene.RegionInfo.RegionName, exportPath); | 911 | m_scene.RegionInfo.RegionName, exportPath); |
881 | } | 912 | } |
882 | 913 | ||
883 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) | 914 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) |
884 | { | 915 | { |
885 | uint xstart = 0; | 916 | uint xstart = 0; |
886 | uint ystart = 0; | 917 | uint ystart = 0; |
887 | 918 | ||
888 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart); | 919 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart); |
889 | 920 | ||
890 | OSDMap responsemap = new OSDMap(); | 921 | OSDMap responsemap = new OSDMap(); |
@@ -892,7 +923,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
892 | OSDArray responsearr = new OSDArray(avatars.Count); | 923 | OSDArray responsearr = new OSDArray(avatars.Count); |
893 | OSDMap responsemapdata = new OSDMap(); | 924 | OSDMap responsemapdata = new OSDMap(); |
894 | int tc = Environment.TickCount; | 925 | int tc = Environment.TickCount; |
895 | /* | 926 | /* |
896 | foreach (ScenePresence av in avatars) | 927 | foreach (ScenePresence av in avatars) |
897 | { | 928 | { |
898 | responsemapdata = new OSDMap(); | 929 | responsemapdata = new OSDMap(); |
@@ -916,10 +947,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
916 | responsemapdata["Extra"] = OSD.FromInteger(0); | 947 | responsemapdata["Extra"] = OSD.FromInteger(0); |
917 | responsemapdata["Extra2"] = OSD.FromInteger(0); | 948 | responsemapdata["Extra2"] = OSD.FromInteger(0); |
918 | responsearr.Add(responsemapdata); | 949 | responsearr.Add(responsemapdata); |
919 | 950 | ||
920 | responsemap["6"] = responsearr; | 951 | responsemap["6"] = responsearr; |
921 | } | 952 | } |
922 | else | 953 | else |
923 | { | 954 | { |
924 | responsearr = new OSDArray(avatars.Count); | 955 | responsearr = new OSDArray(avatars.Count); |
925 | foreach (ScenePresence av in avatars) | 956 | foreach (ScenePresence av in avatars) |
@@ -937,7 +968,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
937 | } | 968 | } |
938 | return responsemap; | 969 | return responsemap; |
939 | } | 970 | } |
940 | 971 | ||
941 | public void LazySaveGeneratedMaptile(byte[] data, bool temporary) | 972 | public void LazySaveGeneratedMaptile(byte[] data, bool temporary) |
942 | { | 973 | { |
943 | // Overwrites the local Asset cache with new maptile data | 974 | // Overwrites the local Asset cache with new maptile data |
@@ -987,19 +1018,19 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
987 | AssetBase asset = new AssetBase(); | 1018 | AssetBase asset = new AssetBase(); |
988 | asset.FullID = m_scene.RegionInfo.RegionSettings.TerrainImageID; | 1019 | asset.FullID = m_scene.RegionInfo.RegionSettings.TerrainImageID; |
989 | asset.Data = data; | 1020 | asset.Data = data; |
990 | asset.Name | 1021 | asset.Name |
991 | = "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); | 1022 | = "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); |
992 | asset.Description = m_scene.RegionInfo.RegionName; | 1023 | asset.Description = m_scene.RegionInfo.RegionName; |
993 | 1024 | ||
994 | asset.Type = 0; | 1025 | asset.Type = 0; |
995 | asset.Temporary = temporary; | 1026 | asset.Temporary = temporary; |
996 | m_scene.CommsManager.AssetCache.AddAsset(asset); | 1027 | m_scene.CommsManager.AssetCache.AddAsset(asset); |
997 | } | 1028 | } |
998 | 1029 | ||
999 | private void MakeRootAgent(ScenePresence avatar) | 1030 | private void MakeRootAgent(ScenePresence avatar) |
1000 | { | 1031 | { |
1001 | // You may ask, why this is in a threadpool to start with.. | 1032 | // You may ask, why this is in a threadpool to start with.. |
1002 | // The reason is so we don't cause the thread to freeze waiting | 1033 | // The reason is so we don't cause the thread to freeze waiting |
1003 | // for the 1 second it costs to start a thread manually. | 1034 | // for the 1 second it costs to start a thread manually. |
1004 | if (!threadrunning) | 1035 | if (!threadrunning) |
1005 | ThreadPool.QueueUserWorkItem(new WaitCallback(this.StartThread)); | 1036 | ThreadPool.QueueUserWorkItem(new WaitCallback(this.StartThread)); |
@@ -1036,6 +1067,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1036 | } | 1067 | } |
1037 | } | 1068 | } |
1038 | } | 1069 | } |
1070 | |||
1039 | } | 1071 | } |
1040 | 1072 | ||
1041 | public struct MapRequestState | 1073 | public struct MapRequestState |