From 180be7de07014aa33bc6066f12a0819b731c1c9d Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 10 Feb 2009 13:10:57 +0000 Subject: this is step 2 of 2 of the OpenSim.Region.Environment refactor. NOTHING has been deleted or moved off to forge at this point. what has happened is that OpenSim.Region.Environment.Modules has been split in two: - OpenSim.Region.CoreModules: all those modules that are either directly or indirectly referenced from other OpenSim packages, or that provide functionality that the OpenSim developer community considers core functionality: CoreModules/Agent/AssetTransaction CoreModules/Agent/Capabilities CoreModules/Agent/TextureDownload CoreModules/Agent/TextureSender CoreModules/Agent/TextureSender/Tests CoreModules/Agent/Xfer CoreModules/Avatar/AvatarFactory CoreModules/Avatar/Chat/ChatModule CoreModules/Avatar/Combat CoreModules/Avatar/Currency/SampleMoney CoreModules/Avatar/Dialog CoreModules/Avatar/Friends CoreModules/Avatar/Gestures CoreModules/Avatar/Groups CoreModules/Avatar/InstantMessage CoreModules/Avatar/Inventory CoreModules/Avatar/Inventory/Archiver CoreModules/Avatar/Inventory/Transfer CoreModules/Avatar/Lure CoreModules/Avatar/ObjectCaps CoreModules/Avatar/Profiles CoreModules/Communications/Local CoreModules/Communications/REST CoreModules/Framework/EventQueue CoreModules/Framework/InterfaceCommander CoreModules/Hypergrid CoreModules/InterGrid CoreModules/Scripting/DynamicTexture CoreModules/Scripting/EMailModules CoreModules/Scripting/HttpRequest CoreModules/Scripting/LoadImageURL CoreModules/Scripting/VectorRender CoreModules/Scripting/WorldComm CoreModules/Scripting/XMLRPC CoreModules/World/Archiver CoreModules/World/Archiver/Tests CoreModules/World/Estate CoreModules/World/Land CoreModules/World/Permissions CoreModules/World/Serialiser CoreModules/World/Sound CoreModules/World/Sun CoreModules/World/Terrain CoreModules/World/Terrain/DefaultEffects CoreModules/World/Terrain/DefaultEffects/bin CoreModules/World/Terrain/DefaultEffects/bin/Debug CoreModules/World/Terrain/Effects CoreModules/World/Terrain/FileLoaders CoreModules/World/Terrain/FloodBrushes CoreModules/World/Terrain/PaintBrushes CoreModules/World/Terrain/Tests CoreModules/World/Vegetation CoreModules/World/Wind CoreModules/World/WorldMap - OpenSim.Region.OptionalModules: all those modules that are not core modules: OptionalModules/Avatar/Chat/IRC-stuff OptionalModules/Avatar/Concierge OptionalModules/Avatar/Voice/AsterixVoice OptionalModules/Avatar/Voice/SIPVoice OptionalModules/ContentManagementSystem OptionalModules/Grid/Interregion OptionalModules/Python OptionalModules/SvnSerialiser OptionalModules/World/NPC OptionalModules/World/TreePopulator --- .../Modules/Hypergrid/HGStandaloneAssetService.cs | 201 ------------- .../Hypergrid/HGStandaloneInventoryService.cs | 314 --------------------- .../Modules/Hypergrid/HGWorldMapModule.cs | 178 ------------ 3 files changed, 693 deletions(-) delete mode 100644 OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs delete mode 100644 OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs delete mode 100644 OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs (limited to 'OpenSim/Region/Environment/Modules/Hypergrid') diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs deleted file mode 100644 index 4cb1c20..0000000 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs +++ /dev/null @@ -1,201 +0,0 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -using System; -using System.Collections.Generic; -using System.Net; -using System.Reflection; - -using log4net; -using Nini.Config; - -using OpenMetaverse; - -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Grid.AssetServer; -using OpenSim.Data; - -namespace OpenSim.Region.Environment.Modules.Hypergrid -{ - public class HGStandaloneAssetService : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool initialized = false; - private static bool enabled = false; - - Scene m_scene; - //AssetService m_assetService; - - #region IRegionModule interface - - public void Initialise(Scene scene, IConfigSource config) - { - if (!initialized) - { - initialized = true; - m_scene = scene; - - // This module is only on for standalones in hypergrid mode - enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); - } - } - - public void PostInitialise() - { - if (enabled) - { - m_log.Info("[HGStandaloneAssetService]: Starting..."); - - //m_assetService = new AssetService(m_scene); - new AssetService(m_scene); - } - } - - public void Close() - { - } - - public string Name - { - get { return "HGStandaloneAssetService"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - } - - public class AssetService - { - private IUserService m_userService; - private bool m_doLookup = false; - - public bool DoLookup - { - get { return m_doLookup; } - set { m_doLookup = value; } - } - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public AssetService(Scene m_scene) - { - AddHttpHandlers(m_scene); - m_userService = m_scene.CommsManager.UserService; - } - - protected void AddHttpHandlers(Scene m_scene) - { - IAssetDataPlugin m_assetProvider = ((AssetServerBase)m_scene.AssetCache.AssetServer).AssetProviderPlugin; - - BaseHttpServer httpServer = m_scene.CommsManager.HttpServer; - httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); - httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); - - } - - ///// - ///// Check that the source of an inventory request is one that we trust. - ///// - ///// - ///// - //public bool CheckTrustSource(IPEndPoint peer) - //{ - // if (m_doLookup) - // { - // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); - // UriBuilder ub = new UriBuilder(m_userserver_url); - // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); - // foreach (IPAddress uaddr in uaddrs) - // { - // if (uaddr.Equals(peer.Address)) - // { - // return true; - // } - // } - - // m_log.WarnFormat( - // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", - // peer); - - // return false; - // } - // else - // { - // return true; - // } - //} - - /// - /// Check that the source of an inventory request for a particular agent is a current session belonging to - /// that agent. - /// - /// - /// - /// - public bool CheckAuthSession(string session_id, string avatar_id) - { - if (m_doLookup) - { - m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); - UUID userID = UUID.Zero; - UUID sessionID = UUID.Zero; - UUID.TryParse(avatar_id, out userID); - UUID.TryParse(session_id, out sessionID); - if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) - { - m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); - return false; - } - UserProfileData userProfile = m_userService.GetUserProfile(userID); - if (userProfile != null && userProfile.CurrentAgent != null && - userProfile.CurrentAgent.SessionID == sessionID) - { - m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); - return true; - } - - m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); - return false; - } - else - { - return true; - } - } - } -} diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs deleted file mode 100644 index 54ba761..0000000 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs +++ /dev/null @@ -1,314 +0,0 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -using System; -using System.Collections.Generic; -using System.Net; -using System.Reflection; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.Environment.Modules.Hypergrid -{ - public class HGStandaloneInventoryService : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool initialized = false; - private static bool enabled = false; - - Scene m_scene; - //InventoryService m_inventoryService; - - #region IRegionModule interface - - public void Initialise(Scene scene, IConfigSource config) - { - if (!initialized) - { - initialized = true; - m_scene = scene; - - // This module is only on for standalones - enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); - } - } - - public void PostInitialise() - { - if (enabled) - { - m_log.Info("[HGStandaloneInvService]: Starting..."); - //m_inventoryService = new InventoryService(m_scene); - new InventoryService(m_scene); - } - } - - public void Close() - { - } - - public string Name - { - get { return "HGStandaloneInventoryService"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - } - - public class InventoryService - { - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private InventoryServiceBase m_inventoryService; - private IUserService m_userService; - private bool m_doLookup = false; - - public bool DoLookup - { - get { return m_doLookup; } - set { m_doLookup = value; } - } - - public InventoryService(Scene m_scene) - { - m_inventoryService = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; - m_userService = m_scene.CommsManager.UserService; - AddHttpHandlers(m_scene); - } - - protected void AddHttpHandlers(Scene m_scene) - { - BaseHttpServer httpServer = m_scene.CommsManager.HttpServer; - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/NewFolder/", m_inventoryService.AddFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/MoveFolder/", m_inventoryService.MoveFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/NewItem/", m_inventoryService.AddItem, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/DeleteItem/", m_inventoryService.DeleteItem, CheckAuthSession)); - - //// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g - //// system folders such as Objects, Textures), but it now returns the entire inventory skeleton. - //// It would have been better to rename this request, but complexities in the BaseHttpServer - //// (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier - //// to do this for now. - //m_scene.AddStreamHandler( - // new RestDeserialiseTrustedHandler> - // ("POST", "/RootFolders/", GetInventorySkeleton, CheckTrustSource)); - - //// for persistent active gestures - //m_scene.AddStreamHandler( - // new RestDeserialiseTrustedHandler> - // ("POST", "/ActiveGestures/", GetActiveGestures, CheckTrustSource)); - } - - - ///// - ///// Check that the source of an inventory request is one that we trust. - ///// - ///// - ///// - //public bool CheckTrustSource(IPEndPoint peer) - //{ - // if (m_doLookup) - // { - // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); - // UriBuilder ub = new UriBuilder(m_userserver_url); - // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); - // foreach (IPAddress uaddr in uaddrs) - // { - // if (uaddr.Equals(peer.Address)) - // { - // return true; - // } - // } - - // m_log.WarnFormat( - // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", - // peer); - - // return false; - // } - // else - // { - // return true; - // } - //} - - /// - /// Check that the source of an inventory request for a particular agent is a current session belonging to - /// that agent. - /// - /// - /// - /// - public bool CheckAuthSession(string session_id, string avatar_id) - { - if (m_doLookup) - { - m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); - UUID userID = UUID.Zero; - UUID sessionID = UUID.Zero; - UUID.TryParse(avatar_id, out userID); - UUID.TryParse(session_id, out sessionID); - if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) - { - m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); - return false; - } - UserProfileData userProfile = m_userService.GetUserProfile(userID); - if (userProfile != null && userProfile.CurrentAgent != null && - userProfile.CurrentAgent.SessionID == sessionID) - { - m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); - return true; - } - - m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); - return false; - } - else - { - return true; - } - } - - - /// - /// Return a user's entire inventory - /// - /// - /// The user's inventory. If an inventory cannot be found then an empty collection is returned. - public InventoryCollection GetUserInventory(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - - m_log.Info("[HGStandaloneInvService]: Processing request for inventory of " + userID); - - // Uncomment me to simulate a slow responding inventory server - //Thread.Sleep(16000); - - InventoryCollection invCollection = new InventoryCollection(); - - List allFolders = ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); - - if (null == allFolders) - { - m_log.WarnFormat("[HGStandaloneInvService]: No inventory found for user {0}", rawUserID); - - return invCollection; - } - - List allItems = new List(); - - foreach (InventoryFolderBase folder in allFolders) - { - List items = ((InventoryServiceBase)m_inventoryService).RequestFolderItems(folder.ID); - - if (items != null) - { - allItems.InsertRange(0, items); - } - } - - invCollection.UserID = userID; - invCollection.Folders = allFolders; - invCollection.Items = allItems; - - // foreach (InventoryFolderBase folder in invCollection.Folders) - // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); - // } - // - // foreach (InventoryItemBase item in invCollection.Items) - // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); - // } - - m_log.InfoFormat( - "[HGStandaloneInvService]: Sending back inventory response to user {0} containing {1} folders and {2} items", - invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); - - return invCollection; - } - - /// - /// Guid to UUID wrapper for same name IInventoryServices method - /// - /// - /// - public List GetInventorySkeleton(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - return ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); - } - - public List GetActiveGestures(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - - m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); - - return ((InventoryServiceBase)m_inventoryService).GetActiveGestures(userID); - } - } -} diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs deleted file mode 100644 index 1d9182e..0000000 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using System.Net; -using System.Reflection; -using System.Threading; -using OpenMetaverse; -using OpenMetaverse.Imaging; -using OpenMetaverse.StructuredData; -using log4net; -using Nini.Config; -using Nwc.XmlRpc; - -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Types; -using OpenSim.Region.Environment.Modules.World.WorldMap; -using Caps = OpenSim.Framework.Communications.Capabilities.Caps; - -using OSD = OpenMetaverse.StructuredData.OSD; -using OSDMap = OpenMetaverse.StructuredData.OSDMap; -using OSDArray = OpenMetaverse.StructuredData.OSDArray; - -namespace OpenSim.Region.Environment.Modules.Hypergrid -{ - public class HGWorldMapModule : WorldMapModule, IRegionModule - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - #region IRegionModule Members - - public override void Initialise(Scene scene, IConfigSource config) - { - IConfig startupConfig = config.Configs["Startup"]; - if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") - m_Enabled = true; - - if (!m_Enabled) - return; - m_log.Info("[HGMap] Initializing..."); - m_scene = scene; - } - - - public override string Name - { - get { return "HGWorldMap"; } - } - - - #endregion - - /// - /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates - /// - /// - /// - /// - /// - public override void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) - { - // - // WARNING!!! COPY & PASTE FROM SUPERCLASS - // The only difference is at the very end - // - - m_log.Info("[HGMap]: Request map blocks " + minX + "-" + maxX + " " + minY + "-" + maxY); - - //m_scene.ForEachScenePresence(delegate (ScenePresence sp) { - // if (!sp.IsChildAgent && sp.UUID == remoteClient.AgentId) - // { - // Console.WriteLine("XXX Root agent"); - // DoRequestMapBlocks(remoteClient, minX, minY, maxX, maxY, flag); - // } - //}; - - List mapBlocks; - if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible - { - List response = new List(); - - // this should return one mapblock at most. But make sure: Look whether the one we requested is in there - mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); - if (mapBlocks != null) - { - foreach (MapBlockData block in mapBlocks) - { - if (block.X == minX && block.Y == minY) - { - // found it => add it to response - response.Add(block); - break; - } - } - } - response = mapBlocks; - if (response.Count == 0) - { - // response still empty => couldn't find the map-tile the user clicked on => tell the client - MapBlockData block = new MapBlockData(); - block.X = (ushort)minX; - block.Y = (ushort)minY; - block.Access = 254; // == not there - response.Add(block); - } - remoteClient.SendMapBlock(response, 0); - } - else - { - // normal mapblock request. Use the provided values - mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); - - // Different from super - FillInMap(mapBlocks, minX, minY, maxX, maxY); - // - - remoteClient.SendMapBlock(mapBlocks, flag); - } - } - - - private void FillInMap(List mapBlocks, int minX, int minY, int maxX, int maxY) - { - for (int x = minX; x <= maxX; x++) - for (int y = minY; y <= maxY; y++) - { - MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); }); - if (mblock == null) - { - mblock = new MapBlockData(); - mblock.X = (ushort)x; - mblock.Y = (ushort)y; - mblock.Name = ""; - mblock.Access = 254; // not here??? - mblock.MapImageId = UUID.Zero; - mapBlocks.Add(mblock); - } - } - } - } -} -- cgit v1.1