Stop attempts to rewear already worn items from removing and reattaching.
Viewer 2/3 will sometimes attempt to rewear attachments, even though they have already been attached during the main login process. This change ignores those attempts. This stops script failures during login, as the rewearing was racing with the script startup code. It might also help with attachments being abnormally put into deleted state. Hopefully resolves some more of http://opensimulator.org/mantis/view.php?id=5644remove-scene-viewer
parent
618277e797
commit
8880aea728
|
@ -147,18 +147,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
|
|
||||||
foreach (SceneObjectGroup grp in sp.GetAttachments())
|
foreach (SceneObjectGroup grp in sp.GetAttachments())
|
||||||
{
|
{
|
||||||
if (grp.HasGroupChanged) // Resizer scripts?
|
// if (grp.HasGroupChanged) // Resizer scripts?
|
||||||
{
|
// {
|
||||||
grp.IsAttachment = false;
|
grp.IsAttachment = false;
|
||||||
grp.AbsolutePosition = grp.RootPart.AttachedPos;
|
grp.AbsolutePosition = grp.RootPart.AttachedPos;
|
||||||
UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID);
|
UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID);
|
||||||
grp.IsAttachment = true;
|
grp.IsAttachment = true;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
|
public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}",
|
||||||
|
// m_scene.RegionInfo.RegionName, sp.Name, silent);
|
||||||
|
|
||||||
foreach (SceneObjectGroup sop in sp.GetAttachments())
|
foreach (SceneObjectGroup sop in sp.GetAttachments())
|
||||||
{
|
{
|
||||||
sop.Scene.DeleteSceneObject(sop, silent);
|
sop.Scene.DeleteSceneObject(sop, silent);
|
||||||
|
@ -214,7 +218,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
|
m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
|
||||||
|
|
||||||
// Save avatar attachment information
|
// Save avatar attachment information
|
||||||
m_log.Info(
|
m_log.Debug(
|
||||||
"[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
|
"[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
|
||||||
+ ", AttachmentPoint: " + AttachmentPt);
|
+ ", AttachmentPoint: " + AttachmentPt);
|
||||||
|
|
||||||
|
@ -339,6 +343,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
|
|
||||||
lock (sp.AttachmentsSyncLock)
|
lock (sp.AttachmentsSyncLock)
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name);
|
||||||
|
|
||||||
foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
|
foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
|
||||||
{
|
{
|
||||||
RezSingleAttachmentFromInventory(sp, obj.ItemID, obj.AttachmentPt);
|
RezSingleAttachmentFromInventory(sp, obj.ItemID, obj.AttachmentPt);
|
||||||
|
@ -375,6 +381,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
// be removed when that functionality is implemented in opensim
|
// be removed when that functionality is implemented in opensim
|
||||||
AttachmentPt &= 0x7f;
|
AttachmentPt &= 0x7f;
|
||||||
|
|
||||||
|
// Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such).
|
||||||
|
// This often happens during login - not sure the exact reason.
|
||||||
|
// For now, we will ignore the request. Unfortunately, this means that we need to dig through all the
|
||||||
|
// ScenePresence attachments. We can't use the data in AvatarAppearance because that's present at login
|
||||||
|
// before anything has actually been attached.
|
||||||
|
bool alreadyOn = false;
|
||||||
|
List<SceneObjectGroup> existingAttachments = sp.GetAttachments();
|
||||||
|
foreach (SceneObjectGroup so in existingAttachments)
|
||||||
|
{
|
||||||
|
if (so.GetFromItemID() == itemID)
|
||||||
|
{
|
||||||
|
alreadyOn = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (sp.Appearance.GetAttachmentForItem(itemID) != null)
|
||||||
|
if (alreadyOn)
|
||||||
|
{
|
||||||
|
// m_log.WarnFormat(
|
||||||
|
// "[ATTACHMENTS MODULE]: Ignoring request by {0} to wear item {1} at {2} since it is already worn",
|
||||||
|
// sp.Name, itemID, AttachmentPt);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
|
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
|
||||||
|
|
||||||
if (att == null)
|
if (att == null)
|
||||||
|
@ -468,7 +500,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
|
// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
|
||||||
// att.Name, remoteClient.Name, AttachmentPt, itemID);
|
// att.Name, sp.Name, AttachmentPt, itemID);
|
||||||
|
|
||||||
if (UUID.Zero == itemID)
|
if (UUID.Zero == itemID)
|
||||||
{
|
{
|
||||||
|
@ -524,7 +556,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}",
|
// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}",
|
||||||
// remoteClient.Name, sceneObjectID);
|
// remoteClient.Name, soLocalId);
|
||||||
|
|
||||||
SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId);
|
SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId);
|
||||||
|
|
||||||
|
@ -677,45 +709,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
{
|
{
|
||||||
if (grp != null)
|
if (grp != null)
|
||||||
{
|
{
|
||||||
if (!grp.HasGroupChanged)
|
if (grp.HasGroupChanged || grp.ContainsScripts())
|
||||||
|
{
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
|
||||||
|
grp.UUID, grp.AttachmentPoint);
|
||||||
|
|
||||||
|
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
|
||||||
|
|
||||||
|
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
||||||
|
item = m_scene.InventoryService.GetItem(item);
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
AssetBase asset = m_scene.CreateAsset(
|
||||||
|
grp.GetPartName(grp.LocalId),
|
||||||
|
grp.GetPartDescription(grp.LocalId),
|
||||||
|
(sbyte)AssetType.Object,
|
||||||
|
Utils.StringToBytes(sceneObjectXml),
|
||||||
|
remoteClient.AgentId);
|
||||||
|
m_scene.AssetService.Store(asset);
|
||||||
|
|
||||||
|
item.AssetID = asset.FullID;
|
||||||
|
item.Description = asset.Description;
|
||||||
|
item.Name = asset.Name;
|
||||||
|
item.AssetType = asset.Type;
|
||||||
|
item.InvType = (int)InventoryType.Object;
|
||||||
|
|
||||||
|
m_scene.InventoryService.UpdateItem(item);
|
||||||
|
|
||||||
|
// this gets called when the agent logs off!
|
||||||
|
if (remoteClient != null)
|
||||||
|
remoteClient.SendInventoryItemCreateUpdate(item, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
|
"[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
|
||||||
grp.UUID, grp.AttachmentPoint);
|
grp.UUID, grp.AttachmentPoint);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
|
|
||||||
grp.UUID, grp.AttachmentPoint);
|
|
||||||
|
|
||||||
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
|
|
||||||
|
|
||||||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
|
||||||
item = m_scene.InventoryService.GetItem(item);
|
|
||||||
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
AssetBase asset = m_scene.CreateAsset(
|
|
||||||
grp.GetPartName(grp.LocalId),
|
|
||||||
grp.GetPartDescription(grp.LocalId),
|
|
||||||
(sbyte)AssetType.Object,
|
|
||||||
Utils.StringToBytes(sceneObjectXml),
|
|
||||||
remoteClient.AgentId);
|
|
||||||
m_scene.AssetService.Store(asset);
|
|
||||||
|
|
||||||
item.AssetID = asset.FullID;
|
|
||||||
item.Description = asset.Description;
|
|
||||||
item.Name = asset.Name;
|
|
||||||
item.AssetType = asset.Type;
|
|
||||||
item.InvType = (int)InventoryType.Object;
|
|
||||||
|
|
||||||
m_scene.InventoryService.UpdateItem(item);
|
|
||||||
|
|
||||||
// this gets called when the agent logs off!
|
|
||||||
if (remoteClient != null)
|
|
||||||
remoteClient.SendInventoryItemCreateUpdate(item, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -735,7 +767,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
private void AttachToAgent(
|
private void AttachToAgent(
|
||||||
IScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
|
IScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}",
|
// m_log.DebugFormat(
|
||||||
|
// "[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}",
|
||||||
// so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);
|
// so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);
|
||||||
|
|
||||||
so.DetachFromBackup();
|
so.DetachFromBackup();
|
||||||
|
@ -788,7 +821,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
/// <returns>The user inventory item created that holds the attachment.</returns>
|
/// <returns>The user inventory item created that holds the attachment.</returns>
|
||||||
private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IClientAPI remoteClient, SceneObjectGroup grp)
|
private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IClientAPI remoteClient, SceneObjectGroup grp)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
|
// m_log.DebugFormat(
|
||||||
|
// "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}",
|
||||||
|
// grp.Name, grp.LocalId, remoteClient.Name);
|
||||||
|
|
||||||
Vector3 inventoryStoredPosition = new Vector3
|
Vector3 inventoryStoredPosition = new Vector3
|
||||||
(((grp.AbsolutePosition.X > (int)Constants.RegionSize)
|
(((grp.AbsolutePosition.X > (int)Constants.RegionSize)
|
||||||
|
|
|
@ -652,7 +652,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (!Entities.Remove(agentID))
|
if (!Entities.Remove(agentID))
|
||||||
{
|
{
|
||||||
m_log.WarnFormat(
|
m_log.WarnFormat(
|
||||||
"[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list",
|
"[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list",
|
||||||
agentID);
|
agentID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
|
m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -389,5 +389,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
for (int i = 0; i < parts.Length; i++)
|
for (int i = 0; i < parts.Length; i++)
|
||||||
parts[i].Inventory.ResumeScripts();
|
parts[i].Inventory.ResumeScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if any part in the scene object contains scripts, false otherwise.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ContainsScripts()
|
||||||
|
{
|
||||||
|
foreach (SceneObjectPart part in Parts)
|
||||||
|
if (part.Inventory.ContainsScripts())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1035,10 +1035,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
item.BasePermissions = perms;
|
item.BasePermissions = perms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_inventorySerial++;
|
m_inventorySerial++;
|
||||||
HasInventoryChanged = true;
|
HasInventoryChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if this part inventory contains any scripts. False otherwise.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public bool ContainsScripts()
|
public bool ContainsScripts()
|
||||||
{
|
{
|
||||||
lock (m_items)
|
lock (m_items)
|
||||||
|
|
Loading…
Reference in New Issue