Mirage Source
Optimize Your Packets! - 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: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: Optimize Your Packets! (/showthread.php?tid=55)

Pages: 1 2


- Obsidian - 04-01-2007

Wow that may have been my previous problem as well! I'll have to check that out (and i did have a problem sending any kind of Long Values... but to get around it... i just did a Str$(LONGVAR), and then just did a AddStringToBuffer... then on the recieving end i just got it back as a long and did CLng(W/E). Glad you picked up on it though, i might go back and actually readd byte arrays now). Big Grin


- Spodi - 04-01-2007

My only guess would be the method used has become obsolete and theres a new method, but you're right, that is odd and fishy.


- Obsidian - 04-01-2007

i dunno, maybe the sub used to control the long variables for the ComSocketServer.dll had changed? I (thought i) remember verrigan saying he had the source and had changed some of it up. If perhaps it was changed and the functions that you're using for mirage had been altered in the DLL... i dunno....


- Dragoons Master - 04-01-2007

The most weird this is that this working DLL, the ones that work with binary packets, is OLDER than the other one. One is from september/05 and the other one is from august/05... Thats weird...


- Dragoons Master - 14-02-2007

Ok, I found THE bug and I fixed it!!! Finaly, after a month of useless attempts for fixing this I did it. Well, there realy was a bug. For everybody that downloaded Verrigan's modified MSE with BinPackets, the bug is that when you send the same data to a lot of diferent persons, like SendDataToAll, the Buffer get's messy the first time you send this data. Why? Simple! It was being used as ByRef and that way when, inside SendDataToNew, this code executes:
Code:
Data = PrefixBuffer(Data, VarPtr(CByte(pType)), 1)
    Data = PrefixBuffer(Data, VarPtr(aLen(Data)), 2)
it will replace the old data with this one already modified... So you need to do this once or don't edit. My fix will only don't change the Data() variable. It will copy the data inside Data() variable to an other variable, DataB.
To fix, inside SendDataToNew, replace:
Code:
Data = PrefixBuffer(Data, VarPtr(CByte(pType)), 1)
    Data = PrefixBuffer(Data, VarPtr(aLen(Data)), 2)
    GameServer.Sockets(Index).WriteBytes Data
With:
Code:
Dim DataB() As Byte
    DataB = Data
    DataB = PrefixBuffer(DataB, VarPtr(CByte(pType)), 1)
    DataB = PrefixBuffer(DataB, VarPtr(aLen(DataB)), 2)
    GameServer.Sockets(Index).WriteBytes Data
That shall fix it!


- Bakekitsune - 24-02-2007

Thanks! also how much faster is this?

maybe like,
how many players could you fit?


- Spodi - 24-02-2007

Binary packets isn't as much about speed as it is lowering bandwidth usage.


- Robin - 24-02-2007

Spodi Wrote:Binary packets isn't as much about speed as it is lowering bandwidth usage.

Still, having the server sending less data means that it will be able to send to a few more people than it could when it was sending a lot of data.


- Spodi - 25-02-2007

I wouldn't be surprised if packing strings together holding the same information as the binary is faster (depending on how you do the binary). It really depends how you treat the packets, too. You can easily write crappy binary packets, just like you can string packets. Just like anything else, they're great, if done right. :wink:


Re: Optimize Your Packets! - JokeofWeek - 23-03-2008

Alright Smile So I converted my packets succesfully from Client to Server, without any problems, using a slightly modified version of modBuffer. Now, I converted all the packets from Server sent to client to byte arrays, and it seems to be having alot of problems. The packets are all done good, I checked those over, but it seems to always totally freeze up the client side and crash VB6. I know this is the Server to Client because I did not have this problem when I had only Client to Server. Does anyone know what could possibly be causing this? :S

Edit: Basically, has anyone succesfully converted Server to Client packets? If so, I'd like to talk to you Big Grin


Re: Optimize Your Packets! - William - 25-03-2008

I suggest you try and reach Grim, he knows what his doing.


Re: Optimize Your Packets! - JokeofWeek - 26-03-2008

Well,I seem to have found where the bug is coming from. It seems that whenever it gets to the MapData packet (in SendMap from server side), it processes the packet and all that, but it prefixes it with the wrong packet length, and that is what is causing the bug.

Does anyone know what could possibly be causing this? o_O It seems to be passing the byte values 34 and 16 (in that order) instead of 34 and 18 for the packet length :S.


Re: - seraphelic - 26-04-2008

Dragoons Master Wrote:Ok, I found THE bug and I fixed it!!! Finaly, after a month of useless attempts for fixing this I did it. Well, there realy was a bug. For everybody that downloaded Verrigan's modified MSE with BinPackets, the bug is that when you send the same data to a lot of diferent persons, like SendDataToAll, the Buffer get's messy the first time you send this data. Why? Simple! It was being used as ByRef and that way when, inside SendDataToNew, this code executes:
Code:
Data = PrefixBuffer(Data, VarPtr(CByte(pType)), 1)
    Data = PrefixBuffer(Data, VarPtr(aLen(Data)), 2)
it will replace the old data with this one already modified... So you need to do this once or don't edit. My fix will only don't change the Data() variable. It will copy the data inside Data() variable to an other variable, DataB.
To fix, inside SendDataToNew, replace:
Code:
Data = PrefixBuffer(Data, VarPtr(CByte(pType)), 1)
    Data = PrefixBuffer(Data, VarPtr(aLen(Data)), 2)
    GameServer.Sockets(Index).WriteBytes Data
With:
Code:
Dim DataB() As Byte
    DataB = Data
    DataB = PrefixBuffer(DataB, VarPtr(CByte(pType)), 1)
    DataB = PrefixBuffer(DataB, VarPtr(aLen(DataB)), 2)
    GameServer.Sockets(Index).WriteBytes Data
That shall fix it!

Alright this confused the Hell out of me..
SendDataToNew doesnt exist, and the only thing similar to it that I could find was SendDataNew on the client, which doesn't use GameServer O.O. Soooo.. wth.

Also, does anyone have more bug fixes for mse-verrigan? I'm unfamiliar with binary packets, and looking around I haven't found anything that goes more indepth about the subject.

-edit-

Holy pain in the ass. I didn't realize the editors hardly work. The HandleSave____'s are bugged :[ And the SendEditNpcs crashes the client (occurs in the prefix buffer). Looking at it I'm not sure what went wrong, any help?