SebastianLawe

Untitled

Oct 23rd, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.34 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. using System.Data.SqlClient;
  8.  
  9. public partial class games_SmashyBall : System.Web.UI.Page
  10. {
  11.     private const int CURRENT_VERSION = 31;
  12.     private const string CURRENT_LAUNCHER_VERSION = "1.0.1.5";
  13.     protected void Page_Load(object sender, EventArgs e)
  14.     {
  15.         if (Request.QueryString.Count >= 2)
  16.         {
  17.             int version = int.Parse(Request.Params.Get("gameVersion"));
  18.             string launcherVersion = Request.Params.Get("launcherVersion");
  19.             if (Request.QueryString.Count >= 6)
  20.             {
  21.                 string id = Request.Params.Get("id");
  22.                 string os = Request.Params.Get("os");
  23.                 int monitors = int.Parse(Request.Params.Get("monitors"));
  24.                 string resolutions = Request.Params.Get("resolutions");
  25.                 int processors = int.Parse(Request.Params.Get("processors"));
  26.                 string is64Bit = Request.Params.Get("is64Bit");
  27.                 try
  28.                 {
  29.                     #region SQL Tracking
  30.                     SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
  31.                     builder.DataSource = @"(local)\sebastianlawe";
  32.                     builder.UserID = System.Web.Configuration.WebConfigurationManager.AppSettings["DatabaseName"];
  33.                     builder.Password = System.Web.Configuration.WebConfigurationManager.AppSettings["DatabasePassword"];
  34.                     using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
  35.                     {
  36.                         connection.Open();
  37.                         using (SqlCommand command = connection.CreateCommand())
  38.                         {
  39.                             command.CommandText = @"INSERT INTO [SebastianLawe].[dbo].[ProjectNORStats] (Id, OperatingSystem, Monitors, Resolutions, Processors, Is64Bit)
  40.                        VALUES (@Id, @OS, @Monitors, @Resolutions, @Processors, @Is64Bit)";
  41.                             SqlParameter parameter = command.CreateParameter();
  42.                             parameter.ParameterName = "@Id";
  43.                             parameter.Value = id;
  44.                             command.Parameters.Add(parameter);
  45.                             //--------------------------
  46.                             parameter = command.CreateParameter();
  47.                             parameter.ParameterName = "@OS";
  48.                             parameter.Value = os;
  49.                             command.Parameters.Add(parameter);
  50.                             //--------------------------
  51.                             parameter = command.CreateParameter();
  52.                             parameter.ParameterName = "@Monitors";
  53.                             parameter.Value = monitors;
  54.                             command.Parameters.Add(parameter);
  55.                             //--------------------------
  56.                             parameter = command.CreateParameter();
  57.                             parameter.ParameterName = "@Resolutions";
  58.                             parameter.Value = SmartTrim(resolutions);
  59.                             command.Parameters.Add(parameter);
  60.                             //--------------------------
  61.                             parameter = command.CreateParameter();
  62.                             parameter.ParameterName = "@Processors";
  63.                             parameter.Value = processors;
  64.                             command.Parameters.Add(parameter);
  65.                             //--------------------------
  66.                             parameter = command.CreateParameter();
  67.                             parameter.ParameterName = "@Is64Bit";
  68.                             parameter.Value = is64Bit;
  69.                             command.Parameters.Add(parameter);
  70.                             command.ExecuteNonQuery();
  71.                         }
  72.                     }
  73.                     #endregion SQL Tracking
  74.                 }
  75.                 catch { }
  76.             }
  77.             using (BinaryWriter metaWriter = new BinaryWriter(Response.OutputStream))
  78.             {
  79.                 metaWriter.Write(CURRENT_VERSION);
  80.                 metaWriter.Write(CURRENT_LAUNCHER_VERSION);
  81.                 metaWriter.Write(19);
  82.                 metaWriter.Write(
  83. @"9/24/2015:
  84. Welcome to Project NOR!
  85.  
  86. This is a first person shooter that takes a new spin on what a shooter is, and has full split screen support.
  87.  
  88. This game is in alpha, and is bound to have plenty of bugs, and frequent updates.
  89.  
  90. Asset changes, and entire theme re-designs may also happen as time progresses.
  91.  
  92. Thanks for understanding that this is not a finished game, and happy testing!");
  93.                 metaWriter.Write(
  94. @"9/25/2015:
  95. Added more in depth controller settings. Added bumpmaps.");
  96.                 metaWriter.Write(
  97. @"9/26/2015:
  98. Fixed bug that prevented matchmaking from working.");
  99.                 metaWriter.Write(
  100. @"9/27/2015:
  101. Fixed bug where player could stick to walls.
  102. Increased player and bot movment speed.
  103. Added the ability to navigate menus with a controller or keyboard.
  104. Removed MapC(the maze) from the game due to performance issues.
  105. Fixed a bug where another team member could collect a point in CTF if another got the flag.
  106. Falling in water now stuns the player alongside being teleported.
  107. Fixed a bug where the player could infintite jump in MapF if the bridges dissapeared.
  108. Fixed a bug where the running animation would continue if a player was stunned.");
  109.                 metaWriter.Write(
  110. @"9/28/2015:
  111. Upgraded Unity runtime to the latest patch, sudden game crashes should hopefully be gone.");
  112.                 metaWriter.Write(
  113. @"9/30/2015:
  114. - New theme song, and initial main menu.
  115. - Fixed bug where team mate can re-steal a flag after its been stolen.
  116. - Fixed bug where AI players would act weird when the game menu is brought up.
  117. - Updated some of the maps with new additions.
  118. - Added optimizations to AI and changeable colours, and a few other routines.
  119. - Made stun bar the colour of whatever team the player is on.
  120. - Overhauled the controller input system. Nothing will be noticed gameplay wise.
  121. - Fixed bug where collision checking would have the player run into invisible walls under certain conditions.
  122. ");
  123.                 metaWriter.Write(
  124. @"10/1/2015:
  125. - Changed pathfinding system for AI.
  126. - Made some performance changes.
  127. ");
  128.                 metaWriter.Write(
  129. @"10/1/2015 - 2:40pm:
  130. - Fixed AI pathfinding in Map F
  131. - Disconnecting appears to have some bugs.
  132. ");
  133.                 metaWriter.Write(
  134. @"10/7/2015 - 5:27am:
  135. - Fixed bug where matchmaking would never find matches.
  136. - Added a new map (MapH).
  137. - Tweaked the AI not to run into one another.
  138. ");
  139.                 metaWriter.Write(
  140. @"10/8/2015 - 9:07am:
  141. - Added graphics options
  142. - Fixed bug where players could shoot from the menu.
  143. - Tweaked lighting.
  144. ");
  145.                 metaWriter.Write(
  146. @"10/12/2015 - 1:34am:
  147. - Added King Of The Hill
  148. - Added Single Flag CTF
  149. - Tweaked teleport enemy players.
  150. - Made blockades wider.
  151. ");
  152.                 metaWriter.Write(
  153. @"10/12/2015 - 2:12am:
  154. - Fixed bug where King Zones wouldn't detect if a player left the zone.
  155. - Fixed bug where teleporting enemy players was not working.
  156. - Fixed raised stun zone in MapH
  157. ");
  158.                 metaWriter.Write(
  159. @"10/14/2015 - 5:50pm:
  160. - Added a new map with new anti-gravity mechanics (MapI)
  161. - AI are not well suited for anti-gravity maps, expect bugs.
  162. ");
  163.                 metaWriter.Write(
  164. @"10/17/2015 - 4:50am:
  165. - Added a new map with anti-gravity mechanics (MapJ).
  166. - Made the anti-gravity mechanics fully flexible.
  167. - Fixed bug where CTF was not working properly.
  168. - Removed Realtime GI (it slows down the development process).
  169. - Modified MapF with new bases.
  170. ");
  171.                 metaWriter.Write(
  172. @"10/17/2015 - 2:04pm:
  173. - Fixed Occlusion Culling on MapJ
  174. - Fixed wall spawning when walking on walls.
  175. ");
  176.                 metaWriter.Write(
  177. @"10/17/2015 - 4:18pm:
  178. - Fixed spawns in MapF
  179. - Adjusted jumping
  180. - Fixed bug where AI would stutter and not follow any path.
  181. ");
  182.                 metaWriter.Write(
  183. @"10/17/2015 - 7:23pm:
  184. - Fixed bug where AI would stutter and not follow any path (still stutters though).
  185. ");
  186.                 metaWriter.Write(
  187. @"10/18/2015 - 5:43am:
  188. - Added level introductions.
  189. - Optimized and changed custom games menu.
  190. ");
  191.                 metaWriter.Write(
  192. @"10/21/2015 - 10:03:
  193. - Fixed bug where jumping would sometimes not work.
  194. - Made some subtle audio adjustments.
  195. ");
  196.                 if (CURRENT_LAUNCHER_VERSION == launcherVersion)
  197.                 {
  198.                     SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
  199.                     builder.DataSource = @"(local)\sebastianlawe";
  200.                     builder.UserID = System.Web.Configuration.WebConfigurationManager.AppSettings["DatabaseName"];
  201.                     builder.Password = System.Web.Configuration.WebConfigurationManager.AppSettings["DatabasePassword"];
  202.                     using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
  203.                     {
  204.                         connection.Open();
  205.                         using (SqlCommand command = connection.CreateCommand())
  206.                         {
  207.                             command.CommandText = @"select top 5 [Url], [ImageUrl] from [SebastianLawe].[dbo].[HomeCarousel]
  208.                                    Order by [DateCreated]  ASC";
  209.                             SqlDataReader reader = command.ExecuteReader();
  210.                             List<KeyValuePair<string, string>> pairs = new List<KeyValuePair<string, string>>();
  211.                             while (reader.Read())
  212.                             {
  213.                                 pairs.Add(new KeyValuePair<string, string>((string)reader.GetValue(0), (string)reader.GetValue(1)));
  214.                             }
  215.                             metaWriter.Write(pairs.Count);
  216.                             foreach (KeyValuePair<string, string> pair in pairs)
  217.                             {
  218.                                 metaWriter.Write(pair.Key);
  219.                                 metaWriter.Write(pair.Value);
  220.                             }
  221.                         }
  222.                     }
  223.                     if (version < CURRENT_VERSION)
  224.                     {
  225.                         using (FileStream input = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"\games\ProjectNOR\", "game.zip"),
  226.                             FileMode.Open, FileAccess.Read))
  227.                         {
  228.                             metaWriter.Write(input.Length);
  229.                             //metaWriter.Write(DateTime.Now.Ticks);
  230.                             byte[] buffer = new byte[32768];
  231.                             int read;
  232.                             while ((read = input.Read(buffer, 0, buffer.Length)) != 0)
  233.                             {
  234.                                 Response.OutputStream.Write(buffer, 0, read);
  235.                             }
  236.                         }
  237.                     }
  238.                 }
  239.                 else
  240.                 {
  241.                     if (launcherVersion == "1.0.0.4")
  242.                     {
  243.                         metaWriter.Write((long)0);
  244.                     }
  245.                     using (FileStream input = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"\games\ProjectNOR\", "launcher.exe"),
  246.                         FileMode.Open, FileAccess.Read))
  247.                     {
  248.                         metaWriter.Write(input.Length);
  249.                         //metaWriter.Write(DateTime.Now.Ticks);
  250.                         byte[] buffer = new byte[32768];
  251.                         int read;
  252.                         while ((read = input.Read(buffer, 0, buffer.Length)) != 0)
  253.                         {
  254.                             Response.OutputStream.Write(buffer, 0, read);
  255.                         }
  256.                     }
  257.                 }
  258.             }
  259.         }
  260.     }
  261.  
  262.     private string SmartTrim(string resolutions)
  263.     {
  264.         string value = "";
  265.         foreach (char character in resolutions)
  266.         {
  267.             if (character != '<')
  268.             {
  269.                 value += character;
  270.             }
  271.             else
  272.             {
  273.                 break;
  274.             }
  275.         }
  276.         return value;
  277.     }
  278. }
Advertisement
Add Comment
Please, Sign In to add comment