change DBGSuids a bit, let it return uuid.zero in more fail cases, not killing region

0.9.1.0-post-fixes
UbitUmarov 2018-12-29 13:29:39 +00:00
parent 4d3d9998a9
commit 7679617d52
1 changed files with 14 additions and 13 deletions

View File

@ -47,24 +47,25 @@ namespace OpenSim.Data
if ((id == null) || (id == DBNull.Value)) if ((id == null) || (id == DBNull.Value))
return UUID.Zero; return UUID.Zero;
if (id.GetType() == typeof(Guid)) Type idtype = id.GetType();
if (idtype == typeof(Guid))
return new UUID((Guid)id); return new UUID((Guid)id);
if (id.GetType() == typeof(byte[])) if (id.GetType() == typeof(string))
{ {
if (((byte[])id).Length == 0) Guid gg;
if (Guid.TryParse((string)id, out gg))
return new UUID(gg);
return UUID.Zero; return UUID.Zero;
else if (((byte[])id).Length == 16)
return new UUID((byte[])id, 0);
}
else if (id.GetType() == typeof(string))
{
if (((string)id).Length == 0)
return UUID.Zero;
else if (((string)id).Length == 36)
return new UUID((string)id);
} }
if (idtype == typeof(byte[]))
{
if (((byte[])id).Length < 16)
return UUID.Zero;
return new UUID((byte[])id, 0);
}
throw new Exception("Failed to convert db value to UUID: " + id.ToString()); throw new Exception("Failed to convert db value to UUID: " + id.ToString());
} }
} }