mantis 8651: try to improve notecards HG sharing ( not tested)

master
UbitUmarov 2020-02-06 19:16:23 +00:00
parent 7a79a6ddfe
commit 8060d132b9
2 changed files with 81 additions and 1 deletions

View File

@ -29,6 +29,7 @@ using OpenMetaverse;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
namespace OpenSim.Framework
{
@ -795,5 +796,68 @@ namespace OpenSim.Framework
item.ID = UUID.Random();
return item;
}
public static List<UUID> GetEmbeddedAssetIDs(byte[] data)
{
if (data == null || data.Length < 60)
return null;
string note = Util.UTF8.GetString(data);
if (String.IsNullOrWhiteSpace(note))
return null;
// waste some time checking rigid versions
string tmpStr = note.Substring(0, 21);
if (!tmpStr.Equals("Linden text version 2"))
return null;
tmpStr = note.Substring(24, 25);
if (!tmpStr.Equals("LLEmbeddedItems version 1"))
return null;
tmpStr = note.Substring(52,5);
if (!tmpStr.Equals("count"))
return null;
int limit = note.Length - 57 - 2;
if (limit > 8)
limit = 8;
int indx = note.IndexOfAny(seps, 57, limit);
if(indx < 0)
return null;
if (!int.TryParse(note.Substring(57, indx - 57), out int count))
return null;
List<UUID> ids = new List<UUID>();
while(count > 0)
{
string valuestr;
UUID assetID = UUID.Zero;
indx = note.IndexOf('}'); // skip to end of permissions
indx = getField(note, indx, "asset_id", false, out valuestr);
if (indx < 0)
{
indx = getField(note, indx, "shadow_id", false, out valuestr);
if (indx < 0)
return null;
if (!UUID.TryParse(valuestr, out assetID))
return null;
assetID = deMoronize(assetID);
}
else
{
if (!UUID.TryParse(valuestr, out assetID))
return null;
}
ids.Add(assetID);
--count;
}
if(ids.Count == 0)
return null;
return ids;
}
}
}

View File

@ -364,7 +364,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else if ((sbyte)AssetType.Notecard == assetType)
{
RecordTextEmbeddedAssetUuids(assetBase);
RecordNoteCardEmbeddedAssetUuids(assetBase);
}
else if ((sbyte)AssetType.LSLText == assetType)
{
@ -546,6 +546,22 @@ namespace OpenSim.Region.Framework.Scenes
}
}
private void RecordNoteCardEmbeddedAssetUuids(AssetBase textAsset)
{
List<UUID> ids = SLUtil.GetEmbeddedAssetIDs(textAsset.Data);
if(ids == null)
return;
for(int i = 0; i < ids.Count; ++i)
{
if (ids[i] == UUID.Zero)
continue;
if (!UncertainAssetsUUIDs.Contains(ids[i]))
UncertainAssetsUUIDs.Add(ids[i]);
AddForInspection(ids[i]);
}
}
/// <summary>
/// Record the uuids referenced by the given wearable asset
/// </summary>