Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 13:44

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C#] Generic Packet Class

Discussion on [C#] Generic Packet Class within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
chea77er's Avatar
 
elite*gold: 12
Join Date: Oct 2009
Posts: 290
Received Thanks: 194
[C#] Generic Packet Class

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:



MarshalHelper.Copy is the sample by microsoft ()

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.
chea77er is offline  
Old 01/29/2011, 07:58   #2
 
lesderid's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
Maybe apply for the Underground?
lesderid is offline  
Old 01/29/2011, 09:04   #3
 
chea77er's Avatar
 
elite*gold: 12
Join Date: Oct 2009
Posts: 290
Received Thanks: 194
I'm not interested to make an "auto login (packet based)". Don't like that.
chea77er is offline  
Old 01/29/2011, 18:48   #4
 
Shadowz75's Avatar
 
elite*gold: 0
Join Date: Mar 2009
Posts: 443
Received Thanks: 597
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:



MarshalHelper.Copy is the sample by microsoft ()

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.
Shadowz75 is offline  
Thanks
2 Users
Old 01/30/2011, 12:35   #5
 
chea77er's Avatar
 
elite*gold: 12
Join Date: Oct 2009
Posts: 290
Received Thanks: 194
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.
chea77er is offline  
Old 01/30/2011, 13:31   #6
 
Shadowz75's Avatar
 
elite*gold: 0
Join Date: Mar 2009
Posts: 443
Received Thanks: 597
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.
Shadowz75 is offline  
Old 01/30/2011, 14:16   #7
 
chea77er's Avatar
 
elite*gold: 12
Join Date: Oct 2009
Posts: 290
Received Thanks: 194
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.
chea77er is offline  
Old 01/30/2011, 19:29   #8
 
elite*gold: 0
Join Date: Dec 2010
Posts: 2
Received Thanks: 2
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
T3thys is offline  
Old 01/30/2011, 20:02   #9
 
InvincibleNoOB's Avatar
 
elite*gold: 20
Join Date: Mar 2007
Posts: 4,277
Received Thanks: 2,990
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.
InvincibleNoOB is offline  
Old 01/31/2011, 17:35   #10


 
Yo123's Avatar
 
elite*gold: 41
Join Date: Nov 2007
Posts: 3,385
Received Thanks: 2,700
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
Yo123 is offline  
Reply


Similar Threads Similar Threads
what is the best class to grind metin2 yang(class selection guide for newbies)
07/07/2012 - Metin2 - 1 Replies
Again, I am using Enligsh. So if you cant read it well, just turn to google online translation. If i am supposed to say or answer what is the best class for grinding metin2 yang in Metin2, of course the most efficiently, i strongly recommand the Warrior, and promote to Sword Warrior at level 5. This class has both high defense and attack, as well as great area attack skill and control skill(I mean the stun skill). I recommend the BM sura as your second choice,because he has the sweetest...



All times are GMT +1. The time now is 13:45.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.