[C#] Generic Packet Class

01/28/2011 21:03 chea77er#1
At first I have to say I didn't done this for SRO, but offcourse you can use it. You can easily add SRO packet header support -> 2bytes(len) ...

Here is it:
[Only registered and activated users can see links. Click Here To Register...]


MarshalHelper.Copy is the sample by microsoft ([Only registered and activated users can see links. Click Here To Register...])

You have to allow unsafe code in your compiler.

It can easily read/write any struct you want.

if you want to write/read strings please add a own function, because there are ASCII and Unicode strings in SRO.
01/29/2011 07:58 lesderid#2
Maybe apply for the Underground?
01/29/2011 09:04 chea77er#3
I'm not interested to make an "auto login (packet based)". Don't like that.
01/29/2011 18:48 Shadowz75#4
Quote:
Originally Posted by chea77er View Post
At first I have to say I didn't done this for SRO, but offcourse you can use it. You can easily add SRO packet header support -> 2bytes(len) ...

Here is it:
[Only registered and activated users can see links. Click Here To Register...]


MarshalHelper.Copy is the sample by microsoft ([Only registered and activated users can see links. Click Here To Register...])

You have to allow unsafe code in your compiler.

It can easily read/write any struct you want.

if you want to write/read strings please add a own function, because there are ASCII and Unicode strings in SRO.
Well, those kind of packet classes are less work, but non generic classes are much faster.
01/30/2011 12:35 chea77er#5
Quote:
Originally Posted by Shadowz75 View Post
Well, those kind of packet classes are less work, but non generic classes are much faster.
Who said it is much work?
Who said it is faster then other?

Generic are slower then normal :) good joke. If thats true, then microsoft should make a new compiler.
01/30/2011 13:31 Shadowz75#6
Quote:
Originally Posted by chea77er View Post
Who said it is much work?
Who said it is faster then other?

Generic are slower then normal :) good joke. If thats true, then microsoft should make a new compiler.
I tested it(with an old class from invicible, almost the same like your class), just try it out. No one said it, but if you are interested in the speed of your application you should consider it.
Btw dont be so aggresiv, it was just a statement based on my experience.
01/30/2011 14:16 chea77er#7
I'm not aggresiv :)

I'm just wondering that Microsoft don't implement Generics like in C++ templates. Because in C++ there aren't any perfomance changes.
01/30/2011 19:29 T3thys#8
My 2 cents
Using binary writer/reader is better.
Attaching a socket to a packet is a bad design. Its not flexible to handle different uses
01/30/2011 20:02 InvincibleNoOB#9
Quote:
Originally Posted by Shadowz75 View Post
Well, those kind of packet classes are less work, but non generic classes are much faster.
No, this is not correct, but you are right about my old class.

Few things about it:
1) Only one buffer - for writing. Let it be static for efficiency OR make sure you rarely change its length. For reading - pointer to the address where packet is stored (only at one place).
2) Return pointer, not byte array. For that reason, instead of freeing the buffer, just set the address pointer to the first element so that it writes over.
3) This class suits best File I/O --> No need to be silkroad related.

One thing is true for sure - unmanaged code beats all limits of efficiency if you code it well. I did rewrite that Celebrity class of mine in Delphi though, if anyone's interested I can post it here.
01/31/2011 17:35 Yo123#10
Quote:
Originally Posted by InvincibleNoOB View Post
I did rewrite that Celebrity class of mine in Delphi though, if anyone's interested I can post it here.
give it a shot:)