diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs index 414f06a..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 | { |
@@ -150,13 +147,22 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
150 | } | 147 | } |
151 | } | 148 | } |
152 | 149 | ||
150 | public void Store(UUID agentId) | ||
151 | { | ||
152 | } | ||
153 | |||
154 | public void UpdateMeshAvatar(UUID agentId) | ||
155 | { | ||
156 | } | ||
157 | |||
153 | public void Store(UUID agentId, WearableCacheItem[] data) | 158 | public void Store(UUID agentId, WearableCacheItem[] data) |
154 | { | 159 | { |
155 | if (m_URL == String.Empty) | 160 | if (m_URL == String.Empty) |
156 | return; | 161 | return; |
157 | 162 | ||
163 | int numberWears = 0; | ||
158 | MemoryStream reqStream; | 164 | MemoryStream reqStream; |
159 | 165 | ||
160 | using (MemoryStream bakeStream = new MemoryStream()) | 166 | using (MemoryStream bakeStream = new MemoryStream()) |
161 | using (XmlTextWriter bakeWriter = new XmlTextWriter(bakeStream, null)) | 167 | using (XmlTextWriter bakeWriter = new XmlTextWriter(bakeStream, null)) |
162 | { | 168 | { |
@@ -164,15 +170,16 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
164 | 170 | ||
165 | for (int i = 0; i < data.Length; i++) | 171 | for (int i = 0; i < data.Length; i++) |
166 | { | 172 | { |
167 | if (data[i] != null) | 173 | if (data[i] != null && data[i].TextureAsset != null) |
168 | { | 174 | { |
169 | bakeWriter.WriteStartElement(String.Empty, "BakedTexture", String.Empty); | 175 | bakeWriter.WriteStartElement(String.Empty, "BakedTexture", String.Empty); |
170 | bakeWriter.WriteAttributeString(String.Empty, "TextureIndex", String.Empty, data[i].TextureIndex.ToString()); | 176 | bakeWriter.WriteAttributeString(String.Empty, "TextureIndex", String.Empty, data[i].TextureIndex.ToString()); |
171 | bakeWriter.WriteAttributeString(String.Empty, "CacheId", String.Empty, data[i].CacheId.ToString()); | 177 | bakeWriter.WriteAttributeString(String.Empty, "CacheId", String.Empty, data[i].CacheId.ToString()); |
172 | if (data[i].TextureAsset != null) | 178 | // if (data[i].TextureAsset != null) |
173 | m_serializer.Serialize(bakeWriter, data[i].TextureAsset); | 179 | m_serializer.Serialize(bakeWriter, data[i].TextureAsset); |
174 | 180 | ||
175 | bakeWriter.WriteEndElement(); | 181 | bakeWriter.WriteEndElement(); |
182 | numberWears++; | ||
176 | } | 183 | } |
177 | } | 184 | } |
178 | 185 | ||
@@ -182,17 +189,18 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
182 | reqStream = new MemoryStream(bakeStream.ToArray()); | 189 | reqStream = new MemoryStream(bakeStream.ToArray()); |
183 | } | 190 | } |
184 | 191 | ||
185 | RestClient rc = new RestClient(m_URL); | ||
186 | rc.AddResourcePath("bakes"); | ||
187 | rc.AddResourcePath(agentId.ToString()); | ||
188 | |||
189 | rc.RequestMethod = "POST"; | ||
190 | |||
191 | Util.FireAndForget( | 192 | Util.FireAndForget( |
192 | delegate | 193 | delegate |
193 | { | 194 | { |
194 | rc.Request(reqStream, m_Auth); | 195 | using(RestClient rc = new RestClient(m_URL)) |
195 | 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 | } | ||
196 | }, null, "XBakesModule.Store" | 204 | }, null, "XBakesModule.Store" |
197 | ); | 205 | ); |
198 | } | 206 | } |