Blaze.Server.TdfEncoder.WriteLabel C# (CSharp) Method

WriteLabel() private method

Encodes a label to tag.
private WriteLabel ( string label ) : void
label string Label to write.
return void
        private void WriteLabel(string label)
        {
            // by Pedro Martins
            int tag = 0;

            for (int i = 0; i < label.Length; i++)
            {
                tag |= (0x20 | (label[i] & 0x1F)) << (3 - i) * 6;
            }

            uint sTag = Utils.SwapBytes(Convert.ToUInt32(tag)) >> 8;

            // hackhackhack
            // FIXME
            MemoryStream hehStream = new MemoryStream();
            BinaryWriter hehWriter = new BinaryWriter(hehStream);
            hehWriter.Write(sTag);

            _stream.Write(hehStream.GetBuffer().Take(3).ToArray(), 0, 3);
        }