SebastianLawe

Untitled

May 2nd, 2015
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web;
  4. using System.Web.UI;
  5. using System.Web.UI.WebControls;
  6. using System.IO;
  7.  
  8. public partial class games_SmashyBall : System.Web.UI.Page
  9. {
  10.     private const int CURRENT_VERSION = 1;
  11.     private const string CURRENT_LAUNCHER_VERSION = "1.0.0.3";
  12.     protected void Page_Load(object sender, EventArgs e)
  13.     {
  14.         if (Request.Params.Count >= 2)
  15.         {
  16.             int version = int.Parse(Request.Params.Get("gameVersion"));
  17.             string launcherVersion = Request.Params.Get("launcherVersion");
  18.             if (Request.Params.Count == 6)
  19.             {
  20.                 string id = Request.Params.Get("id");
  21.                 string os = Request.Params.Get("os");
  22.                 int monitors = int.Parse(Request.Params.Get("monitors"));
  23.                 string resolutions = Request.Params.Get("resolutions");
  24.                 int processors = int.Parse(Request.Params.Get("processors"));
  25.                 string is64Bit = Request.Params.Get("is64Bit");
  26.             }
  27.             using (BinaryWriter metaWriter = new BinaryWriter(Response.OutputStream))
  28.             {
  29.                 metaWriter.Write(CURRENT_VERSION);
  30.                 metaWriter.Write(CURRENT_LAUNCHER_VERSION);
  31.                 metaWriter.Write(2);
  32.                 metaWriter.Write(
  33. @"4/29/2015:
  34. This release of Smashy Ball is for everybody who is up and running on a Windows PC.
  35.  
  36. For the 12 months this game has been out, the PC market has not had proper support or updates for this game.
  37.  
  38. To fix this, this new launcher has been created to make sure you're game version is always up to date.");
  39.  
  40.                 metaWriter.Write(
  41. @"4/30/2015:
  42. Updated the Launcher. You'll have to go and download the new one from itch.io");
  43.                 if (CURRENT_LAUNCHER_VERSION == launcherVersion)
  44.                 {
  45.                     using (FileStream input = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"\games\", "game.zip"),
  46.                         FileMode.Open, FileAccess.Read))
  47.                     {
  48.                         metaWriter.Write(input.Length);
  49.                         //metaWriter.Write(DateTime.Now.Ticks);
  50.                         byte[] buffer = new byte[32768];
  51.                         int read;
  52.                         while ((read = input.Read(buffer, 0, buffer.Length)) != 0)
  53.                         {
  54.                             Response.OutputStream.Write(buffer, 0, read);
  55.                         }
  56.                     }
  57.                 }
  58.                 else
  59.                 {
  60.                     using (FileStream input = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"\games\", "launcher.exe"),
  61.                         FileMode.Open, FileAccess.Read))
  62.                     {
  63.                         metaWriter.Write(input.Length);
  64.                         //metaWriter.Write(DateTime.Now.Ticks);
  65.                         byte[] buffer = new byte[32768];
  66.                         int read;
  67.                         while ((read = input.Read(buffer, 0, buffer.Length)) != 0)
  68.                         {
  69.                             Response.OutputStream.Write(buffer, 0, read);
  70.                         }
  71.                     }
  72.                 }
  73.             }
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment