Server.Network.PacketWriter.WriteAsciiFixed C# (CSharp) Méthode

WriteAsciiFixed() public méthode

Writes a fixed-length ASCII-encoded string value to the underlying stream. To fit (size), the string content is either truncated or padded with null characters.
public WriteAsciiFixed ( string value, int size ) : void
value string
size int
Résultat void
		public void WriteAsciiFixed( string value, int size )
		{
			if ( value == null )
			{
				Console.WriteLine( "Network: Attempted to WriteAsciiFixed() with null value" );
				value = String.Empty;
			}

			int length = value.Length;

			m_Stream.SetLength( m_Stream.Length + size );

			if ( length >= size )
				m_Stream.Position += Encoding.ASCII.GetBytes( value, 0, size, m_Stream.GetBuffer(), (int)m_Stream.Position );
			else
			{
				Encoding.ASCII.GetBytes( value, 0, length, m_Stream.GetBuffer(), (int)m_Stream.Position );
				m_Stream.Position += size;
			}

			/*byte[] buffer = Encoding.ASCII.GetBytes( value );

			if ( buffer.Length >= size )
			{
				m_Stream.Write( buffer, 0, size );
			}
			else
			{
				m_Stream.Write( buffer, 0, buffer.Length );
				Fill( size - buffer.Length );
			}*/
		}