Jumping Problem

09/11/2010 22:53 CptSky#16
The client send a jump packet...

Data + TQClient

You process the jump packet...

Data + TQClient

You broadcast the jump packet...

Data + TQClient (+ TQServer)

Make sure that all out-going packets don't have two seals and have the right one. A good solution is to add TQServer before sending the data and to remove TQClient before processing the data.
09/12/2010 00:05 ImFlamedCOD#17
.Arco

The problem is not in the packet processing of jumping. The problem most likely lies in your packet itself. Check the packets to be sure there correct.
09/12/2010 10:04 Ian*#18
Lets see your GetDistance function and your jump packet.
09/12/2010 12:04 Korvacs#19
Put a breakpoint in at the beginning of the Jump handler and step through untill the client bombs out. Which method does it crash on? Let us know.
09/12/2010 16:34 Arcо#20
See that's the thing though Jack, I can't find out where the client bombs cause it gets through the entire jump handler without any exception, it just dcs at the end.

@Ian
Code:
        public static short GetDistance(ushort X, ushort Y, ushort X2, ushort Y2)
        {
            return (short)Math.Max(Math.Abs(X - X2), Math.Abs(Y - Y2));
        }
09/12/2010 16:38 Korvacs#21
In that case, are you modifying the TQString at the end of the packets? That appears to be the only cause in that case.
09/12/2010 16:40 Arcо#22
Well if I wasn't sending the TQString, then wouldn't ALL mypackets be invalid? o.O
09/12/2010 16:44 Korvacs#23
Quote:
Originally Posted by .Arco View Post
Well if I wasn't sending the TQString, then wouldn't ALL mypackets be invalid? o.O
Yes, however the packets your sending this time are existing ones that require modifying not new ones.

I havent seen your send method so i cant know can i :p
09/12/2010 16:54 Arcо#24
My method for sending packets?
Well here you go.
Code:
        public void Send(IClassPacket Packet)
        {
            lock (this)
            {
                this.Socket.Send(Packet.Serialize());
            }
        }

        public void Send(byte[] Packet)
        {
            lock (this)
            {
                this.Socket.Send(Packet);
            }
        }
    }

    public interface IClassPacket
    {
        void Deserialize(byte[] Bytes);
        byte[] Serialize();
    }
09/12/2010 16:56 Korvacs#25
Whats your Serialize() Method for the General Data packet?

Edit:

In fact whats this method aswell SendScreen()
09/12/2010 17:01 Arcо#26
Quote:
Originally Posted by Korvacs View Post
Whats your Serialize() Method for the General Data packet?

Edit:

In fact whats this method aswell SendScreen()
I'll just give you my entire gendata packet.
Code:
        public void SendScreen(IClassPacket CMsg, bool SendSelf)
        {
            SendScreen(CMsg.Serialize(), SendSelf);
        }
09/12/2010 17:05 Korvacs#27
Yeah, so you never modify the TQstring at the end of the packet, so the client sends the packet with TQClient, and you send it back without changing it to TQServer, so the client receives an invalid packet and disconnects.

Atleast thats what it looks like from here, unless its somewhere in this.RealPacket.
09/12/2010 17:07 Arcо#28
Ah thanks Jack, I've never really messed with the TQSeal before, soexactly how do I implement that into the packet?
09/12/2010 17:10 Korvacs#29
You write an additional 8 bytes onto the end of the packet without modifying the length, any packet sent from the server requires TQServer, other than that you dont need to worry about it since its not a proxy.

Code:
public static byte[] TQServer = Encoding.ASCII.GetBytes("TQServer");
Dump that somewhere and memcpy onto the end of the packet everytime you send.
09/12/2010 17:21 Arcо#30
So something like this.
Code:
        public unsafe void Send(byte[] Packet)
        {
            lock (this)
            {
                fixed (byte* p = Packet)
                    for (int i = 0; i < 8; i++)
                        *(p + i + Packet.Length - 8) = (byte)PacketBuilder.TQServer;
                
                this.Socket.Send(Packet);
            }
        }