From beb7b8d189a99b4385392b2209930e20b489a0c9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Apr 2012 23:23:37 +0100 Subject: Fix a logic error in app domain creation --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index ad2f12e..23a4cf9 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1025,7 +1025,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine sandbox = AppDomain.CreateDomain( m_Scene.RegionInfo.RegionID.ToString(), evidence, appSetup); - m_AppDomains[appDomain].AssemblyResolve += + sandbox.AssemblyResolve += new ResolveEventHandler( AssemblyResolver.OnAssemblyResolve); } -- cgit v1.1 From 2b98e2f106f8a017cbaefcb2c21cc1bc9addde81 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Apr 2012 02:50:36 +0100 Subject: Stop teleports from dropping tall avatars through or embedding them in the floor when lured by short avatars. This involves giving the ceiling of the Z-component in a lure rather than the floor. Ideally we would give the exact float compensating for relative avatar height but it looks like that isn't possible with the parcel id format used in lures --- OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index d295384..2d4cffd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs @@ -151,11 +151,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure Scene scene = (Scene)(client.Scene); ScenePresence presence = scene.GetScenePresence(client.AgentId); + // Round up Z co-ordinate rather than round-down by casting. This stops tall avatars from being given + // a teleport Z co-ordinate by short avatars that drops them through or embeds them in thin floors on + // arrival. + // + // Ideally we would give the exact float position adjusting for the relative height of the two avatars + // but it looks like a float component isn't possible with a parcel ID. UUID dest = Util.BuildFakeParcelID( scene.RegionInfo.RegionHandle, (uint)presence.AbsolutePosition.X, (uint)presence.AbsolutePosition.Y, - (uint)presence.AbsolutePosition.Z); + (uint)Math.Ceiling(presence.AbsolutePosition.Z)); m_log.DebugFormat("TP invite with message {0}", message); -- cgit v1.1 From f3dda2d85d5b72aa880a399805d052b241d3abef Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Apr 2012 03:12:25 +0100 Subject: Add more exception detail to Exception and IOException throws in BaseHttpServer.HandleRequest() --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 9d8561b..0fbf90a 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -662,11 +662,11 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (IOException e) { - m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); + m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}{1}", e.Message, e.StackTrace); } catch (Exception e) { - m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e.StackTrace); + m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}{1}", e.Message, e.StackTrace); SendHTML500(response); } finally -- cgit v1.1 From 63cda3a6d0910b74680cd343ab7bc07a6651f1cb Mon Sep 17 00:00:00 2001 From: Garmin Kawaguichi Date: Thu, 19 Apr 2012 15:47:56 +0200 Subject: concerns GenericSystemDrawing.cs in OpenSim\Region\CoreModules\World\Terrain\FileLoaders\GenericSystemDrawing.cs Ln 67 Apply Justin's solution Signed-off-by: Garmin Kawaguichi --- .../World/Terrain/FileLoaders/GenericSystemDrawing.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index da81dc1..cd46276 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs @@ -64,18 +64,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h) { - Bitmap bitmap = new Bitmap(filename); - ITerrainChannel retval = new TerrainChannel(true); - - for (int x = 0; x < retval.Width; x++) + using (Bitmap bitmap = new Bitmap(filename)) { - for (int y = 0; y < retval.Height; y++) + ITerrainChannel retval = new TerrainChannel(true); + + for (int x = 0; x < retval.Width; x++) { - retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; + for (int y = 0; y < retval.Height; y++) + { + retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; + } } + return retval; } - - return retval; } public virtual ITerrainChannel LoadStream(Stream stream) -- cgit v1.1 From 4ac2f839bdba84569877f5ab8c2e9ea0cfe87413 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Apr 2012 03:32:38 +0100 Subject: Remember to dispose of the bitmap opened from a file in GatekeeperServiceConnector.GetMapImage() --- .../Connectors/Hypergrid/GatekeeperServiceConnector.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 0430ef6..19dffc3 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -154,7 +154,7 @@ namespace OpenSim.Services.Connectors.Hypergrid UUID mapTile = m_HGMapImage; string filename = string.Empty; - Bitmap bitmap = null; + try { WebClient c = new WebClient(); @@ -167,11 +167,18 @@ namespace OpenSim.Services.Connectors.Hypergrid c.DownloadFile(imageURL, filename); } else + { m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: using cached image"); + } + + byte[] imageData = null; - bitmap = new Bitmap(filename); - //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); - byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); + using (Bitmap bitmap = new Bitmap(filename)) + { + //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); + imageData = OpenJPEG.EncodeFromImage(bitmap, true); + } + AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); // !!! for now -- cgit v1.1 From cba64ebc79eaec9cd432d90b8cc48e22272d31f0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Apr 2012 03:46:09 +0100 Subject: Explicitly dispose of bitmaps opened from files in GenericSystemDrawing and JPEG.cs --- .../Terrain/FileLoaders/GenericSystemDrawing.cs | 28 ++++++++++++++-------- .../CoreModules/World/Terrain/FileLoaders/JPEG.cs | 21 +++++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index cd46276..3921bf9 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs @@ -59,7 +59,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// A terrain channel generated from the image. public virtual ITerrainChannel LoadFile(string filename) { - return LoadBitmap(new Bitmap(filename)); + using (Bitmap b = new Bitmap(filename)) + return LoadBitmap(b); } public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h) @@ -75,13 +76,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; } } + return retval; } } public virtual ITerrainChannel LoadStream(Stream stream) { - return LoadBitmap(new Bitmap(stream)); + using (Bitmap b = new Bitmap(stream)) + return LoadBitmap(b); } protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap) @@ -227,16 +230,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// A System.Drawing.Bitmap containing a coloured image protected static Bitmap CreateBitmapFromMap(ITerrainChannel map) { - Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); - - int pallete = gradientmapLd.Height; - - Bitmap bmp = new Bitmap(map.Width, map.Height); - Color[] colours = new Color[pallete]; + int pallete; + Bitmap bmp; + Color[] colours; - for (int i = 0; i < pallete; i++) + using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png")) { - colours[i] = gradientmapLd.GetPixel(0, i); + pallete = gradientmapLd.Height; + + bmp = new Bitmap(map.Width, map.Height); + colours = new Color[pallete]; + + for (int i = 0; i < pallete; i++) + { + colours[i] = gradientmapLd.GetPixel(0, i); + } } for (int y = 0; y < map.Height; y++) diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs index 699d67a..9cc767a 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs @@ -99,16 +99,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders private static Bitmap CreateBitmapFromMap(ITerrainChannel map) { - Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); + int pallete; + Bitmap bmp; + Color[] colours; - int pallete = gradientmapLd.Height; - - Bitmap bmp = new Bitmap(map.Width, map.Height); - Color[] colours = new Color[pallete]; - - for (int i = 0; i < pallete; i++) + using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png")) { - colours[i] = gradientmapLd.GetPixel(0, i); + pallete = gradientmapLd.Height; + + bmp = new Bitmap(map.Width, map.Height); + colours = new Color[pallete]; + + for (int i = 0; i < pallete; i++) + { + colours[i] = gradientmapLd.GetPixel(0, i); + } } for (int y = 0; y < map.Height; y++) -- cgit v1.1 From 75f117484b8e45d0db4273f37cc993bf02f00fcb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Apr 2012 03:57:22 +0100 Subject: Always dispose of existing opened bitmap from file in SaveFile(), instead of simply dropping the reference if the existing file didn't contain a bitmap of the same size. --- .../Terrain/FileLoaders/GenericSystemDrawing.cs | 59 ++++++++++++++-------- 1 file changed, 37 insertions(+), 22 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index 3921bf9..039c3fa 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs @@ -138,35 +138,50 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders // "Saving the image to the same file it was constructed from is not allowed and throws an exception." string tempName = Path.GetTempFileName(); - Bitmap entireBitmap = null; - Bitmap thisBitmap = null; - if (File.Exists(filename)) + Bitmap existingBitmap = null; + Bitmap thisBitmap; + Bitmap newBitmap; + + try { - File.Copy(filename, tempName, true); - entireBitmap = new Bitmap(tempName); - if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) + if (File.Exists(filename)) { - // old file, let's overwrite it - entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); + File.Copy(filename, tempName, true); + existingBitmap = new Bitmap(tempName); + if (existingBitmap.Width != fileWidth * regionSizeX || existingBitmap.Height != fileHeight * regionSizeY) + { + // old file, let's overwrite it + newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); + } + else + { + newBitmap = existingBitmap; + } } + else + { + newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); + } + + thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); + // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); + for (int x = 0; x < regionSizeX; x++) + for (int y = 0; y < regionSizeY; y++) + newBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); + + Save(newBitmap, filename); } - else + finally { - entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); - } - - thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); -// Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); - for (int x = 0; x < regionSizeX; x++) - for (int y = 0; y < regionSizeY; y++) - entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); + if (existingBitmap != null) + existingBitmap.Dispose(); - Save(entireBitmap, filename); - thisBitmap.Dispose(); - entireBitmap.Dispose(); + thisBitmap.Dispose(); + newBitmap.Dispose(); - if (File.Exists(tempName)) - File.Delete(tempName); + if (File.Exists(tempName)) + File.Delete(tempName); + } } protected virtual void Save(Bitmap bmp, string filename) -- cgit v1.1