Mirage Source

Free ORPG making software.
It is currently Sat Feb 27, 2021 10:02 pm

All times are UTC




Post new topic Reply to topic  [ 76 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: How to Port MS to .NET
PostPosted: Sat Oct 19, 2019 6:52 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
This is a starter guide but it will take you very far, it should help you convert your ms server completely. You should always start by converting the server. So do not bother converting the client and server at the same time. You can start converting the ms vb6 client when you can connect with that client to your finished ms server in .NET.

How to Port to VB .net or .net Core.
1. Download Visual Studio 2008.
2. Open your VB project with it and chose convert and run the wizard (begin with the server, its easiest).
3. Run your new vb.net server, and fix all the common errors that appeared.
4. Remove your frmServer and create a new form called ServerWindow (move some data if needed from frmServer).
5. Download https://www.codeproject.com/Articles/11422/Winsock-NET (this one had a bug in it, so when I first tested this I had to modify a row in the source code. So would recommend you include the project so you can debug it easier. This is if you actually want winsock. I used it initially for a smooth port and later changed to TcpClient: https://docs.microsoft.com/en-us/dotnet ... mework-4.8)
6. Implement winsock net to your project.
7. If you have byte arrays you will have more difficulties, I had to rewrite all of modBuffer etc.
8. Make sure things work, connect the client.

Things that confused me at first
  • I was not aware that VB6 and VB.net had missmatching variable declarations. So for example a Long in VB6 is a Integer in VB.net, a Integer in VB6 is a Short in VB.net. So that caused issues for me when I was trying to read all my binary data files (map,items etc...). Because all those bytes need to match exactly. And for some files they still didnt match and that was because VB6 just reads it and doesnt care if it missmatches with the length of the file. While vb.net crashes, but that was basicly solved by try catching the get function for the data, cause the data was still read.
  • Encodings was a issue, there is like ASCII, ETF8, UNIFORM etc when converting to and from bytes. It took me sometime to grasp the fact that that was the issue. But I basically use System.Text.Encoding.Default. for now. You mainly just search for System.Text.Encoding. in your vb.net converted server to see all the locations for it.
  • Its also a little tricky with the indexes of arrays, since vb6 has arrays from value 1-10 for exmple, but thats forbidden in vb.net (it has to start from 0). So there was a -1 here and there to take care of that.

Winsock .NET
Here is the winsock part, pretty short and simple. All you do is add:

Code:
    Public Shared Network As New Sockethandler

in the ServerWindow class. And add:
Code:
    Network.Initialize()

in the ServerWindow form loaded sub.

And then you will have some errors with frmServer.Socket that you change to ServerWindow.Server...

Code:
Imports System.Collections.Generic
Imports System.Net.Sockets
Imports Winsock_Control

Public Class Sockethandler

    Public WithEvents Server As Winsock
    Public Sockets As New Dictionary(Of Integer, Winsock)
    Private m_SocketsToRemove As New List(Of Winsock)

    Public Sub Initialize()
        Server = New Winsock
        Server.LocalPort = 4000
        Server.RemotePort = 4000
        Server.RemoteIP = "127.0.0.1"
        Server.Listen()
    End Sub

    Public Function GetState(index As Integer) As WinsockStates
        If TryGetUser(index) Is Nothing Then
            Return WinsockStates.Closed
        End If

        Return TryGetUser(index).GetState
    End Function

    Public Function TryGetIndex(socket As Winsock) As Integer
        For Each item As KeyValuePair(Of Integer, Winsock) In Sockets
            If item.Value Is socket Then
                Return item.Key
            End If
        Next
        Return -1
    End Function

    Public Function TryGetUser(index As Integer) As Winsock
        If Sockets.ContainsKey(index) Then Return Sockets(index)

        Return Nothing
    End Function

    Private Sub Socket_ConnectionRequest(sender As Winsock, requestID As Socket) Handles Server.ConnectionRequest
        Try
            Dim i As Integer
            i = FindOpenPlayerSlot()

            Sockets.Add(i, sender)
            Dim ws As Winsock = CType(sender, Winsock)

            AddHandler ws.DataArrival, AddressOf wsk_DataArrival
            AddHandler ws.Disconnected, AddressOf wsk_Disconnected

            ws.Accept(requestID)

            Call AcceptConnection(ws, requestID, i)
        Catch ex As Exception
            Diagnostics.Debugger.Break()
        End Try
    End Sub

    Private Sub wsk_Disconnected(sender As Winsock)
        If m_SocketsToRemove.Contains(sender) Then Exit Sub
        m_SocketsToRemove.Add(sender)

        If m_SocketsToRemove.Count > 0 Then
            Try
                CloseSocket(TryGetIndex(sender))
                m_SocketsToRemove.Remove(sender)
            Catch ex As Exception
                Diagnostics.Debugger.Break()
            End Try
        End If
    End Sub

    Private Sub wsk_DataArrival(sender As Winsock, BytesTotal As Integer)
        If IsConnected(TryGetIndex(sender)) Then
            Call IncomingData(TryGetIndex(sender), BytesTotal)
        End If
    End Sub

End Class


Client Graphics
I'm using SFML for the graphics and most likely the audio ( https://www.sfml-dev.org/ ).
Quote:
SFML provides a simple interface to the various components of your PC, to ease the development of games and multimedia applications. It is composed of five modules: system, window, graphics, audio and network.
With SFML, your application can compile and run out of the box on the most common operating systems: Windows, Linux, macOS and soon Android & iOS.


Additional info
1. Download and install: http://go.microsoft.com/fwlink/?linkid=321343
1.1 Make sure it works on computer without powerpacks installed. Those files should be included in EXE.
2. Needed to put Interop.DxVBLib.dll into my: C:\Windows\SysWOW64 folder!
3. Temporarily added ms symbols (should be able to ignore this): http://www.vbforums.com/showthread.php? ... e-PDB-file
4. Net framework 4 on project.
5. Used this for smooth form transitions: http://vbcity.com/forums/t/158363.aspx (put in my basepage).

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


Top
 Profile  
 
PostPosted: Fri Oct 09, 2020 10:30 am 
Offline
Newbie

Joined: Fri Oct 09, 2020 10:28 am
Posts: 1
Slots online bingo free no deposit casino is the best and safest way to make money. I suggest you try it!


Top
 Profile  
 
PostPosted: Thu Nov 26, 2020 10:05 pm 
Offline
Newbie
User avatar

Joined: Thu Nov 26, 2020 12:46 pm
Posts: 10
Location:  Mali
Google Talk: :Google talk&quot
Image


Ежедневный Гороскоп от НЕЙРОСЕТИ!


Персональное предсказание на сегодня онлайн. Планеты находятся в постоянном движении. Аспекты, которые они создают с планетами в Вашей натальной карте называются транзитами. Гороскоп сегодня Телец Онлайн для всех знаков зодиака, а также тематические бесплатные любви, карьеры, стрижек, и авторские от Павла Глобы, Василисы Володиной, Арины Евдокимовой.

_________________
https://www.youtube.com/channel/UCTProT ... JsamKkk6OA Ежедневный Гороскоп


Top
 Profile  
 
PostPosted: Fri Nov 27, 2020 5:52 pm 
Offline
Newbie
User avatar

Joined: Thu Nov 26, 2020 12:46 pm
Posts: 10
Location:  Mali
Google Talk: :Google talk&quot
Image


Ежедневный Гороскоп от НЕЙРОСЕТИ!


Ответ можно найти в актуальном на сегодня. Если одним из первых дел, совершенных вами утром, будет изучение рекомендаций звезд, то вы сможете спланировать свой день гараздо лучше. гороскоп завтра Водолей на сегодня, на неделю, на месяц. по знакам зодиака. Сонник, совместимости, лунный , камни по знакам зодиака.

_________________
https://www.youtube.com/channel/UCTProT ... JsamKkk6OA Ежедневный Гороскоп


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:36 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ помпы ланос
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">чертеж ключа помпы на нексию</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:37 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ помпа авео
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ помпы нексия цена</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:38 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ помпы нексия купить
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ для помпы цена</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:38 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ для натяжки помпы на авео
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ натяжки помпы нексия купить</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:39 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ помпы нексия цена
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ помпы нексия цена</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:39 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ для помпы на нексию
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">самодельный ключ для помпы</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:40 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
купить ключ для помпы нексия
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ для регулировки помпы на лачетти</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:41 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ 41 для помпы
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ на 41 регулировка помпы</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:41 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ безопасности для помпы
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ для регулировки помпы на ланосе</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:42 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ 41 для помпы купить спб
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ на 41 для помпы лачетти</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:43 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ 41 помпа
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ для помпы своими руками</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:43 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ для замены помпы
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">купить ключ для помпы нексии</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:44 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
шевроле круз ключ натяжения помпы
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ помпа ланос</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:45 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ для помпы для ланоса
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">размеры ключа для помпы на нексию</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:45 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ натяжки помпы нексия
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ 41 помпа купить</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:46 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
размеры ключа для помпы на нексию
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ помпы 41 мм купить</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:47 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
помпа ключ
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ для помпы ланос купить</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:47 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
самодельный ключ для помпы
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ помпы нексия купить</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:48 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ для натяжки помпы ланос купить
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ для помпы</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:48 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
ключ для натяжения помпы лачетти
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">ключ 41 для помпы чертеж</a>

_________________
ключ на 41 для помпы купить в спб


Top
 Profile  
 
 Post subject: Test, just a test
PostPosted: Tue Dec 08, 2020 8:49 am 
Offline
Regular

Joined: Tue Dec 08, 2020 8:33 am
Posts: 32
Location: Россия
Google Talk: :Google talk&quot
https://www.avito.ru/voronezh/zapchasti ... 1107349456
нексия ключ для помпы
<a href="https://www.avito.ru/voronezh/zapchasti_i_aksessuary/klyuch_pompy_lachetti_neksiya_lanos_kruz_gm_na_41_1107349456">какой ключ помпы шевроле круз</a>

_________________
ключ на 41 для помпы купить в спб


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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