aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaelTheShifter <[email protected]>2016-05-01 20:23:48 -0400
committerMichaelTheShifter <[email protected]>2016-05-01 20:23:48 -0400
commit0085241d2366f266b5416488dbead174184420b0 (patch)
treebb496c70c8235998ac343e8a63ced5a96d318a03
parentca5438be3956ee012a1bbcdab59512029a47fff2 (diff)
downloadshiftos-c--0085241d2366f266b5416488dbead174184420b0.tar.gz
shiftos-c--0085241d2366f266b5416488dbead174184420b0.tar.bz2
shiftos-c--0085241d2366f266b5416488dbead174184420b0.zip
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
-rw-r--r--source/WindowsFormsApplication1/Package_Grabber.cs55
-rw-r--r--source/WindowsFormsApplication1/Program.cs26
-rw-r--r--source/WindowsFormsApplication1/Properties/Resources.Designer.cs20
-rw-r--r--source/WindowsFormsApplication1/Properties/Resources.resx6
-rw-r--r--source/WindowsFormsApplication1/ShiftOS.csproj2
-rw-r--r--source/WindowsFormsApplication1/WindowComposition.cs41
6 files changed, 87 insertions, 63 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 @@ namespace ShiftOS
{
clients = new Dictionary<string, NetObjectClient>();
}
- var client = new NetObjectClient();
- client.OnReceived += (object s, NetReceivedEventArgs<NetObject> 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
+ }
+ if (!blacklisted)
{
- client.Connect(address, port);
- clients.Add(client.RemoteHost, client);
+ var client = new NetObjectClient();
+ client.OnReceived += (object s, NetReceivedEventArgs<NetObject> 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);
+ }
}
- catch(Exception ex)
+ else
{
- MessageBox.Show($"Error: {ex.Message}");
+ 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.Windows.Forms;
using System.Net;
using System.IO.Compression;
using System.ComponentModel;
+using System.Threading;
namespace ShiftOS
{
@@ -22,7 +23,26 @@ namespace ShiftOS
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 @@ namespace ShiftOS
{
//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
@@ -1446,16 +1446,6 @@ namespace ShiftOS.Properties {
}
/// <summary>
- /// Looks up a localized resource of type System.Byte[].
- /// </summary>
- internal static byte[] Linux_Mint_7 {
- get {
- object obj = ResourceManager.GetObject("Linux_Mint_7", resourceCulture);
- return ((byte[])(obj));
- }
- }
-
- /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap loadbutton {
@@ -1496,16 +1486,6 @@ namespace ShiftOS.Properties {
}
/// <summary>
- /// Looks up a localized resource of type System.Byte[].
- /// </summary>
- internal static byte[] NetSockets {
- get {
- object obj = ResourceManager.GetObject("NetSockets", resourceCulture);
- return ((byte[])(obj));
- }
- }
-
- /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap newfolder {
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 @@
<data name="upgradeshiftericon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\upgradeshiftericon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
- <data name="Linux_Mint_7" type="System.Resources.ResXFileRef, System.Windows.Forms">
- <value>..\Resources\Linux Mint 7.skn;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </data>
<data name="upgradealshifter" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\upgradealshifter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@@ -1180,7 +1177,4 @@
<data name="NoIconFound" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NoIconFound.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
- <data name="NetSockets" type="System.Resources.ResXFileRef, System.Windows.Forms">
- <value>..\bin\Debug\NetSockets.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </data>
</root> \ 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 @@
<Private>True</Private>
</Reference>
<Reference Include="NetSockets">
- <HintPath>..\..\NetSockets.dll</HintPath>
+ <HintPath>..\..\..\..\Downloads\NetSockets.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
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 @@ namespace ShiftOS
{
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