public bool AddUser(string username, string password, DateTime creationTime, string filepath = null) { string str = FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim(); if (str.Length <= 0) { return(false); } if (filepath != null) { str = filepath; } for (int index = 0; index < this.Accounts.Count; ++index) { if (this.Accounts[index].FileUsername == str || this.Accounts[index].Username == username) { return(false); } } this.Accounts.Add(new SaveAccountData() { Username = username, Password = password, FileUsername = str, LastWriteTime = creationTime }); return(true); }
public string AddUserAndGetFilename(string username, string password) { var str = FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim(); if (str.Length <= 0) { return(null); } for (var index = 0; index < Accounts.Count; ++index) { if (Accounts[index].FileUsername == str) { return(null); } if (Accounts[index].Username == username) { return(null); } } var saveAccountData = new SaveAccountData { Username = username, Password = password, FileUsername = str }; Accounts.Add(saveAccountData); LastLoggedInUser = saveAccountData; return(str); }
public bool CanCreateAccountForName(string username) { string str = FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim(); if (str.Length <= 0) { return(false); } for (int index = 0; index < this.Accounts.Count; ++index) { if (this.Accounts[index].FileUsername == str || this.Accounts[index].Username == username) { return(false); } } return(true); }
public string AddUserAndGetFilename(string username, string password) { string str = FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim(); if (str.Length <= 0) { return((string)null); } for (int index = 0; index < this.Accounts.Count; ++index) { if (this.Accounts[index].FileUsername == str || this.Accounts[index].Username == username) { return((string)null); } } SaveAccountData saveAccountData = new SaveAccountData() { Username = username, Password = password, FileUsername = str }; this.Accounts.Add(saveAccountData); this.LastLoggedInUser = saveAccountData; return(str); }
public static string GetSaveFileNameForUsername(string username) { return("save_" + FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim() + ".xml"); }
internal static void LoadContentForModExtensionListener(OSLoadContentEvent e) { if (Extension.Handler.ActiveInfo == null) { return; } e.IsCancelled = true; var os = e.OS; if (os.canRunContent) { // setup for proper game function Settings.slowOSStartup = false; Settings.initShowsTutorial = false; os.initShowsTutorial = false; // replacing OS.LoadContent os.delayer = new ActionDelayer(); ComputerLoader.init(os); os.content = e.OS.ScreenManager.Game.Content; os.username = (os.SaveUserAccountName ?? (Settings.isConventionDemo ? Settings.ConventionLoginName : Environment.UserName)); os.username = FileSanitiser.purifyStringForDisplay(os.username); var compLocation = new Vector2(0.1f, 0.5f); if (os.multiplayer && !os.isServer) { compLocation = new Vector2(0.8f, 0.8f); } os.ramAvaliable = os.totalRam; os.thisComputer = new Computer(os.username + " PC", Utility.GenerateRandomIP(), compLocation, 5, 4, os); os.thisComputer.adminIP = os.thisComputer.ip; os.thisComputer.idName = "playerComp"; os.thisComputer.Memory = new MemoryContents(); os.GibsonIP = Utility.GenerateRandomIP(); UserDetail value = os.thisComputer.users[0]; value.known = true; os.thisComputer.users[0] = value; os.defaultUser = new UserDetail(os.username, "password", 1); os.defaultUser.known = true; ThemeManager.setThemeOnComputer(os.thisComputer, OSTheme.HacknetBlue); if (os.multiplayer) { os.thisComputer.addMultiplayerTargetFile(); os.sendMessage("newComp #" + os.thisComputer.ip + "#" + compLocation.X + "#" + compLocation.Y + "#" + 5 + "#" + os.thisComputer.name); os.multiplayerMissionLoaded = false; } if (!OS.WillLoadSave) { People.init(); } os.modules = new List <Module>(); os.exes = new List <ExeModule>(); os.shells = new List <ShellExe>(); os.shellIPs = new List <string>(); Viewport viewport = os.ScreenManager.GraphicsDevice.Viewport; int num2 = 205; var num3 = (int)((viewport.Width - RamModule.MODULE_WIDTH - 6) * 0.44420000000000004); var num4 = (int)((viewport.Width - RamModule.MODULE_WIDTH - 6) * 0.5558); int height = viewport.Height - num2 - OS.TOP_BAR_HEIGHT - 6; os.terminal = new Terminal(new Rectangle(viewport.Width - 2 - num3, OS.TOP_BAR_HEIGHT, num3, viewport.Height - OS.TOP_BAR_HEIGHT - 2), os) { name = "TERMINAL" }; os.modules.Add(os.terminal); os.netMap = new NetworkMap(new Rectangle(RamModule.MODULE_WIDTH + 4, viewport.Height - num2 - 2, num4 - 1, num2), os) { name = "netMap v1.7" }; os.modules.Add(os.netMap); os.display = new DisplayModule(new Rectangle(RamModule.MODULE_WIDTH + 4, OS.TOP_BAR_HEIGHT, num4 - 2, height), os) { name = "DISPLAY" }; os.modules.Add(os.display); os.ram = new RamModule(new Rectangle(2, OS.TOP_BAR_HEIGHT, RamModule.MODULE_WIDTH, os.ramAvaliable + RamModule.contentStartOffset), os) { name = "RAM" }; os.modules.Add(os.ram); foreach (var m in os.modules.ToArray()) { m.LoadContent(); } if (os.allFactions == null) { os.allFactions = new AllFactions(); os.allFactions.init(); } bool flag = false; if (!OS.WillLoadSave) { os.netMap.nodes.Insert(0, os.thisComputer); os.netMap.visibleNodes.Add(0); MusicManager.loadAsCurrentSong(os.IsDLCConventionDemo ? "Music\\out_run_the_wolves" : "Music\\Revolve"); os.LanguageCreatedIn = Settings.ActiveLocale; } else { os.loadSaveFile(); flag = true; Settings.initShowsTutorial = false; SaveFixHacks.FixSavesWithTerribleHacks(os); } var computer = new Computer("JMail Email Server", Utility.GenerateRandomIP(), new Vector2(0.8f, 0.2f), 6, 1, os) { idName = "jmail" }; computer.daemons.Add(new MailServer(computer, "JMail", os)); MailServer.shouldGenerateJunk = false; computer.users.Add(new UserDetail(os.defaultUser.name, "mailpassword", 2)); computer.initDaemons(); os.netMap.nodes.Add(computer); os.netMap.mailServer = computer; os.topBar = new Rectangle(0, 0, viewport.Width, OS.TOP_BAR_HEIGHT - 1); os.crashModule = new CrashModule(new Rectangle(0, 0, os.ScreenManager.GraphicsDevice.Viewport.Width, os.ScreenManager.GraphicsDevice.Viewport.Height), os); os.crashModule.LoadContent(); Settings.IsInExtensionMode = false; // little hack to prevent intro text module ctor from throwing nullref os.introTextModule = new IntroTextModule(new Rectangle(0, 0, os.ScreenManager.GraphicsDevice.Viewport.Width, os.ScreenManager.GraphicsDevice.Viewport.Height), os) { complete = true, text = new string[] { "" } }; os.introTextModule.LoadContent(); Settings.IsInExtensionMode = true; // hack end os.traceTracker = new TraceTracker(os); os.IncConnectionOverlay = new IncomingConnectionOverlay(os); os.scanLines = os.content.Load <Texture2D>("ScanLines"); os.cross = os.content.Load <Texture2D>("Cross"); os.cog = os.content.Load <Texture2D>("Cog"); os.saveIcon = os.content.Load <Texture2D>("SaveIcon"); os.beepSound = os.content.Load <SoundEffect>("SFX/beep"); os.mailicon = new MailIcon(os, new Vector2(0f, 0f)); os.mailicon.pos.X = viewport.Width - os.mailicon.getWidth() - 2; os.hubServerAlertsIcon = new HubServerAlertsIcon(os.content, "dhs", new string[] { "@channel", "@" + os.defaultUser.name } ); os.hubServerAlertsIcon.Init(os); if (os.HasLoadedDLCContent) { os.AircraftInfoOverlay = new AircraftInfoOverlay(os); } SAChangeAlertIcon.UpdateAlertIcon(os); os.introTextModule.complete |= (flag || !Settings.slowOSStartup); if (!flag) { MusicManager.playSong(); } os.inputEnabled = true; os.isLoaded = true; os.fullscreen = new Rectangle(0, 0, os.ScreenManager.GraphicsDevice.Viewport.Width, os.ScreenManager.GraphicsDevice.Viewport.Height); os.TraceDangerSequence = new TraceDangerSequence(os.content, os.ScreenManager.SpriteBatch, os.fullscreen, os); os.endingSequence = new EndingSequenceModule(os.fullscreen, os); if (Settings.EnableDLC && DLC1SessionUpgrader.HasDLC1Installed) { os.BootAssitanceModule = new BootCrashAssistanceModule(os.fullscreen, os); } if (Settings.EnableDLC && DLC1SessionUpgrader.HasDLC1Installed && HostileHackerBreakinSequence.IsInBlockingHostileFileState(os)) { os.rebootThisComputer(); os.BootAssitanceModule.ShouldSkipDialogueTypeout = true; } else { if (Settings.EnableDLC && HostileHackerBreakinSequence.IsFirstSuccessfulBootAfterBlockingState(os)) { HostileHackerBreakinSequence.ReactToFirstSuccesfulBoot(os); os.rebootThisComputer(); } if (!OS.TestingPassOnly) { os.runCommand("connect " + os.thisComputer.ip); } var folder2 = os.thisComputer.files.root.searchForFolder("sys"); if (folder2.searchForFile("Notes_Reopener.bat") != null) { os.runCommand("notes"); } } if (Settings.EnableDLC && DLC1SessionUpgrader.HasDLC1Installed && os.HasLoadedDLCContent) { bool flag4 = false; if (!os.Flags.HasFlag("AircraftInfoOverlayDeactivated")) { flag4 |= os.Flags.HasFlag("AircraftInfoOverlayActivated"); if (!flag4) { var c = Programs.getComputer(os, "dair_crash"); var folder3 = c.files.root.searchForFolder("FlightSystems"); bool flag5 = false; for (int i = 0; i < folder3.files.Count; i++) { flag5 |= folder3.files[i].name == "747FlightOps.dll"; } var aircraftDaemon = (AircraftDaemon)c.getDaemon(typeof(AircraftDaemon)); if (!flag5 && !os.Flags.HasFlag("DLC_PlaneResult")) { flag4 = true; } } } if (flag4) { var c = Programs.getComputer(os, "dair_crash"); var aircraftDaemon = (AircraftDaemon)c.getDaemon(typeof(AircraftDaemon)); aircraftDaemon.StartReloadFirmware(); aircraftDaemon.StartUpdating(); os.AircraftInfoOverlay.Activate(); os.AircraftInfoOverlay.IsMonitoringDLCEndingCases = true; MissionFunctions.runCommand(0, "playAirlineCrashSongSequence"); } } } else if (os.multiplayer) { os.initializeNetwork(); } os.Flags.AddFlag("FirstAlertComplete"); os.IsInDLCMode = false; os.ShowDLCAlertsIcon = false; if (OS.WillLoadSave) { Stream stream = null; if (e.OS.ForceLoadOverrideStream != null && OS.TestingPassOnly) { stream = e.OS.ForceLoadOverrideStream; } else { stream = SaveFileManager.GetSaveReadStream(e.OS.SaveGameUserName); } Extension.Handler.LoadExtension(Extension.Handler.ActiveInfo.Id); Extension.Handler.ActiveInfo.OnLoad(e.OS, stream); } else { Extension.Handler.CanRegister = true; Extension.Handler.ActiveInfo.OnConstruct(e.OS); Extension.Handler.CanRegister = false; } }