a few test changes

This commit is contained in:
UbitUmarov
2023-03-09 08:26:12 +00:00
parent eb57c75f00
commit b1f2a5b661
4 changed files with 62 additions and 4 deletions

View File

@@ -1182,6 +1182,20 @@ namespace OpenSim.Framework
return md5.ComputeHash(encoding.GetBytes(data));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static UUID ComputeASCIIMD5UUID(string data)
{
using MD5 md5 = MD5.Create();
byte[] bytes = md5.ComputeHash(Encoding.ASCII.GetBytes(data));
UUID uuid = new(bytes,2);
uuid.c &= 0x0fff;
uuid.c |= 0x3000;
uuid.d &= 0x3f;
uuid.d |= 0x80;
return uuid;
}
/// <summary>
/// Return an SHA1 hash
/// </summary>
@@ -1305,12 +1319,24 @@ namespace OpenSim.Framework
return ComputeSHA1UUID(Encoding.Default.GetBytes(src));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static UUID ComputeASCIISHA1UUID(string src)
{
return ComputeSHA1UUID(Encoding.ASCII.GetBytes(src));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static UUID ComputeSHA1UUID(byte[] src)
{
byte[] ret;
using (SHA1 sha = SHA1.Create())
ret = sha.ComputeHash(src);
return new UUID(ret, 2);
UUID uuid = new(ret, 2);
uuid.c &= 0x0fff;
uuid.c |= 0x5000;
uuid.d &= 0x3f;
uuid.d |= 0x80;
return uuid;
}
public static int fast_distance2d(int x, int y)

View File

@@ -2784,6 +2784,7 @@ namespace OpenSim.Region.ClientStack.Linden
pbs.RenderMaterials.entries[i].id = assetID;
}
}
sop.ParentGroup.HasGroupChanged = true;
sop.ScheduleFullUpdate();
}
httpResponse.StatusCode = (int)HttpStatusCode.OK;

View File

@@ -186,7 +186,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (folder is null || folder.Owner.NotEqual(remoteClient.AgentId))
return;
if (transactionID.IsNotZero() && assetType != (byte)AssetType.Settings)
if (transactionID.IsNotZero() &&
assetType != (byte)AssetType.Settings &&
assetType != (byte)AssetType.Material)
{
IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule;
if (agentTransactions is not null)
@@ -395,8 +397,22 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return UUID.Zero;
}
UUID mid = data is null ? Util.ComputeSHA1UUID(UUID.ZeroString) : Util.ComputeSHA1UUID(data);
// this may be bad
if (mid.Equals(item.AssetID))
return mid;
AssetBase matasset = new(mid, item.Name, (sbyte)item.AssetType, remoteClient.AgentId.ToString())
{
Description = item.Description,
Data = data ?? (new byte[1])
};
item.AssetID = matasset.FullID;
m_Scene.AssetService.Store(matasset);
m_Scene.InventoryService.UpdateItem(item);
remoteClient.SendAlertMessage("Material updated");
break;
return matasset.FullID;
}
}

View File

@@ -332,8 +332,23 @@ namespace OpenSim.Region.Framework.Scenes
return UUID.Zero;
}
UUID mid = data is null ? Util.ComputeSHA1UUID(UUID.ZeroString) : Util.ComputeSHA1UUID(data);
// this may be bad
if (mid.Equals(item.AssetID))
return mid;
AssetBase matasset = new(mid, item.Name, (sbyte)item.Type, avatarId.ToString())
{
Description = item.Description,
Data = data ?? (new byte[1])
};
item.AssetID = matasset.FullID;
AssetService.Store(matasset);
sop.Inventory.UpdateInventoryItem(item);
avatar.ControllingClient.SendAlertMessage("Material updated");
break;
return matasset.FullID;
}
}