Attachments now save to MySQL. No reattach on login yet.0.6.0-stable
parent
a179089d1c
commit
6d2e1ad6ba
|
@ -1208,7 +1208,10 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attchpoint, ?item, ?asset)";
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)";
|
||||
|
||||
cmd = (MySqlCommand) dbcon.CreateCommand();
|
||||
cmd.CommandText = sql;
|
||||
|
|
|
@ -834,14 +834,15 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
|
||||
return database.readAttachments(r);
|
||||
Hashtable ret = database.readAttachments(r);
|
||||
|
||||
r.Close();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void UpdateUserAttachments(LLUUID agentID, Hashtable data)
|
||||
{
|
||||
if(data == null)
|
||||
return;
|
||||
|
||||
database.writeAttachments(agentID, data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,8 +362,8 @@ namespace OpenSim.Framework
|
|||
h["skirt_item"] = SkirtItem.ToString();
|
||||
h["skirt_asset"] = SkirtAsset.ToString();
|
||||
|
||||
Hashtable attachments = GetAttachments();
|
||||
if(attachments != null)
|
||||
string attachments = GetAttachmentsString();
|
||||
if(attachments != String.Empty)
|
||||
h["attachments"] = attachments;
|
||||
|
||||
return h;
|
||||
|
@ -413,8 +413,7 @@ namespace OpenSim.Framework
|
|||
|
||||
if(h.ContainsKey("attachments"))
|
||||
{
|
||||
Hashtable attachments = (Hashtable) h["attachments"];
|
||||
SetAttachments(attachments);
|
||||
SetAttachmentsString(h["attachments"].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -510,9 +509,12 @@ namespace OpenSim.Framework
|
|||
return m_attachments[attachpoint][1];
|
||||
}
|
||||
|
||||
public void AddAttachment(int attachpoint, LLUUID item, LLUUID asset)
|
||||
public void SetAttachment(int attachpoint, LLUUID item, LLUUID asset)
|
||||
{
|
||||
if (item == LLUUID.Zero || asset == LLUUID.Zero)
|
||||
if(attachpoint == 0)
|
||||
return;
|
||||
|
||||
if (item == LLUUID.Zero)
|
||||
{
|
||||
if (m_attachments.ContainsKey(attachpoint))
|
||||
m_attachments.Remove(attachpoint);
|
||||
|
@ -525,5 +527,58 @@ namespace OpenSim.Framework
|
|||
m_attachments[attachpoint][0] = item;
|
||||
m_attachments[attachpoint][1] = asset;
|
||||
}
|
||||
|
||||
public void DetachAttachment(LLUUID itemID)
|
||||
{
|
||||
int attachpoint = 0;
|
||||
|
||||
foreach (KeyValuePair<int, LLUUID[]> kvp in m_attachments)
|
||||
{
|
||||
if(kvp.Value[0] == itemID)
|
||||
{
|
||||
attachpoint = kvp.Key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(attachpoint > 0)
|
||||
m_attachments.Remove(attachpoint);
|
||||
}
|
||||
string GetAttachmentsString()
|
||||
{
|
||||
List<string> strings = new List<string>();
|
||||
|
||||
foreach (KeyValuePair<int, LLUUID[]> e in m_attachments)
|
||||
{
|
||||
strings.Add(e.Key.ToString());
|
||||
strings.Add(e.Value[0].ToString());
|
||||
strings.Add(e.Value[1].ToString());
|
||||
}
|
||||
|
||||
return String.Join(",", strings.ToArray());
|
||||
}
|
||||
|
||||
void SetAttachmentsString(string data)
|
||||
{
|
||||
string[] strings = data.Split(new char[] {','});
|
||||
int i = 0;
|
||||
|
||||
m_attachments.Clear();
|
||||
|
||||
while (strings.Length - i > 2)
|
||||
{
|
||||
int attachpoint = Int32.Parse(strings[i]);
|
||||
LLUUID item = new LLUUID(strings[i+1]);
|
||||
LLUUID asset = new LLUUID(strings[i+2]);
|
||||
i += 3;
|
||||
|
||||
if (!m_attachments.ContainsKey(attachpoint))
|
||||
{
|
||||
m_attachments[attachpoint] = new LLUUID[2];
|
||||
m_attachments[attachpoint][0] = item;
|
||||
m_attachments[attachpoint][1] = asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,10 +39,5 @@ namespace OpenSim.Framework.Communications
|
|||
|
||||
void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance);
|
||||
|
||||
void AddAttachment(LLUUID user, LLUUID attach);
|
||||
|
||||
void RemoveAttachment(LLUUID user, LLUUID attach);
|
||||
|
||||
List<LLUUID> GetAttachments(LLUUID user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -776,21 +776,5 @@ namespace OpenSim.Region.Communications.OGS1
|
|||
// Return Empty list (no friends)
|
||||
}
|
||||
}
|
||||
|
||||
public void AddAttachment(LLUUID user, LLUUID item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void RemoveAttachment(LLUUID user, LLUUID item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public List<LLUUID> GetAttachments(LLUUID user)
|
||||
{
|
||||
return new List<LLUUID>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
SceneObjectGroup group = (SceneObjectGroup)obj;
|
||||
|
||||
//group.DetachToGround();
|
||||
DetachSingleAttachmentToInv(group.GetFromAssetID(),remoteClient);
|
||||
m_parentScene.DetachSingleAttachmentToInv(group.GetFromAssetID(),remoteClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero);
|
||||
}
|
||||
|
||||
protected internal void RezSingleAttachment(
|
||||
public SceneObjectGroup RezSingleAttachment(
|
||||
IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,uint ItemFlags, uint NextOwnerMask)
|
||||
{
|
||||
SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, LLVector3.Zero, LLVector3.Zero, LLUUID.Zero, (byte)1, true,
|
||||
|
@ -446,11 +446,12 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
AttachObject(remoteClient,objatt.LocalId,AttachmentPt,new LLQuaternion(0,0,0,1),objatt.AbsolutePosition);
|
||||
objatt.ScheduleGroupForFullUpdate();
|
||||
}
|
||||
return objatt;
|
||||
}
|
||||
|
||||
// What makes this method odd and unique is it tries to detach using an LLUUID.... Yay for standards.
|
||||
// To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID??
|
||||
protected internal void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient)
|
||||
public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient)
|
||||
{
|
||||
if (itemID == LLUUID.Zero) // If this happened, someone made a mistake....
|
||||
return;
|
||||
|
|
|
@ -2316,5 +2316,48 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
//
|
||||
// imod.TestFunction();
|
||||
// }
|
||||
|
||||
public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID,
|
||||
uint AttachmentPt, uint ItemFlags, uint NextOwnerMask)
|
||||
{
|
||||
SceneObjectGroup att = m_innerScene.RezSingleAttachment(remoteClient, itemID, AttachmentPt, ItemFlags, NextOwnerMask);
|
||||
|
||||
if (att == null)
|
||||
{
|
||||
DetachSingleAttachmentToInv(itemID, remoteClient);
|
||||
return;
|
||||
}
|
||||
|
||||
if (att.RootPart != null)
|
||||
AttachmentPt = att.RootPart.AttachmentPoint;
|
||||
|
||||
ScenePresence presence;
|
||||
if(TryGetAvatar(remoteClient.AgentId, out presence))
|
||||
{
|
||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.GetFromAssetID());
|
||||
IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
|
||||
if(ava != null)
|
||||
{
|
||||
ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient)
|
||||
{
|
||||
ScenePresence presence;
|
||||
if(TryGetAvatar(remoteClient.AgentId, out presence))
|
||||
{
|
||||
presence.Appearance.DetachAttachment(itemID);
|
||||
IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
|
||||
if(ava != null)
|
||||
{
|
||||
ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
|
||||
}
|
||||
m_innerScene.DetachSingleAttachmentToInv(itemID, remoteClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2109,8 +2109,8 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
client.OnGrabUpdate += m_innerScene.MoveObject;
|
||||
client.OnDeRezObject += DeRezObject;
|
||||
client.OnRezObject += RezObject;
|
||||
client.OnRezSingleAttachmentFromInv += m_innerScene.RezSingleAttachment;
|
||||
client.OnDetachAttachmentIntoInv += m_innerScene.DetachSingleAttachmentToInv;
|
||||
client.OnRezSingleAttachmentFromInv += RezSingleAttachment;
|
||||
client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv;
|
||||
client.OnObjectAttach += m_innerScene.AttachObject;
|
||||
client.OnObjectDetach += m_innerScene.DetachObject;
|
||||
client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest;
|
||||
|
@ -3859,5 +3859,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
//Console.WriteLine("Terrain packet unacked, resending patch: " + patchX + " , " + patchY);
|
||||
client.SendLayerData(patchX, patchY, Heightmap.GetFloatsSerialised());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue