diff --git a/OpenSim/Framework/LLSDxmlEncode.cs b/OpenSim/Framework/LLSDxmlEncode.cs index 0f020932a1..d3fce28607 100644 --- a/OpenSim/Framework/LLSDxmlEncode.cs +++ b/OpenSim/Framework/LLSDxmlEncode.cs @@ -51,9 +51,9 @@ namespace OpenSim.Framework public const string LLSDEmpty = ""; // got tired of creating a stringbuilder all the time; - public static StringBuilder Start(int size = 256, bool addxmlversion = false) + public static StringBuilder Start(int size = 4096, bool addxmlversion = false) { - StringBuilder sb = new StringBuilder(size); + StringBuilder sb = osStringBuilderCache.Acquire(size); if(addxmlversion) sb.Append(""); // legacy llsd xml name still valid else @@ -69,13 +69,13 @@ namespace OpenSim.Framework public static string End(StringBuilder sb) { sb.Append(""); - return sb.ToString(); + return osStringBuilderCache.GetStringAndRelease(sb); } public static byte[] EndToNBBytes(StringBuilder sb) { sb.Append(""); - return Util.UTF8NBGetbytes(sb.ToString()); + return Util.UTF8NBGetbytes(osStringBuilderCache.GetStringAndRelease(sb)); } // map == a list of key value pairs @@ -316,7 +316,7 @@ namespace OpenSim.Framework else { sb.Append(""); - EscapeToXML(e.ToString(), sb); + EscapeToXML(e.ToString(), sb); sb.Append(""); } } @@ -338,7 +338,7 @@ namespace OpenSim.Framework if(String.IsNullOrEmpty(e)) return; - sb.Append(e); + sb.Append(e); } public static void AddElem(Uri e, StringBuilder sb) @@ -764,11 +764,8 @@ namespace OpenSim.Framework public static void EscapeToXML(string s, StringBuilder sb) { - int i; char c; - int len = s.Length; - - for (i = 0; i < len; i++) + for (int i = 0; i < s.Length; ++i) { c = s[i]; switch (c) diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index 065822a259..cc30494d60 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -211,8 +211,8 @@ namespace OpenSim.Framework {"animatn", AssetType.Animation}, {"gesture", AssetType.Gesture}, {"simstate", AssetType.Simstate}, - {"mesh", AssetType.Mesh} -// "settings", AssetType.Settings} + {"mesh", AssetType.Mesh}, + {"settings", AssetType.Settings} }; private static Dictionary name2Inventory = new Dictionary() { @@ -237,7 +237,7 @@ namespace OpenSim.Framework {"outfit", FolderType.Outfit}, {"myoutfits", FolderType.MyOutfits}, {"mesh", FolderType.Mesh}, -// "settings", FolderType.Settings}, + {"settings", FolderType.Settings}, {"suitcase", FolderType.Suitcase} }; diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index a0a3cfc76e..121d3d385d 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -432,7 +432,6 @@ namespace OpenSim.Region.Framework.Scenes for(int j = 0; j < items.Count; ++j) { TaskInventoryItem tii = items[j]; - items[j] = null; // gc is stupid AddForInspection(tii.AssetID, (sbyte)tii.Type); } @@ -521,7 +520,6 @@ namespace OpenSim.Region.Framework.Scenes return; } - // avoid infinite loops if (GatheredUuids.ContainsKey(assetUuid)) return; @@ -777,21 +775,83 @@ namespace OpenSim.Region.Framework.Scenes } } + private static byte[] wearableSeps = new byte[]{(byte)' ', (byte)'\t'}; /// /// Record the uuids referenced by the given wearable asset /// - /// - private void RecordWearableAssetUuids(AssetBase assetBase) + /// + private void RecordWearableAssetUuids(AssetBase asset) { - //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); - AssetWearable wearableAsset = new AssetBodypart(assetBase.FullID, assetBase.Data); - wearableAsset.Decode(); + if (asset.Data == null || asset.Data.Length < 64) + return; + try + { + osUTF8 ostmp = new osUTF8(asset.Data); + if (!ostmp.SkipLine()) // version + return; + if (!ostmp.SkipLine()) // name + return; + if (!ostmp.SkipLine()) // description + return; + if (!ostmp.SkipLine()) + return; - //m_log.DebugFormat( - // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); + while(ostmp.ReadLine(out osUTF8 line)) + { + line.SelfTrim(wearableSeps); + osUTF8[] parts = line.Split(wearableSeps); + if(parts[0].Lenght == 0) + continue; + parts[0].SelfTrim(wearableSeps); + if(parts[0].ToString() == "textures") + { + if(parts[1].Lenght == 0) + return; + parts[1].SelfTrim(wearableSeps); + if(!int.TryParse(parts[1].ToString(), out int count) || count == 0) + return; + for(int i = 0; i < count; ++i) + { + if(!ostmp.ReadLine(out osUTF8 texline)) + return; + texline.SelfTrim(wearableSeps); + osUTF8[] texparts = texline.Split(wearableSeps); + if(texparts.Length <2 || texparts[1].Lenght < 36) + continue; + texparts[1].SelfTrim(wearableSeps); + if (UUID.TryParse(texparts[1].ToString(), out UUID id) && id != UUID.Zero) + GatheredUuids[id] = (sbyte)AssetType.Texture; + } + } + } + } + catch + { + } + } - foreach (UUID uuid in wearableAsset.Textures.Values) - GatheredUuids[uuid] = (sbyte)AssetType.Texture; + private int getxmlheader(osUTF8 data, out osUTF8 h) + { + h = data; + int st = -1; + while ((st = data.IndexOf('<')) >= 0) + { + break; + } + if (st < 0) + return -1; + ++st; + int ed = -1; + while ((ed = data.IndexOf('>')) >= 0) + { + break; + } + if (ed < 0) + return -1; + + h = data.osUTF8SubString(st, ed - st); + h.SelfTrim(); + return ed + 1; } /// @@ -850,8 +910,7 @@ namespace OpenSim.Region.Framework.Scenes /// private void RecordGestureAssetUuids(AssetBase gestureAsset) { - using (MemoryStream ms = new MemoryStream(gestureAsset.Data)) - using (StreamReader sr = new StreamReader(ms)) + using (StreamReader sr = new StreamReader(new MemoryStream(gestureAsset.Data))) { sr.ReadLine(); // Unknown (Version?) sr.ReadLine(); // Unknown