Imports System.Net Imports System Imports System.IO Imports System.Text Imports System.Globalization Imports RARNET Imports System.Net.Sockets Public Class Form1 Friend WithEvents webdownloader As New System.Net.WebClient Dim cpx, cpy As Int32 Dim donereading As String = Nothing Dim TextLines() As String = Nothing Dim TextLines2() As String = Nothing Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown cpx = e.X cpy = e.Y End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove If e.Button = Windows.Forms.MouseButtons.Left Then Me.Top = Windows.Forms.Cursor.Position.Y() - cpy Me.Left = Windows.Forms.Cursor.Position.X() - cpx End If End Sub Public Sub DownloadNewPatch() Dim PatcherVersion As Object = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\luminousgaming\Launcher", "Version", "") Dim NeedVersion As Integer = TextLines(1).Split("=")(1) Dim NewAviableVersion As Integer = Val(PatcherVersion) + 1 ' If Val(PatcherVersion) < Val(NeedVersion) Then Launch.Enabled = False ProgressBar1.Value = 0 Dim Replace As String = "#Patch" & NewAviableVersion Dim Zeilen() As String = donereading.Split(Chr(9)) ' For i As Integer = 0 To Zeilen.Length - 1 If Zeilen(i).Contains(Replace) = True Then Dim PatchLine As String = TextLines2(i) Dim Data As String = PatchLine.Split(Chr(9))(1) VersionDownload.Text = "Download: " & Replace webdownloader.DownloadFileAsync(New Uri(Data), "patch.rar") End If Next ElseIf PatcherVersion > NeedVersion Then Launch.Enabled = False MessageBox.Show("Over Patch - Please select ""Reset Patcher""", "Altris :: Patching", MessageBoxButtons.OK, MessageBoxIcon.Warning) Infoform.Show() Else Launch.Enabled = True ProgressBar1.Visible = False VersionDownload.Visible = False Prozent.Visible = False End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim TCP As New TcpClient("127.0.0.1", 11100) Dim NetStream As NetworkStream = TCP.GetStream() Dim swriter As New StreamWriter(NetStream) Dim sreader As New StreamReader(NetStream) swriter.WriteLine("getcfg") swriter.Flush() Do While sreader.Peek >= 1 Donereading &= sreader.ReadLine & vbNewLine Loop TextLines = donereading.Split(Environment.NewLine.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries) swriter.WriteLine("getplist") swriter.Flush() donereading = Nothing donereading &= sreader.ReadLine & vbNewLine Do While sreader.Peek >= 1 donereading &= sreader.ReadLine & vbNewLine Loop TCP.Close() NetStream.Close() swriter.Close() sreader.Close() Catch ex As Exception MessageBox.Show(ex.Message, "Error :: Connection", MessageBoxButtons.OK, MessageBoxIcon.Error) Application.Exit() End Try TextLines2 = donereading.Split(Environment.NewLine.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries) Dim STPatcher As String = TextLines(0).Split("=")(1) ' Dim STPatcherIntern As String = My.Settings.Version If Val(STPatcherIntern) < Val(STPatcher) Then webdownloader.DownloadFile(TextLines(0).Split("=")(6), "Updater.exe") Process.Start("Updater.exe") Application.Exit() Else If TextLines(5).Split("=")(1) = True Then '######## Vote ############# Dim OldDate As String If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\luminousgaming\Launcher", "TimeVote", "") <> "" Then OldDate = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\luminousgaming\Launcher", "TimeVote", "") Else My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\luminousgaming\Launcher", "TimeVote", DateTime.Now.AddHours(-1).ToString) OldDate = DateTime.Now.AddHours(-1).ToString End If ' If DateTime.Compare(DateTime.Parse(OldDate), DateTime.Parse(DateTime.Now.ToString)) < 0 Then VoteForm.ShowDialog() My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\luminousgaming\Launcher", "TimeVote", DateTime.Now.AddHours(12).ToString) End If End If DownloadNewPatch() End If End Sub Private Sub downloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles webdownloader.DownloadFileCompleted Dim PatcherVersion As Object = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\luminousgaming\Launcher", "Version", "") Dim NewAviableVersion As Integer = Val(PatcherVersion) + 1 ' If File.Exists("patch.rar") Then Prozent.Visible = False Dim d As Decompressor d = New Decompressor("patch.rar") AddHandler d.OnUnpack, AddressOf Unpacked AddHandler Decompressor.Unpacking, AddressOf InProgress d.UnPackAll(My.Application.Info.DirectoryPath) Application.DoEvents() Prozent.Visible = True ' File.Delete("patch.rar") My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\luminousgaming\Launcher", "Version", NewAviableVersion) DownloadNewPatch() End If End Sub Private Sub downloader_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles webdownloader.DownloadProgressChanged ProgressBar1.Value = e.ProgressPercentage Prozent.Text = e.ProgressPercentage & "%" End Sub Private Sub Launch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Launch.Click If Not File.Exists("Altris.exe") Then MessageBox.Show("Altris.exe not found! Application Exit now!", "Altris :: Start") Application.Exit() Else If TextLines(2).Split("=")(1) = True Then MessageBox.Show(TextLines(4).Split("=")(1), "NanOnline Information", MessageBoxButtons.OK, MessageBoxIcon.Information) End If Process.Start("Altris.exe") Environment.Exit(0) End If End Sub Private Sub ExitIMG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitIMG.Click Application.Exit() End Sub Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) If e.KeyCode = Keys.Enter Then Launch_Click(sender, e) '// call the event procedure. End Sub Public Sub Unpacked(ByVal r As Decompressor.RAREntry) If r.FileName.Length >= 60 Then VersionDownload.Text = "Processing: " & Strings.Left(r.FileName, 60) & " ...." Else VersionDownload.Text = "Processing: " & r.FileName End If End Sub 'Public Sub InProgress(ByVal TotalFileSize As Long, ByVal CurrentFileSize As Long, ByRef bDisposition As Decompressor.RarDisposition) Public Sub InProgress(ByVal TotalFileSize As Long, ByVal CurrentFileSize As Long, ByRef bDisposition As Decompressor.RarDisposition) If TotalFileSize = 0 Then Exit Sub ProgressBar1.Value = CInt(CDbl(Format(CurrentFileSize / TotalFileSize)) * 100) Application.DoEvents() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Infoform.Show() End Sub End Class