From cda4cd6b551156ed503a5f284ad6c5a9a0e1c5a5 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 14 Sep 2011 18:46:42 -0700 Subject: [PATCH] Merge fixes, and fix the build --- .../CoreModules/Asset/FlotsamAssetCache.cs | 10 +- .../Avatar/Attachments/AttachmentsModule.cs | 14 +- .../World/Land/LandManagementModule.cs | 2 + .../Interfaces/IAttachmentsModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 87 +++++---- .../Framework/Scenes/SceneObjectGroup.cs | 178 +++++++----------- .../Framework/Scenes/SceneObjectPart.cs | 8 + .../Region/Framework/Scenes/ScenePresence.cs | 98 +--------- OpenSim/Region/Framework/Scenes/UndoState.cs | 127 ++++--------- .../Shared/Api/Implementation/LSL_Api.cs | 12 +- 10 files changed, 184 insertions(+), 354 deletions(-) diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index a0648f72dc..8e2dba4538 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -313,15 +313,11 @@ namespace Flotsam.RegionModules.AssetCache } catch (Exception e) { - LogException(e); + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", + asset.ID, e.Message, e.StackTrace); } } - catch (Exception e) - { - m_log.ErrorFormat( - "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", - asset.ID, e.Message, e.StackTrace); - } } public void Cache(AssetBase asset) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 8be0455af4..218b7b8096 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -131,7 +131,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // If we're an NPC then skip all the item checks and manipulations since we don't have an // inventory right now. if (sp.PresenceType == PresenceType.Npc) - RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p); + RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null); else RezSingleAttachmentFromInventory(sp.ControllingClient, attach.ItemID, p); } @@ -343,17 +343,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null); } - public UUID RezSingleAttachmentFromInventory( + public ISceneEntity RezSingleAttachmentFromInventory( IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc) - ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); - { + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); if (sp == null) { m_log.ErrorFormat( "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()", remoteClient.Name, remoteClient.AgentId); return null; } // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should // be removed when that functionality is implemented in opensim AttachmentPt &= 0x7f; - SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc); + SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc); if (updateInventoryStatus) { @@ -367,7 +366,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( - IClientAPI remoteClient, UUID itemID, uint AttachmentPt, XmlDocument doc) + IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc) { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); if (invAccess != null) @@ -462,9 +461,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (!att.IsDeleted) attachmentPoint = att.AttachmentPoint; - ScenePresence presence; - if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) - { InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); if (m_scene.InventoryService != null) item = m_scene.InventoryService.GetItem(item); diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index a3066e7a43..474905a954 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -96,6 +96,8 @@ namespace OpenSim.Region.CoreModules.World.Land // caches ExtendedLandData private Cache parcelInfoCache; + private Dictionary forcedPosition = + new Dictionary(); #region INonSharedRegionModule Members diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 6bbdd7dcc9..59c26e7a69 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); // Same as above, but also load script states from a separate doc - UUID RezSingleAttachmentFromInventory( + ISceneEntity RezSingleAttachmentFromInventory( IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc); /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 345c2df0ca..a661ab8b55 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2695,9 +2695,9 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnClientLogin(client); // Send initial parcel data - Vector3 pos = presence.AbsolutePosition; + Vector3 pos = createdSp.AbsolutePosition; ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); - land.SendLandUpdateToClient(presence.ControllingClient); + land.SendLandUpdateToClient(client); } } } @@ -3500,7 +3500,7 @@ namespace OpenSim.Region.Framework.Scenes // check if banned regions are to be blacked out. if (vialogin || (!m_seeIntoBannedRegion)) { - if (!AuthorizeUser(agent.AgentID, out reason)) + if (!AuthorizeUser(agent, out reason)) return false; } } @@ -3696,47 +3696,31 @@ namespace OpenSim.Region.Framework.Scenes /// outputs the reason to this string /// True if the region accepts this agent. False if it does not. False will /// also return a reason. - protected virtual bool AuthorizeUser(UUID agentID, out string reason) + protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) { reason = String.Empty; if (!m_strictAccessControl) return true; - if (Permissions.IsGod(agentID)) return true; - + if (Permissions.IsGod(agent.AgentID)) return true; + if (AuthorizationService != null) { if (!AuthorizationService.IsAuthorizedForRegion( agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region", - agentID, RegionInfo.RegionName); - + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + return false; } } if (m_regInfo.EstateSettings != null) { - int flags = GetUserFlags(agentID); - if (m_regInfo.EstateSettings.IsBanned(agentID, flags)) + if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) { - //Add some more info to help users - if (!m_regInfo.EstateSettings.IsBanned(agentID, 32)) - { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification", - agentID, RegionInfo.RegionName); - reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName); - return false; - } - if (!m_regInfo.EstateSettings.IsBanned(agentID, 4)) - { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file", - agentID, RegionInfo.RegionName); - reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName); - return false; - } - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist", - agentID, RegionInfo.RegionName); + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); reason = String.Format("Denied access to region {0}: You have been banned from that region.", RegionInfo.RegionName); return false; @@ -3753,7 +3737,7 @@ namespace OpenSim.Region.Framework.Scenes if (groupsModule != null) { GroupMembershipData[] GroupMembership = - groupsModule.GetMembershipData(agentID); + groupsModule.GetMembershipData(agent.AgentID); if (GroupMembership != null) { @@ -3782,16 +3766,44 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); if (!m_regInfo.EstateSettings.PublicAccess && - !m_regInfo.EstateSettings.HasAccess(agentID) && + !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && !groupAccess) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate", - agentID, RegionInfo.RegionName); + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", + agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", RegionInfo.RegionName); return false; } + // TODO: estate/region settings are not properly hooked up + // to ILandObject.isRestrictedFromLand() + // if (null != LandChannel) + // { + // // region seems to have local Id of 1 + // ILandObject land = LandChannel.GetLandObject(1); + // if (null != land) + // { + // if (land.isBannedFromLand(agent.AgentID)) + // { + // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", + // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + // reason = String.Format("Denied access to private region {0}: You are banned from that region.", + // RegionInfo.RegionName); + // return false; + // } + + // if (land.isRestrictedFromLand(agent.AgentID)) + // { + // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", + // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); + // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", + // RegionInfo.RegionName); + // return false; + // } + // } + // } + return true; } @@ -5387,9 +5399,16 @@ namespace OpenSim.Region.Framework.Scenes } } - if (!AuthorizeUser(agentID, out reason)) + try + { + if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason)) + { + // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); + return false; + } + } + catch { - // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); return false; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 35684e09ff..ea6aab0ad1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1245,7 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes public void DetachToGround() { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); if (avatar == null) return; @@ -1259,14 +1259,14 @@ namespace OpenSim.Region.Framework.Scenes RootPart.FromItemID = UUID.Zero; AbsolutePosition = detachedpos; - m_rootPart.AttachedAvatar = UUID.Zero; + AttachedAvatar = UUID.Zero; - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; + //SceneObjectPart[] parts = m_parts.GetArray(); + //for (int i = 0; i < parts.Length; i++) + // parts[i].AttachedAvatar = UUID.Zero; m_rootPart.SetParentLocalId(0); - SetAttachmentPoint((byte)0); + AttachmentPoint = (byte)0; m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); HasGroupChanged = true; RootPart.Rezzed = DateTime.Now; @@ -1279,7 +1279,7 @@ namespace OpenSim.Region.Framework.Scenes public void DetachToInventoryPrep() { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); //Vector3 detachedpos = new Vector3(127f, 127f, 127f); if (avatar != null) { @@ -1287,15 +1287,15 @@ namespace OpenSim.Region.Framework.Scenes avatar.RemoveAttachment(this); } - m_rootPart.AttachedAvatar = UUID.Zero; + AttachedAvatar = UUID.Zero; - SceneObjectPart[] parts = m_parts.GetArray(); + /*SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; + parts[i].AttachedAvatar = UUID.Zero;*/ m_rootPart.SetParentLocalId(0); //m_rootPart.SetAttachmentPoint((byte)0); - m_rootPart.IsAttachment = false; + IsAttachment = false; AbsolutePosition = m_rootPart.AttachedPos; //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); //AttachToBackup(); @@ -1471,7 +1471,7 @@ namespace OpenSim.Region.Framework.Scenes public void DeleteGroupFromScene(bool silent) { // We need to keep track of this state in case this group is still queued for backup. - m_isDeleted = true; + IsDeleted = true; DetachFromBackup(); @@ -1746,97 +1746,63 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup Copy(bool userExposed) { - SceneObjectGroup dupe; - try + SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); + dupe.m_isBackedUp = false; + dupe.m_parts = new MapAndArray(); + + // Warning, The following code related to previousAttachmentStatus is needed so that clones of + // attachments do not bordercross while they're being duplicated. This is hacktastic! + // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! + // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state + // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, + // then restore it's attachment state + + // This is only necessary when userExposed is false! + + bool previousAttachmentStatus = dupe.IsAttachment; + + if (!userExposed) + dupe.IsAttachment = true; + + dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); + + if (!userExposed) { - m_dupeInProgress = true; - dupe = (SceneObjectGroup)MemberwiseClone(); - dupe.m_isBackedUp = false; - dupe.m_parts = new MapAndArray(); + dupe.IsAttachment = previousAttachmentStatus; + } - // Warning, The following code related to previousAttachmentStatus is needed so that clones of - // attachments do not bordercross while they're being duplicated. This is hacktastic! - // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! - // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state - // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, - // then restore it's attachment state + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); + dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; - // This is only necessary when userExposed is false! + if (userExposed) + dupe.m_rootPart.TrimPermissions(); - bool previousAttachmentStatus = dupe.IsAttachment; - - if (!userExposed) - dupe.IsAttachment = true; + List partList = new List(m_parts.GetArray()); - if (!userExposed) - dupe.RootPart.IsAttachment = true; + partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) + { + return p1.LinkNum.CompareTo(p2.LinkNum); + } + ); - dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - if (!userExposed) + foreach (SceneObjectPart part in partList) + { + SceneObjectPart newPart; + if (part.UUID != m_rootPart.UUID) { - dupe.IsAttachment = previousAttachmentStatus; + newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); + newPart.LinkNum = part.LinkNum; + } + else + { + newPart = dupe.m_rootPart; } - if (!userExposed) - { - dupe.RootPart.IsAttachment = previousAttachmentStatus; - } - - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); - dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; - - if (userExposed) - dupe.m_rootPart.TrimPermissions(); - - List partList = new List(m_parts.GetArray()); - - partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) - { - return p1.LinkNum.CompareTo(p2.LinkNum); - } - ); - - foreach (SceneObjectPart part in partList) - { - if (part.UUID != m_rootPart.UUID) - { - SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); - - newPart.LinkNum = part.LinkNum; - } - - // Need to duplicate the physics actor as well - if (part.PhysActor != null && userExposed) - { - PrimitiveBaseShape pbs = part.Shape; - - part.PhysActor - = m_scene.PhysicsScene.AddPrimShape( - string.Format("{0}/{1}", part.Name, part.UUID), - pbs, - part.AbsolutePosition, - part.Scale, - part.RotationOffset, - part.PhysActor.IsPhysical, - m_localId); - part.PhysActor.SetMaterial((int)part.Material); - - part.PhysActor.LocalID = part.LocalId; - part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); - } - } - if (userExposed) - { - dupe.UpdateParentIDs(); - dupe.HasGroupChanged = true; - dupe.AttachToBackup(); - } - ScheduleGroupForFullUpdate(); // Need to duplicate the physics actor as well if (part.PhysActor != null && userExposed) { PrimitiveBaseShape pbs = newPart.Shape; - + newPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( string.Format("{0}/{1}", newPart.Name, newPart.UUID), @@ -1846,14 +1812,20 @@ namespace OpenSim.Region.Framework.Scenes newPart.RotationOffset, part.PhysActor.IsPhysical, newPart.LocalId); - + newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); } } - finally + + if (userExposed) { - m_dupeInProgress = false; + dupe.UpdateParentIDs(); + dupe.HasGroupChanged = true; + dupe.AttachToBackup(); + + ScheduleGroupForFullUpdate(); } + return dupe; } @@ -1983,22 +1955,8 @@ namespace OpenSim.Region.Framework.Scenes public void stopMoveToTarget() { - SceneObjectPart rootpart = m_rootPart; - if (rootpart != null) - { - if (IsAttachment) - { - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); - if (avatar != null) avatar.StopMoveToPosition(); - } - else - { - if (rootpart.PhysActor != null) - { - rootpart.PhysActor.PIDActive = false; - } - } - } + if (RootPart.PhysActor != null) + RootPart.PhysActor.PIDActive = false; } public void rotLookAt(Quaternion target, float strength, float damping) @@ -3087,8 +3045,6 @@ namespace OpenSim.Region.Framework.Scenes prevScale.X *= x; prevScale.Y *= y; prevScale.Z *= z; - part.IgnoreUndoUpdate = false; - // RootPart.IgnoreUndoUpdate = true; RootPart.Resize(prevScale); // RootPart.IgnoreUndoUpdate = false; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 69887187a3..0c3b4044d3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3243,6 +3243,14 @@ namespace OpenSim.Region.Framework.Scenes STATUS_ROTATE_Z = rotate; } + public void SetBuoyancy(float fvalue) + { + if (PhysActor != null) + { + PhysActor.Buoyancy = fvalue; + } + } + public void SetDieAtEdge(bool p) { if (m_parentGroup.IsDeleted) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8ee7d8901e..35a8df7d01 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -131,6 +131,7 @@ namespace OpenSim.Region.Framework.Scenes // private SceneObjectGroup proxyObjectGroup; //private SceneObjectPart proxyObjectPart = null; public Vector3 lastKnownAllowedPosition; + public bool sentMessageAboutRestrictedParcelFlyingDown; public Vector4 CollisionPlane = Vector4.UnitW; private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation @@ -4316,103 +4317,6 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju return flags; } - /// - /// RezAttachments. This should only be called upon login on the first region. - /// Attachment rezzings on crossings and TPs are done in a different way. - /// - public void RezAttachments() - { - if (null == m_appearance) - { - m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); - return; - } - - XmlDocument doc = new XmlDocument(); - string stateData = String.Empty; - - IAttachmentsService attServ = m_scene.RequestModuleInterface(); - if (attServ != null) - { - m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); - stateData = attServ.Get(ControllingClient.AgentId.ToString()); - if (stateData != String.Empty) - { - try - { - doc.LoadXml(stateData); - } - catch { } - } - } - - Dictionary itemData = new Dictionary(); - - XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); - if (nodes.Count > 0) - { - foreach (XmlNode n in nodes) - { - XmlElement elem = (XmlElement)n; - string itemID = elem.GetAttribute("ItemID"); - string xml = elem.InnerXml; - - itemData[new UUID(itemID)] = xml; - } - } - - List attachments = m_appearance.GetAttachments(); - foreach (AvatarAttachment attach in attachments) - { - if (IsDeleted) - return; - - int p = attach.AttachPoint; - UUID itemID = attach.ItemID; - - //UUID assetID = attach.AssetID; - // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down - // But they're not used anyway, the item is being looked up for now, so let's proceed. - //if (UUID.Zero == assetID) - //{ - // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); - // continue; - //} - - try - { - string xmlData; - XmlDocument d = new XmlDocument(); - UUID asset; - if (itemData.TryGetValue(itemID, out xmlData)) - { - d.LoadXml(xmlData); - m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); - - // Rez from inventory - asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); - - } - else - { - // Rez from inventory (with a null doc to let - // CHANGED_OWNER happen) - asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); - } - - m_log.InfoFormat( - "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2}", - p, itemID, asset); - } - catch (Exception e) - { - m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace); - } - } - } - private void ReprioritizeUpdates() { if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 81f41dbaa8..0a30f4bda9 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -50,16 +50,11 @@ namespace OpenSim.Region.Framework.Scenes public class UndoState { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public Vector3 Position = Vector3.Zero; public Vector3 Scale = Vector3.Zero; public Quaternion Rotation = Quaternion.Identity; - public Vector3 GroupPosition = Vector3.Zero; - public Quaternion GroupRotation = Quaternion.Identity; - public Vector3 GroupScale = Vector3.Zero; - public DateTime LastUpdated = DateTime.Now; - public UndoType Type; /// /// Is this undo state for an entire group? @@ -77,88 +72,40 @@ namespace OpenSim.Region.Framework.Scenes { ForGroup = forGroup; -// if (ForGroup) - GroupScale = part.ParentGroup.RootPart.Shape.Scale; + // if (ForGroup) + Position = part.ParentGroup.AbsolutePosition; + // else + // Position = part.OffsetPosition; - //FUBAR WARNING: Do NOT get the group's absoluteposition here - //or you'll experience a loop and/or a stack issue - GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; - GroupRotation = part.ParentGroup.GroupRotation; - Position = part.ParentGroup.RootPart.AbsolutePosition; -// else -// Position = part.OffsetPosition; - -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo position {0} for root part", Position); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo position {0} for root part", Position); Rotation = part.RotationOffset; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); Scale = part.Shape.Scale; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo scale {0} for root part", Scale); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); } else { Position = part.OffsetPosition; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo position {0} for child part", Position); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo position {0} for child part", Position); Rotation = part.RotationOffset; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); Scale = part.Shape.Scale; -// m_log.DebugFormat( -// "[UNDO STATE]: Storing undo scale {0} for child part", Scale); - } - } - public void Merge(UndoState last) - { - if ((Type & UndoType.STATE_GROUP_POSITION) == 0 || ((last.Type & UndoType.STATE_GROUP_POSITION) >= (Type & UndoType.STATE_GROUP_POSITION))) - { - GroupPosition = last.GroupPosition; - Position = last.Position; - } - if ((Type & UndoType.STATE_GROUP_SCALE) == 0 || ((last.Type & UndoType.STATE_GROUP_SCALE) >= (Type & UndoType.STATE_GROUP_SCALE))) - { - GroupScale = last.GroupScale; - Scale = last.Scale; - } - if ((Type & UndoType.STATE_GROUP_ROTATION) == 0 || ((last.Type & UndoType.STATE_GROUP_ROTATION) >= (Type & UndoType.STATE_GROUP_ROTATION))) - { - GroupRotation = last.GroupRotation; - Rotation = last.Rotation; - } - if ((Type & UndoType.STATE_PRIM_POSITION) == 0 || ((last.Type & UndoType.STATE_PRIM_POSITION) >= (Type & UndoType.STATE_PRIM_POSITION))) - { - Position = last.Position; - } - if ((Type & UndoType.STATE_PRIM_SCALE) == 0 || ((last.Type & UndoType.STATE_PRIM_SCALE) >= (Type & UndoType.STATE_PRIM_SCALE))) - { - Scale = last.Scale; - } - if ((Type & UndoType.STATE_PRIM_ROTATION) == 0 || ((last.Type & UndoType.STATE_PRIM_ROTATION) >= (Type & UndoType.STATE_PRIM_ROTATION))) - { - Rotation = last.Rotation; - } - Type = Type | last.Type; - } - public bool Compare(UndoState undo) - { - if (undo == null || Position == null) return false; - if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation) - { - return true; - } - else - { - return false; + // m_log.DebugFormat( + // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); } } + /// /// Compare the relevant state in the given part to this state. /// @@ -183,15 +130,15 @@ namespace OpenSim.Region.Framework.Scenes return false; } - private void RestoreState(SceneObjectPart part) + public void PlaybackState(SceneObjectPart part) { part.Undoing = true; if (part.ParentID == 0) { -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", -// Position, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", + // Position, part.Name, part.LocalId); if (Position != Vector3.Zero) { @@ -201,9 +148,9 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.UpdateRootPosition(Position); } -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", -// part.RotationOffset, Rotation, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", + // part.RotationOffset, Rotation, part.Name, part.LocalId); if (ForGroup) part.UpdateRotation(Rotation); @@ -212,9 +159,9 @@ namespace OpenSim.Region.Framework.Scenes if (Scale != Vector3.Zero) { -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", -// part.Shape.Scale, Scale, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", + // part.Shape.Scale, Scale, part.Name, part.LocalId); if (ForGroup) part.ParentGroup.GroupResize(Scale); @@ -228,24 +175,24 @@ namespace OpenSim.Region.Framework.Scenes { if (Position != Vector3.Zero) { -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", -// part.OffsetPosition, Position, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", + // part.OffsetPosition, Position, part.Name, part.LocalId); part.OffsetPosition = Position; } -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", -// part.RotationOffset, Rotation, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", + // part.RotationOffset, Rotation, part.Name, part.LocalId); part.UpdateRotation(Rotation); if (Scale != Vector3.Zero) { -// m_log.DebugFormat( -// "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", -// part.Shape.Scale, Scale, part.Name, part.LocalId); + // m_log.DebugFormat( + // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", + // part.Shape.Scale, Scale, part.Name, part.LocalId); part.Resize(Scale); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bf791a9baf..6f341681e0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1219,7 +1219,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public virtual void llDie() { m_host.AddScriptLPS(1); - if (!m_host.IsAttachment) throw new SelfDeleteException(); + if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException(); } public LSL_Float llGround(LSL_Vector offset) @@ -3250,8 +3250,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SceneObjectGroup grp = m_host.ParentGroup; ScenePresence presence = World.GetScenePresence(m_host.OwnerID); - - grp.AttachToAgent(m_host.OwnerID, (uint)attachment, Vector3.Zero, false); + if (presence.Scene.AttachmentsModule != null) + { + presence.Scene.AttachmentsModule.AttachObject(presence.ControllingClient, grp, (uint)attachment, false); + } } } @@ -8034,7 +8036,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // the UUID with the avatar UUID and report it's bounding box SceneObjectPart part = World.GetSceneObjectPart(objID); if (part != null && part.ParentGroup.IsAttachment) - objID = part.ParentGroup.RootPart.AttachedAvatar; + objID = part.ParentGroup.AttachedAvatar; // Find out if this is an avatar ID. If so, return it's box ScenePresence presence = World.GetScenePresence(objID); @@ -10064,7 +10066,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); if (detectedParams == null) { - if (m_host.IsAttachment == true) + if (m_host.ParentGroup.IsAttachment == true) { detectedParams = new DetectParams(); detectedParams.Key = m_host.OwnerID;