From 0085241d2366f266b5416488dbead174184420b0 Mon Sep 17 00:00:00 2001 From: MichaelTheShifter Date: Sun, 1 May 2016 20:23:48 -0400 Subject: [PATCH] Beta 2.2 Patch 1 Commit for Beta 2.2 Patch 1 - Removed unused "Linux Mint 7" and "NetSockets" files from Resources.resx - Added a better server startup pool, no longer hardcoded. - Added a server blacklist for disabling servers that break the rules of the playshiftos.ml/forum server showcase --- .../Package_Grabber.cs | 57 ++++++++++++++----- source/WindowsFormsApplication1/Program.cs | 26 +++++++-- .../Properties/Resources.Designer.cs | 20 ------- .../Properties/Resources.resx | 6 -- .../WindowsFormsApplication1/ShiftOS.csproj | 2 +- .../WindowComposition.cs | 41 +++++++------ 6 files changed, 88 insertions(+), 64 deletions(-) diff --git a/source/WindowsFormsApplication1/Package_Grabber.cs b/source/WindowsFormsApplication1/Package_Grabber.cs index c9948b0..a041910 100644 --- a/source/WindowsFormsApplication1/Package_Grabber.cs +++ b/source/WindowsFormsApplication1/Package_Grabber.cs @@ -54,29 +54,58 @@ public static void ConnectToServer(string address, int port) { clients = new Dictionary(); } - var client = new NetObjectClient(); - client.OnReceived += (object s, NetReceivedEventArgs a) => { - try { - var obj = (ObjectModel)a.Data.Object; - if (obj.Command == "set_ident") + bool blacklisted = false; + string blacklist = new WebClient().DownloadString("http://playshiftos.ml/server/blacklist"); + string[] splitter = blacklist.Split(';'); + foreach (string addr in splitter) + { + try + { + string[] addSplitter = addr.Split(':'); + string host = addSplitter[0]; + int prt = Convert.ToInt32(addSplitter[1]); + if(address == host && port == prt) { - this_id = obj.SysId; + blacklisted = true; } } catch { } - }; - - try - { - client.Connect(address, port); - clients.Add(client.RemoteHost, client); } - catch(Exception ex) + if (!blacklisted) { - MessageBox.Show($"Error: {ex.Message}"); + var client = new NetObjectClient(); + client.OnReceived += (object s, NetReceivedEventArgs a) => + { + try + { + var obj = (ObjectModel)a.Data.Object; + if (obj.Command == "set_ident") + { + this_id = obj.SysId; + } + } + catch + { + + } + }; + + try + { + client.Connect(address, port); + clients.Add(client.RemoteHost, client); + } + catch (Exception ex) + { + API.CreateInfoboxSession("Server Connection Error", $"{ex.Message}", infobox.InfoboxMode.Info); + } + } + else + { + API.CreateInfoboxSession("Server Connection Error", "The server you are trying to connect to has been blacklisted for breaking the rules of the Server Showcase, therefore you may not connect to it.", infobox.InfoboxMode.Info); } } diff --git a/source/WindowsFormsApplication1/Program.cs b/source/WindowsFormsApplication1/Program.cs index 7f086cb..e7fb173 100644 --- a/source/WindowsFormsApplication1/Program.cs +++ b/source/WindowsFormsApplication1/Program.cs @@ -7,6 +7,7 @@ using System.Net; using System.IO.Compression; using System.ComponentModel; +using System.Threading; namespace ShiftOS { @@ -22,7 +23,26 @@ static void Main(string[] args) Application.SetCompatibleTextRenderingDefault(false); //Extract all dependencies before starting the engine. ExtractDependencies(); - Package_Grabber.ConnectToServer("shiftos.cloudapp.net", 4433); + var poolThread = new Thread(new ThreadStart(new Action(() => { + //Download ShiftOS server startup-pool + string pool = new WebClient().DownloadString("http://playshiftos.ml/server/startup_pool"); + string[] splitter = pool.Split(';'); + foreach(string address in splitter) + { + try + { + string[] addSplitter = address.Split(':'); + string host = addSplitter[0]; + int port = Convert.ToInt32(addSplitter[1]); + Package_Grabber.ConnectToServer(host, port); + } + catch + { + + } + } + }))); + poolThread.Start(); //Start the Windows Forms backend Paths.RegisterPaths(); //Sets ShiftOS path variables based on the current OS. SaveSystem.Utilities.CheckForOlderSaves(); //Backs up C:\ShiftOS on Windows systems if it exists and doesn't contain a _engineInfo.txt file telling ShiftOS what engine created it. @@ -87,10 +107,6 @@ static void ExtractDependencies() { //Wow. This'll make it easy for people... string path = Directory.GetParent(Application.ExecutablePath).FullName; - if(!File.Exists(path + OSInfo.DirectorySeparator + "NetSockets.dll")) - { - File.WriteAllBytes(path + OSInfo.DirectorySeparator + "NetSockets.dll", Properties.Resources.NetSockets); - } string temppath = path + OSInfo.DirectorySeparator + "temp"; string zippath = path + OSInfo.DirectorySeparator + "depend.zip"; var wc = new WebClient(); diff --git a/source/WindowsFormsApplication1/Properties/Resources.Designer.cs b/source/WindowsFormsApplication1/Properties/Resources.Designer.cs index 14b69ef..e8ab95a 100644 --- a/source/WindowsFormsApplication1/Properties/Resources.Designer.cs +++ b/source/WindowsFormsApplication1/Properties/Resources.Designer.cs @@ -1445,16 +1445,6 @@ internal static byte[] LICENSE { } } - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] Linux_Mint_7 { - get { - object obj = ResourceManager.GetObject("Linux_Mint_7", resourceCulture); - return ((byte[])(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -1495,16 +1485,6 @@ internal static System.Drawing.Bitmap minimatchlabyrinthpreview { } } - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] NetSockets { - get { - object obj = ResourceManager.GetObject("NetSockets", resourceCulture); - return ((byte[])(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/source/WindowsFormsApplication1/Properties/Resources.resx b/source/WindowsFormsApplication1/Properties/Resources.resx index 6b09ba4..62c4a5c 100644 --- a/source/WindowsFormsApplication1/Properties/Resources.resx +++ b/source/WindowsFormsApplication1/Properties/Resources.resx @@ -523,9 +523,6 @@ ..\Resources\upgradeshiftericon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Linux Mint 7.skn;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\upgradealshifter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -1180,7 +1177,4 @@ ..\Resources\NoIconFound.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\bin\Debug\NetSockets.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - \ No newline at end of file diff --git a/source/WindowsFormsApplication1/ShiftOS.csproj b/source/WindowsFormsApplication1/ShiftOS.csproj index f102521..55de73e 100644 --- a/source/WindowsFormsApplication1/ShiftOS.csproj +++ b/source/WindowsFormsApplication1/ShiftOS.csproj @@ -52,7 +52,7 @@ True - ..\..\NetSockets.dll + ..\..\..\..\Downloads\NetSockets.dll ..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll diff --git a/source/WindowsFormsApplication1/WindowComposition.cs b/source/WindowsFormsApplication1/WindowComposition.cs index 0e5a5d4..70666ae 100644 --- a/source/WindowsFormsApplication1/WindowComposition.cs +++ b/source/WindowsFormsApplication1/WindowComposition.cs @@ -346,27 +346,32 @@ public static void AnimateDragWindow(Form form, WindowDragEffect effect, bool Dr { case WindowDragEffect.Shake: - var rnd = new Random(); - int xOffset = 0; - int yOffset = 0; - - xOffset = rnd.Next(API.CurrentSkin.ShakeMinOffset, API.CurrentSkin.ShakeMaxOffset); - yOffset = rnd.Next(API.CurrentSkin.ShakeMinOffset, API.CurrentSkin.ShakeMaxOffset); - int leftright = rnd.Next(0, 1); - if (API.Upgrades["fancyeffects"] == true) - { - form.Left += MouseX * xOffset; - form.Top += MouseY * yOffset; - } - else - { - form.Left += MouseX; - form.Top += MouseY; - } - + Shake(form, MouseX, MouseY); break; } } + + //Copyright - Adonis S. Deliannis + public static void Shake(Form form, int mouseX, int mouseY) + { + Point mouse = form.PointToScreen(new Point(mouseX, mouseY)); + int xDist = mouse.X - form.Location.X; + int yDist = mouse.Y - form. Location.Y; + int X = xDist; + int Y = yDist; + Random r = new Random(); + int JiggleCount = 0; + int Z = 15; + + while (JiggleCount < 1000) + { + form.Location = new Point(r.Next(X - Z, X + Z), r.Next(Y - Z, Y + Z)); + JiggleCount++; + } + + JiggleCount = 0; + form.Location = new Point(X, Y); + } } public enum WindowAnimationStyle