Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Collections.Generic
- Imports System.Web
- Imports System.Web.UI
- Imports System.Web.UI.WebControls
- Imports System.IO
- Public Partial Class games_SmashyBall
- Inherits System.Web.UI.Page
- Private Const CURRENT_VERSION As Integer = 1
- Private Const CURRENT_LAUNCHER_VERSION As String = "1.0.0.3"
- Protected Sub Page_Load(sender As Object, e As EventArgs)
- ' Check if we have flags passed by the launcher
- If Request.Params.Count >= 2 Then
- ' Get the version of the game they have.
- Dim version As Integer = Integer.Parse(Request.Params.[Get]("gameVersion"))
- ' Get the version of the launcher
- Dim launcherVersion As String = Request.Params.[Get]("launcherVersion")
- ' If we have more than 6 flags
- If Request.Params.Count = 6 Then
- ' Get the PC ID
- Dim id As String = Request.Params.[Get]("id")
- ' Get the PC operating system
- Dim os As String = Request.Params.[Get]("os")
- ' Get the monitor count
- Dim monitors As Integer = Integer.Parse(Request.Params.[Get]("monitors"))
- ' Get the monitor resolutions
- Dim resolutions As String = Request.Params.[Get]("resolutions")
- ' Get the processor count
- Dim processors As Integer = Integer.Parse(Request.Params.[Get]("processors"))
- ' Get the operating system version.
- Dim is64Bit As String = Request.Params.[Get]("is64Bit")
- End If
- ' Write data back to the launcher
- Using metaWriter As New BinaryWriter(Response.OutputStream)
- ' Write the up to date game version
- metaWriter.Write(CURRENT_VERSION)
- ' Write the up to date launcher version
- metaWriter.Write(CURRENT_LAUNCHER_VERSION)
- ' Write the news message count.
- metaWriter.Write(2)
- ' Write the news
- 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.")
- metaWriter.Write("4/30/2015:" & vbCr & vbLf & "Updated the Launcher. You'll have to go and download the new one from itch.io")
- ' Check if the launcher needs to be updated.
- If CURRENT_LAUNCHER_VERSION = launcherVersion Then
- ' Send the new launcher
- Using input As New FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory & "\games\", "game.zip"), FileMode.Open, FileAccess.Read)
- ' Send the file size so the launcher knows how much data to read
- metaWriter.Write(input.Length)
- ' Send the current time.
- metaWriter.Write(DateTime.Now.Ticks);
- Dim buffer As Byte() = New Byte(32767) {}
- Dim read As Integer
- ' Send the newest launcher to the launcher.
- While (InlineAssignHelper(read, input.Read(buffer, 0, buffer.Length))) <> 0
- Response.OutputStream.Write(buffer, 0, read)
- End While
- End Using
- Else
- Using input As New FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory & "\games\", "launcher.exe"), FileMode.Open, FileAccess.Read)
- ' Send the file size so the launcher knows how much data to read
- metaWriter.Write(input.Length)
- ' Send the current time.
- metaWriter.Write(DateTime.Now.Ticks);
- Dim buffer As Byte() = New Byte(32767) {}
- Dim read As Integer
- ' Send the newest version of the game to the launcher
- While (InlineAssignHelper(read, input.Read(buffer, 0, buffer.Length))) <> 0
- Response.OutputStream.Write(buffer, 0, read)
- End While
- End Using
- End If
- End Using
- End If
- End Sub
- Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
- target = value
- Return value
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment