make bakes reception handle empty BakedTexture elements. But at same time stop sending them, only sending to Xbakes server items that do have a texture, like master does

avinationmerge
UbitUmarov 2015-10-01 19:30:37 +01:00
parent 2abe1ccc59
commit 6bc479fecd
1 changed files with 36 additions and 36 deletions

View File

@ -101,8 +101,6 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
if (m_URL == String.Empty) if (m_URL == String.Empty)
return null; return null;
int size = 0;
using (RestClient rc = new RestClient(m_URL)) using (RestClient rc = new RestClient(m_URL))
{ {
List<WearableCacheItem> ret = new List<WearableCacheItem>(); List<WearableCacheItem> ret = new List<WearableCacheItem>();
@ -113,36 +111,35 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
try try
{ {
Stream s = rc.Request(m_Auth); using(Stream s = rc.Request(m_Auth))
{
using (XmlTextReader sr = new XmlTextReader(s)) using(XmlTextReader sr = new XmlTextReader(s))
{ {
sr.ReadStartElement("BakedAppearance"); sr.ReadStartElement("BakedAppearance");
while (sr.LocalName == "BakedTexture") while(sr.LocalName == "BakedTexture")
{ {
string sTextureIndex = sr.GetAttribute("TextureIndex"); string sTextureIndex = sr.GetAttribute("TextureIndex");
int lTextureIndex = Convert.ToInt32(sTextureIndex); int lTextureIndex = Convert.ToInt32(sTextureIndex);
string sCacheId = sr.GetAttribute("CacheId"); string sCacheId = sr.GetAttribute("CacheId");
UUID lCacheId = UUID.Zero; UUID lCacheId = UUID.Zero;
if (!(UUID.TryParse(sCacheId, out lCacheId))) if(!(UUID.TryParse(sCacheId,out lCacheId)))
{ {
// ?? Nothing here // ?? Nothing here
} }
++size;
sr.ReadStartElement("BakedTexture"); sr.ReadStartElement("BakedTexture");
if(sr.Name=="AssetBase")
{
AssetBase a = (AssetBase)m_serializer.Deserialize(sr); AssetBase a = (AssetBase)m_serializer.Deserialize(sr);
ret.Add(new WearableCacheItem() { CacheId = lCacheId, TextureIndex = (uint)lTextureIndex, TextureAsset = a, TextureID = a.FullID }); ret.Add(new WearableCacheItem() { CacheId = lCacheId,TextureIndex = (uint)lTextureIndex,TextureAsset = a,TextureID = a.FullID });
sr.ReadEndElement(); sr.ReadEndElement();
} }
m_log.DebugFormat("[XBakes]: read {0} textures for user {1}", ret.Count, id);
} }
m_log.DebugFormat("[XBakes]: read {0} textures for user {1}",ret.Count,id);
}
return ret.ToArray(); return ret.ToArray();
} }
}
catch (XmlException) catch (XmlException)
{ {
return null; return null;
@ -153,16 +150,17 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
public void Store(UUID agentId) public void Store(UUID agentId)
{ {
} }
public void UpdateMeshAvatar(UUID agentId) public void UpdateMeshAvatar(UUID agentId)
{ {
} }
public void Store(UUID agentId, WearableCacheItem[] data) public void Store(UUID agentId, WearableCacheItem[] data)
{ {
if (m_URL == String.Empty) if (m_URL == String.Empty)
return; return;
int numberWears = 0;
MemoryStream reqStream; MemoryStream reqStream;
using (MemoryStream bakeStream = new MemoryStream()) using (MemoryStream bakeStream = new MemoryStream())
@ -172,15 +170,16 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
for (int i = 0; i < data.Length; i++) for (int i = 0; i < data.Length; i++)
{ {
if (data[i] != null) if (data[i] != null && data[i].TextureAsset != null)
{ {
bakeWriter.WriteStartElement(String.Empty, "BakedTexture", String.Empty); bakeWriter.WriteStartElement(String.Empty, "BakedTexture", String.Empty);
bakeWriter.WriteAttributeString(String.Empty, "TextureIndex", String.Empty, data[i].TextureIndex.ToString()); bakeWriter.WriteAttributeString(String.Empty, "TextureIndex", String.Empty, data[i].TextureIndex.ToString());
bakeWriter.WriteAttributeString(String.Empty, "CacheId", String.Empty, data[i].CacheId.ToString()); bakeWriter.WriteAttributeString(String.Empty, "CacheId", String.Empty, data[i].CacheId.ToString());
if (data[i].TextureAsset != null) // if (data[i].TextureAsset != null)
m_serializer.Serialize(bakeWriter, data[i].TextureAsset); m_serializer.Serialize(bakeWriter, data[i].TextureAsset);
bakeWriter.WriteEndElement(); bakeWriter.WriteEndElement();
numberWears++;
} }
} }
@ -190,17 +189,18 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
reqStream = new MemoryStream(bakeStream.ToArray()); reqStream = new MemoryStream(bakeStream.ToArray());
} }
RestClient rc = new RestClient(m_URL);
rc.AddResourcePath("bakes");
rc.AddResourcePath(agentId.ToString());
rc.RequestMethod = "POST";
Util.FireAndForget( Util.FireAndForget(
delegate delegate
{ {
using(RestClient rc = new RestClient(m_URL))
{
rc.AddResourcePath("bakes");
rc.AddResourcePath(agentId.ToString());
rc.RequestMethod = "POST";
rc.Request(reqStream, m_Auth); rc.Request(reqStream, m_Auth);
m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", data.Length, agentId); m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", numberWears, agentId);
}
}, null, "XBakesModule.Store" }, null, "XBakesModule.Store"
); );
} }