![]() |
Packet Name - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17) +---- Thread: Packet Name (/showthread.php?tid=367) |
Packet Name - William - 16-10-2006 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? - Van - 16-10-2006 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 - 16-10-2006 It does work, I use it. All my packets look like this: Code: Packet = Chr(15) & SEP_CHAR & Msg & END_CHAR - Dark Echo - 16-10-2006 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: - Spodi - 16-10-2006 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 Code: User_Move = Chr(1) 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: - William - 16-10-2006 @Spodi, your way is pretty much time consuming to 1000% ![]() @Dragoons Master, so your using from Char(1) to Char(253) ? - Gilgamesch - 16-10-2006 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) - Spodi - 16-10-2006 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. - William - 16-10-2006 Hmm.. Well if your using my example, you wont need to write: Code: Public Type DCmd Okay, I give in ![]() - Spodi - 16-10-2006 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. - William - 16-10-2006 Yeah I understand. Why do you want it to be called DCmd? - Spodi - 16-10-2006 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: - William - 16-10-2006 I will probably make different types. Named like: Code: Type Account - William - 16-10-2006 Those are the things you should make small tuts for ![]() - Spodi - 16-10-2006 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: - William - 16-10-2006 Spodi Wrote:Make a tut, make a tutVerrigan 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) ![]() - William - 16-10-2006 Okay, thanks ![]() - William - 16-10-2006 Thanks, Ill check it out. - Spodi - 16-10-2006 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 - 17-10-2006 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:@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. - William - 17-10-2006 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 |