diff options
author | Melanie Thielker | 2014-09-27 02:30:01 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-09-27 02:30:01 +0200 |
commit | 3ea76e3131203f6a553d5a540d5d28aa5ca3f74a (patch) | |
tree | d107b2e8fab320ab9bb9f1902884759b076de5b2 | |
parent | bug fix: add missing attach to region heartbeat event to update animations (diff) | |
download | opensim-SC-3ea76e3131203f6a553d5a540d5d28aa5ca3f74a.zip opensim-SC-3ea76e3131203f6a553d5a540d5d28aa5ca3f74a.tar.gz opensim-SC-3ea76e3131203f6a553d5a540d5d28aa5ca3f74a.tar.bz2 opensim-SC-3ea76e3131203f6a553d5a540d5d28aa5ca3f74a.tar.xz |
Make changes to AnimationSet to allow indexing by names rather than indices. Add some debugging output and prepare for parsing an ascii-based format.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/AnimationSet.cs | 61 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 14 |
2 files changed, 40 insertions, 35 deletions
diff --git a/OpenSim/Framework/AnimationSet.cs b/OpenSim/Framework/AnimationSet.cs index c5ab634..e81d978 100644 --- a/OpenSim/Framework/AnimationSet.cs +++ b/OpenSim/Framework/AnimationSet.cs | |||
@@ -35,53 +35,44 @@ 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 int AnimationCount { get; private set; } | 40 | public int AnimationCount { get; private set; } |
41 | private Dictionary<int, UUID> m_animations = new Dictionary<int, UUID>(); | 41 | private Dictionary<string, UUID> m_animations = new Dictionary<string, UUID>(); |
42 | 42 | public AnimationSet(Byte[] data) | |
43 | public UUID AnimationAt(int index) | ||
44 | { | ||
45 | if (m_animations.ContainsKey(index)) | ||
46 | return m_animations[index]; | ||
47 | return UUID.Zero; | ||
48 | } | ||
49 | |||
50 | public void SetAnimation(int index, UUID animation) | ||
51 | { | 43 | { |
52 | if (index < 0 || index > m_maxAnimations) | 44 | string assetData = System.Text.Encoding.ASCII.GetString(data); |
53 | return; | 45 | Console.WriteLine("--------------------"); |
54 | 46 | Console.WriteLine("AnimationSet length {0} bytes", assetData.Length); | |
55 | m_animations[index] = animation; | 47 | Console.WriteLine("Data: {0}", assetData); |
56 | } | 48 | Console.WriteLine("--------------------"); |
57 | |||
58 | public AnimationSet(Byte[] assetData) | ||
59 | { | ||
60 | if (assetData.Length < 2) | ||
61 | throw new System.ArgumentException(); | ||
62 | |||
63 | if (assetData[0] != 1) // Only version 1 is supported | ||
64 | throw new System.ArgumentException(); | ||
65 | |||
66 | AnimationCount = assetData[1]; | ||
67 | if (assetData.Length - 2 != 16 * AnimationCount) | ||
68 | throw new System.ArgumentException(); | ||
69 | |||
70 | // TODO: Read anims from blob | ||
71 | } | 49 | } |
72 | 50 | ||
73 | public Byte[] ToBytes() | 51 | public Byte[] ToBytes() |
74 | { | 52 | { |
75 | // TODO: Make blob from anims | 53 | // If there was an error parsing the input, we give back an |
76 | return new Byte[0]; | 54 | // empty set rather than the original data. |
55 | if (m_parseError) | ||
56 | { | ||
57 | string dummy = "version 1\ncount 0\n"; | ||
58 | return System.Text.Encoding.ASCII.GetBytes(dummy); | ||
59 | } | ||
60 | |||
61 | string assetData = String.Format("version 1\ncount {0}\n", m_animations.Count); | ||
62 | foreach (KeyValuePair<string, UUID> kvp in m_animations) | ||
63 | assetData += String.Format("{0} {1}\n", kvp.Key, kvp.Value.ToString()); | ||
64 | return System.Text.Encoding.ASCII.GetBytes(assetData); | ||
77 | } | 65 | } |
78 | 66 | ||
79 | public bool Validate(AnimationSetValidator val) | 67 | public bool Validate(AnimationSetValidator val) |
80 | { | 68 | { |
81 | List<int> badAnims = new List<int>(); | 69 | if (m_parseError) |
70 | return false; | ||
71 | |||
72 | List<string> badAnims = new List<string>(); | ||
82 | 73 | ||
83 | bool allOk = true; | 74 | bool allOk = true; |
84 | foreach (KeyValuePair<int, UUID> kvp in m_animations) | 75 | foreach (KeyValuePair<string, UUID> kvp in m_animations) |
85 | { | 76 | { |
86 | if (!val(kvp.Value)) | 77 | if (!val(kvp.Value)) |
87 | { | 78 | { |
@@ -90,7 +81,7 @@ namespace OpenSim.Framework | |||
90 | } | 81 | } |
91 | } | 82 | } |
92 | 83 | ||
93 | foreach (int idx in badAnims) | 84 | foreach (string idx in badAnims) |
94 | m_animations.Remove(idx); | 85 | m_animations.Remove(idx); |
95 | 86 | ||
96 | return allOk; | 87 | return allOk; |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index e8ad0f2..94782f9 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -277,6 +277,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
277 | 277 | ||
278 | remoteClient.SendAlertMessage("Script saved"); | 278 | remoteClient.SendAlertMessage("Script saved"); |
279 | } | 279 | } |
280 | else if ((CustomInventoryType)item.InvType == CustomInventoryType.AnimationSet) | ||
281 | { | ||
282 | AnimationSet animSet = new AnimationSet(data); | ||
283 | if (!animSet.Validate(x => { | ||
284 | int perms = m_Scene.InventoryService.GetAssetPermissions(remoteClient.AgentId, x); | ||
285 | int required = (int)(PermissionMask.Transfer | PermissionMask.Copy); | ||
286 | if ((perms & required) != required) | ||
287 | return false; | ||
288 | return true; | ||
289 | })) | ||
290 | { | ||
291 | data = animSet.ToBytes(); | ||
292 | } | ||
293 | } | ||
280 | 294 | ||
281 | AssetBase asset = | 295 | AssetBase asset = |
282 | CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString()); | 296 | CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString()); |