From 208a9af53cb5e9132fb45711768233960c4eaa99 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Apr 2022 22:13:33 +0100 Subject: [PATCH] cosmetics --- OpenSim/Framework/AgentUpdateArgs.cs | 6 -- .../ClientStack/Linden/UDP/LLClientView.cs | 2 +- .../Avatar/Attachments/AttachmentsModule.cs | 64 +++++++++++-------- .../Transfer/InventoryTransferModule.cs | 20 ++---- OpenSim/Region/Framework/Scenes/Scene.cs | 3 + .../Region/Framework/Scenes/ScenePresence.cs | 30 ++++----- 6 files changed, 62 insertions(+), 63 deletions(-) diff --git a/OpenSim/Framework/AgentUpdateArgs.cs b/OpenSim/Framework/AgentUpdateArgs.cs index cd1c3a0745..994ab87fba 100644 --- a/OpenSim/Framework/AgentUpdateArgs.cs +++ b/OpenSim/Framework/AgentUpdateArgs.cs @@ -35,11 +35,6 @@ namespace OpenSim.Framework /// public class AgentUpdateArgs : EventArgs { - /// - /// Agent's unique ID - /// - public UUID AgentID; - /// /// Rotation of the avatar's body /// @@ -76,7 +71,6 @@ namespace OpenSim.Framework /// /// Session Id /// - public UUID SessionID; public byte State; public Vector3 ClientAgentPosition; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index beafbe0697..f74bc3c66f 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -8231,7 +8231,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ) return true; - float qdelta = Math.Abs(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation)); + float qdelta = Math.Abs(x.BodyRotation.Dot(m_thisAgentUpdateArgs.BodyRotation)); return qdelta < QDELTABody; // significant if body rotation above(below cos) threshold } diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 9fe0e005fc..80fbf1e55f 100755 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -93,8 +93,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // disabled. Registering only when enabled allows for other attachments module implementations. m_scene.RegisterModuleInterface(this); m_scene.EventManager.OnNewClient += SubscribeToClientEvents; - m_scene.EventManager.OnStartScript += (localID, itemID) => OnScriptStateChange(localID, true); - m_scene.EventManager.OnStopScript += (localID, itemID) => OnScriptStateChange(localID, false); + m_scene.EventManager.OnStartScript += OnScriptStarted; + m_scene.EventManager.OnStopScript += OnScriptStopped; } @@ -108,6 +108,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.UnregisterModuleInterface(this); m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; + m_scene.EventManager.OnStartScript -= OnScriptStarted; + m_scene.EventManager.OnStopScript -= OnScriptStopped; } public void RegionLoaded(Scene scene) @@ -286,24 +288,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// /// - private void OnScriptStateChange(uint localID, bool started) + + private void OnScriptStarted(uint localID, UUID itemID) + { + SceneObjectGroup sog = m_scene.GetGroupByPrim(localID); + if (sog != null && sog.IsAttachment) + sog.HasGroupChanged = true; + } + + private void OnScriptStopped(uint localID, UUID itemID) { SceneObjectGroup sog = m_scene.GetGroupByPrim(localID); if (sog != null && sog.IsAttachment) { - if (!started) - { - // FIXME: This is a convoluted way for working out whether the script state has changed to stop - // because it has been manually stopped or because the stop was called in UpdateDetachedObject() below - // This needs to be handled in a less tangled way. - ScenePresence sp = m_scene.GetScenePresence(sog.AttachedAvatar); - if (sp.ControllingClient.IsActive) - sog.HasGroupChanged = true; - } - else - { + // FIXME: This is a convoluted way for working out whether the script state has changed to stop + // because it has been manually stopped or because the stop was called in UpdateDetachedObject() below + // This needs to be handled in a less tangled way. + ScenePresence sp = m_scene.GetScenePresence(sog.AttachedAvatar); + if (sp.ControllingClient.IsActive) sog.HasGroupChanged = true; - } } } @@ -357,21 +360,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments DeleteAttachmentsFromScene(isp, true); // delete } + List attachments = new List(ad.AttachmentObjects.Count); int i = 0; for (int indx = 0; indx < ad.AttachmentObjects.Count; ++indx) { - SceneObjectGroup sog = (SceneObjectGroup)ad.AttachmentObjects[indx]; - sog.LocalId = 0; - sog.RootPart.ClearUpdateSchedule(); + SceneObjectGroup sog = ad.AttachmentObjects[indx] as SceneObjectGroup; + if(sog != null) + { + sog.LocalId = 0; + sog.RootPart.ClearUpdateSchedule(); -// m_log.DebugFormat( -// "[ATTACHMENTS MODULE]: Copying script state with {0} bytes for object {1} for {2} in {3}", -// ad.AttachmentObjectStates[i].Length, sog.Name, sp.Name, m_scene.Name); - - sog.SetState(ad.AttachmentObjectStates[i++], m_scene); - m_scene.IncomingCreateObject(Vector3.Zero, sog); + sog.SetState(ad.AttachmentObjectStates[i++], m_scene); + attachments.Add(sog); + } } + + ad.AttachmentObjects = null; + ad.AttachmentObjectStates = null; + + if (attachments.Count > 0) + m_scene.IncomingAttechments(sp, attachments); + else + sp.GotAttachmentsData = true; } + else + sp.GotAttachmentsData = true; } public void RezAttachments(IScenePresence sp) @@ -1198,8 +1211,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // grid may use an incompatible script engine. bool saveChanged = sp.PresenceType != PresenceType.Npc - && (m_scene.UserManagementModule == null - || m_scene.UserManagementModule.IsLocalGridUser(sp.UUID)); + && (m_scene.UserManagementModule == null || m_scene.UserManagementModule.IsLocalGridUser(sp.UUID)); // Remove the object from the scene so no more updates // are sent. Doing this before the below changes will ensure diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 8779750160..89ffe45def 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -132,14 +132,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer client.OnInstantMessage += OnInstantMessage; } - private Scene FindClientScene(UUID agentId) + private Scene FindClientAndScene(UUID agentId, out ScenePresence presence) { + presence = null; lock (m_Scenelist) { foreach (Scene scene in m_Scenelist) { - ScenePresence presence = scene.GetScenePresence(agentId); - if (presence != null) + presence = scene.GetScenePresence(agentId); + if (presence != null && !presence.IsDeleted) return scene; } } @@ -153,7 +154,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer // (InstantMessageDialog)im.dialog, client.Name, // im.fromAgentID, im.fromAgentName, im.toAgentID); - Scene scene = FindClientScene(client.AgentId); + Scene scene = client.Scene as Scene; if (scene == null) // Something seriously wrong here. return; @@ -416,15 +417,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer private void OnGridInstantMessage(GridInstantMessage im) { // Check if this is ours to handle - // - Scene scene = FindClientScene(new UUID(im.toAgentID)); + UUID recipientID = new UUID(im.toAgentID); + Scene scene = FindClientAndScene(recipientID, out ScenePresence user); if (scene == null) return; - - // Find agent to deliver to - // - ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); if (user == null) return; @@ -443,7 +440,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer if (assetType == AssetType.LinkFolder || assetType == AssetType.Link) return; - UUID recipientID = new UUID(im.toAgentID); UUID copyID; if (AssetType.Folder == assetType) @@ -482,8 +478,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer if (im.binaryBucket.Length < 1) // Invalid return; - UUID recipientID = new UUID(im.toAgentID); - // Bucket is the asset type AssetType assetType = (AssetType)im.binaryBucket[0]; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3824dbba04..329144f4c5 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5007,6 +5007,9 @@ Label_GroupsDone: public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) { + if(!AllowAvatarCrossing) + return false; + if (EntityTransferModule != null) { return EntityTransferModule.Cross(agent, isFlying); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 070e38025c..016ce797e1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2696,30 +2696,26 @@ namespace OpenSim.Region.Framework.Scenes float agent_velocity = AgentControlNormalVel; bool bAllowUpdateMoveToPosition = false; - uint currflags = (uint)flags & (CONTROL_FLAG_NUDGE_MASK | CONTROL_FLAG_NORM_MASK); - uint oldflags = MovementFlag & (CONTROL_FLAG_NUDGE_MASK | CONTROL_FLAG_NORM_MASK); - MovementFlag &= ~(CONTROL_FLAG_NUDGE_MASK | CONTROL_FLAG_NORM_MASK); + uint oldflags = MovementFlags & (CONTROL_FLAG_NUDGE_MASK | CONTROL_FLAG_NORM_MASK); + MovementFlags = (uint)flags & (CONTROL_FLAG_NUDGE_MASK | CONTROL_FLAG_NORM_MASK); - if (currflags != 0) + if (MovementFlags != 0) { DCFlagKeyPressed = true; mvToTarget = false; - MovementFlag |= currflags; - //update_movementflag |= (currflags ^ oldflags) != 0; + //update_movementflag |= (MovementFlags ^ oldflags) != 0; update_movementflag = true; if (m_delayedStop < 0 && (flags & (ACFlags.AGENT_CONTROL_FAST_AT | ACFlags.AGENT_CONTROL_FAST_UP)) == 0) agent_velocity = AgentControlMidVel; - if ((currflags & CONTROL_FLAG_NUDGE_MASK) != 0) - { - currflags |= (currflags >>= 19); - } + if ((MovementFlags & CONTROL_FLAG_NUDGE_MASK) != 0) + MovementFlags |= (MovementFlags >> 19); for (int i = 0, mask = 1; i < 6; ++i, mask <<= 1) { - if((currflags & mask) != 0) + if((MovementFlags & mask) != 0) agent_control_v3 += Dir_Vectors[i]; } } @@ -2816,7 +2812,7 @@ namespace OpenSim.Region.Framework.Scenes if (AgentControlStopActive) { //if (MovementFlag == 0 && Animator.Falling) - if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) + if (MovementFlags == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) { AddNewMovement(agent_control_v3, AgentControlStopSlowVel, true); } @@ -2832,10 +2828,10 @@ namespace OpenSim.Region.Framework.Scenes AddNewMovement(agent_control_v3, agent_velocity); else { - if (MovementFlag != 0) + if (MovementFlags != 0) AddNewMovement(agent_control_v3, agent_velocity); else - m_delayedStop = Util.GetTimeStampMS() + 200.0; + m_delayedStop = Util.GetTimeStampMS() + 250.0; } } } @@ -3004,8 +3000,8 @@ namespace OpenSim.Region.Framework.Scenes const uint noMovFlagsMask = (uint)(~CONTROL_FLAG_NORM_MASK); - MovementFlag &= noMovFlagsMask; - MovementFlag |= tmpAgentControlFlags; + MovementFlags &= noMovFlagsMask; + MovementFlags |= tmpAgentControlFlags; m_AgentControlFlags &= unchecked((ACFlags)noMovFlagsMask); m_AgentControlFlags |= (ACFlags)tmpAgentControlFlags; @@ -3726,7 +3722,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", // vec, Rotation, thisAddSpeedModifier, Name); - m_delayedStop = -1; + //m_delayedStop = -1; // rotate from avatar coord space to world Quaternion rot = Rotation; if (!Flying && !IsNPC)