Character Info

07/20/2011 18:25 zTek#1
So I'm trying to update hellmouth to 5509, however I am having some problems. When I attempt to login, it gets stuck at "logging into game server". I assume something is wrong with char info packet.

Can someone take a look and see if they see anything wrong?
Code:
 public static byte[] SpawnChar(Client C)
        {
            int Len = 8 + 114+ C.Name.Length + C.Spouse.Length;
            int Offset = 0;
            byte[] Packet = new byte[Len];
            try
            { 
                WriteUInt16(Convert.ToUInt16(Len - 8), 0, Packet);
                WriteUInt16(1006, 2, Packet);
                WriteUInt32(C.UID, 4, Packet);
                WriteUInt32(C.Mesh, 10, Packet);
                WriteUInt16(C.Hair, 14, Packet);
                WriteUInt32(C.Money, 16, Packet);
                WriteUInt32(C.CP, 20, Packet);
                WriteUInt64(C.Exp, 24, Packet);   
                WriteUInt16(C.Str, 52, Packet);
                WriteUInt16(C.Agi, 54, Packet);
                WriteUInt16(C.Vit, 56, Packet);
                WriteUInt16(C.Spi, 58, Packet);
                WriteUInt16(C.Stats, 60, Packet);
                WriteUInt16(C.Hp, 62, Packet);
                WriteUInt16(C.Mana, 64, Packet);
                WriteUInt16(C.Pk, 66, Packet);
                WriteByte(C.Level, 68, Packet);
                WriteByte(C.Job, 69, Packet);//job
                WriteByte(0, 70, Packet);//reb  
                WriteByte(1, 71, Packet);//show name
                WriteUInt32(1, 72, Packet);//quiz
                //WriteUInt32(11, 74, Packet);//enlighten
                //WriteUInt16(6, 78, Packet);
                //WriteUInt32(8040, 80, Packet); 
                WriteByte(3, 110, Packet);
                WriteByte((byte)C.Name.Length, 111, Packet);
                //WriteString(C.Name, 110, Packet);
                Offset += C.Name.Length;
                WriteByte(0, 112 + Offset, Packet);
                WriteByte((byte)C.Spouse.Length, 113 + Offset, Packet);
                WriteString(C.Spouse, 114 + Offset, Packet);
            }
            catch (Exception P)
            { Console.WriteLine(P); } 
            return Packet;
        }
Thanks
07/20/2011 18:51 Kiyono#2
I think the login request packet thingy changed ID a while ago so that might be it.
07/20/2011 20:31 Spirited#3
I keep telling you! Blockpoint test! That's how you're supposed to debug everything in C#! If you still don't know it from watching me do it over TV - then look it up on google. You will never ask another question here again if you can blockpoint things.
07/20/2011 20:41 _DreadNought_#4
Code:
            byte[] Packet = new byte[122 + client.Char.Spouse.Length + client.Char.Name.Length];
            WriteUInt16((ushort)(Packet.Length - 8), 0, Packet);
            WriteUInt16(1006, 2, Packet);
            WriteUInt32(client.Char.UID, 4, Packet);
            WriteUInt32(client.Char.Mesh, 10, Packet);
            WriteUInt16(client.Char.HairStyle, 14, Packet);
            WriteUInt32(client.Char.Money, 16, Packet);
            WriteUInt32(client.Char.ConquerPoints, 20, Packet);
            WriteUInt64(client.Char.Experience, 24, Packet);
            WriteUInt16(client.Char.Strength, 52, Packet);
            WriteUInt16(client.Char.Agility, 54, Packet);
            WriteUInt16(client.Char.Vitality, 56, Packet);
            WriteUInt16(client.Char.Spirit, 58, Packet);
            WriteUInt16(client.Char.Atributes, 60, Packet);
            WriteUInt16((ushort)client.Char.Hitpoints, 62, Packet);
            WriteUInt16(client.Char.Mana, 64, Packet);
            WriteUInt16(client.Char.PKPoints, 66, Packet);
            Packet[68] = (byte)client.Char.Level;
            Packet[69] = client.Char.Class;
            Packet[70] = client.Char.FirstRebornClass; /*Previous Reborn: shows up when u highlight the class in the status window*/
            Packet[71] = client.Char.SecondRebornClass;
            Packet[72] = client.Char.Reborn;
            //WriteUInt32(client.Char.QuizPoints, 75, Packet);
            //WriteUInt16(0/*Enlight points*/, 77, Packet);
            //WriteUInt32(500000, 89, Packet);
            Packet[110] = 0x03;
            //WriteByte(1, 108, Packet);//Correct

            Packet[111] = (byte)client.Char.Name.Length;
            WriteString(client.Char.Name, 112, Packet);
            WriteByte((byte)client.Char.Spouse.Length, 113 + client.Char.Name.Length, Packet);
            WriteString(client.Char.Spouse, 114 + client.Char.Name.Length, Packet);
            return Packet;
07/20/2011 21:20 Lateralus#5
Quote:
Originally Posted by Fаng View Post
I keep telling you! Blockpoint test! That's how you're supposed to debug everything in C#! If you still don't know it from watching me do it over TV - then look it up on google. You will never ask another question here again if you can blockpoint things.
Haha, blockpoint.

If you search google for that, it's probably gonna say "Did you mean: breakpoint?".
07/20/2011 22:22 Spirited#6
Quote:
Originally Posted by Lateralus View Post
Haha, blockpoint.

If you search google for that, it's probably gonna say "Did you mean: breakpoint?".
Yes. I mean breakpoint. I was working on refining my cryptography and I was seeing "block" everywhere. ><
07/20/2011 23:57 BaussHacker#7
Why does nobody using structs and operators to return a byte array?
PHP Code:
    public unsafe struct PacketName
    
{
        
//Packet fields here
        
public int PacketLength;

        public static 
implicit operator byte[](PacketName packet)
        {
            
byte[] Packet = new byte[packet.PacketLength];
            
fixed (bytepointer Packet)
            {
            }
            return 
Packet;
        }
    } 
07/21/2011 00:15 Lateralus#8
Quote:
Originally Posted by BaussHacker View Post
Why does nobody using structs and operators to return a byte array?
PHP Code:
    public unsafe struct PacketName
    
{
        
//Packet fields here
        
public int PacketLength;

        public static 
implicit operator byte[](PacketName packet)
        {
            
byte[] Packet = new byte[packet.PacketLength];
            
fixed (bytepointer Packet)
            {
            }
            return 
Packet;
        }
    } 
Code:
/// <summary>
/// 0x3F6/1103 (server->client)
/// The SkillPacket is sent on login and when a player learns or levels a skill/spell.
/// </summary>
public class SkillPacket
{
	#region Packet Accessor
	/// <summary>
	/// A buffer to hold the packet.
	/// </summary>
	private byte[] data;

	/// <summary>
	/// Allows you to access the packet through the class.
	/// </summary>
	/// <param name="packetStructure">The packet structure.</param>
	/// <returns>The actual packet data.</returns>
	public static implicit operator byte[](SkillPacket packetStructure)
	{
		return packetStructure.data;
	}
	#endregion
	#region Constructors
	/// <summary>
	/// Default constructor. For creating packets - initializes the packet buffer and sets the size and type.
	/// </summary>
	public SkillPacket()
	{
		data = new byte[size];
		PBuilder.Write(size, 0, data);
		PBuilder.Write(type, 2, data);
	}

	/// <summary>
	/// Parameterized constructor. For processing packets - initializes the packet buffer with the passed packet.
	/// </summary>
	/// <param name="d">The packet to process.</param>
	public SkillPacket(byte[] d)
	{
		data = new byte[d.Length];
		d.CopyTo(data, 0);
	}
	#endregion

	/// <summary>
	/// Offset - 0.
	/// Value - 12.
	/// </summary>
	private const ushort size = 0x0C;

	/// <summary>
	/// Offset - 2.
	/// Value - 1103.
	/// </summary>
	private const ushort type = 0x44F;

	/// <summary>
	/// Amount of experience.
	/// Offset - 4.
	/// </summary>
	public uint Experience
	{
		get { return BitConverter.ToUInt32(data, 4); }
		set { PBuilder.Write(value, 4, data); }
	}

	/// <summary>
	/// The ID of the skill.
	/// Offset - 8.
	/// </summary>
	public SpellID ID
	{
		get { return (SpellID)BitConverter.ToUInt16(data, 8); }
		set { PBuilder.Write((ushort)value, 8, data); }
	}

	/// <summary>
	/// The level of the skill.
	/// Offset - 10.
	/// </summary>
	public ushort Level
	{
		get { return BitConverter.ToUInt16(data, 10); }
		set { PBuilder.Write(value, 10, data); }
	}
}
That's the way I structure packets. Easy to use, fast, and beautifully organized.
07/21/2011 00:31 Korvacs#9
Quote:
Originally Posted by BaussHacker View Post
Why does nobody using structs and operators to return a byte array?
PHP Code:
    public unsafe struct PacketName
    
{
        
//Packet fields here
        
public int PacketLength;

        public static 
implicit operator byte[](PacketName packet)
        {
            
byte[] Packet = new byte[packet.PacketLength];
            
fixed (bytepointer Packet)
            {
            }
            return 
Packet;
        }
    } 
Or better yet just a struct and then send that...
07/21/2011 00:32 BaussHacker#10
Quote:
Originally Posted by Lateralus View Post
Code:
/// <summary>
/// 0x3F6/1103 (server->client)
/// The SkillPacket is sent on login and when a player learns or levels a skill/spell.
/// </summary>
public class SkillPacket
{
	#region Packet Accessor
	/// <summary>
	/// A buffer to hold the packet.
	/// </summary>
	private byte[] data;

	/// <summary>
	/// Allows you to access the packet through the class.
	/// </summary>
	/// <param name="packetStructure">The packet structure.</param>
	/// <returns>The actual packet data.</returns>
	public static implicit operator byte[](SkillPacket packetStructure)
	{
		return packetStructure.data;
	}
	#endregion
	#region Constructors
	/// <summary>
	/// Default constructor. For creating packets - initializes the packet buffer and sets the size and type.
	/// </summary>
	public SkillPacket()
	{
		data = new byte[size];
		PBuilder.Write(size, 0, data);
		PBuilder.Write(type, 2, data);
	}

	/// <summary>
	/// Parameterized constructor. For processing packets - initializes the packet buffer with the passed packet.
	/// </summary>
	/// <param name="d">The packet to process.</param>
	public SkillPacket(byte[] d)
	{
		data = new byte[d.Length];
		d.CopyTo(data, 0);
	}
	#endregion

	/// <summary>
	/// Offset - 0.
	/// Value - 12.
	/// </summary>
	private const ushort size = 0x0C;

	/// <summary>
	/// Offset - 2.
	/// Value - 1103.
	/// </summary>
	private const ushort type = 0x44F;

	/// <summary>
	/// Amount of experience.
	/// Offset - 4.
	/// </summary>
	public uint Experience
	{
		get { return BitConverter.ToUInt32(data, 4); }
		set { PBuilder.Write(value, 4, data); }
	}

	/// <summary>
	/// The ID of the skill.
	/// Offset - 8.
	/// </summary>
	public SpellID ID
	{
		get { return (SpellID)BitConverter.ToUInt16(data, 8); }
		set { PBuilder.Write((ushort)value, 8, data); }
	}

	/// <summary>
	/// The level of the skill.
	/// Offset - 10.
	/// </summary>
	public ushort Level
	{
		get { return BitConverter.ToUInt16(data, 10); }
		set { PBuilder.Write(value, 10, data); }
	}
}
That's the way I structure packets. Easy to use, fast, and beautifully organized.
Yes yes yes. :bandit: