SebastianLawe

Untitled

Jun 8th, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.81 KB | None | 0 0
  1. Imports System.Collections.Generic
  2. Imports System.Web
  3. Imports System.Web.UI
  4. Imports System.Web.UI.WebControls
  5. Imports System.IO
  6.  
  7. Public Partial Class games_SmashyBall
  8.     Inherits System.Web.UI.Page
  9.     Private Const CURRENT_VERSION As Integer = 1
  10.     Private Const CURRENT_LAUNCHER_VERSION As String = "1.0.0.3"
  11.     Protected Sub Page_Load(sender As Object, e As EventArgs)
  12.         ' Check if we have flags passed by the launcher
  13.         If Request.Params.Count >= 2 Then
  14.             ' Get the version of the game they have.
  15.             Dim version As Integer = Integer.Parse(Request.Params.[Get]("gameVersion"))
  16.             ' Get the version of the launcher
  17.             Dim launcherVersion As String = Request.Params.[Get]("launcherVersion")
  18.             ' If we have more than 6 flags
  19.             If Request.Params.Count = 6 Then
  20.                 ' Get the PC ID
  21.                 Dim id As String = Request.Params.[Get]("id")
  22.                 ' Get the PC operating system
  23.                 Dim os As String = Request.Params.[Get]("os")
  24.                 ' Get the monitor count
  25.                 Dim monitors As Integer = Integer.Parse(Request.Params.[Get]("monitors"))
  26.                 ' Get the monitor resolutions
  27.                 Dim resolutions As String = Request.Params.[Get]("resolutions")
  28.                 ' Get the processor count
  29.                 Dim processors As Integer = Integer.Parse(Request.Params.[Get]("processors"))
  30.                 ' Get the operating system version.
  31.                 Dim is64Bit As String = Request.Params.[Get]("is64Bit")
  32.             End If
  33.             ' Write data back to the launcher
  34.             Using metaWriter As New BinaryWriter(Response.OutputStream)
  35.                 ' Write the up to date game version
  36.                 metaWriter.Write(CURRENT_VERSION)
  37.                 ' Write the up to date launcher version
  38.                 metaWriter.Write(CURRENT_LAUNCHER_VERSION)
  39.                 ' Write the news message count.
  40.                 metaWriter.Write(2)
  41.                 ' Write the news
  42.                 metaWriter.Write("4/29/2015:" & vbCr & vbLf & "This release of Smashy Ball is for everybody who is up and running on a Windows PC." & vbCr & vbLf & " " & vbCr & vbLf & "For the 12 months this game has been out, the PC market has not had proper support or updates for this game." & vbCr & vbLf & " " & vbCr & vbLf & "To fix this, this new launcher has been created to make sure you're game version is always up to date.")
  43.  
  44.                 metaWriter.Write("4/30/2015:" & vbCr & vbLf & "Updated the Launcher. You'll have to go and download the new one from itch.io")
  45.                 ' Check if the launcher needs to be updated.
  46.                 If CURRENT_LAUNCHER_VERSION = launcherVersion Then
  47.                     ' Send the new launcher
  48.                     Using input As New FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory & "\games\", "game.zip"), FileMode.Open, FileAccess.Read)
  49.                         ' Send the file size so the launcher knows how much data to read
  50.                         metaWriter.Write(input.Length)
  51.                         ' Send the current time.
  52.                         metaWriter.Write(DateTime.Now.Ticks);
  53.                        
  54.                         Dim buffer As Byte() = New Byte(32767) {}
  55.                         Dim read As Integer
  56.                         ' Send the newest launcher to the launcher.
  57.                         While (InlineAssignHelper(read, input.Read(buffer, 0, buffer.Length))) <> 0
  58.                             Response.OutputStream.Write(buffer, 0, read)
  59.                         End While
  60.                     End Using
  61.                 Else
  62.                     Using input As New FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory & "\games\", "launcher.exe"), FileMode.Open, FileAccess.Read)
  63.                         ' Send the file size so the launcher knows how much data to read
  64.                         metaWriter.Write(input.Length)
  65.                         ' Send the current time.
  66.                         metaWriter.Write(DateTime.Now.Ticks);
  67.                         Dim buffer As Byte() = New Byte(32767) {}
  68.                         Dim read As Integer
  69.                         ' Send the newest version of the game to the launcher
  70.                         While (InlineAssignHelper(read, input.Read(buffer, 0, buffer.Length))) <> 0
  71.                             Response.OutputStream.Write(buffer, 0, read)
  72.                         End While
  73.                     End Using
  74.                 End If
  75.             End Using
  76.         End If
  77.     End Sub
  78.     Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
  79.         target = value
  80.         Return value
  81.     End Function
  82. End Class
Advertisement
Add Comment
Please, Sign In to add comment