From 859646ef5cf016eecfefb53b2b388fe880c39a3a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Apr 2012 23:54:51 +0100 Subject: minor: Add some method doc. Add warnings since calling SOG link/delink methods directly rather than through Scene may allow race conditions. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 +++ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 0098add..67eb0fe 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -91,6 +91,9 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal Dictionary SceneObjectGroupsByLocalPartID = new Dictionary(); + /// + /// Lock to prevent object group update, linking and delinking operations from running concurrently. + /// private Object m_updateLock = new Object(); #endregion diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a49ed13..8e786c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1962,6 +1962,10 @@ namespace OpenSim.Region.Framework.Scenes /// /// Link the prims in a given group to this group /// + /// + /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads. + /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition. + /// /// The group of prims which should be linked to this group public void LinkToGroup(SceneObjectGroup objectGroup) { @@ -2045,6 +2049,11 @@ namespace OpenSim.Region.Framework.Scenes /// Delink the given prim from this group. The delinked prim is established as /// an independent SceneObjectGroup. /// + /// + /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race + /// condition. But currently there is no + /// alternative method that does take a lonk to delink a single prim. + /// /// /// The object group of the newly delinked prim. Null if part could not be found public SceneObjectGroup DelinkFromGroup(uint partID) @@ -2056,6 +2065,11 @@ namespace OpenSim.Region.Framework.Scenes /// Delink the given prim from this group. The delinked prim is established as /// an independent SceneObjectGroup. /// + /// + /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race + /// condition. But currently there is no + /// alternative method that does take a lonk to delink a single prim. + /// /// /// /// The object group of the newly delinked prim. Null if part could not be found @@ -2081,6 +2095,11 @@ namespace OpenSim.Region.Framework.Scenes /// Delink the given prim from this group. The delinked prim is established as /// an independent SceneObjectGroup. /// + /// + /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race + /// condition. But currently there is no + /// alternative method that does take a lonk to delink a single prim. + /// /// /// /// The object group of the newly delinked prim. -- cgit v1.1 From c85f9d681a7e9cb09e8cf4de97643eadc7a9d4d8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Apr 2012 00:39:39 +0100 Subject: On "show part" command, show link number. This replaces the Parts count which was rather pointless for a prim (it was either 1 if a child or the number of parts if the root). This information is still avaliable on the "show object" command. --- .../Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index f5a5c92..06fea58 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -282,7 +282,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); sb.AppendFormat("Parent: {0}", sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); - sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; + sb.AppendFormat("Link number: {0}\n", sop.LinkNum); return sb; } -- cgit v1.1 From ea73a035531a0e957f54fe897f3a3ff7ca3dc22d Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Apr 2012 20:01:41 +0100 Subject: Don't re-add the assembly resolver for each script if not creating the appdomain --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b7903d5..ad2f12e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1021,11 +1021,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine AppDomain sandbox; if (m_AppDomainLoading) + { sandbox = AppDomain.CreateDomain( m_Scene.RegionInfo.RegionID.ToString(), evidence, appSetup); + m_AppDomains[appDomain].AssemblyResolve += + new ResolveEventHandler( + AssemblyResolver.OnAssemblyResolve); + } else + { sandbox = AppDomain.CurrentDomain; + } //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); @@ -1037,9 +1044,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_AppDomains[appDomain] = sandbox; - m_AppDomains[appDomain].AssemblyResolve += - new ResolveEventHandler( - AssemblyResolver.OnAssemblyResolve); m_DomainScripts[appDomain] = new List(); } catch (Exception e) @@ -1984,4 +1988,4 @@ namespace OpenSim.Region.ScriptEngine.XEngine // m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID); } } -} \ No newline at end of file +} -- cgit v1.1 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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 From 566327a9482506f2965e06b37172dc42f66cd6e5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Apr 2012 23:24:24 +0100 Subject: If a physical prim is manually moved (e.g. by a user) then set the geometry position as well as the body position This is necessary to stop the moved prim snapping back to the original position on deselection if moved only once This resolves http://opensimulator.org/mantis/view.php?id=5966 --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 1f79cd8..7d67da3 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -1579,23 +1579,21 @@ Console.WriteLine(" JointCreateFixed"); //m_log.Debug("[BUG]: race!"); //} } - else - { - // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); - // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); -// _parent_scene.waitForSpaceUnlock(m_targetSpace); - IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); - m_targetSpace = tempspace; + // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); + // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); +// _parent_scene.waitForSpaceUnlock(m_targetSpace); + + IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); + m_targetSpace = tempspace; // _parent_scene.waitForSpaceUnlock(m_targetSpace); - if (prim_geom != IntPtr.Zero) - { - d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + if (prim_geom != IntPtr.Zero) + { + d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); // _parent_scene.waitForSpaceUnlock(m_targetSpace); - d.SpaceAdd(m_targetSpace, prim_geom); - } + d.SpaceAdd(m_targetSpace, prim_geom); } changeSelectedStatus(); -- cgit v1.1 From c8307cdf1e1f06f68fdf3f36d1facd295c77e88d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Apr 2012 23:35:11 +0100 Subject: Improve bitmap disposal to do null checks and not to potentially try disposal of uninitialized variables. This issue doesn't cause the mono 2.10.5 compiler to fail but appears to cause the windows compiler to fail. Resolves http://opensimulator.org/mantis/view.php?id=5973 --- .../World/Terrain/FileLoaders/GenericSystemDrawing.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index 039c3fa..d78ade5 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs @@ -139,8 +139,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders string tempName = Path.GetTempFileName(); Bitmap existingBitmap = null; - Bitmap thisBitmap; - Bitmap newBitmap; + Bitmap thisBitmap = null; + Bitmap newBitmap = null; try { @@ -176,8 +176,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders if (existingBitmap != null) existingBitmap.Dispose(); - thisBitmap.Dispose(); - newBitmap.Dispose(); + if (thisBitmap != null) + thisBitmap.Dispose(); + + if (newBitmap != null) + newBitmap.Dispose(); if (File.Exists(tempName)) File.Delete(tempName); -- cgit v1.1 From 7a574be3fd28ffbd9bce4cfa08451d705728fa20 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 00:12:07 +0100 Subject: Remove redundant prim_geom != IntPtr.Zero checks in ODEPrim. prim_geom == IntPtr.Zero only before a new add prim taint is processed (which is the first taint) or in operations such as scale change which are done in taint or under lock. Therefore, we can remove these checks which were not consistently applied anyway. If there is a genuine problem, better to see it quickly in a NullReferenceException than hide the bug. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 204 ++++++++++++---------------- 1 file changed, 88 insertions(+), 116 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 7d67da3..0a8cf75 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -156,7 +156,15 @@ namespace OpenSim.Region.Physics.OdePlugin /// public IntPtr m_targetSpace = IntPtr.Zero; + /// + /// The prim geometry, used for collision detection. + /// + /// + /// This is never null except for a brief period when the geometry needs to be replaced (due to resizing or + /// mesh change) or when the physical prim is being removed from the scene. + /// public IntPtr prim_geom { get; private set; } + public IntPtr _triMeshData { get; private set; } private IntPtr _linkJointGroup = IntPtr.Zero; @@ -325,14 +333,11 @@ namespace OpenSim.Region.Physics.OdePlugin { prim_geom = geom; //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); - if (prim_geom != IntPtr.Zero) - { - d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); - d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); - _parent_scene.geom_name_map[prim_geom] = Name; - _parent_scene.actor_name_map[prim_geom] = this; - } + d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); + d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); + + _parent_scene.geom_name_map[prim_geom] = Name; if (childPrim) { @@ -765,11 +770,8 @@ namespace OpenSim.Region.Physics.OdePlugin m_collisionCategories &= ~CollisionCategories.Body; m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); - if (prim_geom != IntPtr.Zero) - { - d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); - d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); - } + d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); + d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); d.BodyDestroy(Body); lock (childrenPrim) @@ -793,11 +795,8 @@ namespace OpenSim.Region.Physics.OdePlugin m_collisionCategories &= ~CollisionCategories.Body; m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); - if (prim_geom != IntPtr.Zero) - { - d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); - d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); - } + d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); + d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); Body = IntPtr.Zero; } @@ -864,10 +863,7 @@ namespace OpenSim.Region.Physics.OdePlugin // _parent_scene.waitForSpaceUnlock(m_targetSpace); try { - if (prim_geom == IntPtr.Zero) - { - SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); - } + SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); } catch (AccessViolationException) { @@ -890,73 +886,67 @@ namespace OpenSim.Region.Physics.OdePlugin #if SPAM Console.WriteLine("ZProcessTaints for " + Name); #endif + + // This must be processed as the very first taint so that later operations have a prim_geom to work with + // if this is a new prim. if (m_taintadd) - { changeadd(); - } - - if (prim_geom != IntPtr.Zero) - { - if (!_position.ApproxEquals(m_taintposition, 0f)) - changemove(); - if (m_taintrot != _orientation) - { - if (childPrim && IsPhysical) // For physical child prim... - { - rotate(); - // KF: ODE will also rotate the parent prim! - // so rotate the root back to where it was - OdePrim parent = (OdePrim)_parent; - parent.rotate(); - } - else - { - //Just rotate the prim - rotate(); - } + if (!_position.ApproxEquals(m_taintposition, 0f)) + changemove(); + + if (m_taintrot != _orientation) + { + if (childPrim && IsPhysical) // For physical child prim... + { + rotate(); + // KF: ODE will also rotate the parent prim! + // so rotate the root back to where it was + OdePrim parent = (OdePrim)_parent; + parent.rotate(); } - - if (m_taintPhysics != IsPhysical && !(m_taintparent != _parent)) - changePhysicsStatus(); + else + { + //Just rotate the prim + rotate(); + } + } + + if (m_taintPhysics != IsPhysical && !(m_taintparent != _parent)) + changePhysicsStatus(); - if (!_size.ApproxEquals(m_taintsize, 0f)) - changesize(); + if (!_size.ApproxEquals(m_taintsize, 0f)) + changesize(); - if (m_taintshape) - changeshape(); + if (m_taintshape) + changeshape(); - if (m_taintforce) - changeAddForce(); + if (m_taintforce) + changeAddForce(); - if (m_taintaddangularforce) - changeAddAngularForce(); + if (m_taintaddangularforce) + changeAddAngularForce(); - if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f)) - changeSetTorque(); + if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f)) + changeSetTorque(); - if (m_taintdisable) - changedisable(); + if (m_taintdisable) + changedisable(); - if (m_taintselected != m_isSelected) - changeSelectedStatus(); + if (m_taintselected != m_isSelected) + changeSelectedStatus(); - if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) - changevelocity(); + if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) + changevelocity(); - if (m_taintparent != _parent) - changelink(); + if (m_taintparent != _parent) + changelink(); - if (m_taintCollidesWater != m_collidesWater) - changefloatonwater(); + if (m_taintCollidesWater != m_collidesWater) + changefloatonwater(); - if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) - changeAngularLock(); - } - else - { - m_log.ErrorFormat("[PHYSICS]: The scene reused a disposed PhysActor for {0}! *waves finger*, Don't be evil. A couple of things can cause this. An improper prim breakdown(be sure to set prim_geom to zero after d.GeomDestroy! An improper buildup (creating the geom failed). Or, the Scene Reused a physics actor after disposing it.)", Name); - } + if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) + changeAngularLock(); } /// @@ -1093,18 +1083,10 @@ Console.WriteLine("ZProcessTaints for " + Name); prm.m_collisionCategories |= CollisionCategories.Body; prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); - if (prm.prim_geom == IntPtr.Zero) - { - m_log.WarnFormat( - "[PHYSICS]: Unable to link one of the linkset elements {0} for parent {1}. No geom yet", - prm.Name, prim.Name); - continue; - } //Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name); d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); - d.Quaternion quat = new d.Quaternion(); quat.W = prm._orientation.W; quat.X = prm._orientation.X; @@ -1303,11 +1285,8 @@ Console.WriteLine("ZProcessTaints for " + Name); disableBodySoft(); } - if (prim_geom != IntPtr.Zero) - { - d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); - d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); - } + d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); + d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); if (IsPhysical) { @@ -1328,11 +1307,8 @@ Console.WriteLine("ZProcessTaints for " + Name); if (m_collidesWater) m_collisionFlags |= CollisionCategories.Water; - if (prim_geom != IntPtr.Zero) - { - d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); - d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); - } + d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); + d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); if (IsPhysical) { @@ -1472,6 +1448,9 @@ Console.WriteLine("CreateGeom:"); } else { + m_log.WarnFormat( + "[ODE PRIM]: Called RemoveGeom() on {0} {1} where geometry was already null.", Name, LocalID); + return false; } } @@ -1505,16 +1484,13 @@ Console.WriteLine("changeadd 1"); #endif CreateGeom(m_targetSpace, mesh); - if (prim_geom != IntPtr.Zero) - { - d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); - d.Quaternion myrot = new d.Quaternion(); - myrot.X = _orientation.X; - myrot.Y = _orientation.Y; - myrot.Z = _orientation.Z; - myrot.W = _orientation.W; - d.GeomSetQuaternion(prim_geom, ref myrot); - } + d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + d.Quaternion myrot = new d.Quaternion(); + myrot.X = _orientation.X; + myrot.Y = _orientation.Y; + myrot.Z = _orientation.Z; + myrot.W = _orientation.W; + d.GeomSetQuaternion(prim_geom, ref myrot); if (IsPhysical && Body == IntPtr.Zero) enableBody(); @@ -1588,13 +1564,11 @@ Console.WriteLine(" JointCreateFixed"); m_targetSpace = tempspace; // _parent_scene.waitForSpaceUnlock(m_targetSpace); - if (prim_geom != IntPtr.Zero) - { - d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + + d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); // _parent_scene.waitForSpaceUnlock(m_targetSpace); - d.SpaceAdd(m_targetSpace, prim_geom); - } + d.SpaceAdd(m_targetSpace, prim_geom); changeSelectedStatus(); @@ -2045,18 +2019,16 @@ Console.WriteLine(" JointCreateFixed"); { m_collidesWater = m_taintCollidesWater; - if (prim_geom != IntPtr.Zero) + if (m_collidesWater) { - if (m_collidesWater) - { - m_collisionFlags |= CollisionCategories.Water; - } - else - { - m_collisionFlags &= ~CollisionCategories.Water; - } - d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); + m_collisionFlags |= CollisionCategories.Water; + } + else + { + m_collisionFlags &= ~CollisionCategories.Water; } + + d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); } /// -- cgit v1.1 From 06552f217ebd9301fd487c788a13fd75d61a46de Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 00:54:48 +0100 Subject: Add TestSetPhysics() to SOP status tests --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 ++++++--- .../Framework/Scenes/Tests/SceneObjectStatusTests.cs | 20 ++++++++++++++++++++ OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 046553b..d2cd37d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1706,6 +1706,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) { + if (ParentGroup.Scene == null) + return; + if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) return; @@ -4161,7 +4164,7 @@ namespace OpenSim.Region.Framework.Scenes // For now, we use the NINJA naming scheme for identifying joints. // In the future, we can support other joint specification schemes such as a // custom checkbox in the viewer GUI. - if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) + if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) { string hingeString = "hingejoint"; return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); @@ -4177,7 +4180,7 @@ namespace OpenSim.Region.Framework.Scenes // For now, we use the NINJA naming scheme for identifying joints. // In the future, we can support other joint specification schemes such as a // custom checkbox in the viewer GUI. - if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) + if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) { string ballString = "balljoint"; return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); @@ -4193,7 +4196,7 @@ namespace OpenSim.Region.Framework.Scenes // For now, we use the NINJA naming scheme for identifying joints. // In the future, we can support other joint specification schemes such as a // custom checkbox in the viewer GUI. - if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) + if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) { return IsHingeJoint() || IsBallJoint(); } diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 2a342d5..16e8b63 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -62,5 +62,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); } + + [Test] + public void TestSetPhysics() + { + TestHelpers.InMethod(); + +// Scene scene = SceneSetupHelpers.SetupScene(); + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); + SceneObjectPart rootPart = so.RootPart; + Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); + + so.ScriptSetPhysicsStatus(true); + +// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); + Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); + + so.ScriptSetPhysicsStatus(false); + + Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); + } } } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 318758d..7a6b1cf 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -153,7 +153,7 @@ namespace OpenSim.Tests.Common PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); testScene.PhysicsScene - = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); + = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); testScene.RegionInfo.EstateSettings = new EstateSettings(); testScene.LoginsDisabled = false; -- cgit v1.1 From 71900968b221b89860d1cef162f3b0d1236e1c73 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 01:01:24 +0100 Subject: refactor: extract common setup code in SceneObjectStatusTests --- .../Scenes/Tests/SceneObjectStatusTests.cs | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 16e8b63..b8e1b92 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -43,22 +43,30 @@ namespace OpenSim.Region.Framework.Scenes.Tests [TestFixture] public class SceneObjectStatusTests { + private TestScene m_scene; + private SceneObjectGroup m_so1; + + [SetUp] + public void Init() + { + m_scene = SceneHelpers.SetupScene(); + SceneObjectGroup m_so1 = SceneHelpers.CreateSceneObject(1, UUID.Zero); + } + [Test] public void TestSetPhantom() { TestHelpers.InMethod(); -// Scene scene = SceneSetupHelpers.SetupScene(); - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); - SceneObjectPart rootPart = so.RootPart; + SceneObjectPart rootPart = m_so1.RootPart; Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); - so.ScriptSetPhantomStatus(true); + m_so1.ScriptSetPhantomStatus(true); // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); - so.ScriptSetPhantomStatus(false); + m_so1.ScriptSetPhantomStatus(false); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); } @@ -68,17 +76,15 @@ namespace OpenSim.Region.Framework.Scenes.Tests { TestHelpers.InMethod(); -// Scene scene = SceneSetupHelpers.SetupScene(); - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); - SceneObjectPart rootPart = so.RootPart; + SceneObjectPart rootPart = m_so1.RootPart; Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); - so.ScriptSetPhysicsStatus(true); + m_so1.ScriptSetPhysicsStatus(true); // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); - so.ScriptSetPhysicsStatus(false); + m_so1.ScriptSetPhysicsStatus(false); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); } -- cgit v1.1 From 17bf2a62db39ba58ca691a6754bf79fe6b3ee474 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 01:09:19 +0100 Subject: Add test for correct physics status on linking two physics objects Also fixes last build break. --- .../Scenes/Tests/SceneObjectStatusTests.cs | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index b8e1b92..6270ac1 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.Reflection; using NUnit.Framework; using OpenMetaverse; @@ -44,13 +45,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests public class SceneObjectStatusTests { private TestScene m_scene; + private UUID m_ownerId = TestHelpers.ParseTail(0x1); private SceneObjectGroup m_so1; + private SceneObjectGroup m_so2; [SetUp] public void Init() { m_scene = SceneHelpers.SetupScene(); - SceneObjectGroup m_so1 = SceneHelpers.CreateSceneObject(1, UUID.Zero); + m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10); + m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20); } [Test] @@ -86,7 +90,27 @@ namespace OpenSim.Region.Framework.Scenes.Tests m_so1.ScriptSetPhysicsStatus(false); - Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); + Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); + } + + /// + /// Test that linking results in the correct physical status for all linkees. + /// + [Test] + public void TestLinkPhysicsBothPhysical() + { + TestHelpers.InMethod(); + + m_scene.AddSceneObject(m_so1); + m_scene.AddSceneObject(m_so2); + + m_so1.ScriptSetPhysicsStatus(true); + m_so2.ScriptSetPhysicsStatus(true); + + m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List() { m_so2.LocalId }); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); } } } \ No newline at end of file -- cgit v1.1 From 9ac48b2aff2ddd00821b7e6ecd71ce134f7a0f25 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 01:43:09 +0100 Subject: Fix a bug where linking a non-physical prim with a physical prim as root would make the non-physical prim phantom rather than part of the physics object. On region restart, the whole object would become physical as expected. Observed behaviour from elsewhere is that all prims in a new linkset should take on the status of the root prim. Add regression test for this behaviour. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 +++ .../Framework/Scenes/Tests/SceneObjectStatusTests.cs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8e786c1..49a3485 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2010,6 +2010,7 @@ namespace OpenSim.Region.Framework.Scenes linkPart.CreateSelected = true; linkPart.LinkNum = linkNum++; + linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); SceneObjectPart[] ogParts = objectGroup.Parts; Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) @@ -2220,6 +2221,8 @@ namespace OpenSim.Region.Framework.Scenes oldRot = part.RotationOffset; Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; part.RotationOffset = newRot; + + part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); } /// diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 6270ac1..91f4a34 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -112,5 +112,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); } + + /// + /// Test that linking results in the correct physical status for all linkees. + /// + [Test] + public void TestLinkPhysicsRootPhysicalOnly() + { + TestHelpers.InMethod(); + + m_scene.AddSceneObject(m_so1); + m_scene.AddSceneObject(m_so2); + + m_so1.ScriptSetPhysicsStatus(true); + + m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List() { m_so2.LocalId }); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); + } } } \ No newline at end of file -- cgit v1.1 From d5c724e5b8cc15ce278b80070238e72a2e4ea0e8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 01:51:57 +0100 Subject: Add regression test for prim status when root prim in a new linkset is non-physical --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- .../Framework/Scenes/Tests/SceneObjectStatusTests.cs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d2cd37d..1592131 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1708,7 +1708,7 @@ namespace OpenSim.Region.Framework.Scenes { if (ParentGroup.Scene == null) return; - + if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) return; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 91f4a34..8cdd645 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -131,5 +131,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); } + + /// + /// Test that linking results in the correct physical status for all linkees. + /// + [Test] + public void TestLinkPhysicsChildPhysicalOnly() + { + TestHelpers.InMethod(); + + m_scene.AddSceneObject(m_so1); + m_scene.AddSceneObject(m_so2); + + m_so2.ScriptSetPhysicsStatus(true); + + m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List() { m_so2.LocalId }); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); + } } } \ No newline at end of file -- cgit v1.1 From 77a7de87e1c89385bc906d1b409ec1c94c41b9e6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 02:45:16 +0100 Subject: Add test for setting physics in a linkset --- .../Scenes/Tests/SceneObjectStatusTests.cs | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 8cdd645..882031c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests } [Test] - public void TestSetPhantom() + public void TestSetPhantomSinglePrim() { TestHelpers.InMethod(); @@ -76,7 +76,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests } [Test] - public void TestSetPhysics() + public void TestSetPhysicsSinglePrim() { TestHelpers.InMethod(); @@ -92,6 +92,32 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); } + + [Test] + public void TestSetPhysicsLinkset() + { + TestHelpers.InMethod(); + + m_scene.AddSceneObject(m_so1); + m_scene.AddSceneObject(m_so2); + + m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List() { m_so2.LocalId }); + + m_so1.ScriptSetPhysicsStatus(true); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); + + m_so1.ScriptSetPhysicsStatus(false); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); + + m_so1.ScriptSetPhysicsStatus(true); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); + } /// /// Test that linking results in the correct physical status for all linkees. -- cgit v1.1 From f60959459574b1473dbe35d780aa0fbe4d688580 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 03:23:51 +0100 Subject: refactor: Simplify ODEPrim.AddChildPrim() by returning early where appropriate. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 232 ++++++++++++++-------------- 1 file changed, 117 insertions(+), 115 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 0a8cf75..cbb49ac 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -1042,142 +1042,144 @@ Console.WriteLine("ZProcessTaints for " + Name); /// Child prim private void AddChildPrim(OdePrim prim) { -//Console.WriteLine("AddChildPrim " + Name); - if (LocalID != prim.LocalID) + if (LocalID == prim.LocalID) + return; + + if (Body == IntPtr.Zero) { - if (Body == IntPtr.Zero) + Body = d.BodyCreate(_parent_scene.world); + setMass(); + } + + lock (childrenPrim) + { + if (childrenPrim.Contains(prim)) + return; + +//Console.WriteLine("childrenPrim.Add " + prim); + childrenPrim.Add(prim); + + foreach (OdePrim prm in childrenPrim) { - Body = d.BodyCreate(_parent_scene.world); - setMass(); + d.Mass m2; + d.MassSetZero(out m2); + d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); + + d.Quaternion quat = new d.Quaternion(); + quat.W = prm._orientation.W; + quat.X = prm._orientation.X; + quat.Y = prm._orientation.Y; + quat.Z = prm._orientation.Z; + + d.Matrix3 mat = new d.Matrix3(); + d.RfromQ(out mat, ref quat); + d.MassRotate(ref m2, ref mat); + d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z); + d.MassAdd(ref pMass, ref m2); } - if (Body != IntPtr.Zero) + + foreach (OdePrim prm in childrenPrim) { - lock (childrenPrim) - { - if (!childrenPrim.Contains(prim)) - { -//Console.WriteLine("childrenPrim.Add " + prim); - childrenPrim.Add(prim); - - foreach (OdePrim prm in childrenPrim) - { - d.Mass m2; - d.MassSetZero(out m2); - d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); - - d.Quaternion quat = new d.Quaternion(); - quat.W = prm._orientation.W; - quat.X = prm._orientation.X; - quat.Y = prm._orientation.Y; - quat.Z = prm._orientation.Z; - - d.Matrix3 mat = new d.Matrix3(); - d.RfromQ(out mat, ref quat); - d.MassRotate(ref m2, ref mat); - d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z); - d.MassAdd(ref pMass, ref m2); - } - - foreach (OdePrim prm in childrenPrim) - { - prm.m_collisionCategories |= CollisionCategories.Body; - prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); + prm.m_collisionCategories |= CollisionCategories.Body; + prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); //Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name); - d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); - d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); - - d.Quaternion quat = new d.Quaternion(); - quat.W = prm._orientation.W; - quat.X = prm._orientation.X; - quat.Y = prm._orientation.Y; - quat.Z = prm._orientation.Z; - - d.Matrix3 mat = new d.Matrix3(); - d.RfromQ(out mat, ref quat); - if (Body != IntPtr.Zero) - { - d.GeomSetBody(prm.prim_geom, Body); - prm.childPrim = true; - d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z); - //d.GeomSetOffsetPosition(prim.prim_geom, - // (Position.X - prm.Position.X) - pMass.c.X, - // (Position.Y - prm.Position.Y) - pMass.c.Y, - // (Position.Z - prm.Position.Z) - pMass.c.Z); - d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); - //d.GeomSetOffsetRotation(prm.prim_geom, ref mat); - d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); - d.BodySetMass(Body, ref pMass); - } - else - { - m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name); - } + d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); + d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); - prm.m_interpenetrationcount = 0; - prm.m_collisionscore = 0; - prm.m_disabled = false; + d.Quaternion quat = new d.Quaternion(); + quat.W = prm._orientation.W; + quat.X = prm._orientation.X; + quat.Y = prm._orientation.Y; + quat.Z = prm._orientation.Z; - // The body doesn't already have a finite rotation mode set here - if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) - { - prm.createAMotor(m_angularlock); - } - prm.Body = Body; - _parent_scene.ActivatePrim(prm); - } + d.Matrix3 mat = new d.Matrix3(); + d.RfromQ(out mat, ref quat); + if (Body != IntPtr.Zero) + { + d.GeomSetBody(prm.prim_geom, Body); + prm.childPrim = true; + d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z); + //d.GeomSetOffsetPosition(prim.prim_geom, + // (Position.X - prm.Position.X) - pMass.c.X, + // (Position.Y - prm.Position.Y) - pMass.c.Y, + // (Position.Z - prm.Position.Z) - pMass.c.Z); + d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); + //d.GeomSetOffsetRotation(prm.prim_geom, ref mat); + d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); + d.BodySetMass(Body, ref pMass); + } + else + { + m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name); + } + + prm.m_interpenetrationcount = 0; + prm.m_collisionscore = 0; + prm.m_disabled = false; + + // The body doesn't already have a finite rotation mode set here + if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) + { + prm.createAMotor(m_angularlock); + } + prm.Body = Body; + _parent_scene.ActivatePrim(prm); + } - m_collisionCategories |= CollisionCategories.Body; - m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); + m_collisionCategories |= CollisionCategories.Body; + m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); //Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + Name); - d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); + d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); //Console.WriteLine(" Post GeomSetCategoryBits 2"); - d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); - - d.Quaternion quat2 = new d.Quaternion(); - quat2.W = _orientation.W; - quat2.X = _orientation.X; - quat2.Y = _orientation.Y; - quat2.Z = _orientation.Z; - - d.Matrix3 mat2 = new d.Matrix3(); - d.RfromQ(out mat2, ref quat2); - d.GeomSetBody(prim_geom, Body); - d.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z); - //d.GeomSetOffsetPosition(prim.prim_geom, - // (Position.X - prm.Position.X) - pMass.c.X, - // (Position.Y - prm.Position.Y) - pMass.c.Y, - // (Position.Z - prm.Position.Z) - pMass.c.Z); - //d.GeomSetOffsetRotation(prim_geom, ref mat2); - d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); - d.BodySetMass(Body, ref pMass); - - d.BodySetAutoDisableFlag(Body, true); - d.BodySetAutoDisableSteps(Body, body_autodisable_frames); + d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); - m_interpenetrationcount = 0; - m_collisionscore = 0; - m_disabled = false; + d.Quaternion quat2 = new d.Quaternion(); + quat2.W = _orientation.W; + quat2.X = _orientation.X; + quat2.Y = _orientation.Y; + quat2.Z = _orientation.Z; - // The body doesn't already have a finite rotation mode set here - if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) - { - createAMotor(m_angularlock); - } - d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); - if (m_vehicle.Type != Vehicle.TYPE_NONE) - m_vehicle.Enable(Body, _parent_scene); + d.Matrix3 mat2 = new d.Matrix3(); + d.RfromQ(out mat2, ref quat2); + d.GeomSetBody(prim_geom, Body); + d.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z); + //d.GeomSetOffsetPosition(prim.prim_geom, + // (Position.X - prm.Position.X) - pMass.c.X, + // (Position.Y - prm.Position.Y) - pMass.c.Y, + // (Position.Z - prm.Position.Z) - pMass.c.Z); + //d.GeomSetOffsetRotation(prim_geom, ref mat2); + d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); + d.BodySetMass(Body, ref pMass); - _parent_scene.ActivatePrim(this); - } - } + d.BodySetAutoDisableFlag(Body, true); + d.BodySetAutoDisableSteps(Body, body_autodisable_frames); + + m_interpenetrationcount = 0; + m_collisionscore = 0; + m_disabled = false; + + // The body doesn't already have a finite rotation mode set here + if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) + { + createAMotor(m_angularlock); } + + d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); + + if (m_vehicle.Type != Vehicle.TYPE_NONE) + m_vehicle.Enable(Body, _parent_scene); + + _parent_scene.ActivatePrim(this); } } private void ChildSetGeom(OdePrim odePrim) { +// m_log.DebugFormat( +// "[ODE PRIM]: ChildSetGeom {0} {1} for {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID); + //if (IsPhysical && Body != IntPtr.Zero) lock (childrenPrim) { -- cgit v1.1 From ae2b8f70074e4dfe2cbbd03dd543c7468fc50cc1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Apr 2012 03:42:54 +0100 Subject: Comment out spurious Body != IntPtr.Zero code after disableBody(), since disableBody() sets Body == IntPtr.Zero on all code paths. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 27 ++++++++++++++++++--------- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 3 ++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index cbb49ac..3f88353 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -1056,7 +1056,9 @@ Console.WriteLine("ZProcessTaints for " + Name); if (childrenPrim.Contains(prim)) return; -//Console.WriteLine("childrenPrim.Add " + prim); +// m_log.DebugFormat( +// "[ODE PRIM]: Linking prim {0} {1} to {2} {3}", prim.Name, prim.LocalID, Name, LocalID); + childrenPrim.Add(prim); foreach (OdePrim prm in childrenPrim) @@ -1194,12 +1196,14 @@ Console.WriteLine("ZProcessTaints for " + Name); //prm.childPrim = false; } } + disableBody(); - if (Body != IntPtr.Zero) - { - _parent_scene.DeactivatePrim(this); - } + // Spurious - Body == IntPtr.Zero after disableBody() +// if (Body != IntPtr.Zero) +// { +// _parent_scene.DeactivatePrim(this); +// } lock (childrenPrim) { @@ -1213,6 +1217,9 @@ Console.WriteLine("ZProcessTaints for " + Name); private void ChildDelink(OdePrim odePrim) { +// m_log.DebugFormat( +// "[ODE PRIM]: Delinking prim {0} {1} from {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID); + // Okay, we have a delinked child.. need to rebuild the body. lock (childrenPrim) { @@ -1227,6 +1234,7 @@ Console.WriteLine("ZProcessTaints for " + Name); //prm.childPrim = false; } } + disableBody(); lock (childrenPrim) @@ -1235,10 +1243,11 @@ Console.WriteLine("ZProcessTaints for " + Name); childrenPrim.Remove(odePrim); } - if (Body != IntPtr.Zero) - { - _parent_scene.DeactivatePrim(this); - } + // Spurious - Body == IntPtr.Zero after disableBody() +// if (Body != IntPtr.Zero) +// { +// _parent_scene.DeactivatePrim(this); +// } lock (childrenPrim) { diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 842ff91..409b27b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -2226,7 +2226,8 @@ namespace OpenSim.Region.Physics.OdePlugin /// internal void RemovePrimThreadLocked(OdePrim prim) { -//Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName); +// m_log.DebugFormat("[ODE SCENE]: Removing physical prim {0} {1}", prim.Name, prim.LocalID); + lock (prim) { RemoveCollisionEventReporting(prim); -- cgit v1.1 From 8205fe79ceaeebd31509a044005bf27d226dbe07 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 22 Apr 2012 19:51:51 +0100 Subject: Fix bug where setting phantom on a prim would result in a server log message rather than setting phantom. This was an oversight when removing some race conditions from PhysicsActor setting recently. Regression tests extended to probe this code path. Extending regression tests required implementation of a BasicPhysicsPrim (there was none before). However, BasicPhysics plugin is still of no current practical use other than to fill in as a component for other parts of regression testing. --- .../World/Archiver/Tests/ArchiverTests.cs | 4 +- OpenSim/Region/Framework/Scenes/Scene.cs | 14 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 +- .../Scenes/Tests/SceneObjectStatusTests.cs | 2 + .../Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs | 344 +++++++++++++++++++++ .../BasicPhysicsPlugin/BasicPhysicsScene.cs | 41 +-- 6 files changed, 382 insertions(+), 32 deletions(-) create mode 100644 OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 63f1363..e05e8f6 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -102,9 +102,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); Vector3 groupPosition = new Vector3(10, 20, 30); Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); - Vector3 offsetPosition = new Vector3(5, 10, 15); +// Vector3 offsetPosition = new Vector3(5, 10, 15); - return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; + return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, Vector3.Zero) { Name = partName }; } protected SceneObjectPart CreateSceneObjectPart2() diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e488fe1..a87dfb7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -684,8 +684,8 @@ namespace OpenSim.Region.Framework.Scenes //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); - PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); - CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); + PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); + CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) @@ -800,13 +800,11 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; } - /// - /// Mock constructor for scene group persistency unit tests. - /// SceneObjectGroup RegionId property is delegated to Scene. - /// - /// public Scene(RegionInfo regInfo) { + PhysicalPrims = true; + CollidablePrims = true; + BordersLocked = true; Border northBorder = new Border(); northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- @@ -833,8 +831,6 @@ namespace OpenSim.Region.Framework.Scenes m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); - -// m_lastUpdate = Util.EnvironmentTickCount(); } #endregion diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1592131..4bec2d4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4290,7 +4290,10 @@ namespace OpenSim.Region.Framework.Scenes AddFlag(PrimFlags.Phantom); if (PhysActor != null) + { RemoveFromPhysics(); + pa = null; + } } else // Not phantom { @@ -4356,7 +4359,7 @@ namespace OpenSim.Region.Framework.Scenes { pa.SetVolumeDetect(1); AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active - this.VolumeDetectActive = true; + VolumeDetectActive = true; } } else @@ -4364,9 +4367,9 @@ namespace OpenSim.Region.Framework.Scenes // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like // (mumbles, well, at least if you have infinte CPU powers :-)) if (pa != null) - PhysActor.SetVolumeDetect(0); + pa.SetVolumeDetect(0); - this.VolumeDetectActive = false; + VolumeDetectActive = false; } if (SetTemporary) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 882031c..51751ef 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests { TestHelpers.InMethod(); + m_scene.AddSceneObject(m_so1); + SceneObjectPart rootPart = m_so1.RootPart; Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs new file mode 100644 index 0000000..ba7fe1e --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs @@ -0,0 +1,344 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * 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 OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 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 Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Physics.Manager; + +namespace OpenSim.Region.Physics.BasicPhysicsPlugin +{ + public class BasicPhysicsPrim : PhysicsActor + { + private Vector3 _position; + private Vector3 _velocity; + private Vector3 _acceleration; + private Vector3 _size; + private PrimitiveBaseShape _shape; + private Vector3 m_rotationalVelocity; + private bool flying; + private bool iscolliding; + + public BasicPhysicsPrim( + string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape) + { + Name = name; + LocalID = localId; + Position = position; + Size = size; + Orientation = orientation; + Shape = shape; + } + + public override int PhysicsActorType + { + get { return (int) ActorTypes.Agent; } + set { return; } + } + + public override Vector3 RotationalVelocity + { + get { return m_rotationalVelocity; } + set { m_rotationalVelocity = value; } + } + + public override bool SetAlwaysRun + { + get { return false; } + set { return; } + } + + public override uint LocalID + { + set { return; } + } + + public override bool Grabbed + { + set { return; } + } + + public override bool Selected + { + set { return; } + } + + public override float Buoyancy + { + get { return 0f; } + set { return; } + } + + public override bool FloatOnWater + { + set { return; } + } + + public override bool IsPhysical + { + get { return false; } + set { return; } + } + + public override bool ThrottleUpdates + { + get { return false; } + set { return; } + } + + public override bool Flying + { + get { return flying; } + set { flying = value; } + } + + public override bool IsColliding + { + get { return iscolliding; } + set { iscolliding = value; } + } + + public override bool CollidingGround + { + get { return false; } + set { return; } + } + + public override bool CollidingObj + { + get { return false; } + set { return; } + } + + public override bool Stopped + { + get { return false; } + } + + public override Vector3 Position + { + get { return _position; } + set { _position = value; } + } + + public override Vector3 Size + { + get { return _size; } + set { + _size = value; + _size.Z = _size.Z / 2.0f; + } + } + + public override PrimitiveBaseShape Shape + { + set { _shape = value; } + } + + public override float Mass + { + get { return 0f; } + } + + public override Vector3 Force + { + get { return Vector3.Zero; } + set { return; } + } + + public override int VehicleType + { + get { return 0; } + set { return; } + } + + public override void VehicleFloatParam(int param, float value) + { + + } + + public override void VehicleVectorParam(int param, Vector3 value) + { + + } + + public override void VehicleRotationParam(int param, Quaternion rotation) + { + + } + + public override void VehicleFlags(int param, bool remove) + { + + } + + public override void SetVolumeDetect(int param) + { + + } + + public override Vector3 CenterOfMass + { + get { return Vector3.Zero; } + } + + public override Vector3 GeometricCenter + { + get { return Vector3.Zero; } + } + + public override Vector3 Velocity + { + get { return _velocity; } + set { _velocity = value; } + } + + public override Vector3 Torque + { + get { return Vector3.Zero; } + set { return; } + } + + public override float CollisionScore + { + get { return 0f; } + set { } + } + + public override Quaternion Orientation { get; set; } + + public override Vector3 Acceleration + { + get { return _acceleration; } + set { _acceleration = value; } + } + + public override bool Kinematic + { + get { return true; } + set { } + } + + public override void link(PhysicsActor obj) + { + } + + public override void delink() + { + } + + public override void LockAngularMotion(Vector3 axis) + { + } + + public override void AddForce(Vector3 force, bool pushforce) + { + } + + public override void AddAngularForce(Vector3 force, bool pushforce) + { + } + + public override void SetMomentum(Vector3 momentum) + { + } + + public override void CrossingFailure() + { + } + + public override Vector3 PIDTarget + { + set { return; } + } + + public override bool PIDActive + { + set { return; } + } + + public override float PIDTau + { + set { return; } + } + + public override float PIDHoverHeight + { + set { return; } + } + + public override bool PIDHoverActive + { + set { return; } + } + + public override PIDHoverType PIDHoverType + { + set { return; } + } + + public override float PIDHoverTau + { + set { return; } + } + + public override Quaternion APIDTarget + { + set { return; } + } + + public override bool APIDActive + { + set { return; } + } + + public override float APIDStrength + { + set { return; } + } + + public override float APIDDamping + { + set { return; } + } + + public override void SubscribeEvents(int ms) + { + } + + public override void UnSubscribeEvents() + { + } + + public override bool SubscribedEvents() + { + return false; + } + } +} diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs index 2e14216..f5826ed 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs @@ -34,9 +34,17 @@ using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.BasicPhysicsPlugin { + /// + /// This is an incomplete extremely basic physics implementation + /// + /// + /// Not useful for anything at the moment apart from some regression testing in other components where some form + /// of physics plugin is needed. + /// public class BasicScene : PhysicsScene { private List _actors = new List(); + private List _prims = new List(); private float[] _heightMap; //protected internal string sceneIdentifier; @@ -50,10 +58,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { } - public override void Dispose() + public override void Dispose() {} + + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, + Vector3 size, Quaternion rotation, bool isPhysical, uint localid) { + BasicPhysicsPrim prim = new BasicPhysicsPrim(primName, localid, position, size, rotation, pbs); + prim.IsPhysical = isPhysical; + + _prims.Add(prim); + return prim; } + public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) { BasicActor act = new BasicActor(size); @@ -63,30 +80,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin return act; } - public override void RemovePrim(PhysicsActor prim) + public override void RemovePrim(PhysicsActor actor) { + BasicPhysicsPrim prim = (BasicPhysicsPrim)actor; + if (_prims.Contains(prim)) + _prims.Remove(prim); } public override void RemoveAvatar(PhysicsActor actor) { - BasicActor act = (BasicActor) actor; + BasicActor act = (BasicActor)actor; if (_actors.Contains(act)) - { _actors.Remove(act); - } - } - -/* - public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation) - { - return null; - } -*/ - - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, - Vector3 size, Quaternion rotation, bool isPhysical, uint localid) - { - return null; } public override void AddPhysicsActorTaint(PhysicsActor prim) -- cgit v1.1 From 58c890df5d82cef6e5d648b6e3a299b058b309dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 22 Apr 2012 20:03:34 +0100 Subject: Make TestSetPhysicsSinglePrim() actually add the object to the scene in order to test more code paths. --- OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 51751ef..360566d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -82,6 +82,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests { TestHelpers.InMethod(); + m_scene.AddSceneObject(m_so1); + SceneObjectPart rootPart = m_so1.RootPart; Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); -- cgit v1.1 From 49ed68e98c34c752fac407aa9359201e244df19f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 22 Apr 2012 20:28:12 +0100 Subject: refactor: simply some properties code in BasicPhysicsPlugin --- .../BasicPhysicsPlugin/BasicPhysicsActor.cs | 42 ++++------------------ .../Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs | 42 ++++------------------ 2 files changed, 12 insertions(+), 72 deletions(-) diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs index b1a3ff9..e43136a 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs @@ -36,13 +36,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { public class BasicActor : PhysicsActor { - private Vector3 _position; - private Vector3 _velocity; - private Vector3 _acceleration; private Vector3 _size; - private Vector3 m_rotationalVelocity; - private bool flying; - private bool iscolliding; public BasicActor(Vector3 size) { @@ -55,11 +49,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin set { return; } } - public override Vector3 RotationalVelocity - { - get { return m_rotationalVelocity; } - set { m_rotationalVelocity = value; } - } + public override Vector3 RotationalVelocity { get; set; } public override bool SetAlwaysRun { @@ -105,17 +95,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin set { return; } } - public override bool Flying - { - get { return flying; } - set { flying = value; } - } + public override bool Flying { get; set; } - public override bool IsColliding - { - get { return iscolliding; } - set { iscolliding = value; } - } + public override bool IsColliding { get; set; } public override bool CollidingGround { @@ -134,11 +116,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin get { return false; } } - public override Vector3 Position - { - get { return _position; } - set { _position = value; } - } + public override Vector3 Position { get; set; } public override Vector3 Size { @@ -206,11 +184,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin get { return Vector3.Zero; } } - public override Vector3 Velocity - { - get { return _velocity; } - set { _velocity = value; } - } + public override Vector3 Velocity { get; set; } public override Vector3 Torque { @@ -230,11 +204,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin set { } } - public override Vector3 Acceleration - { - get { return _acceleration; } - set { _acceleration = value; } - } + public override Vector3 Acceleration { get; set; } public override bool Kinematic { diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs index ba7fe1e..b89eeed 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs @@ -36,14 +36,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { public class BasicPhysicsPrim : PhysicsActor { - private Vector3 _position; - private Vector3 _velocity; - private Vector3 _acceleration; private Vector3 _size; private PrimitiveBaseShape _shape; - private Vector3 m_rotationalVelocity; - private bool flying; - private bool iscolliding; public BasicPhysicsPrim( string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape) @@ -62,11 +56,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin set { return; } } - public override Vector3 RotationalVelocity - { - get { return m_rotationalVelocity; } - set { m_rotationalVelocity = value; } - } + public override Vector3 RotationalVelocity { get; set; } public override bool SetAlwaysRun { @@ -112,17 +102,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin set { return; } } - public override bool Flying - { - get { return flying; } - set { flying = value; } - } + public override bool Flying { get; set; } - public override bool IsColliding - { - get { return iscolliding; } - set { iscolliding = value; } - } + public override bool IsColliding { get; set; } public override bool CollidingGround { @@ -141,11 +123,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin get { return false; } } - public override Vector3 Position - { - get { return _position; } - set { _position = value; } - } + public override Vector3 Position { get; set; } public override Vector3 Size { @@ -213,11 +191,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin get { return Vector3.Zero; } } - public override Vector3 Velocity - { - get { return _velocity; } - set { _velocity = value; } - } + public override Vector3 Velocity { get; set; } public override Vector3 Torque { @@ -233,11 +207,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override Quaternion Orientation { get; set; } - public override Vector3 Acceleration - { - get { return _acceleration; } - set { _acceleration = value; } - } + public override Vector3 Acceleration { get; set; } public override bool Kinematic { -- cgit v1.1 From 679da63da617d031e5e7ae3f2d2a29db1a23ace3 Mon Sep 17 00:00:00 2001 From: Talun Date: Sun, 22 Apr 2012 23:07:50 +0100 Subject: Mantis 5977 Corrections to llRegionSayTo Signed-off-by: BlueWall --- OpenSim/Framework/OSChatMessage.cs | 20 +++++++ .../Region/CoreModules/Avatar/Chat/ChatModule.cs | 52 ++++++++++------ .../Scripting/WorldComm/WorldCommModule.cs | 70 +++++++++++----------- OpenSim/Region/Framework/Interfaces/IWorldComm.cs | 2 +- .../Framework/Scenes/Scene.PacketHandlers.cs | 26 +++++++- .../Shared/Api/Implementation/LSL_Api.cs | 8 ++- 6 files changed, 120 insertions(+), 58 deletions(-) diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs index 54fa275..455756d 100644 --- a/OpenSim/Framework/OSChatMessage.cs +++ b/OpenSim/Framework/OSChatMessage.cs @@ -51,10 +51,12 @@ namespace OpenSim.Framework protected object m_senderObject; protected ChatTypeEnum m_type; protected UUID m_fromID; + protected UUID m_toID; public OSChatMessage() { m_position = new Vector3(); + m_toID = UUID.Zero; } /// @@ -102,6 +104,15 @@ namespace OpenSim.Framework set { m_from = value; } } + /// + /// The name of the sender (needed for scripts) + /// + public string To + { + get { return m_from; } + set { m_from = value; } + } + #region IEventArgs Members /// TODO: Sender and SenderObject should just be Sender and of @@ -132,6 +143,15 @@ namespace OpenSim.Framework } /// + /// The single recipient or all if not set. + /// + public UUID TargetUUID + { + get { return m_toID; } + set { m_toID = value; } + } + + /// /// /// public IScene Scene diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 10b4c37..e4452fb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -186,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat { string fromName = c.From; UUID fromID = UUID.Zero; + UUID targetID = c.TargetUUID; string message = c.Message; IScene scene = c.Scene; Vector3 fromPos = c.Position; @@ -221,24 +222,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat message = message.Substring(0, 1000); // m_log.DebugFormat( -// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", -// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); +// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", +// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); HashSet receiverIDs = new HashSet(); - + foreach (Scene s in m_scenes) { - // This should use ForEachClient, but clients don't have a position. - // If camera is moved into client, then camera position can be used - s.ForEachRootScenePresence( - delegate(ScenePresence presence) + if (targetID == UUID.Zero) + { + // This should use ForEachClient, but clients don't have a position. + // If camera is moved into client, then camera position can be used + s.ForEachRootScenePresence( + delegate(ScenePresence presence) + { + if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false)) + receiverIDs.Add(presence.UUID); + } + ); + } + else + { + // This is a send to a specific client eg from llRegionSayTo + // no need to check distance etc, jand send is as say + ScenePresence presence = s.GetScenePresence(targetID); + if (presence != null && !presence.IsChildAgent) { - if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) - receiverIDs.Add(presence.UUID); + if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true)) + receiverIDs.Add(presence.UUID); } - ); + } } - + (scene as Scene).EventManager.TriggerOnChatToClients( fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); } @@ -315,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat /// precondition protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, UUID fromAgentID, string fromName, ChatTypeEnum type, - string message, ChatSourceType src) + string message, ChatSourceType src, bool ignoreDistance) { // don't send stuff to child agents if (presence.IsChildAgent) return false; @@ -326,12 +341,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); - - if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || - type == ChatTypeEnum.Say && dis > m_saydistance || - type == ChatTypeEnum.Shout && dis > m_shoutdistance) + + if (!ignoreDistance) { - return false; + if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || + type == ChatTypeEnum.Say && dis > m_saydistance || + type == ChatTypeEnum.Shout && dis > m_shoutdistance) + { + return false; + } } // TODO: should change so the message is sent through the avatar rather than direct to the ClientView diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 176c86d..8358bc0 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -308,56 +308,56 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm /// /// Message. /// - public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) + public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) { - error = null; // Is id an avatar? ScenePresence sp = m_scene.GetScenePresence(target); if (sp != null) { - // Send message to avatar + // ignore if a child agent this is restricted to inside one region + if (sp.IsChildAgent) + return; + + // Send message to the avatar. + // Channel zero only goes to the avatar + // non zero channel messages only go to the attachments if (channel == 0) { - m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); - } - - List attachments = sp.GetAttachments(); - - if (attachments.Count == 0) - return true; - - // Get uuid of attachments - List targets = new List(); - foreach (SceneObjectGroup sog in attachments) + m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); + } + else { - if (!sog.IsDeleted) - targets.Add(sog.UUID); - } + List attachments = sp.GetAttachments(); + if (attachments.Count == 0) + return; - // Need to check each attachment - foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) - { - if (li.GetHostID().Equals(id)) - continue; + // Get uuid of attachments + List targets = new List(); + foreach (SceneObjectGroup sog in attachments) + { + if (!sog.IsDeleted) + targets.Add(sog.UUID); + } - if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) - continue; + // Need to check each attachment + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + { + if (li.GetHostID().Equals(id)) + continue; - if (targets.Contains(li.GetHostID())) - QueueMessage(new ListenerInfo(li, name, id, msg)); - } + if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) + continue; - return true; - } + if (targets.Contains(li.GetHostID())) + QueueMessage(new ListenerInfo(li, name, id, msg)); + } + } - // Need to toss an error here - if (channel == 0) - { - error = "Cannot use llRegionSayTo to message objects on channel 0"; - return false; + return; } + // No avatar found so look for an object foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { // Dont process if this message is from yourself! @@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } } - return true; + return; } protected void QueueMessage(ListenerInfo li) diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index e8e375e..4e74781 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs @@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Message. /// - bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); + void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg); /// /// Are there any listen events ready to be dispatched? diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 87ffc74..2701d6e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -38,8 +38,9 @@ namespace OpenSim.Region.Framework.Scenes { public partial class Scene { + protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, - UUID fromID, bool fromAgent, bool broadcast) + UUID fromID, UUID targetID, bool fromAgent, bool broadcast) { OSChatMessage args = new OSChatMessage(); @@ -63,14 +64,20 @@ namespace OpenSim.Region.Framework.Scenes } args.From = fromName; - //args. + args.TargetUUID = targetID; if (broadcast) EventManager.TriggerOnChatBroadcast(this, args); else EventManager.TriggerOnChatFromWorld(this, args); } - + + protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, + UUID fromID, bool fromAgent, bool broadcast) + { + SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast); + } + /// /// /// @@ -108,6 +115,19 @@ namespace OpenSim.Region.Framework.Scenes { SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) + { + SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); + } /// /// Invoked when the client requests a prim. diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 36c9d5e..a2176ba 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -839,13 +839,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); + if (channel == ScriptBaseClass.DEBUG_CHANNEL) + { + return; + } + UUID TargetID; UUID.TryParse(target, out TargetID); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) - if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) - LSLError(error); + wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); } public LSL_Integer llListen(int channelID, string name, string ID, string msg) -- cgit v1.1 From 60065f06b3fd6f680202405e117402b22d62f902 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 23 Apr 2012 22:23:47 +0100 Subject: refactor: Replace calls to InventorySelf() with existing m_itemID in LSL_Api There's no point look up an item ID that we already have. --- .../Shared/Api/Implementation/LSL_Api.cs | 136 +++++++-------------- 1 file changed, 42 insertions(+), 94 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 36c9d5e..6000293 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -85,7 +85,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected IScriptEngine m_ScriptEngine; protected SceneObjectPart m_host; protected uint m_localID; + + /// + /// The UUID of the item that hosts this script + /// protected UUID m_itemID; + protected bool throwErrorOnNotImplemented = true; protected AsyncCommandManager AsyncCommands = null; protected float m_ScriptDelayFactor = 1.0f; @@ -267,25 +272,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - protected UUID InventorySelf() - { - UUID invItemID = new UUID(); - - lock (m_host.TaskInventory) - { - foreach (KeyValuePair inv in m_host.TaskInventory) - { - if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) - { - invItemID = inv.Key; - break; - } - } - } - - return invItemID; - } - protected UUID InventoryKey(string name, int type) { m_host.AddScriptLPS(1); @@ -2697,17 +2683,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGiveMoney(string destination, int amount) { - UUID invItemID=InventorySelf(); - if (invItemID == UUID.Zero) - return 0; - m_host.AddScriptLPS(1); - TaskInventoryItem item = m_host.TaskInventory[invItemID]; + TaskInventoryItem item; lock (m_host.TaskInventory) { - item = m_host.TaskInventory[invItemID]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter == UUID.Zero) @@ -2955,10 +2937,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter != UUID.Zero) @@ -2983,10 +2965,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } m_host.AddScriptLPS(1); @@ -3026,10 +3008,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter != m_host.OwnerID) @@ -3058,10 +3040,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter != m_host.OwnerID) @@ -3313,18 +3295,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); - if (invItemID == UUID.Zero) - return; - TaskInventoryItem item; lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter == UUID.Zero) @@ -3350,18 +3328,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - UUID invItemID=InventorySelf(); - if (invItemID == UUID.Zero) - return; - TaskInventoryItem item; lock (m_host.TaskInventory) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) + if (!m_host.TaskInventory.ContainsKey(m_itemID)) return; else - item = m_host.TaskInventory[InventorySelf()]; + item = m_host.TaskInventory[m_itemID]; } if (item.PermsGranter == UUID.Zero) @@ -3417,21 +3391,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRequestPermissions(string agent, int perm) { - UUID agentID = new UUID(); + UUID agentID; if (!UUID.TryParse(agent, out agentID)) return; - UUID invItemID = InventorySelf(); - - if (invItemID == UUID.Zero) - return; // Not in a prim? How?? - TaskInventoryItem item; lock (m_host.TaskInventory) { - item = m_host.TaskInventory[invItemID]; + item = m_host.TaskInventory[m_itemID]; } if (agentID == UUID.Zero || perm == 0) // Releasing permissions @@ -3466,8 +3435,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { lock (m_host.TaskInventory) { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = perm; + m_host.TaskInventory[m_itemID].PermsGranter = agentID; + m_host.TaskInventory[m_itemID].PermsMask = perm; } m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( @@ -3490,8 +3459,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { lock (m_host.TaskInventory) { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = perm; + m_host.TaskInventory[m_itemID].PermsGranter = agentID; + m_host.TaskInventory[m_itemID].PermsMask = perm; } m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( @@ -3515,8 +3484,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { lock (m_host.TaskInventory) { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = 0; + m_host.TaskInventory[m_itemID].PermsGranter = agentID; + m_host.TaskInventory[m_itemID].PermsMask = 0; } presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; @@ -3524,7 +3493,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } presence.ControllingClient.SendScriptQuestion( - m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); + m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm); return; } @@ -3541,20 +3510,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (taskID != m_host.UUID) return; - UUID invItemID = InventorySelf(); - - if (invItemID == UUID.Zero) - return; - - client.OnScriptAnswer-=handleScriptAnswer; - m_waitingForScriptAnswer=false; + client.OnScriptAnswer -= handleScriptAnswer; + m_waitingForScriptAnswer = false; if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) llReleaseControls(); lock (m_host.TaskInventory) { - m_host.TaskInventory[invItemID].PermsMask = answer; + m_host.TaskInventory[m_itemID].PermsMask = answer; } m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( @@ -3627,7 +3591,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCreateLink(string target, int parent) { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); + UUID targetID; if (!UUID.TryParse(target, out targetID)) @@ -3636,7 +3600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api TaskInventoryItem item; lock (m_host.TaskInventory) { - item = m_host.TaskInventory[invItemID]; + item = m_host.TaskInventory[m_itemID]; } if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 @@ -3688,11 +3652,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llBreakLink(int linknum) { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); lock (m_host.TaskInventory) { - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); @@ -9691,17 +9654,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetCameraPos() { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); - - if (invItemID == UUID.Zero) - return new LSL_Vector(); lock (m_host.TaskInventory) { - if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) + if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero) return new LSL_Vector(); - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) { ShoutError("No permissions to track the camera"); return new LSL_Vector(); @@ -9720,16 +9679,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llGetCameraRot() { m_host.AddScriptLPS(1); - UUID invItemID = InventorySelf(); - if (invItemID == UUID.Zero) - return new LSL_Rotation(); lock (m_host.TaskInventory) { - if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) + if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero) return new LSL_Rotation(); - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) { ShoutError("No permissions to track the camera"); return new LSL_Rotation(); @@ -9907,10 +9863,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - // our key in the object we are in - UUID invItemID = InventorySelf(); - if (invItemID == UUID.Zero) return; - // the object we are in UUID objectID = m_host.ParentUUID; if (objectID == UUID.Zero) return; @@ -9919,10 +9871,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (m_host.TaskInventory) { // we need the permission first, to know which avatar we want to set the camera for - agentID = m_host.TaskInventory[invItemID].PermsGranter; + agentID = m_host.TaskInventory[m_itemID].PermsGranter; if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; } ScenePresence presence = World.GetScenePresence(agentID); @@ -9963,10 +9915,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - // our key in the object we are in - UUID invItemID=InventorySelf(); - if (invItemID == UUID.Zero) return; - // the object we are in UUID objectID = m_host.ParentUUID; if (objectID == UUID.Zero) return; @@ -9975,9 +9923,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID agentID; lock (m_host.TaskInventory) { - agentID = m_host.TaskInventory[invItemID].PermsGranter; + agentID = m_host.TaskInventory[m_itemID].PermsGranter; if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; + if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; } ScenePresence presence = World.GetScenePresence(agentID); -- cgit v1.1 From 1f8d1bcdcf7ae48ad0b3609e532ad87859f6300b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 23 Apr 2012 22:52:46 +0100 Subject: Replace common code to fetch self inventory item (as opposed to uuid) with GetSelfInventoryItem() However, at some point it would be far more convenient to receive the TaskInventoryItem in the constructor rather than just the item UUID, so we don't have to constantly refetch our self item. --- .../Shared/Api/Implementation/LSL_Api.cs | 231 +++++++-------------- 1 file changed, 76 insertions(+), 155 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6000293..a353b25 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -272,6 +272,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + /// + /// Get the inventory item that hosts ourselves. + /// + /// + /// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need + /// to keep looking ourselves up. + /// + /// + protected TaskInventoryItem GetSelfInventoryItem() + { + lock (m_host.TaskInventory) + return m_host.TaskInventory[m_itemID]; + } + protected UUID InventoryKey(string name, int type) { m_host.AddScriptLPS(1); @@ -2685,12 +2699,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter == UUID.Zero) return 0; @@ -2933,15 +2942,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTakeControls(int controls, int accept, int pass_on) { - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter != UUID.Zero) { @@ -2961,18 +2962,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llReleaseControls() { - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } - m_host.AddScriptLPS(1); + TaskInventoryItem item = GetSelfInventoryItem(); + if (item.PermsGranter != UUID.Zero) { ScenePresence presence = World.GetScenePresence(item.PermsGranter); @@ -3004,15 +2997,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) // return; - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter != m_host.OwnerID) return; @@ -3036,15 +3021,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.ParentGroup.AttachmentPoint == 0) return; - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter != m_host.OwnerID) return; @@ -3295,15 +3272,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter == UUID.Zero) return; @@ -3328,15 +3297,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - if (!m_host.TaskInventory.ContainsKey(m_itemID)) - return; - else - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (item.PermsGranter == UUID.Zero) return; @@ -3396,12 +3357,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(agent, out agentID)) return; - TaskInventoryItem item; - - lock (m_host.TaskInventory) - { - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if (agentID == UUID.Zero || perm == 0) // Releasing permissions { @@ -3531,39 +3487,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 10 && item.ItemID == m_itemID) - { - return item.PermsGranter.ToString(); - } - } - } - - return UUID.Zero.ToString(); + return GetSelfInventoryItem().PermsGranter.ToString(); } public LSL_Integer llGetPermissions() { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 10 && item.ItemID == m_itemID) - { - int perms = item.PermsMask; - if (m_automaticLinkPermission) - perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; - return perms; - } - } - } + int perms = GetSelfInventoryItem().PermsMask; - return 0; + if (m_automaticLinkPermission) + perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; + + return perms; } public LSL_Integer llGetLinkNumber() @@ -3597,11 +3533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(target, out targetID)) return; - TaskInventoryItem item; - lock (m_host.TaskInventory) - { - item = m_host.TaskInventory[m_itemID]; - } + TaskInventoryItem item = GetSelfInventoryItem(); if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) @@ -3653,14 +3585,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 + && !m_automaticLinkPermission) { - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 - && !m_automaticLinkPermission) - { - ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); - return; - } + ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); + return; } if (linknum < ScriptBaseClass.LINK_THIS) @@ -4537,23 +4466,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetScriptName() { - string result = String.Empty; - m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 10 && item.ItemID == m_itemID) - { - result = item.Name != null ? item.Name : String.Empty; - break; - } - } - } + TaskInventoryItem item = GetSelfInventoryItem(); - return result; + return item.Name != null ? item.Name : String.Empty; } public LSL_Integer llGetLinkNumberOfSides(int link) @@ -9655,16 +9572,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero) - return new LSL_Vector(); + TaskInventoryItem item = GetSelfInventoryItem(); - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) - { - ShoutError("No permissions to track the camera"); - return new LSL_Vector(); - } + if (item.PermsGranter == UUID.Zero) + return new LSL_Vector(); + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + { + ShoutError("No permissions to track the camera"); + return new LSL_Vector(); } ScenePresence presence = World.GetScenePresence(m_host.OwnerID); @@ -9680,16 +9596,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) - { - if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero) - return new LSL_Rotation(); + TaskInventoryItem item = GetSelfInventoryItem(); - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) - { - ShoutError("No permissions to track the camera"); - return new LSL_Rotation(); - } + if (item.PermsGranter == UUID.Zero) + return new LSL_Rotation(); + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + { + ShoutError("No permissions to track the camera"); + return new LSL_Rotation(); } ScenePresence presence = World.GetScenePresence(m_host.OwnerID); @@ -9865,17 +9780,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // the object we are in UUID objectID = m_host.ParentUUID; - if (objectID == UUID.Zero) return; + if (objectID == UUID.Zero) + return; - UUID agentID; - lock (m_host.TaskInventory) - { - // we need the permission first, to know which avatar we want to set the camera for - agentID = m_host.TaskInventory[m_itemID].PermsGranter; + TaskInventoryItem item = GetSelfInventoryItem(); - if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; - } + // we need the permission first, to know which avatar we want to set the camera for + UUID agentID = item.PermsGranter; + + if (agentID == UUID.Zero) + return; + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) + return; ScenePresence presence = World.GetScenePresence(agentID); @@ -9917,21 +9834,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // the object we are in UUID objectID = m_host.ParentUUID; - if (objectID == UUID.Zero) return; + if (objectID == UUID.Zero) + return; + + TaskInventoryItem item = GetSelfInventoryItem(); // we need the permission first, to know which avatar we want to clear the camera for - UUID agentID; - lock (m_host.TaskInventory) - { - agentID = m_host.TaskInventory[m_itemID].PermsGranter; - if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; - } + UUID agentID = item.PermsGranter; + + if (agentID == UUID.Zero) + return; + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) + return; ScenePresence presence = World.GetScenePresence(agentID); // we are not interested in child-agents - if (presence.IsChildAgent) return; + if (presence.IsChildAgent) + return; presence.ControllingClient.SendClearFollowCamProperties(objectID); } -- cgit v1.1 From 40e37d8b78379db08de541c8c7a9fed1d22ec5ef Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Apr 2012 00:03:57 +0100 Subject: Add osForceAttachToAvatar() and osForceDetachFromAvatar() These behave identically to llAttachToAvatar() and llDetachFromAvatar() except that they do not enforce the PERMISSION_ATTACH check Intended for use in completely controlled dedicated environments where these checks are more a UI hinderance than a help. Threat level high. --- .../Shared/Api/Implementation/ApiManager.cs | 41 ++++++------ .../Shared/Api/Implementation/LSL_Api.cs | 73 +++++++++++++--------- .../Shared/Api/Implementation/OSSL_Api.cs | 28 +++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 14 +++++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 13 +++- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 7 +++ 6 files changed, 127 insertions(+), 49 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs index 47ed6ba..684138f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs @@ -29,42 +29,43 @@ using System; using System.Collections; using System.Collections.Generic; using System.Reflection; +using log4net; using OpenSim.Region.ScriptEngine.Interfaces; namespace OpenSim.Region.ScriptEngine.Shared.Api { public class ApiManager { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary m_Apis = new Dictionary(); public string[] GetApis() { - if (m_Apis.Count > 0) + if (m_Apis.Count <= 0) { - List l = new List(m_Apis.Keys); - return l.ToArray(); - } + Assembly a = Assembly.GetExecutingAssembly(); - Assembly a = Assembly.GetExecutingAssembly(); + Type[] types = a.GetExportedTypes(); - Type[] types = a.GetExportedTypes(); - - foreach (Type t in types) - { - string name = t.ToString(); - int idx = name.LastIndexOf('.'); - if (idx != -1) - name = name.Substring(idx+1); - - if (name.EndsWith("_Api")) + foreach (Type t in types) { - name = name.Substring(0, name.Length - 4); - m_Apis[name] = t; + string name = t.ToString(); + int idx = name.LastIndexOf('.'); + if (idx != -1) + name = name.Substring(idx+1); + + if (name.EndsWith("_Api")) + { + name = name.Substring(0, name.Length - 4); + m_Apis[name] = t; + } } } - List ret = new List(m_Apis.Keys); - return ret.ToArray(); +// m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count); + + return new List(m_Apis.Keys).ToArray(); } public IScriptApi CreateApi(string api) @@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ret; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9cb97f9..d4c872c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2994,7 +2994,49 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_UrlModule.ReleaseURL(url); } - public void llAttachToAvatar(int attachment) + /// + /// Attach the object containing this script to the avatar that owns it. + /// + /// The attachment point (e.g. ATTACH_CHEST) + /// true if the attach suceeded, false if it did not + public bool AttachToAvatar(int attachmentPoint) + { + SceneObjectGroup grp = m_host.ParentGroup; + ScenePresence presence = World.GetScenePresence(m_host.OwnerID); + + IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; + + if (attachmentsModule != null) + return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false); + else + return false; + } + + /// + /// Detach the object containing this script from the avatar it is attached to. + /// + /// + /// Nothing happens if the object is not attached. + /// + public void DetachFromAvatar() + { + Util.FireAndForget(DetachWrapper, m_host); + } + + private void DetachWrapper(object o) + { + SceneObjectPart host = (SceneObjectPart)o; + + SceneObjectGroup grp = host.ParentGroup; + UUID itemID = grp.FromItemID; + ScenePresence presence = World.GetScenePresence(host.OwnerID); + + IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; + if (attachmentsModule != null) + attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); + } + + public void llAttachToAvatar(int attachmentPoint) { m_host.AddScriptLPS(1); @@ -3007,15 +3049,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) - { - SceneObjectGroup grp = m_host.ParentGroup; - - ScenePresence presence = World.GetScenePresence(m_host.OwnerID); - - IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; - if (attachmentsModule != null) - attachmentsModule.AttachObject(presence, grp, (uint)attachment, false); - } + AttachToAvatar(attachmentPoint); } public void llDetachFromAvatar() @@ -3031,24 +3065,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) - { - IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; - if (attachmentsModule != null) - Util.FireAndForget(DetachWrapper, m_host); - } - } - - private void DetachWrapper(object o) - { - SceneObjectPart host = (SceneObjectPart)o; - - SceneObjectGroup grp = host.ParentGroup; - UUID itemID = grp.FromItemID; - ScenePresence presence = World.GetScenePresence(host.OwnerID); - - IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; - if (attachmentsModule != null) - attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); + DetachFromAvatar(); } public void llTakeCamera(string avatar) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index fe94b79..3f261ea 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -209,6 +209,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api throw new Exception("OSSL Runtime Error: " + msg); } + /// + /// Initialize the LSL interface. + /// + /// + /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no + /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from + /// ScriptInstance. + /// private void InitLSL() { if (m_LSL_Api != null) @@ -3093,5 +3101,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); } } + + public void osForceAttachToAvatar(int attachmentPoint) + { + CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); + + m_host.AddScriptLPS(1); + + InitLSL(); + ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); + } + + public void osForceDetachFromAvatar() + { + CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); + + m_host.AddScriptLPS(1); + + InitLSL(); + ((LSL_Api)m_LSL_Api).DetachFromAvatar(); + } } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 545bbee..d0c852b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osAvatarPlayAnimation(string avatar, string animation); void osAvatarStopAnimation(string avatar, string animation); + // Attachment commands + + /// + /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH + /// + /// The attachment point. For example, ATTACH_CHEST + void osForceAttachToAvatar(int attachment); + + /// + /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH + /// + /// Nothing happens if the object is not attached. + void osForceDetachFromAvatar(); + //texture draw functions string osMovePen(string drawList, int x, int y); string osDrawLine(string drawList, int startX, int startY, int endX, int endY); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index b94b9bf..36ac0e3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); } + // Avatar functions - //Texture Draw functions + public void osForceAttachToAvatar(int attachmentPoint) + { + m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); + } + + public void osForceDetachFromAvatar() + { + m_OSSL_Functions.osForceDetachFromAvatar(); + } + + // Texture Draw functions public string osMovePen(string drawList, int x, int y) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 6e36742..2c8af81 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public IScriptApi GetApi(string name) { if (m_Apis.ContainsKey(name)) + { +// m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName); + return m_Apis[name]; + } + +// m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName); + return null; } -- cgit v1.1 From 6c21e15cb9542c06e69fd8acd6d4c04aad2cd7da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Apr 2012 00:32:01 +0100 Subject: Add online/offline indicator to "friends show" region console command. Improve output table formatting. --- .../Avatar/Friends/FriendsCommandsModule.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs index e68f9d0..2602050 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs @@ -58,6 +58,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends private Scene m_scene; private IFriendsModule m_friendsModule; private IUserManagement m_userManagementModule; + private IPresenceService m_presenceService; // private IAvatarFactoryModule m_avatarFactory; @@ -99,8 +100,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends m_friendsModule = m_scene.RequestModuleInterface(); m_userManagementModule = m_scene.RequestModuleInterface(); + m_presenceService = m_scene.RequestModuleInterface(); - if (m_friendsModule != null && m_userManagementModule != null) + if (m_friendsModule != null && m_userManagementModule != null && m_presenceService != null) { m_scene.AddCommand( "Friends", this, "friends show", @@ -162,7 +164,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId); - MainConsole.Instance.OutputFormat("UUID, Name, MyFlags, TheirFlags"); + MainConsole.Instance.OutputFormat( + "{0,-36} {1,-36} {2,-7} {3,7} {4,10}", "UUID", "Name", "Status", "MyFlags", "TheirFlags"); foreach (FriendInfo friend in friends) { @@ -175,14 +178,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends UUID friendId; string friendName; + string onlineText; if (UUID.TryParse(friend.Friend, out friendId)) friendName = m_userManagementModule.GetUserName(friendId); else friendName = friend.Friend; + OpenSim.Services.Interfaces.PresenceInfo[] pi = m_presenceService.GetAgents(new string[] { friend.Friend }); + if (pi.Length > 0) + onlineText = "online"; + else + onlineText = "offline"; + MainConsole.Instance.OutputFormat( - "{0} {1} {2} {3}", friend.Friend, friendName, friend.MyFlags, friend.TheirFlags); + "{0,-36} {1,-36} {2,-7} {3,-7} {4,-10}", + friend.Friend, friendName, onlineText, friend.MyFlags, friend.TheirFlags); } } } -- cgit v1.1 From fd279889788420a63d7454833ab33cb4060edf38 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 23 Apr 2012 21:29:18 -0700 Subject: Changed the Map-related messages from Info to Debug. They're debug messages. --- OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | 4 ++-- OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs | 4 ++-- OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | 4 ++-- OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index f86c790..aa306c7 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs @@ -225,7 +225,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap int tc = 0; double[,] hm = whichScene.Heightmap.GetDoubles(); tc = Environment.TickCount; - m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); EntityBase[] objs = whichScene.GetEntities(); Dictionary z_sort = new Dictionary(); //SortedList z_sort = new SortedList(); @@ -541,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap g.Dispose(); } // lock entities objs - m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); return mapbmp; } diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs index eb1a27f..992bff3 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap public void TerrainToBitmap(Bitmap mapbmp) { int tc = Environment.TickCount; - m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); double[,] hm = m_scene.Heightmap.GetDoubles(); bool ShadowDebugContinue = true; @@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap } } } - m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); } } } diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index 1d2141e..d13c2ef 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs @@ -278,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap public void TerrainToBitmap(Bitmap mapbmp) { int tc = Environment.TickCount; - m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); // These textures should be in the AssetCache anyway, as every client conneting to this // region needs them. Except on start, when the map is recreated (before anyone connected), @@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap } } } - m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); + m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); } } } diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs index 6163fd1..4f4e296 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs @@ -88,11 +88,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); - m_log.Info("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString()); + m_log.Debug("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString()); } else { - m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); + m_log.Debug("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); } m_scene.RegisterModuleInterface(this); -- cgit v1.1 From c6f30e044b6cd2ed8493ad0e2914786eef4f7890 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Apr 2012 19:49:52 +0100 Subject: Restore _parent_scene.actor_name_map[prim_geom] = this; accidentally removed from ODEPrim.SetGeom. This occurred in 7a574be3fd from Sat 21 Apr 2012. This should fix collision detection. Mnay thanks to tglion for the spot and the fix in http://opensimulator.org/mantis/view.php?id=5988 --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 3f88353..0716214 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -338,6 +338,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); _parent_scene.geom_name_map[prim_geom] = Name; + _parent_scene.actor_name_map[prim_geom] = this; if (childPrim) { -- cgit v1.1 From 0e3053e4c97670e897496ffa98d7039bf686e6d2 Mon Sep 17 00:00:00 2001 From: Olivier van Helden and Gudule Lapointe (Speculoos.net) Date: Thu, 19 Apr 2012 01:17:56 +0200 Subject: DST settings to match client default Pacific Time (mantis #5972) --- OpenSim/Services/LLLoginService/LLLoginResponse.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 844c5ae..8fdcf4e 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -349,7 +349,21 @@ namespace OpenSim.Services.LLLoginService private void SetDefaultValues() { - DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; + TimeZoneInfo gridTimeZone; + try + { + // First try to fetch DST from Pacific Standard Time, because this is + // the one expected by the viewer. "US/Pacific" is the string to search + // on linux and mac, and should work also on Windows (to confirm) + gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific"); + } + catch (Exception e) + { + m_log.WarnFormat("[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time", e.Message); + gridTimeZone = TimeZoneInfo.Local; + } + DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; + StipendSinceLogin = "N"; Gendered = "Y"; EverLoggedIn = "Y"; -- cgit v1.1 From cbe889e10bc06f0a3e31b4094c88bf022635dff9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Apr 2012 20:30:19 +0100 Subject: minor: formatting changes to top of LLLoginResponse.SetDefaultValues(), chiefly some break up of the long line. --- OpenSim/Services/LLLoginService/LLLoginResponse.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 8fdcf4e..10a44ed 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -350,6 +350,7 @@ namespace OpenSim.Services.LLLoginService private void SetDefaultValues() { TimeZoneInfo gridTimeZone; + try { // First try to fetch DST from Pacific Standard Time, because this is @@ -359,9 +360,13 @@ namespace OpenSim.Services.LLLoginService } catch (Exception e) { - m_log.WarnFormat("[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time", e.Message); + m_log.WarnFormat( + "[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time", + e.Message); + gridTimeZone = TimeZoneInfo.Local; } + DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; StipendSinceLogin = "N"; -- cgit v1.1 From 6011bfa5e36d77ad58cf50ddd99b8c6289144f57 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 19:19:08 +0300 Subject: OSSL: fixed the threat level check for osParseJSONNew --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3f261ea..7fc7337 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1617,7 +1617,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public Object osParseJSONNew(string JSON) { - CheckThreatLevel(ThreatLevel.None, "osParseJSON"); + CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); m_host.AddScriptLPS(1); -- cgit v1.1 From c70e85a3271aaa9e6d892240964cb55cbc2960c7 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 18:38:21 +0300 Subject: When reading a region, use null objects to represent NULL fields. Previously NULL fields were converted to an empty string due to the use of ToString(). But if the field was an Int (e.g., "locZ"), then the subsequent attempt to convert an empty string to an int caused an exception. Now the field is null so we don't try to convert it, so there's no exception. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index c20c392..948cdf3 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -187,7 +187,11 @@ namespace OpenSim.Data.MySQL if (s == "locY") continue; - ret.Data[s] = result[s].ToString(); + object value = result[s]; + if (value is DBNull) + ret.Data[s] = null; + else + ret.Data[s] = result[s].ToString(); } retList.Add(ret); -- cgit v1.1 From da5fd53702ce97d13da2cb50da0753d507e6c11b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 18:39:23 +0300 Subject: Fixed problem with MySQL: it was possible for one thread to use an incomplete list of column names if another thread was creating the list at the same time. Now this is thread-safe. --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 23 +++++++++++++------- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 6 ++++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 29 ++++++++++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 8d82f61..664ce84 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -79,14 +79,7 @@ namespace OpenSim.Data.MySQL { ret.PrincipalID = principalID; - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } + CheckColumnNames(result); foreach (string s in m_ColumnNames) { @@ -105,6 +98,20 @@ namespace OpenSim.Data.MySQL } } + private void CheckColumnNames(IDataReader result) + { + if (m_ColumnNames != null) + return; + + List columnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + columnNames.Add(row["ColumnName"].ToString()); + + m_ColumnNames = columnNames; + } + public bool Store(AuthenticationData data) { if (data.Data.ContainsKey("UUID")) diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 754cf72..da8e958 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -91,15 +91,17 @@ namespace OpenSim.Data.MySQL if (m_ColumnNames != null) return; - m_ColumnNames = new List(); + List columnNames = new List(); DataTable schemaTable = reader.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) { if (row["ColumnName"] != null && (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) - m_ColumnNames.Add(row["ColumnName"].ToString()); + columnNames.Add(row["ColumnName"].ToString()); } + + m_ColumnNames = columnNames; } public virtual T[] Get(string field, string key) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 948cdf3..d1f1932 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -162,17 +162,7 @@ namespace OpenSim.Data.MySQL ret.sizeX = Convert.ToInt32(result["sizeX"]); ret.sizeY = Convert.ToInt32(result["sizeY"]); - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - { - if (row["ColumnName"] != null) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - } + CheckColumnNames(result); foreach (string s in m_ColumnNames) { @@ -202,6 +192,23 @@ namespace OpenSim.Data.MySQL return retList; } + private void CheckColumnNames(IDataReader result) + { + if (m_ColumnNames != null) + return; + + List columnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + { + if (row["ColumnName"] != null) + columnNames.Add(row["ColumnName"].ToString()); + } + + m_ColumnNames = columnNames; + } + public bool Store(RegionData data) { if (data.Data.ContainsKey("uuid")) -- cgit v1.1 From d3a4d67a207976cd0d116bb9021f7dfc896784e8 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 17:26:37 +0300 Subject: Refactored how asset/inventory types are associated with content types: gathered all the knowledge into a single class. Added the Mesh content type. --- OpenSim/Framework/SLUtil.cs | 382 ++++++++++++++++-------------------- OpenSim/Framework/Tests/UtilTest.cs | 23 ++- 2 files changed, 177 insertions(+), 228 deletions(-) diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index db4541e..537de7a 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -38,239 +38,189 @@ namespace OpenSim.Framework public static class SLUtil { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + #region SL / file extension / content-type conversions - public static string SLAssetTypeToContentType(int assetType) + private class TypeMapping { - switch ((AssetType)assetType) + private sbyte assetType; + private InventoryType inventoryType; + private string contentType; + private string contentType2; + private string extension; + + public sbyte AssetTypeCode + { + get { return assetType; } + } + + public object AssetType + { + get { + if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) + return (OpenMetaverse.AssetType)assetType; + else + return OpenMetaverse.AssetType.Unknown; + } + } + + public InventoryType InventoryType + { + get { return inventoryType; } + } + + public string ContentType + { + get { return contentType; } + } + + public string ContentType2 + { + get { return contentType2; } + } + + public string Extension + { + get { return extension; } + } + + private TypeMapping(sbyte assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) + { + this.assetType = assetType; + this.inventoryType = inventoryType; + this.contentType = contentType; + this.contentType2 = contentType2; + this.extension = extension; + } + + public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) + : this((sbyte)assetType, inventoryType, contentType, contentType2, extension) + { + } + + public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension) + : this((sbyte)assetType, inventoryType, contentType, null, extension) { - case AssetType.Texture: - return "image/x-j2c"; - case AssetType.Sound: - return "audio/ogg"; - case AssetType.CallingCard: - return "application/vnd.ll.callingcard"; - case AssetType.Landmark: - return "application/vnd.ll.landmark"; - case AssetType.Clothing: - return "application/vnd.ll.clothing"; - case AssetType.Object: - return "application/vnd.ll.primitive"; - case AssetType.Notecard: - return "application/vnd.ll.notecard"; - case AssetType.Folder: - return "application/vnd.ll.folder"; - case AssetType.RootFolder: - return "application/vnd.ll.rootfolder"; - case AssetType.LSLText: - return "application/vnd.ll.lsltext"; - case AssetType.LSLBytecode: - return "application/vnd.ll.lslbyte"; - case AssetType.TextureTGA: - case AssetType.ImageTGA: - return "image/tga"; - case AssetType.Bodypart: - return "application/vnd.ll.bodypart"; - case AssetType.TrashFolder: - return "application/vnd.ll.trashfolder"; - case AssetType.SnapshotFolder: - return "application/vnd.ll.snapshotfolder"; - case AssetType.LostAndFoundFolder: - return "application/vnd.ll.lostandfoundfolder"; - case AssetType.SoundWAV: - return "audio/x-wav"; - case AssetType.ImageJPEG: - return "image/jpeg"; - case AssetType.Animation: - return "application/vnd.ll.animation"; - case AssetType.Gesture: - return "application/vnd.ll.gesture"; - case AssetType.Simstate: - return "application/x-metaverse-simstate"; - case AssetType.FavoriteFolder: - return "application/vnd.ll.favoritefolder"; - case AssetType.Link: - return "application/vnd.ll.link"; - case AssetType.LinkFolder: - return "application/vnd.ll.linkfolder"; - case AssetType.CurrentOutfitFolder: - return "application/vnd.ll.currentoutfitfolder"; - case AssetType.OutfitFolder: - return "application/vnd.ll.outfitfolder"; - case AssetType.MyOutfitsFolder: - return "application/vnd.ll.myoutfitsfolder"; - case AssetType.Unknown: - default: - return "application/octet-stream"; } } - public static string SLInvTypeToContentType(int invType) + /// + /// Maps between AssetType, InventoryType and Content-Type. + /// Where more than one possibility exists, the first one takes precedence. E.g.: + /// AssetType "AssetType.Texture" -> Content-Type "image-xj2c" + /// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture" + /// + private static TypeMapping[] MAPPINGS = new TypeMapping[] { + new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"), + new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"), + new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"), + new TypeMapping(AssetType.TextureTGA, InventoryType.Texture, "image/tga", "tga"), + new TypeMapping(AssetType.ImageTGA, InventoryType.Texture, "image/tga", "tga"), + new TypeMapping(AssetType.ImageJPEG, InventoryType.Texture, "image/jpeg", "jpg"), + new TypeMapping(AssetType.Sound, InventoryType.Sound, "audio/ogg", "application/ogg", "ogg"), + new TypeMapping(AssetType.SoundWAV, InventoryType.Sound, "audio/x-wav", "wav"), + new TypeMapping(AssetType.CallingCard, InventoryType.CallingCard, "application/vnd.ll.callingcard", "application/x-metaverse-callingcard", "callingcard"), + new TypeMapping(AssetType.Landmark, InventoryType.Landmark, "application/vnd.ll.landmark", "application/x-metaverse-landmark", "landmark"), + new TypeMapping(AssetType.Clothing, InventoryType.Wearable, "application/vnd.ll.clothing", "application/x-metaverse-clothing", "clothing"), + new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), + new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), + new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"), + new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"), + new TypeMapping(AssetType.RootFolder, InventoryType.RootCategory, "application/vnd.ll.rootfolder", "rootfolder"), + new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"), + new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"), + new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"), + new TypeMapping(AssetType.TrashFolder, InventoryType.Folder, "application/vnd.ll.trashfolder", "trashfolder"), + new TypeMapping(AssetType.SnapshotFolder, InventoryType.Folder, "application/vnd.ll.snapshotfolder", "snapshotfolder"), + new TypeMapping(AssetType.LostAndFoundFolder, InventoryType.Folder, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"), + new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"), + new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"), + new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"), + new TypeMapping(AssetType.FavoriteFolder, InventoryType.Unknown, "application/vnd.ll.favoritefolder", "favoritefolder"), + new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"), + new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"), + new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), + new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), + new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), + new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm") + }; + + private static Dictionary asset2Content; + private static Dictionary asset2Extension; + private static Dictionary inventory2Content; + private static Dictionary content2Asset; + private static Dictionary content2Inventory; + + static SLUtil() { - switch ((InventoryType)invType) + asset2Content = new Dictionary(); + asset2Extension = new Dictionary(); + inventory2Content = new Dictionary(); + content2Asset = new Dictionary(); + content2Inventory = new Dictionary(); + + foreach (TypeMapping mapping in MAPPINGS) { - case InventoryType.Animation: - return "application/vnd.ll.animation"; - case InventoryType.CallingCard: - return "application/vnd.ll.callingcard"; - case InventoryType.Folder: - return "application/vnd.ll.folder"; - case InventoryType.Gesture: - return "application/vnd.ll.gesture"; - case InventoryType.Landmark: - return "application/vnd.ll.landmark"; - case InventoryType.LSL: - return "application/vnd.ll.lsltext"; - case InventoryType.Notecard: - return "application/vnd.ll.notecard"; - case InventoryType.Attachment: - case InventoryType.Object: - return "application/vnd.ll.primitive"; - case InventoryType.Sound: - return "audio/ogg"; - case InventoryType.Snapshot: - case InventoryType.Texture: - return "image/x-j2c"; - case InventoryType.Wearable: - return "application/vnd.ll.clothing"; - default: - return "application/octet-stream"; + sbyte assetType = mapping.AssetTypeCode; + if (!asset2Content.ContainsKey(assetType)) + asset2Content.Add(assetType, mapping.ContentType); + if (!asset2Extension.ContainsKey(assetType)) + asset2Extension.Add(assetType, mapping.Extension); + if (!inventory2Content.ContainsKey(mapping.InventoryType)) + inventory2Content.Add(mapping.InventoryType, mapping.ContentType); + if (!content2Asset.ContainsKey(mapping.ContentType)) + content2Asset.Add(mapping.ContentType, assetType); + if (!content2Inventory.ContainsKey(mapping.ContentType)) + content2Inventory.Add(mapping.ContentType, mapping.InventoryType); + + if (mapping.ContentType2 != null) + { + if (!content2Asset.ContainsKey(mapping.ContentType2)) + content2Asset.Add(mapping.ContentType2, assetType); + if (!content2Inventory.ContainsKey(mapping.ContentType2)) + content2Inventory.Add(mapping.ContentType2, mapping.InventoryType); + } } } + + public static string SLAssetTypeToContentType(int assetType) + { + string contentType; + if (!asset2Content.TryGetValue((sbyte)assetType, out contentType)) + contentType = asset2Content[(sbyte)AssetType.Unknown]; + return contentType; + } + + public static string SLInvTypeToContentType(int invType) + { + string contentType; + if (!inventory2Content.TryGetValue((InventoryType)invType, out contentType)) + contentType = inventory2Content[InventoryType.Unknown]; + return contentType; + } public static sbyte ContentTypeToSLAssetType(string contentType) { - switch (contentType) - { - case "image/x-j2c": - case "image/jp2": - return (sbyte)AssetType.Texture; - case "application/ogg": - case "audio/ogg": - return (sbyte)AssetType.Sound; - case "application/vnd.ll.callingcard": - case "application/x-metaverse-callingcard": - return (sbyte)AssetType.CallingCard; - case "application/vnd.ll.landmark": - case "application/x-metaverse-landmark": - return (sbyte)AssetType.Landmark; - case "application/vnd.ll.clothing": - case "application/x-metaverse-clothing": - return (sbyte)AssetType.Clothing; - case "application/vnd.ll.primitive": - case "application/x-metaverse-primitive": - return (sbyte)AssetType.Object; - case "application/vnd.ll.notecard": - case "application/x-metaverse-notecard": - return (sbyte)AssetType.Notecard; - case "application/vnd.ll.folder": - return (sbyte)AssetType.Folder; - case "application/vnd.ll.rootfolder": - return (sbyte)AssetType.RootFolder; - case "application/vnd.ll.lsltext": - case "application/x-metaverse-lsl": - return (sbyte)AssetType.LSLText; - case "application/vnd.ll.lslbyte": - case "application/x-metaverse-lso": - return (sbyte)AssetType.LSLBytecode; - case "image/tga": - // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA - return (sbyte)AssetType.ImageTGA; - case "application/vnd.ll.bodypart": - case "application/x-metaverse-bodypart": - return (sbyte)AssetType.Bodypart; - case "application/vnd.ll.trashfolder": - return (sbyte)AssetType.TrashFolder; - case "application/vnd.ll.snapshotfolder": - return (sbyte)AssetType.SnapshotFolder; - case "application/vnd.ll.lostandfoundfolder": - return (sbyte)AssetType.LostAndFoundFolder; - case "audio/x-wav": - return (sbyte)AssetType.SoundWAV; - case "image/jpeg": - return (sbyte)AssetType.ImageJPEG; - case "application/vnd.ll.animation": - case "application/x-metaverse-animation": - return (sbyte)AssetType.Animation; - case "application/vnd.ll.gesture": - case "application/x-metaverse-gesture": - return (sbyte)AssetType.Gesture; - case "application/x-metaverse-simstate": - return (sbyte)AssetType.Simstate; - case "application/vnd.ll.favoritefolder": - return (sbyte)AssetType.FavoriteFolder; - case "application/vnd.ll.link": - return (sbyte)AssetType.Link; - case "application/vnd.ll.linkfolder": - return (sbyte)AssetType.LinkFolder; - case "application/vnd.ll.currentoutfitfolder": - return (sbyte)AssetType.CurrentOutfitFolder; - case "application/vnd.ll.outfitfolder": - return (sbyte)AssetType.OutfitFolder; - case "application/vnd.ll.myoutfitsfolder": - return (sbyte)AssetType.MyOutfitsFolder; - case "application/octet-stream": - default: - return (sbyte)AssetType.Unknown; - } + sbyte assetType; + if (!content2Asset.TryGetValue(contentType, out assetType)) + assetType = (sbyte)AssetType.Unknown; + return (sbyte)assetType; } public static sbyte ContentTypeToSLInvType(string contentType) { - switch (contentType) - { - case "image/x-j2c": - case "image/jp2": - case "image/tga": - case "image/jpeg": - return (sbyte)InventoryType.Texture; - case "application/ogg": - case "audio/ogg": - case "audio/x-wav": - return (sbyte)InventoryType.Sound; - case "application/vnd.ll.callingcard": - case "application/x-metaverse-callingcard": - return (sbyte)InventoryType.CallingCard; - case "application/vnd.ll.landmark": - case "application/x-metaverse-landmark": - return (sbyte)InventoryType.Landmark; - case "application/vnd.ll.clothing": - case "application/x-metaverse-clothing": - case "application/vnd.ll.bodypart": - case "application/x-metaverse-bodypart": - return (sbyte)InventoryType.Wearable; - case "application/vnd.ll.primitive": - case "application/x-metaverse-primitive": - return (sbyte)InventoryType.Object; - case "application/vnd.ll.notecard": - case "application/x-metaverse-notecard": - return (sbyte)InventoryType.Notecard; - case "application/vnd.ll.folder": - return (sbyte)InventoryType.Folder; - case "application/vnd.ll.rootfolder": - return (sbyte)InventoryType.RootCategory; - case "application/vnd.ll.lsltext": - case "application/x-metaverse-lsl": - case "application/vnd.ll.lslbyte": - case "application/x-metaverse-lso": - return (sbyte)InventoryType.LSL; - case "application/vnd.ll.trashfolder": - case "application/vnd.ll.snapshotfolder": - case "application/vnd.ll.lostandfoundfolder": - return (sbyte)InventoryType.Folder; - case "application/vnd.ll.animation": - case "application/x-metaverse-animation": - return (sbyte)InventoryType.Animation; - case "application/vnd.ll.gesture": - case "application/x-metaverse-gesture": - return (sbyte)InventoryType.Gesture; - case "application/x-metaverse-simstate": - return (sbyte)InventoryType.Snapshot; - case "application/octet-stream": - default: - return (sbyte)InventoryType.Unknown; - } + InventoryType invType; + if (!content2Inventory.TryGetValue(contentType, out invType)) + invType = InventoryType.Unknown; + return (sbyte)invType; + } + + public static string SLAssetTypeToExtension(int assetType) + { + string extension; + if (!asset2Extension.TryGetValue((sbyte)assetType, out extension)) + extension = asset2Extension[(sbyte)AssetType.Unknown]; + return extension; } #endregion SL / file extension / content-type conversions @@ -377,4 +327,4 @@ namespace OpenSim.Framework return output; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index 1ca35df..f0d2a3f 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs @@ -214,16 +214,13 @@ namespace OpenSim.Framework.Tests for (int i = 0; i < contenttypes.Length; i++) { - if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18) - { - Assert.That(contenttypes[i] == "image/tga"); - } + int expected; + if (contenttypes[i] == "image/tga") + expected = 12; // if we know only the content-type "image/tga", then we assume the asset type is TextureTGA; not ImageTGA else - { - Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i], - "Expecting {0} but got {1}", assettypes[i], - SLUtil.ContentTypeToSLAssetType(contenttypes[i])); - } + expected = assettypes[i]; + Assert.AreEqual(expected, SLUtil.ContentTypeToSLAssetType(contenttypes[i]), + String.Format("Incorrect AssetType mapped from Content-Type {0}", contenttypes[i])); } int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; @@ -237,7 +234,7 @@ namespace OpenSim.Framework.Tests "application/vnd.ll.primitive", "application/vnd.ll.notecard", "application/vnd.ll.folder", - "application/octet-stream", + "application/vnd.ll.rootfolder", "application/vnd.ll.lsltext", "image/x-j2c", "application/vnd.ll.primitive", @@ -247,7 +244,8 @@ namespace OpenSim.Framework.Tests for (int i=0;i - /// Maps between AssetType, InventoryType and Content-Type. - /// Where more than one possibility exists, the first one takes precedence. E.g.: - /// AssetType "AssetType.Texture" -> Content-Type "image-xj2c" - /// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture" - /// - private static TypeMapping[] MAPPINGS = new TypeMapping[] { - new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"), - new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"), - new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"), - new TypeMapping(AssetType.TextureTGA, InventoryType.Texture, "image/tga", "tga"), - new TypeMapping(AssetType.ImageTGA, InventoryType.Texture, "image/tga", "tga"), - new TypeMapping(AssetType.ImageJPEG, InventoryType.Texture, "image/jpeg", "jpg"), - new TypeMapping(AssetType.Sound, InventoryType.Sound, "audio/ogg", "application/ogg", "ogg"), - new TypeMapping(AssetType.SoundWAV, InventoryType.Sound, "audio/x-wav", "wav"), - new TypeMapping(AssetType.CallingCard, InventoryType.CallingCard, "application/vnd.ll.callingcard", "application/x-metaverse-callingcard", "callingcard"), - new TypeMapping(AssetType.Landmark, InventoryType.Landmark, "application/vnd.ll.landmark", "application/x-metaverse-landmark", "landmark"), - new TypeMapping(AssetType.Clothing, InventoryType.Wearable, "application/vnd.ll.clothing", "application/x-metaverse-clothing", "clothing"), - new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), - new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), - new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"), - new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"), - new TypeMapping(AssetType.RootFolder, InventoryType.RootCategory, "application/vnd.ll.rootfolder", "rootfolder"), - new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"), - new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"), - new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"), - new TypeMapping(AssetType.TrashFolder, InventoryType.Folder, "application/vnd.ll.trashfolder", "trashfolder"), - new TypeMapping(AssetType.SnapshotFolder, InventoryType.Folder, "application/vnd.ll.snapshotfolder", "snapshotfolder"), - new TypeMapping(AssetType.LostAndFoundFolder, InventoryType.Folder, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"), - new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"), - new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"), - new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"), - new TypeMapping(AssetType.FavoriteFolder, InventoryType.Unknown, "application/vnd.ll.favoritefolder", "favoritefolder"), - new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"), - new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"), - new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), - new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), - new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), - new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm") - }; - - private static Dictionary asset2Content; - private static Dictionary asset2Extension; - private static Dictionary inventory2Content; - private static Dictionary content2Asset; - private static Dictionary content2Inventory; - - static SLUtil() + public static string SLInvTypeToContentType(int invType) { - asset2Content = new Dictionary(); - asset2Extension = new Dictionary(); - inventory2Content = new Dictionary(); - content2Asset = new Dictionary(); - content2Inventory = new Dictionary(); - - foreach (TypeMapping mapping in MAPPINGS) + switch ((InventoryType)invType) { - sbyte assetType = mapping.AssetTypeCode; - if (!asset2Content.ContainsKey(assetType)) - asset2Content.Add(assetType, mapping.ContentType); - if (!asset2Extension.ContainsKey(assetType)) - asset2Extension.Add(assetType, mapping.Extension); - if (!inventory2Content.ContainsKey(mapping.InventoryType)) - inventory2Content.Add(mapping.InventoryType, mapping.ContentType); - if (!content2Asset.ContainsKey(mapping.ContentType)) - content2Asset.Add(mapping.ContentType, assetType); - if (!content2Inventory.ContainsKey(mapping.ContentType)) - content2Inventory.Add(mapping.ContentType, mapping.InventoryType); - - if (mapping.ContentType2 != null) - { - if (!content2Asset.ContainsKey(mapping.ContentType2)) - content2Asset.Add(mapping.ContentType2, assetType); - if (!content2Inventory.ContainsKey(mapping.ContentType2)) - content2Inventory.Add(mapping.ContentType2, mapping.InventoryType); - } + case InventoryType.Animation: + return "application/vnd.ll.animation"; + case InventoryType.CallingCard: + return "application/vnd.ll.callingcard"; + case InventoryType.Folder: + return "application/vnd.ll.folder"; + case InventoryType.Gesture: + return "application/vnd.ll.gesture"; + case InventoryType.Landmark: + return "application/vnd.ll.landmark"; + case InventoryType.LSL: + return "application/vnd.ll.lsltext"; + case InventoryType.Notecard: + return "application/vnd.ll.notecard"; + case InventoryType.Attachment: + case InventoryType.Object: + return "application/vnd.ll.primitive"; + case InventoryType.Sound: + return "audio/ogg"; + case InventoryType.Snapshot: + case InventoryType.Texture: + return "image/x-j2c"; + case InventoryType.Wearable: + return "application/vnd.ll.clothing"; + default: + return "application/octet-stream"; } } - - public static string SLAssetTypeToContentType(int assetType) - { - string contentType; - if (!asset2Content.TryGetValue((sbyte)assetType, out contentType)) - contentType = asset2Content[(sbyte)AssetType.Unknown]; - return contentType; - } - - public static string SLInvTypeToContentType(int invType) - { - string contentType; - if (!inventory2Content.TryGetValue((InventoryType)invType, out contentType)) - contentType = inventory2Content[InventoryType.Unknown]; - return contentType; - } public static sbyte ContentTypeToSLAssetType(string contentType) { - sbyte assetType; - if (!content2Asset.TryGetValue(contentType, out assetType)) - assetType = (sbyte)AssetType.Unknown; - return (sbyte)assetType; + switch (contentType) + { + case "image/x-j2c": + case "image/jp2": + return (sbyte)AssetType.Texture; + case "application/ogg": + case "audio/ogg": + return (sbyte)AssetType.Sound; + case "application/vnd.ll.callingcard": + case "application/x-metaverse-callingcard": + return (sbyte)AssetType.CallingCard; + case "application/vnd.ll.landmark": + case "application/x-metaverse-landmark": + return (sbyte)AssetType.Landmark; + case "application/vnd.ll.clothing": + case "application/x-metaverse-clothing": + return (sbyte)AssetType.Clothing; + case "application/vnd.ll.primitive": + case "application/x-metaverse-primitive": + return (sbyte)AssetType.Object; + case "application/vnd.ll.notecard": + case "application/x-metaverse-notecard": + return (sbyte)AssetType.Notecard; + case "application/vnd.ll.folder": + return (sbyte)AssetType.Folder; + case "application/vnd.ll.rootfolder": + return (sbyte)AssetType.RootFolder; + case "application/vnd.ll.lsltext": + case "application/x-metaverse-lsl": + return (sbyte)AssetType.LSLText; + case "application/vnd.ll.lslbyte": + case "application/x-metaverse-lso": + return (sbyte)AssetType.LSLBytecode; + case "image/tga": + // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA + return (sbyte)AssetType.ImageTGA; + case "application/vnd.ll.bodypart": + case "application/x-metaverse-bodypart": + return (sbyte)AssetType.Bodypart; + case "application/vnd.ll.trashfolder": + return (sbyte)AssetType.TrashFolder; + case "application/vnd.ll.snapshotfolder": + return (sbyte)AssetType.SnapshotFolder; + case "application/vnd.ll.lostandfoundfolder": + return (sbyte)AssetType.LostAndFoundFolder; + case "audio/x-wav": + return (sbyte)AssetType.SoundWAV; + case "image/jpeg": + return (sbyte)AssetType.ImageJPEG; + case "application/vnd.ll.animation": + case "application/x-metaverse-animation": + return (sbyte)AssetType.Animation; + case "application/vnd.ll.gesture": + case "application/x-metaverse-gesture": + return (sbyte)AssetType.Gesture; + case "application/x-metaverse-simstate": + return (sbyte)AssetType.Simstate; + case "application/vnd.ll.favoritefolder": + return (sbyte)AssetType.FavoriteFolder; + case "application/vnd.ll.link": + return (sbyte)AssetType.Link; + case "application/vnd.ll.linkfolder": + return (sbyte)AssetType.LinkFolder; + case "application/vnd.ll.currentoutfitfolder": + return (sbyte)AssetType.CurrentOutfitFolder; + case "application/vnd.ll.outfitfolder": + return (sbyte)AssetType.OutfitFolder; + case "application/vnd.ll.myoutfitsfolder": + return (sbyte)AssetType.MyOutfitsFolder; + case "application/octet-stream": + default: + return (sbyte)AssetType.Unknown; + } } public static sbyte ContentTypeToSLInvType(string contentType) { - InventoryType invType; - if (!content2Inventory.TryGetValue(contentType, out invType)) - invType = InventoryType.Unknown; - return (sbyte)invType; - } - - public static string SLAssetTypeToExtension(int assetType) - { - string extension; - if (!asset2Extension.TryGetValue((sbyte)assetType, out extension)) - extension = asset2Extension[(sbyte)AssetType.Unknown]; - return extension; + switch (contentType) + { + case "image/x-j2c": + case "image/jp2": + case "image/tga": + case "image/jpeg": + return (sbyte)InventoryType.Texture; + case "application/ogg": + case "audio/ogg": + case "audio/x-wav": + return (sbyte)InventoryType.Sound; + case "application/vnd.ll.callingcard": + case "application/x-metaverse-callingcard": + return (sbyte)InventoryType.CallingCard; + case "application/vnd.ll.landmark": + case "application/x-metaverse-landmark": + return (sbyte)InventoryType.Landmark; + case "application/vnd.ll.clothing": + case "application/x-metaverse-clothing": + case "application/vnd.ll.bodypart": + case "application/x-metaverse-bodypart": + return (sbyte)InventoryType.Wearable; + case "application/vnd.ll.primitive": + case "application/x-metaverse-primitive": + return (sbyte)InventoryType.Object; + case "application/vnd.ll.notecard": + case "application/x-metaverse-notecard": + return (sbyte)InventoryType.Notecard; + case "application/vnd.ll.folder": + return (sbyte)InventoryType.Folder; + case "application/vnd.ll.rootfolder": + return (sbyte)InventoryType.RootCategory; + case "application/vnd.ll.lsltext": + case "application/x-metaverse-lsl": + case "application/vnd.ll.lslbyte": + case "application/x-metaverse-lso": + return (sbyte)InventoryType.LSL; + case "application/vnd.ll.trashfolder": + case "application/vnd.ll.snapshotfolder": + case "application/vnd.ll.lostandfoundfolder": + return (sbyte)InventoryType.Folder; + case "application/vnd.ll.animation": + case "application/x-metaverse-animation": + return (sbyte)InventoryType.Animation; + case "application/vnd.ll.gesture": + case "application/x-metaverse-gesture": + return (sbyte)InventoryType.Gesture; + case "application/x-metaverse-simstate": + return (sbyte)InventoryType.Snapshot; + case "application/octet-stream": + default: + return (sbyte)InventoryType.Unknown; + } } #endregion SL / file extension / content-type conversions @@ -327,4 +377,4 @@ namespace OpenSim.Framework return output; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index f0d2a3f..1ca35df 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs @@ -214,13 +214,16 @@ namespace OpenSim.Framework.Tests for (int i = 0; i < contenttypes.Length; i++) { - int expected; - if (contenttypes[i] == "image/tga") - expected = 12; // if we know only the content-type "image/tga", then we assume the asset type is TextureTGA; not ImageTGA + if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18) + { + Assert.That(contenttypes[i] == "image/tga"); + } else - expected = assettypes[i]; - Assert.AreEqual(expected, SLUtil.ContentTypeToSLAssetType(contenttypes[i]), - String.Format("Incorrect AssetType mapped from Content-Type {0}", contenttypes[i])); + { + Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i], + "Expecting {0} but got {1}", assettypes[i], + SLUtil.ContentTypeToSLAssetType(contenttypes[i])); + } } int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; @@ -234,7 +237,7 @@ namespace OpenSim.Framework.Tests "application/vnd.ll.primitive", "application/vnd.ll.notecard", "application/vnd.ll.folder", - "application/vnd.ll.rootfolder", + "application/octet-stream", "application/vnd.ll.lsltext", "image/x-j2c", "application/vnd.ll.primitive", @@ -244,8 +247,7 @@ namespace OpenSim.Framework.Tests for (int i=0;i @@ -891,13 +891,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // Calls attach with a Zero position if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) { - m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); +// m_log.Debug( +// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId +// + ", AttachmentPoint: " + AttachmentPt); // Save avatar attachment information - m_log.Debug( - "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId - + ", AttachmentPoint: " + AttachmentPt); - + m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); } } catch (Exception e) -- cgit v1.1 From f24289c47f81caf92c7cb91428008ce1bd038301 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 01:09:23 +0100 Subject: Comment out AvatarService.SetAvatar debug log line for now --- OpenSim/Services/AvatarService/AvatarService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs index c59a9e0..423c781 100644 --- a/OpenSim/Services/AvatarService/AvatarService.cs +++ b/OpenSim/Services/AvatarService/AvatarService.cs @@ -93,7 +93,7 @@ namespace OpenSim.Services.AvatarService if (kvp.Key.StartsWith("_")) count++; - m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count); +// m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count); m_Database.Delete("PrincipalID", principalID.ToString()); AvatarBaseData av = new AvatarBaseData(); -- cgit v1.1 From a65ca24701ac34415bf76f4d9094ab42ae721c9a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 01:51:40 +0100 Subject: Add regression test TestSameRegionTeleport() --- .../EntityTransfer/EntityTransferModule.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++ .../Scenes/Tests/ScenePresenceTeleportTests.cs | 36 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index feb783f..221e0bd 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -192,7 +192,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", position, sp.Name, sp.UUID, emergencyPos); - + position = emergencyPos; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b5f789b..9005acd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -990,6 +990,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void Teleport(Vector3 pos) { +// m_log.DebugFormat("[SCENE PRESENCE]: Moving {0} to {1} in {2}", Name, pos, Scene.RegionInfo.RegionName); + bool isFlying = Flying; RemoveFromPhysicalScene(); Velocity = Vector3.Zero; @@ -1002,6 +1004,10 @@ namespace OpenSim.Region.Framework.Scenes public void TeleportWithMomentum(Vector3 pos) { +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Moving {0} to {1} with existing momentum {2} in {3} ", +// Name, pos, Velocity, Scene.RegionInfo.RegionName); + bool isFlying = Flying; RemoveFromPhysicalScene(); CheckLandingPoint(ref pos); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index bebc10c..eb7bfbd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -33,6 +33,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers; +using OpenSim.Region.CoreModules.Framework.EntityTransfer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; @@ -47,6 +48,41 @@ namespace OpenSim.Region.Framework.Scenes.Tests [TestFixture] public class ScenePresenceTeleportTests { + [Test] + public void TestSameRegionTeleport() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + EntityTransferModule etm = new EntityTransferModule(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + // Not strictly necessary since FriendsModule assumes it is the default (!) + config.Configs["Modules"].Set("EntityTransferModule", etm.Name); + + TestScene scene = SceneHelpers.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); + SceneHelpers.SetupSceneModules(scene, config, etm); + + Vector3 teleportPosition = new Vector3(10, 11, 12); + Vector3 teleportLookAt = new Vector3(20, 21, 22); + + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); + sp.AbsolutePosition = new Vector3(30, 31, 32); + scene.RequestTeleportLocation( + sp.ControllingClient, + scene.RegionInfo.RegionHandle, + teleportPosition, + teleportLookAt, + (uint)TeleportFlags.ViaLocation); + + Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition)); + + // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera + // position instead). +// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); + } + /// /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. /// -- cgit v1.1 From 683cfc6f827c15ee70e4651cbcc7b94a01d2f8e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 02:07:55 +0100 Subject: refactor: Combine ScenePresence.Teleport() and TeleportWithMomentum() These are identical apart from setting Velocity = zero, which has no practical effect anyway since this is zeroed when the avatar is added back to the physics scene. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 ---------------- .../OptionalModules/Scripting/Minimodule/SPAvatar.cs | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9005acd..8cb4921 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -994,22 +994,6 @@ namespace OpenSim.Region.Framework.Scenes bool isFlying = Flying; RemoveFromPhysicalScene(); - Velocity = Vector3.Zero; - CheckLandingPoint(ref pos); - AbsolutePosition = pos; - AddToPhysicalScene(isFlying); - - SendTerseUpdateToAllClients(); - } - - public void TeleportWithMomentum(Vector3 pos) - { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Moving {0} to {1} with existing momentum {2} in {3} ", -// Name, pos, Velocity, Scene.RegionInfo.RegionName); - - bool isFlying = Flying; - RemoveFromPhysicalScene(); CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 922eaaf..d192309 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public Vector3 WorldPosition { get { return GetSP().AbsolutePosition; } - set { GetSP().TeleportWithMomentum(value); } + set { GetSP().Teleport(value); } } public bool IsChildAgent -- cgit v1.1 From af86e2939c54837d47303668266ca314d405fb37 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 03:47:26 +0100 Subject: zero out SP velocity before calling SP.Teleport(), as the client expects (though this is also effectively done by physics at the moment) --- .../Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 221e0bd..f094346 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -215,6 +215,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.ControllingClient.SendTeleportStart(teleportFlags); sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); + sp.Velocity = Vector3.Zero; sp.Teleport(position); foreach (SceneObjectGroup grp in sp.GetAttachments()) -- cgit v1.1 From 3be3189ee067b26fa6486535a65a0c0e99a9ef5b Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 Apr 2012 04:00:01 +0100 Subject: Commit the avination Teleport() methods (adaptedto justincc's changes) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8cb4921..e8178ce 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -990,13 +990,24 @@ namespace OpenSim.Region.Framework.Scenes /// public void Teleport(Vector3 pos) { -// m_log.DebugFormat("[SCENE PRESENCE]: Moving {0} to {1} in {2}", Name, pos, Scene.RegionInfo.RegionName); + TeleportWithMomentum(pos, null); + } + public void TeleportWithMomentum(Vector3 pos, Vector3? v) + { bool isFlying = Flying; + Vector3 vel = Velocity; RemoveFromPhysicalScene(); CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); + if (PhysicsActor != null) + { + if (v.HasValue) + PhysicsActor.SetMomentum((Vector3)v); + else + PhysicsActor.SetMomentum(vel); + } SendTerseUpdateToAllClients(); } -- cgit v1.1 From cf1c34605bf58ee783c2a7d0c63f51ecf6d3288a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 24 Apr 2012 22:17:10 -0700 Subject: HG: Moved User-level code down to the HGEntityTransferModule where it belongs. --- .../Framework/EntityTransfer/EntityTransferModule.cs | 15 +-------------- .../Framework/EntityTransfer/HGEntityTransferModule.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 221e0bd..8d810fc 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -61,8 +61,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer set { m_MaxTransferDistance = value; } } - private int m_levelHGTeleport = 0; - protected bool m_Enabled = false; protected Scene m_aScene; protected List m_Scenes = new List(); @@ -106,7 +104,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (transferConfig != null) { MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); - m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); } m_agentsInTransit = new List(); @@ -240,16 +237,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer destinationRegionName = finalDestination.RegionName; - // check if HyperGrid teleport is allowed, based on user level - int flags = m_aScene.GridService.GetRegionFlags(sp.Scene.RegionInfo.ScopeID, reg.RegionID); - - if (((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) && (sp.UserLevel < m_levelHGTeleport)) - { - m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); - sp.ControllingClient.SendTeleportFailed("HyperGrid teleport not permitted"); - return; - } - uint curX = 0, curY = 0; Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY); int curCellX = (int)(curX / Constants.RegionSize); @@ -413,7 +400,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer bool logout = false; if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) { - sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", + sp.ControllingClient.SendTeleportFailed(String.Format("Teleport refused: {0}", reason)); return; } diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 7f9175d..6a92e61 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_Initialized = false; + private int m_levelHGTeleport = 0; private GatekeeperServiceConnector m_GatekeeperConnector; @@ -68,6 +69,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string name = moduleConfig.GetString("EntityTransferModule", ""); if (name == Name) { + IConfig transferConfig = source.Configs["EntityTransfer"]; + if (transferConfig != null) + m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); + InitialiseCommon(source); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); } @@ -164,6 +169,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { // this user is going to another grid + // check if HyperGrid teleport is allowed, based on user level + if (sp.UserLevel < m_levelHGTeleport) + { + m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); + reason = "HyperGrid teleport not permitted"; + return false; + } + if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) { string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); -- cgit v1.1 From 7aa25c6762e40ee9254e2982a9fca89913fa0279 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 24 Apr 2012 22:40:07 -0700 Subject: Slight rewording of output messages. --- .../CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 6a92e61..634fb43 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // check if HyperGrid teleport is allowed, based on user level if (sp.UserLevel < m_levelHGTeleport) { - m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); + m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); reason = "HyperGrid teleport not permitted"; return false; } -- cgit v1.1