From e929a9f5105c00b0a3a2b4e75a876bbb95bbfa7b Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 13 Jul 2017 21:30:04 -0400 Subject: Delete a LOT of obsolete code --- ShiftOS_TheReturn/Hacking.cs | 94 +++++++++++++++++++++++++++++++++ ShiftOS_TheReturn/LoginManager.cs | 5 +- ShiftOS_TheReturn/SaveSystem.cs | 1 - ShiftOS_TheReturn/Server.cs | 4 +- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + 5 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 ShiftOS_TheReturn/Hacking.cs (limited to 'ShiftOS_TheReturn') diff --git a/ShiftOS_TheReturn/Hacking.cs b/ShiftOS_TheReturn/Hacking.cs new file mode 100644 index 0000000..db47f66 --- /dev/null +++ b/ShiftOS_TheReturn/Hacking.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public static class Hacking + { + private static List _activeConnections = new List(); + private static List Hackables = new List(); + + public static Objects.Hackable[] AvailableToHack + { + get + { + return Hackables.Where(x => Shiftorium.UpgradeInstalled(x.Dependencies) && !Shiftorium.UpgradeInstalled(x.ID)).ToArray(); + } + } + + + public static HackableSystem[] ActiveConnections + { + get + { + return _activeConnections.ToArray(); + } + } + + public static HackableSystem[] PwnedConnections + { + get + { + return _activeConnections.Where(x => x.IsPwn3d).ToArray(); + } + } + + public static HackableSystem[] TimedConnections + { + get + { + return _activeConnections.Where(x => x.Data.ConnectionTimeoutLevel > 0&&!x.IsPwn3d).ToArray(); + } + } + + public static void Initiate() + { + foreach(var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IHackableProvider)))) + { + var @interface = (IHackableProvider)Activator.CreateInstance(type, null); + Hackables.AddRange(@interface.GetHackables()); + + } + + var hackable = Hackables.FirstOrDefault(x => Hackables.Where(y => x.SystemName == y.SystemName).Count() > 1); + if(hackable != null) + { + throw new DataConflictException("Data conflict encountered while initiating the hacking engine. Two or more hackables were found with the same hostname \"" + hackable.SystemName + "\". This is a direct violation of the ShiftOS save system and Shiftorium backend."); + } + } + } + + public class DataConflictException : Exception + { + public DataConflictException(string message) : base(message) + { + + } + } + + public interface IHackableProvider + { + Objects.Hackable[] GetHackables(); + } + + public class HackableSystem + { + public Objects.Hackable Data { get; set; } + public List PortsToUnlock { get; set; } + public bool FirewallCracked { get; set; } + public Objects.ShiftFS.Directory Filesystem { get; set; } + public int MillisecondsCountdown { get; set; } + public bool IsPwn3d { get; set; } + } + + public class Port + { + public string Name { get; set; } + public int Value { get; set; } + public int Difficulty { get; set; } + public bool Cracked { get; set; } + } +} diff --git a/ShiftOS_TheReturn/LoginManager.cs b/ShiftOS_TheReturn/LoginManager.cs index d326f2c..de30cf1 100644 --- a/ShiftOS_TheReturn/LoginManager.cs +++ b/ShiftOS_TheReturn/LoginManager.cs @@ -35,7 +35,8 @@ namespace ShiftOS.Engine } } - public static event Action LoginComplete; + [Obsolete("Old code.")] + public static event Action LoginComplete; } /// @@ -57,7 +58,7 @@ namespace ShiftOS.Engine /// /// Occurs when the login is complete. /// - event Action LoginComplete; + event Action LoginComplete; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 292af41..99d1868 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -90,7 +90,6 @@ namespace ShiftOS.Engine { var root = new ShiftOS.Objects.ShiftFS.Directory(); root.Name = "System"; - root.permissions = UserPermissions.Guest; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } diff --git a/ShiftOS_TheReturn/Server.cs b/ShiftOS_TheReturn/Server.cs index ddbd15b..6edef9e 100644 --- a/ShiftOS_TheReturn/Server.cs +++ b/ShiftOS_TheReturn/Server.cs @@ -7,15 +7,17 @@ using ShiftOS.Objects; namespace ShiftOS.Engine { + [Obsolete("Old code.")] public interface Server { /// /// Occurs when someone sends a message to the server. /// /// The message from the client. - void MessageReceived(ServerMessage msg); + void MessageReceived(dynamic msg); } + [Obsolete("Old code.")] [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] public class ServerAttribute : Attribute { diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 02a5eeb..27d54cc 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -133,6 +133,7 @@ + -- cgit v1.2.3