Mirage Source

Free ORPG making software.
It is currently Sat Apr 27, 2024 3:10 pm

All times are UTC




Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Packet Enum - Completed
PostPosted: Wed Sep 26, 2007 3:48 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Introduction
Currently each packet has a name that takes up 1 byte per character. Thats not good, instead we want to keep the packet name, but only want it to take up 1-2 bytes per packet.

Backup your source!

Begin with adding this in a module in the client:
Code:
Public Enum ClientPacketNames

End Enum

We will store the packet names inside it. And make them only take up 1-2 bytes, regarding what number thats assigned to them.

Now go into your handledata sub client side. The first packet on the top on a unedited mse1 is:
Code:
If LCase(Parse(0)) = "alertmsg" Then

We will rename that line of code to this:
Code:
If LCase(Parse(0)) = CPNAlertMsg Then

The CPN stands for ClientPacketNames, this is just how I'd like to organize it. Now, go into your:
Code:
Public Enum ClientPacketNames

And at the top of that add:
Code:
CPNAlertMsg = 0

So it looks like:
Code:
Public Enum ClientPacketNames
CPNAlertMsg = 0 '"alertmsg"

End Enum

I suggest you add the packet name as a comment after the new name as I did in the example above, cause that method will be very usefull when your starting on the server.
Now all the names below that will have +1 on their number. So you dont need to write = 1, = 2 etc. It does that on its own.
Now basicly you do the same for all the packets in the client handledata sub. This is the time consuming part, but it's worth it. I will do one more example for you though. The next packet in a unedited mse1 is:
Code:
If LCase(Parse(0)) = "allchars" Then

Now you should know how to write that, but if you don't, here it is:
Code:
If LCase(Parse(0)) = CPNAllChars Then

And after that, you will need to add that to the Enum, so it looks like this:
Code:
Public Enum ClientPacketNames
CPNAlertMsg = 0 ' "alertmsg"
CPNAllChars ' "allchars"

End Enum

That should give you enough information to carry this on through the whole client handledata sub.

When you have completed that! You will copy the whole Public Enum ClientPacketNames and paste it into the server in a module. When you've done that, you will start searching for the old packet names in the server. Now it's good that we saved those old names after the new onse in the enum type. So now, search for the first you have in your Enum type, in a unedited MSE1, It should be:
Code:
"alertmsg"

Now you will find this:
Code:
Sub AlertMsg(ByVal Index As Long, ByVal Msg As String)
Dim Packet As String

    Packet = "ALERTMSG" & SEP_CHAR & Msg & SEP_CHAR & END_CHAR
   
    Call SendDataTo(Index, Packet)
    Call CloseSocket(Index)
End Sub

But we are focusing on this part:
Code:
Packet = "ALERTMSG" & SEP_CHAR & Msg & SEP_CHAR & END_CHAR

We will change that to the new packet name that only take 1 byte, instead of 8 bytes. So it looks like this:
Code:
Packet = CPNAlertMsg & SEP_CHAR & Msg & SEP_CHAR & END_CHAR

And you will keep doing that for all the packets thats being sent from the server to client. When this is done, probably after 1-2 hours. You will do the same procedure, but from the other direction.

Now you start on the server, with adding a:
Code:
Public Enum ServerPacketNames

End Enum

And do as you did in the client before, and also remember to paste the whole Public Enum ServerPacketNames into the client after your done with them.

If you need any further help, just post and I'd be glad to help you.

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


Top
 Profile  
 
 Post subject: Re: Packet Enum
PostPosted: Wed Sep 26, 2007 3:54 pm 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
I am confused, William. Why are we writing tutorials to do what Verrigan's packet system already does? Anyone with the most limited skill could pull that out..

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 4:07 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 remember being confuzed about this when struggeling with ore 2 years back. And Verrigan never did a tutorial for this, I believe he made a source code floating around with it. But I don't think many people even have that source.

So I suggest you take a step back and let people add this since I've spoken with a lot of people who don't have this, and many dont know about it. So please give me another reason why I shouldn't post this ?

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


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 4:17 pm 
Dave, you made a binary account tut, and Obsi posted the newer version of it that was easier to follow. Verrigan's byte packet, binary packet, w/e tut was good, but didn't give many examples, so it's hard to follow, if you can even follow it at all.


Top
  
 
PostPosted: Wed Sep 26, 2007 4:26 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
It's easy to follow >_>

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 4:29 pm 
Robin wrote:
It's easy to follow >_>


Not for the average programmer.


Top
  
 
PostPosted: Wed Sep 26, 2007 5:11 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Well, if you're average you shouldn't try and add it then.

You'd just end up getting confused when adding new packets or following other tutorials which require you to edit packets.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 6: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
Robin wrote:
Well, if you're average you shouldn't try and add it then.

You'd just end up getting confused when adding new packets or following other tutorials which require you to edit packets.

A programmer should always push their limits, no matter what it is.

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


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 7:19 pm 
William wrote:
Robin wrote:
Well, if you're average you shouldn't try and add it then.

You'd just end up getting confused when adding new packets or following other tutorials which require you to edit packets.

A programmer should always push their limits, no matter what it is.


Agreed. Most programmers, if they're smart, back up their project before attempting anything. Unless they know for a fact what they added will work and won't mess anything else up.


Top
  
 
PostPosted: Wed Sep 26, 2007 7:31 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
That is kind of correct, but if you try to add this thing to your game but never ever sow anything about packets and sockets, there will be no way you will ever understand this. I know you should push your limits but you can't try to understand complex numbers when you can only sum and multiply things... In all my tutorials I ask the user to read and read again and again, if you don't understand DON'T go ahead!

_________________
http://www.blackages.com.br
Image
Dave wrote:
GameBoy wrote:
www.FreeMoney.com
I admit I clicked. I immediately closed upon realizing there was, in fact, no free money.
Robin wrote:
I love you and your computer.Marry me.


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 7:36 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Dragoons Master wrote:
That is kind of correct, but if you try to add this thing to your game but never ever sow anything about packets and sockets, there will be no way you will ever understand this. I know you should push your limits but you can't try to understand complex numbers when you can only sum and multiply things... In all my tutorials I ask the user to read and read again and again, if you don't understand DON'T go ahead!


-Hugs Dragoons Master-

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 7:38 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Aug 17, 2006 5:27 pm
Posts: 866
Location: United Kingdom
Why anyone can complain about a positive tutorial i dont know.


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 7: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
Fox wrote:
Why anyone can complain about a positive tutorial i dont know.

Same here.

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


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 7:46 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
That's not the point. What I'm talking about is that a user with no knowledge about packets should not try this for beggining. He should study on internet first and then do this. I never said that you should not post this tutorial, I just said that the tutorial does not have to be used by users that don't know anything about protocols, etc...

_________________
http://www.blackages.com.br
Image
Dave wrote:
GameBoy wrote:
www.FreeMoney.com
I admit I clicked. I immediately closed upon realizing there was, in fact, no free money.
Robin wrote:
I love you and your computer.Marry me.


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 7:53 pm 
Dragoons Master wrote:
That's not the point. What I'm talking about is that a user with no knowledge about packets should not try this for beggining. He should study on internet first and then do this. I never said that you should not post this tutorial, I just said that the tutorial does not have to be used by users that don't know anything about protocols, etc...


I agree with you, but some people, myself included, don't learn anything from research. I learn more from trial and error and examples and such. I'm an average programmer, but I understand packets and such. All this does is instead of sending the string "packetname" it sends a number, to save space and shit.


Top
  
 
PostPosted: Wed Sep 26, 2007 8: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
Humm, ok then xD

_________________
http://www.blackages.com.br
Image
Dave wrote:
GameBoy wrote:
www.FreeMoney.com
I admit I clicked. I immediately closed upon realizing there was, in fact, no free money.
Robin wrote:
I love you and your computer.Marry me.


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 8:20 pm 
Dragoons Master wrote:
Humm, ok then xD


What I'm saying is, a lot of people learn better from hands on experience than reading up on things. I have very little short term memory, so if I just read on something, I don't learn anything at all, cause I forget it really fast.


Top
  
 
PostPosted: Wed Sep 26, 2007 8:33 pm 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
Everyone forgets it fast. The trick is reading it over adn over as you need it. Eventually just memorize it.

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Wed Sep 26, 2007 8:46 pm 
Anyways..

Will using this improve the speed any?


Top
  
 
PostPosted: Thu Sep 27, 2007 12:29 am 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
Speed? Probably not. It will reduce your bandwidth some.

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
PostPosted: Thu Sep 27, 2007 9:05 am 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
I'd say it increases the speed some, the packets will be sent a little faster when the size is smaller. Instead of sending 10 bytes when a player move in the game, it now send 1 or 2 bytes depending on which number was assigned to the packet name in the type. If you've done optimizations such with $ etc. Then you should know that doing this tut is like 1000times better.

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


Top
 Profile  
 
PostPosted: Thu Sep 27, 2007 12:26 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Aug 17, 2006 5:27 pm
Posts: 866
Location: United Kingdom
Guys what i dont understand is we obsess over bits, and bytes so much;

if you look at mainstream online games they spam the hell out of the server and client, they have 32897423987432 more packets sending constantly than MS does; yet we still get some little lags on MS.

Why is this? Simply because its vb6.0?


Top
 Profile  
 
PostPosted: Thu Sep 27, 2007 12:33 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Well, it's obviously cause vb aint so good. But never the less, the largest part is how it's programmed. I don't encounter any lag in my game now. And nor do the players. Of course it highly depends on how many players you got, but a MS game can for sure carry tons of players as long as you've spent a lot time fixing the source up.

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


Top
 Profile  
 
PostPosted: Thu Sep 27, 2007 12:39 pm 
Winsock plays a part in it too. These mainstream games have custom socket handlers and shit like that.


Top
  
 
PostPosted: Thu Sep 27, 2007 1:11 pm 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
These commercial game servers also run on 100 different computers with a fiber connection to the internet :)

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 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:  
Powered by phpBB® Forum Software © phpBB Group