mirror of
https://github.com/seriocomedy/ShiftOS-C-.git
synced 2025-01-22 17:22:14 +00:00
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
This commit is contained in:
parent
ca5438be39
commit
0085241d23
6 changed files with 88 additions and 64 deletions
|
@ -54,29 +54,58 @@ public static void ConnectToServer(string address, int port)
|
|||
{
|
||||
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
|
||||
{
|
||||
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<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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1445,16 +1445,6 @@ internal static byte[] LICENSE {
|
|||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
|
@ -1495,16 +1485,6 @@ internal static System.Drawing.Bitmap minimatchlabyrinthpreview {
|
|||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue