Client DC 2 seconds after CharacterInfo Packet Sent

03/24/2011 22:32 _DreadNought_#1
Hey guys,
Working with 5165 here(custom source)

I'm having a few probs with this, My Client seem to Disconnect about 2 seconds after my CharacterInfo packet is sent.

It's called by this void
Code:
public static void Login(byte[] Packet, GameClient Client)
        {
            LoginPacket Login = new LoginPacket();
            Login.Deserialize(Packet);
            Accounts Acc = null;
            AuthClient AC = null;
            Console.WriteLine(Login.Identifier);
            if (Kernel.PendingConnections.ContainsKey(Login.Identifier))
            {
                Kernel.PendingConnections.TryGetValue(Login.Identifier, out AC);
                Console.WriteLine(Login.Identifier);
                Kernel.PendingConnections.Remove(Login.Identifier);
                Acc = AC.Info;
                if (Acc != null)
                {
                    string ResponseMessage = "";
                    Client.Info = Acc;
                    if (Client.Info.EntityID == 0)
                        Client.Send(Messages.NEW_ROLE);
                    else
                    {
                        Client.Send(Messages.ANSWER_OK);
                        ResponseMessage = "ANSWER_OK";
                    }
                    if (ResponseMessage == "ANSWER_OK")
                    {
                        if (Kernel.ClientPool.ContainsKey(Client.Entity.UID))
                        {
                            GameClient Fucked = Server.GetCharByUID(Client.Entity.UID);
                            Fucked.Disconnect();
                        }
                        Characters.LoadCharacter(Client);
                        Kernel.ClientPool.Add(Client.Entity.UID, Client);
                        CharacterInfo ci = new CharacterInfo(Client);


                        (HERE!!!!!!!)     Client.Send(ci.ToArray());


                        Client.Info.IP = Client._socket.RemoteEndPoint.ToString().Split(' ')[0].ToString();
                        Client.Info.UpdateEntireAccount();
                        Console.WriteLine("Account: {0} && Character: {1} has logged in!", Client.Info.Username, Client.Entity.Name);
                    }
                }
            }
        }
And the characterInfo packet is as follows:
Code:
using System;
using Painless.Networking;
using ProjectD.Game;

namespace ProjectD.Packet_Processor.Structures
{
    public class CharacterInfo : PacketWriter, ProjectD.Core.Interfaces.iPacket
    {
        GameClient client;
        public CharacterInfo(GameClient _client)
        {
            client = _client;
        }
        public void Deserialize(byte[] buffer)
        {
            throw new NotImplementedException();
        }
        public byte[] ToArray()
        {
            byte[] Packet = new byte[98 + client.Entity.Spouse.Length + client.Entity.Name.Length];
            WriteUInt16((ushort)(Packet.Length - 8), 0, Packet);
            WriteUInt16(0x3ee, 2, Packet);
            WriteUInt32(client.Entity.UID, 4, Packet);
            WriteUInt32(client.Entity.Mesh, 8, Packet);
            WriteUInt16(client.Entity.Hairstyle, 12, Packet);
            WriteUInt32(client.Entity.Money, 14, Packet);
            WriteUInt32(client.Entity.ConquerPoints, 18, Packet);
            WriteUInt64(0/*Experience*/, 22, Packet);
            WriteUInt16(client.Entity.Strength, 50, Packet);
            WriteUInt16(client.Entity.Agility, 52, Packet);
            WriteUInt16(client.Entity.Vitality, 54, Packet);
            WriteUInt16(client.Entity.Spirit, 56, Packet);
            WriteUInt16(0/*Atributes*/, 58, Packet);
            WriteUInt16((ushort)client.Entity.Hitpoints, 60, Packet);
            WriteUInt16(client.Entity.Mana, 62, Packet);
            WriteUInt16(0/*PKpoint*/, 64, Packet);
            Packet[66] = (byte)client.Entity.Level;
            Packet[67] = client.Entity.Class;
            Packet[69] = client.Entity.Reborn;
            Packet[70] = 1;
            WriteUInt32(0/*QuizPoints*/, 71, Packet);
            Packet[87] = 2;
            WriteStringWithLength(client.Entity.Name, 88, Packet);
            WriteStringWithLength(client.Entity.Spouse, 89 + Packet[88], Packet);
            return Packet;
        }
        public void Send(GameClient client)
        {
            client.Send(ToArray());
        }
    }
}
But it still disconnects? Any Thoughts? Totally stuck with this one.
03/24/2011 23:29 Arco.#2
Why don't you try/catch.

try
{Client.Send(ci.ToArray());}
catch(Exception E)
{Console.WriteLine(E.Tostring());}

See if anything happens there?
03/24/2011 23:51 _Emme_#3
Correct me if I'm wrong but aren't you supposed to add the login status with the length?

Anyhow, make sure your entity isn't null, and as Arco said, put a try/catch and write us the exception and we'll look into it.
03/25/2011 01:28 Korvacs#4
I assume your Send function adds "TQServer" to the end of that packet?
03/25/2011 17:09 _DreadNought_#5
Nothing caught in exceptions.

@korv, Yea.

The GameClient nor the Entity is null.
03/25/2011 19:11 Arco.#6
Quote:
Originally Posted by _DreadNought_ View Post
Nothing caught in exceptions.

@korv, Yea.

The GameClient nor the Entity is null.
Breakpoint Client.Send(ci.ToArray()); and step into it, keep doing that until client disconnection.
03/25/2011 19:59 _DreadNought_#7
The exact line the disconnects the client is:
_socket.Send(_buffer);

Not that we couldnt of guessed that.

will try seeing if theres any exceptions there.

#edit
No socket exceptions either.

The fuck? :/
03/26/2011 03:12 Arco.#8
Quote:
Originally Posted by _DreadNought_ View Post
The exact line the disconnects the client is:
_socket.Send(_buffer);

Not that we couldnt of guessed that.

will try seeing if theres any exceptions there.

#edit
No socket exceptions either.

The fuck? :/
You're adding the extra 8 bytes towards the length AND adding TQ server to it as well?
03/26/2011 09:02 Spirited42#9
Put a breakpoint at "Client.Info.IP = Client._socket.RemoteEndPoint.ToString().Split(' ')[0].ToString();". Does it ever hit that? If it does, the character info packet isn't the problem. It's being sent correctly. You might be missing something else. And how did you add me on your iPod? o.O
03/26/2011 11:09 _DreadNought_#10
Yes it is being sent correctly and yes its hitting the IP thing Fang.

However the character info wasn't right but it wasn't it's fault.

The character UID does not appear to be being stored correctly therefor the UID of the character is null not the character itsself.

Thanks for the trys guys.

#Requesting a close