public void LLUUIDs() { // Creation LLUUID a = new LLUUID(); byte[] bytes = a.GetBytes(); for (int i = 0; i < 16; i++) { Assert.IsTrue(bytes[i] == 0x00); } // Comparison a = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF }, 0); LLUUID b = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0); Assert.IsTrue(a == b, "LLUUID comparison operator failed, " + a.ToString() + " should equal " + b.ToString()); // From string a = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0); string zeroonetwo = "00010203-0405-0607-0809-0a0b0c0d0e0f"; b = new LLUUID(zeroonetwo); Assert.IsTrue(a == b, "LLUUID hyphenated string constructor failed, should have " + a.ToString() + " but we got " + b.ToString()); // ToString() string one = a.ToString(); string two = b.ToString(); Assert.IsTrue(a == b); one = a.ToString(); two = b.ToString(); Assert.IsTrue(a == b); Assert.IsTrue(a == zeroonetwo); // TODO: CRC test }
public string VoiceAccountFromUUID(LLUUID id) { string result = "x" + Convert.ToBase64String(id.GetBytes()); return(result.Replace('+', '-').Replace('/', '_')); }
public override byte[] AsBinary() { return(value.GetBytes()); }
public byte[] ToBytes() { int i = 0; byte[] bytes = new byte[126 + Texture.Length]; Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; bytes[i++] = this.PCode; bytes[i++] = (byte)(this.PathBegin % 256); bytes[i++] = (byte)((this.PathBegin >> 8) % 256); bytes[i++] = (byte)(this.PathEnd % 256); bytes[i++] = (byte)((this.PathEnd >> 8) % 256); bytes[i++] = this.PathScaleX; bytes[i++] = this.PathScaleY; bytes[i++] = this.PathShearX; bytes[i++] = this.PathShearY; bytes[i++] = (byte)this.PathSkew; bytes[i++] = (byte)(this.ProfileBegin % 256); bytes[i++] = (byte)((this.ProfileBegin >> 8) % 256); bytes[i++] = (byte)(this.ProfileEnd % 256); bytes[i++] = (byte)((this.ProfileEnd >> 8) % 256); Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; bytes[i++] = this.PathCurve; bytes[i++] = this.ProfileCurve; bytes[i++] = (byte)(ParentID % 256); bytes[i++] = (byte)((ParentID >> 8) % 256); bytes[i++] = (byte)((ParentID >> 16) % 256); bytes[i++] = (byte)((ParentID >> 24) % 256); bytes[i++] = (byte)(this.ProfileHollow % 256); bytes[i++] = (byte)((this.ProfileHollow >> 8) % 256); bytes[i++] = ((byte)this.PathRadiusOffset); bytes[i++] = this.PathRevolutions; bytes[i++] = ((byte)this.PathTaperX); bytes[i++] = ((byte)this.PathTaperY); bytes[i++] = ((byte)this.PathTwist); bytes[i++] = ((byte)this.PathTwistBegin); bytes[i++] = (byte)(Texture.Length % 256); bytes[i++] = (byte)((Texture.Length >> 8) % 256); Array.Copy(Texture, 0, bytes, i, Texture.Length); i += Texture.Length; bytes[i++] = (byte)(this.CreationDate % 256); bytes[i++] = (byte)((this.CreationDate >> 8) % 256); bytes[i++] = (byte)((this.CreationDate >> 16) % 256); bytes[i++] = (byte)((this.CreationDate >> 24) % 256); bytes[i++] = (byte)(this.OwnerMask % 256); bytes[i++] = (byte)((this.OwnerMask >> 8) % 256); bytes[i++] = (byte)((this.OwnerMask >> 16) % 256); bytes[i++] = (byte)((this.OwnerMask >> 24) % 256); bytes[i++] = (byte)(this.NextOwnerMask % 256); bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256); bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256); bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256); bytes[i++] = (byte)(this.GroupMask % 256); bytes[i++] = (byte)((this.GroupMask >> 8) % 256); bytes[i++] = (byte)((this.GroupMask >> 16) % 256); bytes[i++] = (byte)((this.GroupMask >> 24) % 256); bytes[i++] = (byte)(this.EveryoneMask % 256); bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256); bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256); bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256); bytes[i++] = (byte)(this.BaseMask % 256); bytes[i++] = (byte)((this.BaseMask >> 8) % 256); bytes[i++] = (byte)((this.BaseMask >> 16) % 256); bytes[i++] = (byte)((this.BaseMask >> 24) % 256); Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12; if (this.Rotation == new LLQuaternion(0, 0, 0, 0)) { this.Rotation = new LLQuaternion(0, 1, 0, 0); } Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12; bytes[i++] = (byte)(this.LocalID % 256); bytes[i++] = (byte)((this.LocalID >> 8) % 256); bytes[i++] = (byte)((this.LocalID >> 16) % 256); bytes[i++] = (byte)((this.LocalID >> 24) % 256); Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16; return(bytes); }