Register for your free account! | Forgot your password?

You last visited: Today at 04:31

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

Advertisement



Packet Handling Ways

Discussion on Packet Handling Ways within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Packet Handling Ways

well im interested in packet and i seen alot of examples of building packets so here is some examples

Heres Example of Attack Packets : 1st Example

Code:
public Attack(bool Create)
        {
            if (Create)
            {
                Buffer = new byte[8 + 40];
                Writer.WriteUInt16(40, 0, Buffer);
                Writer.WriteUInt16(1022, 2, Buffer);
            }
        }
2nd Example

Code:
public Attack(bool Create)
        {
            if (Create)
            {
                Buffer = new byte[48];
                Writer.WriteUInt16(40, 0, Buffer);
                Writer.WriteUInt16(1022, 2, Buffer);
            }
        }
3rd Example

Code:
public Attack(bool Create)
        {
            if (Create)
            {
                Buffer = new byte[48];
                Writer.WriteUInt16(Buffer.Length - 8, 0, Buffer);
                Writer.WriteUInt16(1022, 2, Buffer);
            }
        }
So which one sends packets faster and which way is the best ot they all the same ??

And when should i use smthing like that

Code:
public uint Attacker
        {
            get { return BitConverter.ToUInt32(Buffer, 8); }
            set { Writer.WriteUInt32(value, 8, Buffer); }
        }

        public uint Attacked
        {
            get { return BitConverter.ToUInt32(Buffer, 12); }
            set { Writer.WriteUInt32(value, 12, Buffer); }
        }
        public Conquer_Online_Server.Network.GamePackets.SpellUse.EffectValue FirstEffect
        {
            get { return (Conquer_Online_Server.Network.GamePackets.SpellUse.EffectValue)Buffer[32]; }
            set { Writer.WriteByte((byte)value, 32, Buffer); }
        }
the last number called offset ..Right ?? anyways y the uint attacked have last number 12 not smthing else and same for effect value it contains number 32 at last ...

Code:
public AttackEffects1 Effect1
        {
            get { return (AttackEffects1)Buffer[32]; }
            set { Buffer[32] = (Byte)value; }
        }
(Conquer_Online_Server.Network.GamePackets.SpellUse.EffectValue)Buffer[32]; }
            set { Writer.WriteByte((byte)value, 32, Buffer); }
        }
Which one of them would be better to use and Which one is sent faster ?
shadowman123 is offline  
Old 01/16/2012, 07:27   #2
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
1. Not really any difference in speed.

2. Yes the last number is 'offset', but you need to understand what it means, because it doesn't necessary need to be known as offset, because it could be position as well. Offset it just the name most use. Offset basically just means the location within the buffer, so that's the location in the buffer you would like to write.

3. Same as 1 I guess, didn't quite get it,
I don't have a username is offline  
Old 01/16/2012, 07:54   #3
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
I like how you're talking about 'different ways of writing packets' and then show three examples that are identical.

The only thing you changed is the order in which you do some math.


As I said in your other thread... you need to understand what packets are better before you worry about this stuff.

Note: Video sucks it's just me showing a few 'common' ways of structuring packets as well as a bit of info on how to interpret the ACTUAL packet data. The better reference would be found as links in......
pro4never is offline  
Old 01/16/2012, 10:05   #4
 
Arco.'s Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
I'll be the first to bluntly point out, this thread has nothing to do with packet handling.
Arco. is offline  
Thanks
1 User
Old 01/16/2012, 14:28   #5
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
well i meant packet building ways Not handling you r right there is nothing about handling ways Rofl
shadowman123 is offline  
Old 01/17/2012, 08:09   #6
 
Nullable's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
lol'd @ faster/best...

[almost offtopic rant]
These simple micro-optimizations aren't going to be any helpful in the long run, you don't change the way you construct a packet to another way simply because the other one is a little bit faster, i.e. it doesn't really matter in the end if you use pointers to fill up the packet vs. BinaryWriter or anything similar. Think big changes, get out of the raw performance mindset already. That, however, doesn't mean that you shouldn't pay attention to these micro-optimizations, it just means that they should NEVER be your top priority.
[/almost offtopic rant]
Nullable is offline  
Reply


Similar Threads Similar Threads
Socket Handling
11/03/2011 - CO2 Private Server - 3 Replies
Well i wanna know smthing about sockets ...i wanna handle about 500 Player (As an example) how to know the max number of player that my socket can handle without getting players in my server ??
Handling Packets
10/19/2011 - CO2 Private Server - 0 Replies
well iam learning Coding using C# Tutorials but i didnt find how to handle packets ..So any1 have tutorials or guides for that i'd be appreciate
[Question]New way of packet handling?
01/26/2011 - CO2 Private Server - 16 Replies
I have been thinking, and to me it seems that a lot of the packet handlers (especially LOTF) are pretty large. Would it take up more resources to do something more dynamic such as the following? This is just an example obviously. But the main concept is there. The void would be your PacketID, the Arg1 would be your data. And it simply calls the method immediately rather then going through a case? class Program { static void Main(string args) { string...



All times are GMT +1. The time now is 04:32.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.