From 7f0350b98858309d8c6e8b7689c2efdf12ca60b9 Mon Sep 17 00:00:00 2001 From: Marck Date: Sun, 12 Dec 2010 20:06:23 +0100 Subject: [PATCH 1/5] Trigger event with flag CHANGED_LINK when agent sits on objects that have not a sit target defined. This fixes Mantis #4692. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 ------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f87056e48e..4fcd8f5c9d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3251,13 +3251,6 @@ namespace OpenSim.Region.Framework.Scenes //} } - public void SetAvatarOnSitTarget(UUID avatarID) - { - m_sitTargetAvatar = avatarID; - if (ParentGroup != null) - ParentGroup.TriggerScriptChangedEvent(Changed.LINK); - } - public void SetAxisRotation(int axis, int rotate) { if (m_parentGroup != null) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f64d53987c..30c9365bb4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1703,7 +1703,9 @@ namespace OpenSim.Region.Framework.Scenes } // Reset sit target. if (part.GetAvatarOnSitTarget() == UUID) - part.SetAvatarOnSitTarget(UUID.Zero); + part.SitTargetAvatar = UUID.Zero; + if (part.ParentGroup != null) + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); m_parentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); @@ -1807,11 +1809,13 @@ namespace OpenSim.Region.Framework.Scenes if (SitTargetisSet && SitTargetUnOccupied) { - part.SetAvatarOnSitTarget(UUID); + part.SitTargetAvatar = UUID; offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); sitOrientation = avSitOrientation; autopilot = false; } + if (part.ParentGroup != null) + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); pos = part.AbsolutePosition + offset; //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) From 870bbcfc6c264c515ac660837d16ccad4e59ac64 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 13 Dec 2010 09:42:27 -0800 Subject: [PATCH 2/5] This may have been the biggest, baddest bug in OpenSim ever... confusion between bytes per second and bytes per millisecond. --- OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index bdbd2848c6..4d9ca0959b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -119,6 +119,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Properties + // To help debugging + private static int idCount = 0; + private int id; + /// /// Default constructor /// @@ -134,6 +138,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP MaxBurst = maxBurst; DripRate = dripRate; lastDrip = Environment.TickCount & Int32.MaxValue; + id = idCount++; } /// @@ -191,6 +196,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (tokensPerMS == 0) { content = maxBurst; + //Console.WriteLine("XXX (" + id + ") content = maxBurst and maxBurst = " + maxBurst); return true; } else @@ -205,11 +211,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP return false; } - int dripAmount = deltaMS * tokensPerMS; - + // dripAmpount here is in bytes per millisecond + int dripAmount = deltaMS * tokensPerMS; + // but content is in bytes per second, so let's multiply by 1000 + dripAmount = dripAmount * 1000; content = Math.Min(content + dripAmount, maxBurst); lastDrip = now; + //Console.WriteLine("XXX (" + id + ") deltaMS=" + deltaMS + "; tokensPerMS=" + tokensPerMS + "; content=" + content + "; dripAmount=" + dripAmount); return true; } } From 6b8d01d8c4b4c4f05e0bc51724984dab22e4ee51 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 13 Dec 2010 11:45:17 -0800 Subject: [PATCH 3/5] It turns out that the 1/2 sec burst for prims download is not a bug, but a feature of the client. The client sets the throttles in such a way that makes the server behave like that. The same happens in the Linden Grid. Revert "This may have been the biggest, baddest bug in OpenSim ever... confusion between bytes per second and bytes per millisecond." This reverts commit 870bbcfc6c264c515ac660837d16ccad4e59ac64. --- OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index 4d9ca0959b..bdbd2848c6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -119,10 +119,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Properties - // To help debugging - private static int idCount = 0; - private int id; - /// /// Default constructor /// @@ -138,7 +134,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP MaxBurst = maxBurst; DripRate = dripRate; lastDrip = Environment.TickCount & Int32.MaxValue; - id = idCount++; } /// @@ -196,7 +191,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (tokensPerMS == 0) { content = maxBurst; - //Console.WriteLine("XXX (" + id + ") content = maxBurst and maxBurst = " + maxBurst); return true; } else @@ -211,14 +205,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP return false; } - // dripAmpount here is in bytes per millisecond - int dripAmount = deltaMS * tokensPerMS; - // but content is in bytes per second, so let's multiply by 1000 - dripAmount = dripAmount * 1000; + int dripAmount = deltaMS * tokensPerMS; + content = Math.Min(content + dripAmount, maxBurst); lastDrip = now; - //Console.WriteLine("XXX (" + id + ") deltaMS=" + deltaMS + "; tokensPerMS=" + tokensPerMS + "; content=" + content + "; dripAmount=" + dripAmount); return true; } } From 9a24c0b41c786f49766c212c656f8162e4c263ef Mon Sep 17 00:00:00 2001 From: Marck Date: Mon, 13 Dec 2010 21:19:33 +0100 Subject: [PATCH 4/5] Show map tile for hyperlinks. Perform Check4096 before adding a hyperlink. Configuration option AssetService in section [GridService] must be set to enable this functionality. Map tiles do currently not show for hyperlinks set in simulators that are connected to grids, see Mantis #5270. --- .../Hypergrid/GatekeeperServiceConnector.cs | 29 +++---- .../Services/GridService/HypergridLinker.cs | 76 ++++++++++--------- .../HypergridService/GatekeeperService.cs | 29 ++++--- bin/Robust.HG.ini.example | 6 ++ bin/config-include/GridCommon.ini.example | 3 + bin/config-include/GridHypergrid.ini | 9 ++- .../StandaloneCommon.ini.example | 3 + bin/config-include/StandaloneHypergrid.ini | 11 ++- 8 files changed, 95 insertions(+), 71 deletions(-) diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 85c13804a6..d4fd1b8950 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Net; using System.Reflection; using OpenSim.Framework; @@ -48,7 +49,7 @@ namespace OpenSim.Services.Connectors.Hypergrid { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -// private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); + private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); private IAssetService m_AssetService; @@ -143,24 +144,25 @@ namespace OpenSim.Services.Connectors.Hypergrid return true; } - UUID m_MissingTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); - - public UUID GetMapImage(UUID regionID, string imageURL) + public UUID GetMapImage(UUID regionID, string imageURL, string storagePath) { if (m_AssetService == null) - return m_MissingTexture; + return m_HGMapImage; + UUID mapTile = m_HGMapImage; + string filename = string.Empty; + Bitmap bitmap = null; try { - WebClient c = new WebClient(); //m_log.Debug("JPEG: " + imageURL); - string filename = regionID.ToString(); - c.DownloadFile(imageURL, filename + ".jpg"); - Bitmap m = new Bitmap(filename + ".jpg"); + string name = regionID.ToString(); + filename = Path.Combine(storagePath, name + ".jpg"); + c.DownloadFile(imageURL, filename); + bitmap = new Bitmap(filename); //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); - byte[] imageData = OpenJPEG.EncodeFromImage(m, true); - AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture, regionID.ToString()); + byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); + AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); // !!! for now //info.RegionSettings.TerrainImageID = ass.FullID; @@ -172,14 +174,13 @@ namespace OpenSim.Services.Connectors.Hypergrid m_AssetService.Store(ass); // finally - return ass.FullID; - + mapTile = ass.FullID; } catch // LEGIT: Catching problems caused by OpenJPEG p/invoke { m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); } - return UUID.Zero; + return mapTile; } public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 9863ba0e6b..643d0fc114 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net; using System.Reflection; @@ -52,8 +53,6 @@ namespace OpenSim.Services.GridService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); - private static uint m_autoMappingX = 0; private static uint m_autoMappingY = 0; private static bool m_enableAutoMapping = false; @@ -65,6 +64,7 @@ namespace OpenSim.Services.GridService protected UUID m_ScopeID = UUID.Zero; protected bool m_Check4096 = true; + protected string m_MapTileDirectory = string.Empty; // Hyperlink regions are hyperlinks on the map public readonly Dictionary m_HyperlinkRegions = new Dictionary(); @@ -121,9 +121,24 @@ namespace OpenSim.Services.GridService m_Check4096 = gridConfig.GetBoolean("Check4096", true); + m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", string.Empty); + m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); - m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); + m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); + } + + if (!string.IsNullOrEmpty(m_MapTileDirectory)) + { + try + { + Directory.CreateDirectory(m_MapTileDirectory); + } + catch (Exception e) + { + m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e); + m_MapTileDirectory = string.Empty; + } } if (MainConsole.Instance != null) @@ -271,42 +286,22 @@ namespace OpenSim.Services.GridService if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason)) return false; - if (regionID != UUID.Zero) - { - region = m_GridService.GetRegionByUUID(scopeID, regionID); - if (region != null) - { - m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", - region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize); - regInfo = region; - return true; - } - - regInfo.RegionID = regionID; - - if ( externalName == string.Empty ) - regInfo.RegionName = regInfo.ServerURI; - else - regInfo.RegionName = externalName; - - m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName); - - // Try get the map image - //regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); - // I need a texture that works for this... the one I tried doesn't seem to be working - regInfo.TerrainImage = m_HGMapImage; - - AddHyperlinkRegion(regInfo, handle); - m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID); - - } - else + if (regionID == UUID.Zero) { m_log.Warn("[HYPERGRID LINKER]: Unable to link region"); reason = "Remote region could not be found"; return false; } + region = m_GridService.GetRegionByUUID(scopeID, regionID); + if (region != null) + { + m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", + region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize); + regInfo = region; + return true; + } + uint x, y; if (m_Check4096 && !Check4096(handle, out x, out y)) { @@ -316,7 +311,20 @@ namespace OpenSim.Services.GridService return false; } - m_log.Debug("[HYPERGRID LINKER]: link region succeeded"); + regInfo.RegionID = regionID; + + if ( externalName == string.Empty ) + regInfo.RegionName = regInfo.ServerURI; + else + regInfo.RegionName = externalName; + + m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName); + + // Get the map image + regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory); + + AddHyperlinkRegion(regInfo, handle); + m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID); return true; } diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 05be7b8307..4419201a50 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -123,42 +123,39 @@ namespace OpenSim.Services.HypergridService externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : ""); imageURL = string.Empty; reason = string.Empty; - + GridRegion region = null; m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName); if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty) { List defs = m_GridService.GetDefaultRegions(m_ScopeID); if (defs != null && defs.Count > 0) - m_DefaultGatewayRegion = defs[0]; - - try { - regionID = m_DefaultGatewayRegion.RegionID; - regionHandle = m_DefaultGatewayRegion.RegionHandle; + region = defs[0]; + m_DefaultGatewayRegion = region; } - catch + else { reason = "Grid setup problem. Try specifying a particular region here."; m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to send information. Please specify a default region for this grid!"); return false; } - - return true; } - - GridRegion region = m_GridService.GetRegionByName(m_ScopeID, regionName); - if (region == null) + else { - reason = "Region not found"; - return false; + region = m_GridService.GetRegionByName(m_ScopeID, regionName); + if (region == null) + { + reason = "Region not found"; + return false; + } } regionID = region.RegionID; regionHandle = region.RegionHandle; - string regionimage = "regionImage" + region.RegionID.ToString(); - regionimage = regionimage.Replace("-", ""); + string regionimage = "regionImage" + regionID.ToString(); + regionimage = regionimage.Replace("-", ""); imageURL = region.ServerURI + "index.php?method=" + regionimage; return true; diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index c690e06f82..9adf1ac5ff 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -68,6 +68,12 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 ;; Perform distance check for the creation of a linked region ; Check4096 = "True" + ;; Needed to display non-default map tile images for linked regions + AssetService = "OpenSim.Services.AssetService.dll:AssetService" + + ;; Directory for map tile images of linked regions + ; MapTileDirectory = "./" + ;; Next, we can specify properties of regions, including default and fallback regions ;; The syntax is: Region_ = "" ;; or: Region_ = "" diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 1122cbd186..761e5eb1dd 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example @@ -42,6 +42,9 @@ GridServerURI = "http://mygridserver.com:8003" ;AllowHypergridMapSearch = true + ;; Directory for map tile images of linked regions + ; MapTileDirectory = "./" + [AvatarService] ; ; change this to your grid-wide grid server diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index 409b2a9760..e983755787 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini @@ -44,12 +44,15 @@ LocalGridInventoryService = "OpenSim.Region.CoreModules.dll:RemoteXInventoryServicesConnector" [GridService] - ; RemoteGridServicesConnector instantiates a LocalGridServicesConnector, - ; which in turn uses this + ; RemoteGridServicesConnector instantiates a LocalGridServicesConnector, + ; which in turn uses this LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" - AllowHypergridMapSearch = true + ; Needed to display non-default map tile images for linked regions + AssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector" + + AllowHypergridMapSearch = true [LibraryService] LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService" diff --git a/bin/config-include/StandaloneCommon.ini.example b/bin/config-include/StandaloneCommon.ini.example index 58059f52a1..4956bc34fa 100644 --- a/bin/config-include/StandaloneCommon.ini.example +++ b/bin/config-include/StandaloneCommon.ini.example @@ -65,6 +65,9 @@ ;; With hypergrid, perform distance check for the creation of a linked region ; Check4096 = true + ;; Directory for map tile images of remote regions + ; MapTileDirectory = "./" + ;; Next, we can specify properties of regions, including default and fallback regions ;; The syntax is: Region_ = "" ;; where can be DefaultRegion, FallbackRegion, NoDirectLogin, Persistent, LockedOut diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 68aa7397fc..486f22e698 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -65,12 +65,15 @@ LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" [GridService] - ; LocalGridServicesConnector needs this - LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" - Realm = "regions" + ; LocalGridServicesConnector needs this + LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" + Realm = "regions" StorageProvider = "OpenSim.Data.Null.dll" - AllowHypergridMapSearch = true + ; Needed to display non-default map tile images for remote regions + AssetService = "OpenSim.Services.AssetService.dll:AssetService" + + AllowHypergridMapSearch = true [PresenceService] LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" From a4588befb7b75d0b48664a3ff1998464aac5eed5 Mon Sep 17 00:00:00 2001 From: Marck Date: Mon, 13 Dec 2010 22:00:34 +0100 Subject: [PATCH 5/5] Changed logging level for message about failure to retrieve a map image from a linked region. --- .../Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index d4fd1b8950..1ac8478220 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -178,7 +178,7 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch // LEGIT: Catching problems caused by OpenJPEG p/invoke { - m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); + m_log.Info("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); } return mapTile; }