Merge branch 'master' into ubitworkmaster
commit
cfb1a27300
|
@ -35,7 +35,7 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public class AnimationSet
|
public class AnimationSet
|
||||||
{
|
{
|
||||||
private readonly int m_maxAnimations = 255;
|
private bool m_parseError = false;
|
||||||
|
|
||||||
public const uint createBasePermitions = (uint)(PermissionMask.All); // no export ?
|
public const uint createBasePermitions = (uint)(PermissionMask.All); // no export ?
|
||||||
public const uint createNextPermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
|
public const uint createNextPermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
|
||||||
|
@ -86,50 +86,41 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AnimationCount { get; private set; }
|
public int AnimationCount { get; private set; }
|
||||||
private Dictionary<int, UUID> m_animations = new Dictionary<int, UUID>();
|
private Dictionary<string, UUID> m_animations = new Dictionary<string, UUID>();
|
||||||
|
public AnimationSet(Byte[] data)
|
||||||
public UUID AnimationAt(int index)
|
|
||||||
{
|
{
|
||||||
if (m_animations.ContainsKey(index))
|
string assetData = System.Text.Encoding.ASCII.GetString(data);
|
||||||
return m_animations[index];
|
Console.WriteLine("--------------------");
|
||||||
return UUID.Zero;
|
Console.WriteLine("AnimationSet length {0} bytes", assetData.Length);
|
||||||
}
|
Console.WriteLine("Data: {0}", assetData);
|
||||||
|
Console.WriteLine("--------------------");
|
||||||
public void SetAnimation(int index, UUID animation)
|
|
||||||
{
|
|
||||||
if (index < 0 || index > m_maxAnimations)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_animations[index] = animation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AnimationSet(Byte[] assetData)
|
|
||||||
{
|
|
||||||
if (assetData.Length < 2)
|
|
||||||
throw new System.ArgumentException();
|
|
||||||
|
|
||||||
if (assetData[0] != 1) // Only version 1 is supported
|
|
||||||
throw new System.ArgumentException();
|
|
||||||
|
|
||||||
AnimationCount = assetData[1];
|
|
||||||
if (assetData.Length - 2 != 16 * AnimationCount)
|
|
||||||
throw new System.ArgumentException();
|
|
||||||
|
|
||||||
// TODO: Read anims from blob
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Byte[] ToBytes()
|
public Byte[] ToBytes()
|
||||||
{
|
{
|
||||||
// TODO: Make blob from anims
|
// If there was an error parsing the input, we give back an
|
||||||
return new Byte[0];
|
// empty set rather than the original data.
|
||||||
|
if (m_parseError)
|
||||||
|
{
|
||||||
|
string dummy = "version 1\ncount 0\n";
|
||||||
|
return System.Text.Encoding.ASCII.GetBytes(dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
string assetData = String.Format("version 1\ncount {0}\n", m_animations.Count);
|
||||||
|
foreach (KeyValuePair<string, UUID> kvp in m_animations)
|
||||||
|
assetData += String.Format("{0} {1}\n", kvp.Key, kvp.Value.ToString());
|
||||||
|
return System.Text.Encoding.ASCII.GetBytes(assetData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Validate(AnimationSetValidator val)
|
public bool Validate(AnimationSetValidator val)
|
||||||
{
|
{
|
||||||
List<int> badAnims = new List<int>();
|
if (m_parseError)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
List<string> badAnims = new List<string>();
|
||||||
|
|
||||||
bool allOk = true;
|
bool allOk = true;
|
||||||
foreach (KeyValuePair<int, UUID> kvp in m_animations)
|
foreach (KeyValuePair<string, UUID> kvp in m_animations)
|
||||||
{
|
{
|
||||||
if (!val(kvp.Value))
|
if (!val(kvp.Value))
|
||||||
{
|
{
|
||||||
|
@ -138,7 +129,7 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int idx in badAnims)
|
foreach (string idx in badAnims)
|
||||||
m_animations.Remove(idx);
|
m_animations.Remove(idx);
|
||||||
|
|
||||||
return allOk;
|
return allOk;
|
||||||
|
|
|
@ -172,6 +172,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||||
{
|
{
|
||||||
AssetXferUploader uploader = RequestXferUploader(transactionID);
|
AssetXferUploader uploader = RequestXferUploader(transactionID);
|
||||||
|
|
||||||
|
// Here we need to get the old asset to extract the
|
||||||
|
// texture UUIDs if it's a wearable.
|
||||||
|
if (item.Type == (int)AssetType.Bodypart ||
|
||||||
|
item.Type == (int)AssetType.Clothing ||
|
||||||
|
item.Type == (int)CustomAssetType.AnimationSet)
|
||||||
|
{
|
||||||
|
AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
|
||||||
|
if (oldAsset != null)
|
||||||
|
uploader.SetOldData(oldAsset.Data);
|
||||||
|
}
|
||||||
|
|
||||||
uploader.RequestUpdateTaskInventoryItem(remoteClient, item);
|
uploader.RequestUpdateTaskInventoryItem(remoteClient, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +191,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||||
{
|
{
|
||||||
AssetXferUploader uploader = RequestXferUploader(transactionID);
|
AssetXferUploader uploader = RequestXferUploader(transactionID);
|
||||||
|
|
||||||
|
// Here we need to get the old asset to extract the
|
||||||
|
// texture UUIDs if it's a wearable.
|
||||||
|
if (item.AssetType == (int)AssetType.Bodypart ||
|
||||||
|
item.AssetType == (int)AssetType.Clothing ||
|
||||||
|
item.AssetType == (int)CustomAssetType.AnimationSet)
|
||||||
|
{
|
||||||
|
AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
|
||||||
|
if (oldAsset != null)
|
||||||
|
uploader.SetOldData(oldAsset.Data);
|
||||||
|
}
|
||||||
|
|
||||||
uploader.RequestUpdateInventoryItem(remoteClient, item);
|
uploader.RequestUpdateInventoryItem(remoteClient, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,6 +278,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
|
|
||||||
remoteClient.SendAlertMessage("Script saved");
|
remoteClient.SendAlertMessage("Script saved");
|
||||||
}
|
}
|
||||||
|
else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet)
|
||||||
|
{
|
||||||
|
AnimationSet animSet = new AnimationSet(data);
|
||||||
|
if (!animSet.Validate(x => {
|
||||||
|
int perms = m_Scene.InventoryService.GetAssetPermissions(remoteClient.AgentId, x);
|
||||||
|
int required = (int)(PermissionMask.Transfer | PermissionMask.Copy);
|
||||||
|
if ((perms & required) != required)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
data = animSet.ToBytes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AssetBase asset =
|
AssetBase asset =
|
||||||
CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString());
|
CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString());
|
||||||
|
|
Loading…
Reference in New Issue