Packet Info.

01/19/2010 07:35 Santa#1
I heard that the lotf packets are very poorly coded, is that true? And what is the downfall of unsafe code?

Anyway to convert them to a better coded packet, like "Packet.WriteUint16(X);" instead of the *(p-1) = XXX". i think i might know when it says like "*(p-1) = (uint)XXX" or w/e, but what is its just like *(p-1) = XXX". Is that just WriteByte?

That may be confusing, but the first question is what I really wanna know.
01/19/2010 07:37 Arcо#2
Quote:
Originally Posted by StarBucks View Post
I heard that the lotf packets are very poorly coded, is that true? And what is the downfall of unsafe code?

Anyway to convert them to a better coded packet, like "Packet.WriteUint16(X);" instead of the *(p-1) = XXX". i think i might know when it says like "*(p-1) = (uint)XXX" or w/e, but what is its just like *(p-1) = XXX". Is that just WriteByte?

That may be confusing, but the first question is what I really wanna know.
Yes, lotf is poorly coded period.
01/19/2010 07:41 Santa#3
Quote:
Originally Posted by Hepatitis C View Post
Yes, lotf is poorly coded period.
I do realize, but what part, and why.
01/19/2010 07:47 Arcо#4
Quote:
Originally Posted by StarBucks View Post
I do realize, but what part, and why.
Lol all of it ftl.
It is super unstable.
Tanel's technique is just plain horrible :/
01/19/2010 09:00 N¡ghtMare ?? WooT#5
ya, it takes alot fix to fix lotf.
in my server i fixed alot things, but still need alot.
here is what i fixed so far i remember:
Quote:
Damage
GuildWar The one i released
ArtisanWind
PK
Gear dissapear
Stamina
Some NPC's that was bad
Items from shoppingmall (Ninja amulet etc.)
Reborn
Potency
There is some more, i just cant remember =]
01/19/2010 09:44 ~Yuki~#6
Packets arent too bad coded. just a unssafe class... use them but stay with your packethandler and it will result good.
01/19/2010 09:48 N¡ghtMare ?? WooT#7
Quote:
Originally Posted by ~Yuki~ View Post
Packets arent too bad coded. just a unssafe class... use them but stay with your packethandler and it will result good.
i wouldnt say the packets are bad either.
The bad things in lotf is more calculations and so on.
01/19/2010 12:01 Korvacs#8
Just so you know this:

Code:
                *(ushort*)PTR = (ushort)Buffer.Length;
                *((ushort*)(PTR + 2)) = 2030;
                *((uint*)(PTR + 4)) = npc.StaticID;
                *((ushort*)(PTR + 8)) = (ushort)npc.Cords.Position.X;
                *((ushort*)(PTR + 10)) = (ushort)npc.Cords.Position.Y;
                *((ushort*)(PTR + 12)) = (ushort)(npc.StaticID + (byte)npc.Direction);
                *((ushort*)(PTR + 14)) = npc.Interaction;
Is faster than this:

Code:
            PacketBuilder Packet = new PacketBuilder(new byte[20]);
            Packet.WriteUInt16(Packet.Packet.Length);
            Packet.WriteUInt16(2030);
            Packet.WriteUInt32((uint)Type);
            Packet.WriteUInt16(X);
            Packet.WriteUInt16(Y);
            Packet.WriteUInt16(SubType);
            Packet.WriteUInt16(Dir);
            Packet.WriteUInt32((uint)Flag);
01/19/2010 16:29 Santa#9
Quote:
Originally Posted by Korvacs View Post
Just so you know this:

Code:
                *(ushort*)PTR = (ushort)Buffer.Length;
                *((ushort*)(PTR + 2)) = 2030;
                *((uint*)(PTR + 4)) = npc.StaticID;
                *((ushort*)(PTR + 8)) = (ushort)npc.Cords.Position.X;
                *((ushort*)(PTR + 10)) = (ushort)npc.Cords.Position.Y;
                *((ushort*)(PTR + 12)) = (ushort)(npc.StaticID + (byte)npc.Direction);
                *((ushort*)(PTR + 14)) = npc.Interaction;
Is faster than this:

Code:
            PacketBuilder Packet = new PacketBuilder(new byte[20]);
            Packet.WriteUInt16(Packet.Packet.Length);
            Packet.WriteUInt16(2030);
            Packet.WriteUInt32((uint)Type);
            Packet.WriteUInt16(X);
            Packet.WriteUInt16(Y);
            Packet.WriteUInt16(SubType);
            Packet.WriteUInt16(Dir);
            Packet.WriteUInt32((uint)Flag);
Yes, i do understand that, but i someone was saying pointers aren't good to use and its what makes lotf unstable

@yuki, what do you mean stick with my PAcket handler?
01/19/2010 16:55 Korvacs#10
Pointers are good aslong as you do it correctly.
01/19/2010 18:13 ~Yuki~#11
Quote:
Originally Posted by StarBucks View Post
Yes, i do understand that, but i someone was saying pointers aren't good to use and its what makes lotf unstable

@yuki, what do you mean stick with my PAcket handler?
The packethandler in lotf pretty much sux so just ues the one u already got in cofuture.
01/19/2010 18:53 Kiyono#12
Quote:
Originally Posted by Korvacs View Post
Pointers are good aslong as you do it correctly.
So how is LOTF's use incorrect?
01/19/2010 19:22 Korvacs#13
Quote:
Originally Posted by Kiyono View Post
So how is LOTF's use incorrect?
They do/did things like:

Code:
            byte[] Buffer = new byte[20];
            fixed (byte* PTR = Buffer)
            {
                *(ushort*)PTR = (ushort)Buffer.Length;
                *((ushort*)(PTR + 2)) = 2030;
                *((uint*)(PTR + 4)) = npc.StaticID;
                *((ushort*)(PTR + 8)) = (ushort)npc.Cords.Position.X;
                *((ushort*)(PTR + 10)) = (ushort)npc.Cords.Position.Y;
                *((ushort*)(PTR + 12)) = (ushort)(npc.StaticID + (byte)npc.Direction);
                *((uint*)(PTR + 20)) = npc.Interaction;
            }
So that the last uint was not dumped into the buffer, it would be dumped into invalid memory and you would get memory errors and memory leaks.
01/19/2010 21:14 Kiyono#14
Quote:
Originally Posted by Korvacs View Post
They do/did things like:

Code:
            byte[] Buffer = new byte[20];
            fixed (byte* PTR = Buffer)
            {
                *(ushort*)PTR = (ushort)Buffer.Length;
                *((ushort*)(PTR + 2)) = 2030;
                *((uint*)(PTR + 4)) = npc.StaticID;
                *((ushort*)(PTR + 8)) = (ushort)npc.Cords.Position.X;
                *((ushort*)(PTR + 10)) = (ushort)npc.Cords.Position.Y;
                *((ushort*)(PTR + 12)) = (ushort)(npc.StaticID + (byte)npc.Direction);
                *((uint*)(PTR + 20)) = npc.Interaction;
            }
So that the last uint was not dumped into the buffer, it would be dumped into invalid memory and you would get memory errors and memory leaks.
So what would be the correct way of doing it since it looks pretty much the same as your example.

//edit I think that I see what the problem is, uint uses 4 bytes making it 22 bytes total while it was stated before that 20 was the max causing the 2 leftover bytes to be dumped into invalid memory.
This means that ushort had to be used cause that uses 2 bytes which would end up at 20, correct?
01/19/2010 22:19 PeTe Ninja#15
Quote:
Originally Posted by StarBucks View Post
Yes, i do understand that, but i someone was saying pointers aren't good to use and its what makes lotf unstable

@yuki, what do you mean stick with my PAcket handler?
what makes lotf unstable is the way they use packets. send/receive.

also just to say somehow i never had a stability problem... it always worked for me i could keep it on for days...