diff options
author | Oren Hurvitz | 2014-06-01 17:39:11 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-07-21 08:30:03 +0100 |
commit | 99ac770abbe3a95887c4b10c82f3985aa878eeef (patch) | |
tree | 8c946dab083dd50a352f3861415eca43185d8d95 /OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs | |
parent | Set "[Terrain]SendTerrainUpdatesByViewDistance=true" by default. (diff) | |
download | opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.zip opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.gz opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.bz2 opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.xz |
Close streams immediately when we finish using them
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs index 3afc87f..b3b38b2 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -113,31 +113,34 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
113 | 113 | ||
114 | public byte[] ToBytes() | 114 | public byte[] ToBytes() |
115 | { | 115 | { |
116 | byte[] outputbytes = new byte[0]; | 116 | byte[] outputbytes; |
117 | 117 | ||
118 | BinaryWriter iostream = new BinaryWriter(new MemoryStream()); | 118 | using (MemoryStream ms = new MemoryStream()) |
119 | iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown0))); | 119 | using (BinaryWriter iostream = new BinaryWriter(ms)) |
120 | iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown1))); | ||
121 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Priority))); | ||
122 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(Length))); | ||
123 | iostream.Write(BinBVHUtil.WriteNullTerminatedString(ExpressionName)); | ||
124 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(InPoint))); | ||
125 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(OutPoint))); | ||
126 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Loop ? 1 : 0))); | ||
127 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseInTime))); | ||
128 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseOutTime))); | ||
129 | iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes(HandPose))); | ||
130 | iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes((uint)(Joints.Length)))); | ||
131 | |||
132 | for (int i = 0; i < Joints.Length; i++) | ||
133 | { | 120 | { |
134 | Joints[i].WriteBytesToStream(iostream, InPoint, OutPoint); | 121 | iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown0))); |
122 | iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown1))); | ||
123 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Priority))); | ||
124 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(Length))); | ||
125 | iostream.Write(BinBVHUtil.WriteNullTerminatedString(ExpressionName)); | ||
126 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(InPoint))); | ||
127 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(OutPoint))); | ||
128 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Loop ? 1 : 0))); | ||
129 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseInTime))); | ||
130 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseOutTime))); | ||
131 | iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes(HandPose))); | ||
132 | iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes((uint)(Joints.Length)))); | ||
133 | |||
134 | for (int i = 0; i < Joints.Length; i++) | ||
135 | { | ||
136 | Joints[i].WriteBytesToStream(iostream, InPoint, OutPoint); | ||
137 | } | ||
138 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(0))); | ||
139 | |||
140 | using (MemoryStream ms2 = (MemoryStream)iostream.BaseStream) | ||
141 | outputbytes = ms2.ToArray(); | ||
135 | } | 142 | } |
136 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(0))); | 143 | |
137 | MemoryStream ms = (MemoryStream)iostream.BaseStream; | ||
138 | outputbytes = ms.ToArray(); | ||
139 | ms.Close(); | ||
140 | iostream.Close(); | ||
141 | return outputbytes; | 144 | return outputbytes; |
142 | } | 145 | } |
143 | 146 | ||