26-09-2007, 03:48 PM
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:
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:
We will rename that line of code to this:
The CPN stands for ClientPacketNames, this is just how I'd like to organize it. Now, go into your:
And at the top of that add:
So it looks like:
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:
Now you should know how to write that, but if you don't, here it is:
And after that, you will need to add that to the Enum, so it looks like this:
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:
Now you will find this:
But we are focusing on this part:
We will change that to the new packet name that only take 1 byte, instead of 8 bytes. So it looks like this:
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:
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.
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
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
Code:
If LCase(Parse(0)) = CPNAlertMsg Then
Code:
Public Enum ClientPacketNames
Code:
CPNAlertMsg = 0
Code:
Public Enum ClientPacketNames
CPNAlertMsg = 0 '"alertmsg"
End Enum
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
Code:
If LCase(Parse(0)) = CPNAllChars Then
Code:
Public Enum ClientPacketNames
CPNAlertMsg = 0 ' "alertmsg"
CPNAllChars ' "allchars"
End Enum
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"
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
Code:
Packet = "ALERTMSG" & SEP_CHAR & Msg & SEP_CHAR & END_CHAR
Code:
Packet = CPNAlertMsg & SEP_CHAR & Msg & SEP_CHAR & END_CHAR
Now you start on the server, with adding a:
Code:
Public Enum ServerPacketNames
End Enum
If you need any further help, just post and I'd be glad to help you.