All pastes #913511 Raw Edit

tobz

public text v1 · immutable
·published 2008-02-22 03:24 UTC
rendered paste body
#region Usings...
using System;
using System.Collections.Generic;
using System.Text;
using Cell.Core;
using LoginEngine.Packets;
using LoginEngine.QueryBase;
using LoginEngine;
using System.IO;
#endregion

namespace LoginEngine.Packets
{
	public class CharacterEntry
	{
		private static byte[] s_firstRandomSegment;
		private static byte[] s_secondRandomSegment;
		private static byte[] s_thirdRandomSegment;
		private static byte[] s_fourthRandomSegment;
		private static byte[] s_fifthRandomSegment;
		private static byte[] s_sixthRandomSegment;

		private byte[] m_rawCharacterData;

		static CharacterEntry()
		{
			s_firstRandomSegment = new byte[] { 0xDF, 0xDF, 0x00, 0x01, 0x00, 0x01, 0x00, 0x90,
												0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x61, 0x5B, 
												0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x01, 
												0x00, 0x00, 0x00, 0x04 };
			s_secondRandomSegment = new byte[] { 0x61, 0x00, 0x00, 0xC7, 0x9D };
			s_thirdRandomSegment = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
												0x00, 0x00, 0x9C, 0x50, 0x00, 0x67, 0x77, 0x6C, 
												0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04 };
			s_fourthRandomSegment = new byte[] { 0x00, 0x00, 0x00, 0x0B };
			s_fifthRandomSegment = new byte[] { 0x00, 0x00, 0x00, 0x03 };
			s_sixthRandomSegment = new byte[] { 0x00, 0x00, 0x00, 0x0C, 0x61, 0x72, 0x65, 0x61, 
												0x20, 0x75, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 
												0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
												0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
												0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 
												0x00, 0x00, 0x00, 0x03, 0x64, 0x37, 0x38 };
		}

		public CharacterEntry()
		{
		}

		public string Name
		{
			get;
			set;
		}

		public uint ID
		{
			get;
			set;
		}

		public uint Level
		{
			get;
			set;
		}

		public uint Profession
		{
			get;
			set;
		}

		public uint Breed
		{
			get;
			set;
		}

		public uint ZoneID
		{
			get;
			set;
		}

		public byte[] RawData
		{
			get
			{
				if (m_rawCharacterData == null)
				{
					GenerateCharacterData();
				}

				return m_rawCharacterData;
			}
		}

		private void GenerateCharacterData()
		{
			MemoryStream memStream = new MemoryStream(149);

			using (BinaryWriter writer = new BinaryWriter(memStream))
			{
				writer.Write(s_firstRandomSegment);
				//This is a Random Acoount Seed ID...
				writer.Write(ID);

				writer.Write(s_secondRandomSegment);

				//This Tells the Client the Zone ID where you are at..
				writer.Write(ZoneId);

				writer.Write(s_thirdRandomSegment);

				//this is a Random Seed ID Again... its the same as the first one...
				writer.Write(ID);

				writer.Write(s_fourthRandomSegment);

				//Character Name send to the Client...
				writer.Write(Encoding.ASCII.GetBytes(Name));

				//Character Breed send to the Client...
				writer.Write(Breed);

				writer.Write(s_fifthRandomSegment);

				//Character Profession send to the Client...
				writer.Write(Profession);

				//Character Level send to the Client...
				writer.Write(Level);

				writer.Write(s_sixthRandomSegment);

				m_rawCharacterData = memStream.ToArray();
			}
		}
	}
}