Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 11:52

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

Advertisement



Dynamic Packets - A clean, elegant, efficient solution

Discussion on Dynamic Packets - A clean, elegant, efficient solution within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Dynamic Packets - A clean, elegant, efficient solution

Dynamic packets have always been a problem in regards to how to create and define them in terms of code. I've always knew this was possible, but John (of ConquerAI) recently coded something similar so I thought I would improve it.

What is a dynamic packet?
A dynamic packet is a packet that varies in size due to unfixed sizes. An example of a dynamic packet is any packet that uses the CNetStringPacker, such as the chat packet.

Why are they a problem?
Back in I believe 2009, or 2010, I introduced to the community the idea of defining packets are structures and accessing fields and writing to them via pointer-logic. While this was amazingly fast and easy to maintain, problems quickly began to arose due to two things:
1. Structure alignment causing fields to have unexpected sizes
2. Dynamic packets

As a result, tedious code would have to be written for these packets to parse fields, and write them. I've noticed even in newer sources, people have gone back to the method of using a writer instead of structures (which I can understand why, many people are "afraid" of pointers) -- but once again, you end up writing tedious code.

Using Reflection.Emit, I have created a way of dynamically creating a writer/reader method for packet-types at run time, and cacheing them so they don't impede performance. They are as efficient as if they were coded and compiled originally -- thus they remove the need to manually ever code parsers again.

Here's the project SVN for those that are interested, there's a sample to see how to use it, and define custom-marshalers as well:


Sample usuage/code:


Comment/feedback is appreciated.
InfamousNoone is offline  
Thanks
8 Users
Old 08/10/2012, 02:41   #2
 
elite*gold: 0
Join Date: Sep 2006
Posts: 774
Received Thanks: 8,580
Neat
phize is offline  
Old 08/10/2012, 03:09   #3
 
ImFlamedCOD's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 378
Received Thanks: 141
Very clean , *thumbs up*
ImFlamedCOD is offline  
Old 08/10/2012, 07:24   #4
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Added support for enums, structures and unions. Provided an example. Will add support for arrays of structures (and primtives) later...

Added support for arrays (but chose to write my packer as a List<T> for simplicity sake)
InfamousNoone is offline  
Old 05/29/2013, 13:16   #5
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
I think this deserves more attention. Surprised I've never come across this. Wish I had in earlier state of my development, considering rewriting all my packets using something like this.
Super Aids is offline  
Old 05/29/2013, 18:16   #6
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Planned on using it in V3, decided it didn't call for it and used something a little more light weight but yeah this comes from a time when I was heavily playing around with IL.
InfamousNoone is offline  
Thanks
2 Users
Old 05/29/2013, 18:43   #7
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
Yeah, was not exactly thinking of using this, but just a similar technology
Super Aids is offline  
Old 05/30/2013, 20:12   #8
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,225
Received Thanks: 868
Quote:
Originally Posted by InfProCodez
var chat = new MsgChat("Hybrid", "ALL", "YOLO!", 1000);
I shall avenge all 'yolo' speakers.
_DreadNought_ is offline  
Old 05/31/2013, 00:22   #9
 
.Kinshi's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 341
Received Thanks: 255
This is a super interesting library you made.
Two thumbs up.
.Kinshi is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Have any solution to build a vSRO server on dynamic IP ?
03/09/2012 - SRO Private Server - 1 Replies
Hi all, Hamachi is too lag and I want to find out a solution to make vSRO server vi dynamic IP. I have an idea and register a free no-ip domain, example sro.no-ip.com. I replace all IP sections on server.cfg with no-ip domain and modify certification ini file (srNodeType.ini) But when I launch CustomCertificationServer, error:
[Release]Solution for c9 Behind Router / Dynamic
12/24/2011 - SRO Private Server - 10 Replies
If you read the guide on how to run a server with a Dynamic IP or behind a router then you most likely ran into the issue with the c9 from a wan connection outside your Ip. The issue seems to be the server programs and files not being able to pass your router when a connection comes in. No matter what ports you forward or what exceptions you add anywhere. Our solution was this. If your internet is set up like this Modem > Router > Computer / Wireless PC's
Most efficient way to write packets?
04/18/2011 - CO2 Private Server - 10 Replies
What is more efficient to use? Pointers or MemoryStream?
ELEGANT HACK
07/05/2010 - Combat Arms Hacks, Bots, Cheats & Exploits - 21 Replies
Entfernen Sie die Datei, die Sie Ihren Desktop heruntergeladen. Elegant.exe, run-spritzen klicken. Spiel zu starten. dawload http://rapidshare.com/files/401683942/elegant_not elli_hack.rar.html NUMPAD 5 - FULL WIREFRAME NUMPAD 6 - SKELETONS NUMPAD 7 - BULLET TRACERS NUMPAD 8 - PLAYER GLOW



All times are GMT +1. The time now is 11:52.


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.