aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2014-09-29 20:36:03 +0100
committerUbitUmarov2014-09-29 20:36:03 +0100
commitcfb1a2730045420319f0678ccc70e61d6a46df82 (patch)
treeae0e0c7684a4d9da05b0ac04f4892bffcfb7209d /OpenSim
parent change avatar physics and motion control. Still not that good :( (diff)
parentAlso fetch and store old asset for animation sets (diff)
downloadopensim-SC_OLD-cfb1a2730045420319f0678ccc70e61d6a46df82.zip
opensim-SC_OLD-cfb1a2730045420319f0678ccc70e61d6a46df82.tar.gz
opensim-SC_OLD-cfb1a2730045420319f0678ccc70e61d6a46df82.tar.bz2
opensim-SC_OLD-cfb1a2730045420319f0678ccc70e61d6a46df82.tar.xz
Merge branch 'master' into ubitworkmaster
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/AnimationSet.cs61
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs22
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs14
3 files changed, 62 insertions, 35 deletions
diff --git a/OpenSim/Framework/AnimationSet.cs b/OpenSim/Framework/AnimationSet.cs
index 56e1068..8ac9081 100644
--- a/OpenSim/Framework/AnimationSet.cs
+++ b/OpenSim/Framework/AnimationSet.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Framework
35 35
36 public class AnimationSet 36 public class AnimationSet
37 { 37 {
38 private readonly int m_maxAnimations = 255; 38 private bool m_parseError = false;
39 39
40 public const uint createBasePermitions = (uint)(PermissionMask.All); // no export ? 40 public const uint createBasePermitions = (uint)(PermissionMask.All); // no export ?
41 public const uint createNextPermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify); 41 public const uint createNextPermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
@@ -86,50 +86,41 @@ namespace OpenSim.Framework
86 } 86 }
87 87
88 public int AnimationCount { get; private set; } 88 public int AnimationCount { get; private set; }
89 private Dictionary<int, UUID> m_animations = new Dictionary<int, UUID>(); 89 private Dictionary<string, UUID> m_animations = new Dictionary<string, UUID>();
90 90 public AnimationSet(Byte[] data)
91 public UUID AnimationAt(int index)
92 {
93 if (m_animations.ContainsKey(index))
94 return m_animations[index];
95 return UUID.Zero;
96 }
97
98 public void SetAnimation(int index, UUID animation)
99 {
100 if (index < 0 || index > m_maxAnimations)
101 return;
102
103 m_animations[index] = animation;
104 }
105
106 public AnimationSet(Byte[] assetData)
107 { 91 {
108 if (assetData.Length < 2) 92 string assetData = System.Text.Encoding.ASCII.GetString(data);
109 throw new System.ArgumentException(); 93 Console.WriteLine("--------------------");
110 94 Console.WriteLine("AnimationSet length {0} bytes", assetData.Length);
111 if (assetData[0] != 1) // Only version 1 is supported 95 Console.WriteLine("Data: {0}", assetData);
112 throw new System.ArgumentException(); 96 Console.WriteLine("--------------------");
113
114 AnimationCount = assetData[1];
115 if (assetData.Length - 2 != 16 * AnimationCount)
116 throw new System.ArgumentException();
117
118 // TODO: Read anims from blob
119 } 97 }
120 98
121 public Byte[] ToBytes() 99 public Byte[] ToBytes()
122 { 100 {
123 // TODO: Make blob from anims 101 // If there was an error parsing the input, we give back an
124 return new Byte[0]; 102 // empty set rather than the original data.
103 if (m_parseError)
104 {
105 string dummy = "version 1\ncount 0\n";
106 return System.Text.Encoding.ASCII.GetBytes(dummy);
107 }
108
109 string assetData = String.Format("version 1\ncount {0}\n", m_animations.Count);
110 foreach (KeyValuePair<string, UUID> kvp in m_animations)
111 assetData += String.Format("{0} {1}\n", kvp.Key, kvp.Value.ToString());
112 return System.Text.Encoding.ASCII.GetBytes(assetData);
125 } 113 }
126 114
127 public bool Validate(AnimationSetValidator val) 115 public bool Validate(AnimationSetValidator val)
128 { 116 {
129 List<int> badAnims = new List<int>(); 117 if (m_parseError)
118 return false;
119
120 List<string> badAnims = new List<string>();
130 121
131 bool allOk = true; 122 bool allOk = true;
132 foreach (KeyValuePair<int, UUID> kvp in m_animations) 123 foreach (KeyValuePair<string, UUID> kvp in m_animations)
133 { 124 {
134 if (!val(kvp.Value)) 125 if (!val(kvp.Value))
135 { 126 {
@@ -138,7 +129,7 @@ namespace OpenSim.Framework
138 } 129 }
139 } 130 }
140 131
141 foreach (int idx in badAnims) 132 foreach (string idx in badAnims)
142 m_animations.Remove(idx); 133 m_animations.Remove(idx);
143 134
144 return allOk; 135 return allOk;
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 1e14f45..1a19585 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -172,6 +172,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
172 { 172 {
173 AssetXferUploader uploader = RequestXferUploader(transactionID); 173 AssetXferUploader uploader = RequestXferUploader(transactionID);
174 174
175 // Here we need to get the old asset to extract the
176 // texture UUIDs if it's a wearable.
177 if (item.Type == (int)AssetType.Bodypart ||
178 item.Type == (int)AssetType.Clothing ||
179 item.Type == (int)CustomAssetType.AnimationSet)
180 {
181 AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
182 if (oldAsset != null)
183 uploader.SetOldData(oldAsset.Data);
184 }
185
175 uploader.RequestUpdateTaskInventoryItem(remoteClient, item); 186 uploader.RequestUpdateTaskInventoryItem(remoteClient, item);
176 } 187 }
177 188
@@ -180,6 +191,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
180 { 191 {
181 AssetXferUploader uploader = RequestXferUploader(transactionID); 192 AssetXferUploader uploader = RequestXferUploader(transactionID);
182 193
194 // Here we need to get the old asset to extract the
195 // texture UUIDs if it's a wearable.
196 if (item.AssetType == (int)AssetType.Bodypart ||
197 item.AssetType == (int)AssetType.Clothing ||
198 item.AssetType == (int)CustomAssetType.AnimationSet)
199 {
200 AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
201 if (oldAsset != null)
202 uploader.SetOldData(oldAsset.Data);
203 }
204
183 uploader.RequestUpdateInventoryItem(remoteClient, item); 205 uploader.RequestUpdateInventoryItem(remoteClient, item);
184 } 206 }
185 } 207 }
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index b3dc0c0..64a9610 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -278,6 +278,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
278 278
279 remoteClient.SendAlertMessage("Script saved"); 279 remoteClient.SendAlertMessage("Script saved");
280 } 280 }
281 else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet)
282 {
283 AnimationSet animSet = new AnimationSet(data);
284 if (!animSet.Validate(x => {
285 int perms = m_Scene.InventoryService.GetAssetPermissions(remoteClient.AgentId, x);
286 int required = (int)(PermissionMask.Transfer | PermissionMask.Copy);
287 if ((perms & required) != required)
288 return false;
289 return true;
290 }))
291 {
292 data = animSet.ToBytes();
293 }
294 }
281 295
282 AssetBase asset = 296 AssetBase asset =
283 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString()); 297 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString());