diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs index 7bec18f..c0686d9 100644 --- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs | |||
@@ -101,8 +101,6 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
101 | if (m_URL == String.Empty) | 101 | if (m_URL == String.Empty) |
102 | return null; | 102 | return null; |
103 | 103 | ||
104 | int size = 0; | ||
105 | |||
106 | using (RestClient rc = new RestClient(m_URL)) | 104 | using (RestClient rc = new RestClient(m_URL)) |
107 | { | 105 | { |
108 | List<WearableCacheItem> ret = new List<WearableCacheItem>(); | 106 | List<WearableCacheItem> ret = new List<WearableCacheItem>(); |
@@ -113,35 +111,34 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
113 | 111 | ||
114 | try | 112 | try |
115 | { | 113 | { |
116 | Stream s = rc.Request(m_Auth); | 114 | using(Stream s = rc.Request(m_Auth)) |
117 | |||
118 | using (XmlTextReader sr = new XmlTextReader(s)) | ||
119 | { | 115 | { |
120 | sr.ReadStartElement("BakedAppearance"); | 116 | using(XmlTextReader sr = new XmlTextReader(s)) |
121 | while (sr.LocalName == "BakedTexture") | ||
122 | { | 117 | { |
123 | string sTextureIndex = sr.GetAttribute("TextureIndex"); | 118 | sr.ReadStartElement("BakedAppearance"); |
124 | int lTextureIndex = Convert.ToInt32(sTextureIndex); | 119 | while(sr.LocalName == "BakedTexture") |
125 | string sCacheId = sr.GetAttribute("CacheId"); | ||
126 | UUID lCacheId = UUID.Zero; | ||
127 | if (!(UUID.TryParse(sCacheId, out lCacheId))) | ||
128 | { | 120 | { |
121 | string sTextureIndex = sr.GetAttribute("TextureIndex"); | ||
122 | int lTextureIndex = Convert.ToInt32(sTextureIndex); | ||
123 | string sCacheId = sr.GetAttribute("CacheId"); | ||
124 | UUID lCacheId = UUID.Zero; | ||
125 | if(!(UUID.TryParse(sCacheId,out lCacheId))) | ||
126 | { | ||
129 | // ?? Nothing here | 127 | // ?? Nothing here |
128 | } | ||
129 | |||
130 | sr.ReadStartElement("BakedTexture"); | ||
131 | if(sr.Name=="AssetBase") | ||
132 | { | ||
133 | AssetBase a = (AssetBase)m_serializer.Deserialize(sr); | ||
134 | ret.Add(new WearableCacheItem() { CacheId = lCacheId,TextureIndex = (uint)lTextureIndex,TextureAsset = a,TextureID = a.FullID }); | ||
135 | sr.ReadEndElement(); | ||
136 | } | ||
130 | } | 137 | } |
131 | 138 | m_log.DebugFormat("[XBakes]: read {0} textures for user {1}",ret.Count,id); | |
132 | ++size; | ||
133 | |||
134 | sr.ReadStartElement("BakedTexture"); | ||
135 | AssetBase a = (AssetBase)m_serializer.Deserialize(sr); | ||
136 | ret.Add(new WearableCacheItem() { CacheId = lCacheId, TextureIndex = (uint)lTextureIndex, TextureAsset = a, TextureID = a.FullID }); | ||
137 | |||
138 | sr.ReadEndElement(); | ||
139 | } | 139 | } |
140 | 140 | return ret.ToArray(); | |
141 | m_log.DebugFormat("[XBakes]: read {0} textures for user {1}", ret.Count, id); | ||
142 | } | 141 | } |
143 | |||
144 | return ret.ToArray(); | ||
145 | } | 142 | } |
146 | catch (XmlException) | 143 | catch (XmlException) |
147 | { | 144 | { |
@@ -153,18 +150,19 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
153 | public void Store(UUID agentId) | 150 | public void Store(UUID agentId) |
154 | { | 151 | { |
155 | } | 152 | } |
153 | |||
156 | public void UpdateMeshAvatar(UUID agentId) | 154 | public void UpdateMeshAvatar(UUID agentId) |
157 | { | 155 | { |
158 | } | 156 | } |
159 | 157 | ||
160 | |||
161 | public void Store(UUID agentId, WearableCacheItem[] data) | 158 | public void Store(UUID agentId, WearableCacheItem[] data) |
162 | { | 159 | { |
163 | if (m_URL == String.Empty) | 160 | if (m_URL == String.Empty) |
164 | return; | 161 | return; |
165 | 162 | ||
163 | int numberWears = 0; | ||
166 | MemoryStream reqStream; | 164 | MemoryStream reqStream; |
167 | 165 | ||
168 | using (MemoryStream bakeStream = new MemoryStream()) | 166 | using (MemoryStream bakeStream = new MemoryStream()) |
169 | using (XmlTextWriter bakeWriter = new XmlTextWriter(bakeStream, null)) | 167 | using (XmlTextWriter bakeWriter = new XmlTextWriter(bakeStream, null)) |
170 | { | 168 | { |
@@ -172,15 +170,16 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
172 | 170 | ||
173 | for (int i = 0; i < data.Length; i++) | 171 | for (int i = 0; i < data.Length; i++) |
174 | { | 172 | { |
175 | if (data[i] != null) | 173 | if (data[i] != null && data[i].TextureAsset != null) |
176 | { | 174 | { |
177 | bakeWriter.WriteStartElement(String.Empty, "BakedTexture", String.Empty); | 175 | bakeWriter.WriteStartElement(String.Empty, "BakedTexture", String.Empty); |
178 | bakeWriter.WriteAttributeString(String.Empty, "TextureIndex", String.Empty, data[i].TextureIndex.ToString()); | 176 | bakeWriter.WriteAttributeString(String.Empty, "TextureIndex", String.Empty, data[i].TextureIndex.ToString()); |
179 | bakeWriter.WriteAttributeString(String.Empty, "CacheId", String.Empty, data[i].CacheId.ToString()); | 177 | bakeWriter.WriteAttributeString(String.Empty, "CacheId", String.Empty, data[i].CacheId.ToString()); |
180 | if (data[i].TextureAsset != null) | 178 | // if (data[i].TextureAsset != null) |
181 | m_serializer.Serialize(bakeWriter, data[i].TextureAsset); | 179 | m_serializer.Serialize(bakeWriter, data[i].TextureAsset); |
182 | 180 | ||
183 | bakeWriter.WriteEndElement(); | 181 | bakeWriter.WriteEndElement(); |
182 | numberWears++; | ||
184 | } | 183 | } |
185 | } | 184 | } |
186 | 185 | ||
@@ -190,17 +189,18 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
190 | reqStream = new MemoryStream(bakeStream.ToArray()); | 189 | reqStream = new MemoryStream(bakeStream.ToArray()); |
191 | } | 190 | } |
192 | 191 | ||
193 | RestClient rc = new RestClient(m_URL); | ||
194 | rc.AddResourcePath("bakes"); | ||
195 | rc.AddResourcePath(agentId.ToString()); | ||
196 | |||
197 | rc.RequestMethod = "POST"; | ||
198 | |||
199 | Util.FireAndForget( | 192 | Util.FireAndForget( |
200 | delegate | 193 | delegate |
201 | { | 194 | { |
202 | rc.Request(reqStream, m_Auth); | 195 | using(RestClient rc = new RestClient(m_URL)) |
203 | m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", data.Length, agentId); | 196 | { |
197 | rc.AddResourcePath("bakes"); | ||
198 | rc.AddResourcePath(agentId.ToString()); | ||
199 | rc.RequestMethod = "POST"; | ||
200 | |||
201 | rc.Request(reqStream, m_Auth); | ||
202 | m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", numberWears, agentId); | ||
203 | } | ||
204 | }, null, "XBakesModule.Store" | 204 | }, null, "XBakesModule.Store" |
205 | ); | 205 | ); |
206 | } | 206 | } |