Mirage Source

Free ORPG making software.
It is currently Thu Apr 18, 2024 9:31 am

All times are UTC




Post new topic Reply to topic  [ 47 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Packet Name
PostPosted: Mon Oct 16, 2006 10:12 am 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Would there be a big difference changing all the packet names ex:
Code:
 "playerlogin"


to something like this:

Code:
 "3"


So instead of having names, you can use numbers for them. and for easy use, you can make a .txt file numbered from 1 to max packets. Like

1. addPlayer
2. playerlogin
etc..

So you keep track of which packets are which number. Cause i believe 5 characters in the packet name, equals to 5 bytes? and if you use numbers, you would probably not get over than 100. so that would improve the speed some, correct?

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 10:47 am 
Offline
Newbie

Joined: Tue Jul 25, 2006 11:02 am
Posts: 15
Sounds logically, I think it will, but wouldn't it be even better if you send is a byte then, instead of a string?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 1:08 pm 
Offline
Pro
User avatar

Joined: Mon May 29, 2006 3:26 pm
Posts: 493
Location: São Paulo, Brasil
Google Talk: blackagesbr@gmail.com
It does work, I use it.
All my packets look like this:
Code:
Packet = Chr(15) & SEP_CHAR & Msg & END_CHAR

This is the global msg packet and I use Chr function which makes easier becouse I can have like 253 packets w/ only one byte(its not 255 becouse we have SEP_CHAR and END_CHAR)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 1:33 pm 
Offline
Knowledgeable

Joined: Tue May 30, 2006 5:11 am
Posts: 156
Location: Australia
Thats an awesome idea.. Also it would 'help' provide a bit of protection against people who try and read your packets.. It might not stop them, but it would help a little.. Great idea dude.. :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 2:18 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
I did this to vbGORE before I used binary packets and to the Kronia game. Though I created a UDT to define each of the packets so I could keep them in order instead of always having to look them up.

Code:
Public Type DCmd
  User_Move As String * 1
  User_Attack As String * 1
  Server_SetUserPos As String * 1
End Type
Public Dcmd As Dcmd


Code:
User_Move = Chr(1)
User_Attack = Chr(2)
...


Code:
Packet = Dcmd.User_Move & ...


Using just numbers limits you a ton. And yes this is an improvement on speed, an improvement where MS and ES both need badly. :wink:

_________________
NetGore Free Open Source MMORPG Maker


Last edited by Spodi on Mon Oct 16, 2006 3:24 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 2:50 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
@Spodi, your way is pretty much time consuming to 1000% :P hehe. You will need to put all the packet names into that Type..

@Dragoons Master, so your using from Char(1) to Char(253) ?

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 3:19 pm 
Offline
Knowledgeable

Joined: Sun May 28, 2006 9:06 pm
Posts: 147
William wrote:
@Dragoons Master, so your using from Char(1) to Char(253) ?


i am using the same system, sepchar is chr(0) and endchar is chr(255) (not sure, i used the last one there is)

_________________
There are only 10 types of people in the world. Those who understand binary and those who don't.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 3:27 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
How is it time consuming? You'll spend less time in the long run since you dont have to keep a lookup table of what every Chr(x) value is. Is it easier to see Server_UpdateUserPosition or Chr(213) and know what it is? Also, you're not calculating the char on the fly and rather storing it in memory (I think you can sacrafice one byte of memory) in a fixed-length string... doesn't get much faster then that. :wink:

Anyways, if you are assigning the characters anyways, why not just do it in an easy-to-use lookup table instead of some crappy lookup table you have to write in a seperate document? I just fail to see how it'd be more time consuming.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 3:36 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Hmm..

Well if your using my example, you wont need to write:

Code:
Public Type DCmd


Okay, I give in ;) But still you dont need to write a document if you have good memory :oops: hehe

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 3:43 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Ohhh trust me, you do. :wink: Theres 100's of features in vbGORE that I have completely forgot about that I find every now and then just because the project has become so large I even loose my way around it sometimes. :wink:

Also, if you ever want to have other programmers or distribute your code, it is a must to have. If you are going to use this method, it is a pretty safe thing to say that you will need a lookup table of "some sort". I suggested the above since I like to be able to type in a command where all my packet IDs are gathered up and nothing more, and have a list of the packets be shown. Since I use binary packets, too, misformatting one part of a packet can ruin the whole entire packet for the one recieving it (whether it is the server or client).

A seperate document with the packet information may be nice, but I can see it causing a bit of updating problems. For example, it'd be extra work if you want to change numbers or move things around since you have to edit it in multiple places. With this, I just have a sub that sets all the packet values, copy it from the server to client (or vise versa) and then the packet values will always match up, period. Doesn't matter then what numbers I use, as long as the names are correct. :D

You will also be kicking yourself if you ever take a break for a week or two and end up forgetting a bunch of the packet numbers if you dont chart them. :lol:

Another way you could do it is to format them like:

Code:
Public Const DCmd_Server_UpdateUserPos As String * 1 = C


...then type DCmd_ and press I believe Alt + Space to bring up the pop-up box, but that'd prevent you from using a lot of characters unfortunately.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 3:55 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Yeah I understand. Why do you want it to be called DCmd?

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:06 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
DCmd is just what I use (Data Command). You can call it anything you want, though you will most likely want to use something pretty short. I have DCmd (packet identifiers), SID (stat identifiers), SkID (skill identifiers), and EID (emoticon identifiers) I believe. Now if I had to write those all out every time (would is a LOT of times), I'd just go crazy. :lol:

Though you can also, if you want to use something longer, use a short unique combination (like wjz), then just use a VB IDE plugin to find your temp name and change it to a different name. :wink:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:22 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
I will probably make different types. Named like:

Code:
Type Account

Type Player

Type NPC

Type ITEM

etc.. Pretty easy to navigate that way.

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:24 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
I use an array to store the addresses of the functions.. Then, when I receive a packet, it parses out the first byte and calls the function by the address stored in the array based on the packet number. (Very fast)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:25 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Those are the things you should make small tuts for ;)

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:27 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Verrigan wrote:
I use an array to store the addresses of the functions.. Then, when I receive a packet, it parses out the first byte and calls the function by the address stored in the array based on the packet number. (Very fast)


Mind elaborating on what you mean / how you did this? :wink:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:28 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
I did... and Spodi wrote one too. :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:28 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Spodi wrote:
Verrigan wrote:
I use an array to store the addresses of the functions.. Then, when I receive a packet, it parses out the first byte and calls the function by the address stored in the array based on the packet number. (Very fast)


Mind elaborating on what you mean / how you did this? :wink:

Make a tut, make a tut ;) hehe

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:34 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
I made a tutorial... See 'Optimizing your packets'.. or whatever the name is..

Basically, I created a separate function for each packet.

I stored the function addresses in an array... And created an Enumeration of each of the packets.. Then... bleh... This will take a long time to explain...

My HandleData sub is about 10 lines.. It checks the packet type, calls the function by its address using CallWndProc (I think).. and so on and so forth..

I have a download somewhere, but it is not complete, and still a bit buggy.. (First edition...)

I've helped Dave get it working (almost 100%) in Valkoria.. but he has quit working on it for the time being.. :(

The download for the source is in the 'Optimize your packets' tutorial.. I am trying to eat, so I can't look for it atm. :P


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:38 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Okay, thanks :)

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:40 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
Here's the link: http://www.verrigan.net/downloads/MSE-Verrigan.zip

Be warned... I mentioned before... It is old and buggy code.. But you'll get the idea. :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:41 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Thanks, Ill check it out.

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 4:43 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Hmm, never really thought of using the memory address for a sub instead of just calling it by name - I'll check that out. Though, sounds like it might not be worth the hassle. :wink:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 5:17 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
Spodi wrote:
Hmm, never really thought of using the memory address for a sub instead of just calling it by name - I'll check that out. Though, sounds like it might not be worth the hassle. :wink:


It's really not worth the hassle for a game with less than 50 players on it. ;)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 2:27 am 
Offline
Pro
User avatar

Joined: Mon May 29, 2006 3:26 pm
Posts: 493
Location: São Paulo, Brasil
Google Talk: blackagesbr@gmail.com
Spodi wrote:
Ohhh trust me, you do. :wink: Theres 100's of features in vbGORE that I have completely forgot about that I find every now and then just because the project has become so large I even loose my way around it sometimes. :wink:

Also, if you ever want to have other programmers or distribute your code, it is a must to have. If you are going to use this method, it is a pretty safe thing to say that you will need a lookup table of "some sort". I suggested the above since I like to be able to type in a command where all my packet IDs are gathered up and nothing more, and have a list of the packets be shown. Since I use binary packets, too, misformatting one part of a packet can ruin the whole entire packet for the one recieving it (whether it is the server or client).

A seperate document with the packet information may be nice, but I can see it causing a bit of updating problems. For example, it'd be extra work if you want to change numbers or move things around since you have to edit it in multiple places. With this, I just have a sub that sets all the packet values, copy it from the server to client (or vise versa) and then the packet values will always match up, period. Doesn't matter then what numbers I use, as long as the names are correct. :D

You will also be kicking yourself if you ever take a break for a week or two and end up forgetting a bunch of the packet numbers if you dont chart them. :lol:

Another way you could do it is to format them like:

Code:
Public Const DCmd_Server_UpdateUserPos As String * 1 = C


...then type DCmd_ and press I believe Alt + Space to bring up the pop-up box, but that'd prevent you from using a lot of characters unfortunately.

@Spodi, you are totaly right, it's much easier to use it this way.

@William, No. Like Gilgamesch said, I use from 1 to 236 and 238 - 255. 0 and 237 are the Sep and End chars.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group