From 1c7accf9500250abad243eaeb6f6baadf7644e78 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 24 Aug 2013 05:55:53 -0500 Subject: [PATCH 1/3] * Fix a null ref that causes a stack unwind when crossing borders. Less stack unwinding.. the faster it goes. * Tweak XEngine so that it's partially functional again. It's still not great, but basic things work. (cherry picked from commit 01c3be27460fd3f28efd17b8d6606b883350f653) --- .../CoreModules/Avatar/Combat/CombatModule.cs | 2 + .../Shared/Instance/ScriptInstance.cs | 3 +- .../Region/ScriptEngine/XEngine/XEngine.cs | 56 +++++++++++++++---- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 343cdb5c1e..c52d586fa1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs @@ -182,6 +182,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule try { ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + if (obj == null) + return; if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0 || avatar.Scene.RegionInfo.RegionSettings.AllowDamage) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 2fb073decf..275b608f7a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -231,6 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance ItemID = ScriptTask.ItemID; AssetID = ScriptTask.AssetID; } + LocalID = part.LocalId; PrimName = part.ParentGroup.Name; StartParam = startParam; @@ -1240,4 +1241,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance return null; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 9d1e143ef1..27d7674dc8 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1316,13 +1316,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine ScriptInstance instance = null; // Create the object record + UUID appDomain = assetID; + + + lockScriptsForRead(true); if ((!m_Scripts.ContainsKey(itemID)) || (m_Scripts[itemID].AssetID != assetID)) { lockScriptsForRead(false); - - UUID appDomain = assetID; + instance = new ScriptInstance(this, part, + item, + startParam, postOnRez, + m_MaxScriptQueue); + + if (part.ParentGroup.IsAttachment) appDomain = part.ParentGroup.RootPart.UUID; @@ -1345,9 +1353,39 @@ namespace OpenSim.Region.ScriptEngine.XEngine sandbox = AppDomain.CreateDomain( m_Scene.RegionInfo.RegionID.ToString(), evidence, appSetup); - m_AppDomains[appDomain].AssemblyResolve += - new ResolveEventHandler( - AssemblyResolver.OnAssemblyResolve); + if (m_AppDomains.ContainsKey(appDomain)) + { + m_AppDomains[appDomain].AssemblyResolve += + new ResolveEventHandler( + AssemblyResolver.OnAssemblyResolve); + if (m_DomainScripts.ContainsKey(appDomain)) + { + m_DomainScripts[appDomain].Add(itemID); + } + else + { + m_DomainScripts.Add(appDomain, new List()); + m_DomainScripts[appDomain].Add(itemID); + } + } + else + { + m_AppDomains.Add(appDomain, sandbox); + m_AppDomains[appDomain].AssemblyResolve += + new ResolveEventHandler( + AssemblyResolver.OnAssemblyResolve); + if (m_DomainScripts.ContainsKey(appDomain)) + { + m_DomainScripts[appDomain].Add(itemID); + } + else + { + m_DomainScripts.Add(appDomain, new List()); + m_DomainScripts[appDomain].Add(itemID); + } + + } + } else { @@ -1373,12 +1411,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine return false; } } - m_DomainScripts[appDomain].Add(itemID); - - instance = new ScriptInstance(this, part, - item, - startParam, postOnRez, - m_MaxScriptQueue); + instance.Load(m_AppDomains[appDomain], assembly, stateSource); // m_log.DebugFormat( @@ -1502,6 +1535,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (handlerObjectRemoved != null) { SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); + if (part != null) handlerObjectRemoved(part.UUID); } From 120b6948ed873a3af7713b411b956b8cb4c7f516 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 24 Aug 2013 18:55:21 -0500 Subject: [PATCH 2/3] * This fixes the border crossing offsets by storing the final keyframe location in the hijacked variable KeyFrame.AngularVelocity. When steps in OnTimer <= 0.0, normalize the final position by Constants.RegionSize and move the object there. The hack here is KeyFrame.AngularVelocity probably isn't the right name for this variable because it's the un-mucked with keyframe position. When you determine the feasibility of changing the name without affecting the serialization of existing objects in world... It's simply a name change to KeyFrame.FinalPosition or something proper. (cherry picked from commit e0399ccaec68889c12e4679b4d62142b49b379df) --- .../Region/Framework/Scenes/KeyframeMotion.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 29652aaa66..4d153da9d0 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -498,6 +498,7 @@ namespace OpenSim.Region.Framework.Scenes k.Position = pos; // k.Velocity = Vector3.Zero; } + k.AngularVelocity = (Vector3)k.Position; k.StartRotation = rot; if (k.Rotation.HasValue) @@ -632,13 +633,13 @@ namespace OpenSim.Region.Framework.Scenes // Do the frame processing double steps = (double)m_currentFrame.TimeMS / tickDuration; - + if (steps <= 0.0) { m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_nextPosition = (Vector3)m_currentFrame.Position; + m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity); m_group.AbsolutePosition = m_nextPosition; // we are sending imediate updates, no doing force a extra terseUpdate @@ -726,7 +727,26 @@ namespace OpenSim.Region.Framework.Scenes m_group.SendGroupRootTerseUpdate(); } } + private Vector3 NormalizeVector(Vector3? pPosition) + { + if (pPosition == null) + return Vector3.Zero; + Vector3 tmp = (Vector3) pPosition; + + while (tmp.X > Constants.RegionSize) + tmp.X -= Constants.RegionSize; + while (tmp.X < 0) + tmp.X += Constants.RegionSize; + while (tmp.Y > Constants.RegionSize) + tmp.Y -= Constants.RegionSize; + while (tmp.Y < 0) + tmp.Y += Constants.RegionSize; + + return tmp; + + + } public Byte[] Serialize() { StopTimer(); From ece2d24077cacba677de5cebdd3a9da463306ecd Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 5 Oct 2013 17:36:58 -0500 Subject: [PATCH 3/3] * Fixes cases where Last Attachment Point gets overwritten with 0 when it shouldn't * Fixes cases where Last Attachment Point doesn't get written when it should. * Fixes Null Reference in BaseHttpServer when shutting down, null path provided. * Drop then Wear retains Last Attachment Point --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 1 + .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 3 ++- .../Framework/InventoryAccess/InventoryAccessModule.cs | 8 ++++++-- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index ed733cf1a9..5681eceb57 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -1967,6 +1967,7 @@ namespace OpenSim.Framework.Servers.HttpServer public void RemoveHTTPHandler(string httpMethod, string path) { + if (path == null) return; // Caps module isn't loaded, tries to remove handler where path = null lock (m_HTTPHandlers) { if (httpMethod != null && httpMethod.Length == 0) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 81a727840d..051e959aa3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -685,6 +685,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); + so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint; + sp.RemoveAttachment(so); so.FromItemID = UUID.Zero; @@ -699,7 +701,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.ClearPartAttachmentData(); rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive,false); so.HasGroupChanged = true; - so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint; rootPart.Rezzed = DateTime.Now; rootPart.RemFlag(PrimFlags.TemporaryOnRez); so.AttachToBackup(); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 3feeb139d9..ac4203ff1f 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -390,9 +390,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // Trees could be attached and it's been done, but it makes // no sense. State must be preserved because it's the tree type - if (objectGroup.RootPart.Shape.PCode != (byte)PCode.Tree && - objectGroup.RootPart.Shape.PCode != (byte)PCode.NewTree) + if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree && + objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree) + { objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; + if (objectGroup.RootPart.AttachPoint > 0) + objectGroup.RootPart.Shape.LastAttachPoint = objectGroup.RootPart.AttachPoint; + } objectGroup.AbsolutePosition = inventoryStoredPosition; objectGroup.RootPart.RotationOffset = inventoryStoredRotation; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6deb8705b2..997a1be96b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1667,7 +1667,8 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); if (avatar == null) return; - + m_rootPart.Shape.LastAttachPoint = m_rootPart.Shape.State; + m_rootPart.AttachedPos = m_rootPart.OffsetPosition; avatar.RemoveAttachment(this); Vector3 detachedpos = new Vector3(127f,127f,127f); @@ -2107,6 +2108,7 @@ namespace OpenSim.Region.Framework.Scenes if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) { + RootPart.Shape.LastAttachPoint = RootPart.Shape.State; RootPart.Shape.State = 0; ScheduleGroupForFullUpdate(); }