Mirage Source

Free ORPG making software.
It is currently Sat Dec 04, 2021 6:38 am

All times are UTC




Post new topic Reply to topic  [ 93 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: Sat Sep 30, 2006 12:21 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
So, I can't seem to get ZLip working correctly serverside. Client side was easy. You see after installing IOCP and the packet buffer to it, I wanted to try Zlip. But the packetbuffer sub SendQueuedData had to be changed in order to work with IOCP (thanks Obsidian).

So here is my SendQueuedData sub with IOCP and the packet buffer added:
Code:
Sub SendQueuedData()
Dim i As Integer, n As Long
Dim TmpStr As String
Dim dbytes() As Byte
Dim Sploc As Integer
Dim ECloc As Integer
Dim lR As Long

    For i = 1 To MAX_PLAYERS
      TmpStr = ""
      With ConQueues(i)
        If Not .Lock Then
            On Error Resume Next
            If GameServer.Sockets(i).Socket Is Nothing Then
                .Lines = ""
            End If
            If Len(.Lines) = 0 And QueueDisconnect(i) = True Then
                Call CloseSocket(i)
                QueueDisconnect(i) = False
            Else
            If Len(.Lines) > 0 Then
               If Len(.Lines) < MAX_PACKETLEN Then
                 TmpStr = .Lines
               Else
                 TmpStr = Left(.Lines, MAX_PACKETLEN)
               End If
               .Lines = Right(.Lines, Len(.Lines) - Len(TmpStr))
            End If
          End If
          If Len(TmpStr) > 0 Then
            dbytes = StrConv(TmpStr, vbFromUnicode)
            If IsConnected(i) Then
                'Call EnigmaEncrypt(dbytes, "travis")
                GameServer.Sockets(i).WriteBytes dbytes
                DoEvents
            End If
          End If
        End If
      End With
    Next
    DoEvents
End Sub

This is what Zlib want me to replace it with:
Code:
Sub SendQueuedData()
Dim ECloc As Integer
Dim lR As Long

  Dim i As Integer, N As Long
  Dim TmpStr As String
 
  For i = 1 To MAX_PLAYERS
    If frmServer.lblOnOff.Caption = "OFFLINE" Then Exit Sub
    TmpStr = ""
    With ConQueues(i)
      If Not .Lock Then
        If frmServer.Socket(i).State <> 7 Then
          .Lines = ""
        End If
        If Len(.Lines) = 0 And QueueDisconnect(i) = True Then
          Call CloseSocket(i)
          QueueDisconnect(i) = False
        Else
          If Len(.Lines) > 0 Then
             If Len(.Lines) < MAX_PACKETLEN Then
               TmpStr = .Lines
             Else
               TmpStr = Left(.Lines, MAX_PACKETLEN)
             End If
             ECloc = InStr(1, .Lines, END_CHAR)
             TmpStr = Left(.Lines, ECloc)
             .Lines = Right(.Lines, Len(.Lines) - Len(TmpStr))
          End If
        End If
        If Len(TmpStr) > 0 Then
             Debug.Print "Sending: " & TmpStr
             TmpStr = Compress(TmpStr, lR)
             TmpStr = lR & SEP_CHAR & TmpStr
             Call frmServer.Socket(i).SendData(TmpStr)
        End If
      End If
    End With
    DoEvents
  Next
End Sub

If you look close, you will se some differences between them. And I need to know how to make Zlib work with IOCP and the packetbuffer.So somehow they should be mixed together. THis is out of my knowledge so I need some help.

Related Topics
Zlib: http://ms.shannaracorp.com/backup-forum ... sp?TID=218
PacketBuffer: http://ms.shannaracorp.com/backup-forum ... sp?TID=224
IOCP: http://ms.shannaracorp.com/backup-forum ... sp?TID=120

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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 1:07 pm 
You keep saying Zlip, instead of Zlib.

Why don't you compare all of them, find the differences, and just add all the differences into one sub?


Top
  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 1:10 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
I added ZLib into one of my sources. It worked fine, except when it was compiled. It only worked correctly when it was run in VB. Does anyone else have that problem?

_________________
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  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 1:16 pm 
Offline
Pro

Joined: Mon May 29, 2006 1:40 pm
Posts: 430
You don't understand what zlib does do you? Well here it is.

Just using strings with zlib:
Code:
If Len(TmpStr) > 0 Then
            TmpStr = Compress(TmpStr, lR)
            TmpStr = lR & SEP_CHAR & TmpStr
            dbytes = StrConv(TmpStr, vbFromUnicode)
            If IsConnected(i) Then
                GameServer.Sockets(i).WriteBytes dbytes
                DoEvents
            End If
          End If

does zlib need a string to enrypt? or can it encrypt byte arrays?
If it can decrypt byte arrays faster(which it should) theres probably a better way.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 1:43 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
@Advocate: Just noticed I wrote both Zlib and Zlip.. hehe anyway, just a spelling error..

@Misunderstood: If I understood Zlib correctly, I think it Compresses the data (encrypts it). And it doesn't make the packets bigger, that why Zlib is so good. And it also allows for decryption. WHich means that the encryption actually is a compression.. well anyway. The code you posted, is that only what should be changed?

@Kite: Dont know yet, cause I aint got it working yet. ALthough I will try with Miss code first.

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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 2:28 pm 
Offline
Pro

Joined: Mon May 29, 2006 1:40 pm
Posts: 430
Well it is the only place data is sent to the client right?
If it is, then yes, otherwise, no.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 2:45 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Most any compression you find will make packets bigger, or not compress them more then a byte or two, unless you have packets >150 bytes (in which case, for a 2D game, you're already ****ed).

ZLib compresses in byte arrays, as does like every other encryption / compression.

Quote:
dbytes = StrConv(TmpStr, vbFromUnicode)


That is turning your string into a byte array right there.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 2:55 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Zlib Home Site wrote:
the compression method currently used in zlib essentially never expands the data.

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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 3:04 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
I have done plenty of testing with tons of different compression algorithms on packets ranging from like 3 bytes to 300 bytes. "Essentially never" may not apply to insanely small data. :wink:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 3:16 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Okay Im following your advice, and will not add Zlib. Thanks

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


Last edited by William on Sat Sep 30, 2006 3:58 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 3:43 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Glad I could be of help. :wink:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 9:44 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
I'd add it more of a conditional type of thing. You know, adding it for the biggest packets and such.

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 9:54 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
pingu wrote:
I'd add it more of a conditional type of thing. You know, adding it for the biggest packets and such.


I don't see a reason for that, either you have it for all or none. That my opinion at least. And I don't think the biggest once will help you anything, but let Spodi respond :P

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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 10:12 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Well you shouldn't have packets that large, especially not sent more then once every few minutes. If you do for some really wierd reason, though, you can add a check of the packet size first (>250 bytes) then compress it and check if the compression did much of anything (discard the compression if < 10 bytes saved). If it did compress, add a byte to the start of the packet that states it is compressed.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 11:45 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
How do you check the size of a packet?

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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 30, 2006 11:48 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
Lenb(packet string) returns the number of bytes long

_________________
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  
 
 Post subject:
PostPosted: Sun Oct 01, 2006 1:37 am 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
Spodi wrote:
Quote:
dbytes = StrConv(TmpStr, vbFromUnicode)


That is turning your string into a byte array right there.

Just for everyone's information... so is this:
Code:
  dbytes = TmpStr

It just doesn't take out the unicode. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 01, 2006 5:13 am 
Offline
Pro

Joined: Mon May 29, 2006 2:15 am
Posts: 368
you can remove that enigmaencrypt... that was something else i was working on before i sent you that code... :roll:

_________________
Image
Image
The quality of a man is not measured by how well he treats the knowledgeable and competent, but rather how he treats those less fortunate than himself.


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

All times are UTC


Who is online

Users browsing this forum: wanai and 4 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:  
cron
Powered by phpBB® Forum Software © phpBB Group