Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Would there be a big difference changing all the packet names ex:
to something like this:
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?
Sounds logically, I think it will, but wouldn't it be even better if you send is a byte then, instead of a string?
Dragoons Master
Unregistered
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)
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:
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:
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
@Spodi, your way is pretty much time consuming to 1000%  hehe. You will need to put all the packet names into that Type..
@Dragoons Master, so your using from Char(1) to Char(253) ?
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)
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.
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Hmm..
Well if your using my example, you wont need to write:
Okay, I give in  But still you dont need to write a document if you have good memory :oops: hehe
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.
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.
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Yeah I understand. Why do you want it to be called DCmd?
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:
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
I will probably make different types. Named like:
Code: Type Account
Type Player
Type NPC
Type ITEM
etc.. Pretty easy to navigate that way.
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Those are the things you should make small tuts for
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:
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
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
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Okay, thanks
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Thanks, Ill check it out.
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:
Dragoons Master
Unregistered
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.
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.
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Im probably going for Spodi's way. Seems easy and fast to do. Havnt checked Verrigans yet thou, but you said it was time consuming... hmm
|