From a5e9429f2bb2276486cc2f1ed2249e14fba90d6a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 31 Jul 2014 03:10:50 +0100 Subject: MESS: changes in MakeRootAgent and CompleteMovement reordering things. Added sending of land overlay and parcel information. This in order to only send avatar related information after having its position well defined and on the right parcel. THIS MAY STILL BE BAD :) --- OpenSim/Framework/ILandChannel.cs | 2 + .../Region/CoreModules/World/Land/LandChannel.cs | 8 +- .../CoreModules/World/Land/LandManagementModule.cs | 26 +++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 143 +++++++++++++++++---- .../RegionCombinerLargeLandChannel.cs | 1 + OpenSim/Tests/Common/Mock/TestLandChannel.cs | 1 + 6 files changed, 151 insertions(+), 30 deletions(-) diff --git a/OpenSim/Framework/ILandChannel.cs b/OpenSim/Framework/ILandChannel.cs index c46c03c..63cc7eb 100644 --- a/OpenSim/Framework/ILandChannel.cs +++ b/OpenSim/Framework/ILandChannel.cs @@ -93,5 +93,7 @@ namespace OpenSim.Region.Framework.Interfaces void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); + void sendClientInitialLandInfo(IClientAPI remoteClient); + } } diff --git a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs index beb0a24..378826d 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs @@ -213,7 +213,13 @@ namespace OpenSim.Region.CoreModules.World.Land m_landManagementModule.setParcelOtherCleanTime(remoteClient, localID, otherCleanTime); } } - + public void sendClientInitialLandInfo(IClientAPI remoteClient) + { + if (m_landManagementModule != null) + { + m_landManagementModule.sendClientInitialLandInfo(remoteClient); + } + } #endregion } } diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index c444c29..0a2882a 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage; m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan; m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps; - + lock (m_scene) { m_scene.LandChannel = (ILandChannel)landChannel; @@ -194,13 +194,14 @@ namespace OpenSim.Region.CoreModules.World.Land client.OnParcelEjectUser += ClientOnParcelEjectUser; client.OnParcelFreezeUser += ClientOnParcelFreezeUser; client.OnSetStartLocationRequest += ClientOnSetHome; - +/* avatar is still a child here position is unknow EntityBase presenceEntity; if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) { SendParcelOverlay(client); SendLandUpdate((ScenePresence)presenceEntity, true); } +*/ } public void EventMakeChildAgent(ScenePresence avatar) @@ -385,12 +386,29 @@ namespace OpenSim.Region.CoreModules.World.Land return; } + public void sendClientInitialLandInfo(IClientAPI remoteClient) + { + SendParcelOverlay(remoteClient); + ScenePresence avatar; + if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out avatar)) + return; + if (avatar.IsChildAgent) + return; + + ILandObject over = GetLandObject(avatar.AbsolutePosition.X,avatar.AbsolutePosition.Y); + if (over == null) + return; + + avatar.currentParcelUUID = over.LandData.GlobalID; + over.SendLandUpdateToClient(avatar.ControllingClient); + } + public void SendLandUpdate(ScenePresence avatar, bool force) { if (avatar.IsChildAgent) return; - - ILandObject over = GetLandObjectClipedXY(avatar.AbsolutePosition.X,avatar.AbsolutePosition.Y); + + ILandObject over = GetLandObjectClipedXY(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); if (over != null) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6b627be..5775747 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -140,8 +140,67 @@ namespace OpenSim.Region.Framework.Scenes /// public static readonly float SIGNIFICANT_MOVEMENT = 2.0f; - public UUID currentParcelUUID = UUID.Zero; + private UUID m_currentParcelUUID = UUID.Zero; + private object parcelLock = new Object(); + public UUID currentParcelUUID + { + get { return m_currentParcelUUID; } + set + { + lock (parcelLock) + { + m_currentParcelUUID = value; + } + } + } + + public bool ParcelAllowThisAvatarSounds + { + get + { + try + { + lock (parcelLock) + { + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); + if (land == null) + return true; + if (land.LandData.AnyAVSounds) + return true; + if (!land.LandData.GroupAVSounds) + return false; + return land.LandData.GroupID == ControllingClient.ActiveGroupId; + } + } + catch + { + return true; + } + } + } + + public bool ParcelHideThisAvatar + { + get + { + try + { + lock (parcelLock) + { + ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); + if (land == null || !land.LandData.SeeAVs) + return false; + return true; + } + } + catch + { + return false; + } + } + } + /// /// The animator for this avatar /// @@ -482,21 +541,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public bool ParcelAllowThisAvatarSounds - { - get - { - ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); - if (land == null) - return true; - if (land.LandData.AnyAVSounds) - return true; - if (!land.LandData.GroupAVSounds) - return false; - return land.LandData.GroupID == ControllingClient.ActiveGroupId; - } - } public byte State { get; set; } @@ -1023,6 +1068,9 @@ namespace OpenSim.Region.Framework.Scenes /// This method is on the critical path for transferring an avatar from one region to another. Delay here /// delays that crossing. /// + + + // only in use as part of completemovement private bool MakeRootAgent(Vector3 pos, bool isFlying) { lock (m_completeMovementLock) @@ -1229,6 +1277,7 @@ namespace OpenSim.Region.Framework.Scenes // // One cannot simply iterate over attachments in a fire and forget thread because this would no longer // be locked, allowing race conditions if other code changes the attachments list. + List attachments = GetAttachments(); if (attachments.Count > 0) @@ -1236,16 +1285,19 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); - // Resume scripts + // Resume scripts this possible should also be moved down after sending the avatar to viewer ? foreach (SceneObjectGroup sog in attachments) { - sog.ScheduleGroupForFullUpdate(); +// sending attachments before the avatar ? +// moved to completemovement where it already was +// sog.ScheduleGroupForFullUpdate(); sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.ResumeScripts(); } } } +/* SendAvatarDataToAllAgents(); // send the animations of the other presences to me @@ -1254,6 +1306,7 @@ namespace OpenSim.Region.Framework.Scenes if (presence != this) presence.Animator.SendAnimPackToClient(ControllingClient); }); +*/ // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will // stall on the border crossing since the existing child agent will still have the last movement @@ -1421,6 +1474,9 @@ namespace OpenSim.Region.Framework.Scenes public void StopFlying() { + if (IsInTransit) + return; + Vector3 pos = AbsolutePosition; if (Appearance.AvatarHeight != 127.0f) pos += new Vector3(0f, 0f, (Appearance.AvatarHeight / 6f)); @@ -1661,9 +1717,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.InfoFormat( "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", client.Name, Scene.Name, AbsolutePosition); - - - + m_inTransit = true; try { @@ -1709,8 +1763,9 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); // Remember in HandleUseCircuitCode, we delayed this to here - if (m_teleportFlags > 0) - SendInitialDataToMe(); +// this prims etc, moved down +// if (m_teleportFlags > 0) +// SendInitialDataToMe(); // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); @@ -1742,6 +1797,20 @@ namespace OpenSim.Region.Framework.Scenes // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); // } + // send initial land overlay and parcel + if (!IsChildAgent) + { + ILandChannel landch = m_scene.LandChannel; + if (landch != null) + { + landch.sendClientInitialLandInfo(client); + } + } + + // send agentData to all clients including us (?) + // get appearance + // if in cache sent it to all clients + // send what we have to us, even if not in cache ( bad? ) ValidateAndSendAppearanceAndAgentData(); // Create child agents in neighbouring regions @@ -1750,11 +1819,11 @@ namespace OpenSim.Region.Framework.Scenes IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface(); if (m_agentTransfer != null) m_agentTransfer.EnableChildAgents(this); - +/* moved down IFriendsModule friendsModule = m_scene.RequestModuleInterface(); if (friendsModule != null) friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); - +*/ } // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region @@ -1769,6 +1838,27 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); + + // send the rest of the world + if (m_teleportFlags > 0) + SendInitialDataToMe(); + + if (!IsChildAgent) + { +// moved from makeroot missing in sendInitialDataToMe ? + m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) + { + if (presence != this) + presence.Animator.SendAnimPackToClient(ControllingClient); + }); + + if (openChildAgents) + { + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); + if (friendsModule != null) + friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); + } + } } finally { @@ -1864,6 +1954,9 @@ namespace OpenSim.Region.Framework.Scenes return; } + if (IsInTransit) + return; + #region Sanity Checking // This is irritating. Really. @@ -3307,13 +3400,13 @@ namespace OpenSim.Region.Framework.Scenes SendAvatarDataToAllAgents(); // This invocation always shows up in the viewer logs as an error. Is it needed? + // try to send what we have even if not in cache SendAppearanceToAgent(this); // If we are using the the cached appearance then send it out to everyone if (cachedappearance) { m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); - // If the avatars baked textures are all in the cache, then we have a // complete appearance... send it out, if not, then we'll send it when // the avatar finishes updating its appearance diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs index 4bf2a82..e5e76e9 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs @@ -196,6 +196,7 @@ namespace OpenSim.Region.RegionCombinerModule RootRegionLandChannel.SetParcelOtherCleanTime(remoteClient, localID, otherCleanTime); } + public void sendClientInitialLandInfo(IClientAPI remoteClient) { } #endregion } } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs index 3115035..8135bfc 100644 --- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs +++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs @@ -111,5 +111,6 @@ namespace OpenSim.Tests.Common.Mock public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} + public void sendClientInitialLandInfo(IClientAPI remoteClient) { } } } \ No newline at end of file -- cgit v1.1