- create entries in avatarattachments table when first attaching an object; fix issue 2512

- correct attachment offset; fix issue 2513
- thanks Thomas for the patches
0.6.0-stable
Mike Mazur 2008-11-06 06:23:58 +00:00
parent 397b608af5
commit 5d8e08a072
2 changed files with 46 additions and 2 deletions

View File

@ -542,12 +542,21 @@ namespace OpenSim.Region.Environment.Scenes
}
group.SetAttachmentPoint(Convert.ToByte(AttachmentPt));
group.AbsolutePosition = attachPos;
// Saves and gets assetID
UUID itemId;
if (group.GetFromAssetID() == UUID.Zero)
{
m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId);
m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
}
else
{
itemId = group.GetFromAssetID();
}
m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group);
group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos);
// In case it is later dropped again, don't let
// it get cleaned up

View File

@ -1815,8 +1815,9 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId)
public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
{
itemID = UUID.Zero;
if (grp != null)
{
string sceneObjectXml = grp.ToXmlString();
@ -1866,6 +1867,7 @@ namespace OpenSim.Region.Environment.Scenes
userInfo.AddItem(item);
remoteClient.SendInventoryItemCreateUpdate(item);
itemID = item.ID;
return item.AssetID;
}
return UUID.Zero;
@ -2356,6 +2358,39 @@ namespace OpenSim.Region.Environment.Scenes
m_innerScene.AttachObject(controllingClient, localID, attachPoint, rot, pos);
}
public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
{
if (null == itemID)
{
m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID.");
return;
}
if (0 == AttachmentPt)
{
m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point.");
return;
}
if (null == att.RootPart)
{
m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!");
return;
}
ScenePresence presence;
if (TryGetAvatar(remoteClient.AgentId, out presence))
{
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.UUID);
IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
if (ava != null)
{
m_log.InfoFormat("[SCENE INVENTORY]: Saving avatar attachment. AgentID:{0} ItemID:{1} AttachmentPoint:{2}", remoteClient.AgentId, itemID, AttachmentPt);
ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
}
}
}
public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
{
SceneObjectPart part = GetSceneObjectPart(itemID);