From 207a5f17b58d58be249387c2195554d58f72a525 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 3 Jun 2012 13:43:39 +0200
Subject: When regions are set to shut down the instance, always send
 notifications to all affected regions and disregard the region id parameter.

---
 .../RemoteController/RemoteAdminPlugin.cs          | 36 ++++++++++++++++++----
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 9e72a98..437d150 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -258,10 +258,25 @@ namespace OpenSim.ApplicationPlugins.RemoteController
             {
                 m_log.Info("[RADMIN]: Request to restart Region.");
 
-                CheckRegionParams(requestData, responseData);
-
                 Scene rebootedScene = null;
-                GetSceneFromRegionParams(requestData, responseData, out rebootedScene);
+                bool restartAll = false;
+
+                IConfig startupConfig = m_configSource.Configs["Startup"];
+                if (startupConfig != null)
+                {
+                    if (startupConfig.GetBoolean("InworldRestartShutsDown", false))
+                    {
+                        rebootedScene = m_application.SceneManager.CurrentOrFirstScene;
+                        restartAll = true;
+                    }
+                }
+
+                if (rebootedScene == null)
+                {
+                    CheckRegionParams(requestData, responseData);
+
+                    GetSceneFromRegionParams(requestData, responseData, out rebootedScene);
+                }
 
                 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
 
@@ -324,11 +339,20 @@ namespace OpenSim.ApplicationPlugins.RemoteController
                     notice = false;
                 }
 
-                if (restartModule != null)
+                List<Scene> restartList;
+
+                if (restartAll)
+                    restartList = m_application.SceneManager.Scenes;
+                else
+                    restartList = new List<Scene>() { rebootedScene };
+
+                foreach (Scene s in m_application.SceneManager.Scenes)
                 {
-                    restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
-                    responseData["success"] = true;
+                    restartModule = s.RequestModuleInterface<IRestartModule>();
+                    if (restartModule != null)
+                        restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
                 }
+                responseData["success"] = true;
             }
             catch (Exception e)
             {
-- 
cgit v1.1


From 28e5abd9176aeba3b5004d07748ae88cccbcd57a Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 4 Jun 2012 21:05:56 +0200
Subject: Fix llAttachToAvatar and "Attach" viewer option to preserve saved
 attach positions.

---
 .../Avatar/Attachments/AttachmentsModule.cs        | 26 ++++++++++++++++++----
 .../Attachments/Tests/AttachmentsModuleTests.cs    |  4 ++--
 .../Framework/Interfaces/IAttachmentsModule.cs     |  2 +-
 OpenSim/Region/Framework/Scenes/Scene.cs           |  2 +-
 .../Shared/Api/Implementation/LSL_Api.cs           |  2 +-
 5 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index d7c7283..fd7cad2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -227,7 +227,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
             sp.ClearAttachments();
         }
         
-        public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
+        public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData)
         {
             lock (sp.AttachmentsSyncLock)
             {
@@ -273,9 +273,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
                     attachPos = Vector3.Zero;
                 }
     
+                if (useAttachData)
+                {
+                    group.RootPart.RotationOffset = group.RootPart.AttachRotation;
+                    attachPos = group.RootPart.AttachOffset;
+                    if (attachmentPt == 0)
+                    {
+                        attachmentPt = group.RootPart.AttachPoint;
+                        if (attachmentPt == 0)
+                        {
+                            attachmentPt = (uint)AttachmentPoint.LeftHand;
+                            attachPos = Vector3.Zero;
+                        }
+                    }
+                    else if (group.RootPart.AttachPoint != attachmentPt)
+                    {
+                        attachPos = Vector3.Zero;
+                    }
+                }
                 group.AttachmentPoint = attachmentPt;
                 group.AbsolutePosition = attachPos;
-    
+
                 // We also don't want to do any of the inventory operations for an NPC.
                 if (sp.PresenceType != PresenceType.Npc)
                 {
@@ -792,7 +810,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
                         // This will throw if the attachment fails
                         try
                         {
-                            AttachObject(sp, objatt, attachmentPt, false);
+                            AttachObject(sp, objatt, attachmentPt, false, false);
                         }
                         catch (Exception e)
                         {
@@ -947,7 +965,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
                 AttachmentPt &= 0x7f;
 
                 // Calls attach with a Zero position
-                if (AttachObject(sp, part.ParentGroup, AttachmentPt, false))
+                if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true))
                 {
                     m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId);
 
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index bfe5e4a..7119ad2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
 
             SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup;
 
-            m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false);
+            m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false, false);
 
             // Check status on scene presence
             Assert.That(m_presence.HasAttachments(), Is.True);
@@ -317,4 +317,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
 //            Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
 //        }
     }
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 69ce967..0516cb1 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Region.Framework.Interfaces
         /// <param name="AttachmentPt"></param>
         /// <param name="silent"></param>
         /// <returns>true if the object was successfully attached, false otherwise</returns>
-        bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent);
+        bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo);
 
         /// <summary>
         /// Rez an attachment from user inventory and change inventory status to match.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a9a4cda..6a120c1 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2692,7 +2692,7 @@ namespace OpenSim.Region.Framework.Scenes
                     RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
                     
                     if (AttachmentsModule != null)
-                        AttachmentsModule.AttachObject(sp, grp, 0, false);
+                        AttachmentsModule.AttachObject(sp, grp, 0, false, false);
                 }
                 else
                 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ec0966b..ec44da0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3344,7 +3344,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 
                 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
                 if (attachmentsModule != null)
-                    attachmentsModule.AttachObject(presence, grp, (uint)attachment, false);
+                    attachmentsModule.AttachObject(presence, grp, (uint)attachment, false, true);
             }
         }
 
-- 
cgit v1.1


From 401b97788f826397a552b25ab9b30c5549abd54f Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 4 Jun 2012 20:35:12 +0100
Subject:  fix addforce/impulse.

---
 OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 9a40ab5..9b3b51b 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -3252,9 +3252,9 @@ namespace OpenSim.Region.Physics.OdePlugin
         }
 
 
-        private void changeAddImpulse(Vector3 impulse)
+        private void changeAddForce(Vector3 theforce)
         {
-            m_forceacc += impulse *m_invTimeStep;
+            m_forceacc += theforce;
             if (!m_isSelected)
             {
                 lock (this)
@@ -3960,7 +3960,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     break;
 
                 case changes.AddForce:
-                    changeAddImpulse((Vector3)arg);
+                    changeAddForce((Vector3)arg);
                     break;
 
                 case changes.AddAngForce:
-- 
cgit v1.1


From fd176aab8f97aaad037eefc1ae7dc5b9fb670a99 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 4 Jun 2012 22:41:29 +0200
Subject: Actually trigger land collisions in the root even when a child
 collides

---
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a57e9bc..5694c8c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2634,7 +2634,7 @@ namespace OpenSim.Region.Framework.Scenes
                 colliding.Add(CreateDetObjectForGround());
                 LandCollidingMessage.Colliders = colliding;
 
-                notify(LocalId, LandCollidingMessage);
+                notify(ParentGroup.RootPart.LocalId, LandCollidingMessage);
             }
         }
 
-- 
cgit v1.1


From 170b820a114e5a53e70d7f1624109239b182ec9f Mon Sep 17 00:00:00 2001
From: Melanie
Date: Tue, 5 Jun 2012 01:53:25 +0200
Subject: Fix land collisions to work like SL.

---
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 5694c8c..8e74dc8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2626,14 +2626,24 @@ namespace OpenSim.Region.Framework.Scenes
 
         private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify)
         {
-            if ((ParentGroup.RootPart.ScriptEvents & ev) != 0)
+            bool sendToRoot = true;
+
+            ColliderArgs LandCollidingMessage = new ColliderArgs();
+            List<DetectedObject> colliding = new List<DetectedObject>();
+                
+            colliding.Add(CreateDetObjectForGround());
+            LandCollidingMessage.Colliders = colliding;
+
+            if (Inventory.ContainsScripts())
             {
-                ColliderArgs LandCollidingMessage = new ColliderArgs();
-                List<DetectedObject> colliding = new List<DetectedObject>();
-                    
-                colliding.Add(CreateDetObjectForGround());
-                LandCollidingMessage.Colliders = colliding;
+                if (!PassCollisions)
+                    sendToRoot = false;
+            }
+            if ((ScriptEvents & ev) != 0)
+                notify(LocalId, LandCollidingMessage);
 
+            if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot)
+            {
                 notify(ParentGroup.RootPart.LocalId, LandCollidingMessage);
             }
         }
-- 
cgit v1.1


From 768447e41b358c7685ee85f36224d1bfdfd36fcf Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 5 Jun 2012 04:43:23 +0100
Subject:  Stop llRezAtRoot() from applying velocity setting impulse in
 World.RezObject, doing it only in itself, so its applyed after resuming
 scripts etc. It was giving twice the requested velocity.

---
 OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ec44da0..e825b74 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3079,7 +3079,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                         // need the magnitude later
                         // float velmag = (float)Util.GetMagnitude(llvel);
 
-                        SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param);
+                        // rez with zero velocity so we can apply it here after resume scripts etc
+//                        SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param);
+                        SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), Vector3.Zero, param);
 
                         // If either of these are null, then there was an unknown error.
                         if (new_group == null)
@@ -3102,7 +3104,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 
                         if (pa != null && pa.IsPhysical && llvel != Vector3.Zero)
                         {
-                            //Recoil.
                             llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
                         }
                         // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
-- 
cgit v1.1


From 372b76031bc6ae43d075a53574581d451e1200f3 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 5 Jun 2012 05:52:25 +0100
Subject:  revert last bad commit  but fix recoil direction

---
 OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index e825b74..d83b05d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3079,9 +3079,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                         // need the magnitude later
                         // float velmag = (float)Util.GetMagnitude(llvel);
 
-                        // rez with zero velocity so we can apply it here after resume scripts etc
-//                        SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param);
-                        SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), Vector3.Zero, param);
+                        SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param);
 
                         // If either of these are null, then there was an unknown error.
                         if (new_group == null)
@@ -3104,7 +3102,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 
                         if (pa != null && pa.IsPhysical && llvel != Vector3.Zero)
                         {
-                            llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
+                            // recoil                          
+                            llvel *= -groupmass;
+                            llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0);
                         }
                         // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
                         return;
-- 
cgit v1.1


From bdc62144ae19749751bd437c5bde12e2f453dfa5 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 5 Jun 2012 05:53:44 +0100
Subject: fix the real cause of double velocity

---
 OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 0d178c3..b7466be 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -352,7 +352,6 @@ namespace OpenSim.Region.Framework.Scenes
             if (pa != null && pa.IsPhysical && vel != Vector3.Zero)
             {
                 sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false);
-                sceneObject.Velocity = vel;
             }
 
             return true;
-- 
cgit v1.1