Ejemplo n.º 1
0
        public static void ReInitPeopleForExtension()
        {
            People.all.Clear();
            People.hackers.Clear();
            People.hubAgents.Clear();
            int    num  = 0;
            string path = Path.Combine(Utils.GetFileLoadPrefix(), "People");

            if (Directory.Exists(path))
            {
                foreach (FileSystemInfo file in new DirectoryInfo(path).GetFiles("*.xml"))
                {
                    Person person = People.loadPersonFromFile(LocalizedFileLoader.GetLocalizedFilepath(path + "/" + Path.GetFileName(file.Name)));
                    if (person != null)
                    {
                        People.all.Insert(0, person);
                        ++num;
                    }
                }
            }
            for (int index = num; index < 200; ++index)
            {
                bool   male    = Utils.flipCoin();
                string fName   = male ? People.maleNames[Utils.random.Next(People.maleNames.Length)] : People.femaleNames[Utils.random.Next(People.femaleNames.Length)];
                string surname = People.surnames[Utils.random.Next(People.surnames.Length)];
                People.all.Add(new Person(fName, surname, male, false, UsernameGenerator.getName()));
            }
            People.hackers = new List <Person>();
            People.generatePeopleForList(People.hackers, 10, true);
            People.hubAgents = new List <Person>();
            People.generatePeopleForList(People.hubAgents, 22, true);
        }
Ejemplo n.º 2
0
 public void removeMission(string missionPath)
 {
     for (int index = 0; index < this.missions.Count; ++index)
     {
         if (this.missions[index].reloadGoalsSourceFile == LocalizedFileLoader.GetLocalizedFilepath(missionPath))
         {
             this.removeMission(index);
             --index;
         }
     }
 }
Ejemplo n.º 3
0
 public static void LoadInDLCPeople()
 {
     if (!Settings.EnableDLC || !DLC1SessionUpgrader.HasDLC1Installed)
     {
         return;
     }
     foreach (FileSystemInfo file in new DirectoryInfo("Content/DLC/People").GetFiles("*.xml"))
     {
         Person person = People.loadPersonFromFile(LocalizedFileLoader.GetLocalizedFilepath("Content/DLC/People/" + Path.GetFileName(file.Name)));
         if (person != null)
         {
             People.all.Insert(0, person);
         }
     }
 }
Ejemplo n.º 4
0
        public static void init()
        {
            People.maleNames   = Utils.readEntireFile("Content/PersonData/MaleNames.txt").Replace("\r", "").Split(Utils.newlineDelim);
            People.femaleNames = Utils.readEntireFile("Content/PersonData/FemaleNames.txt").Replace("\r", "").Split(Utils.newlineDelim);
            People.surnames    = Utils.readEntireFile("Content/PersonData/Surnames.txt").Replace("\r", "").Split(Utils.newlineDelim);
            People.all         = new List <Person>(200);
            int num = 0;

            FileInfo[]    files      = new DirectoryInfo("Content/People").GetFiles("*.xml");
            List <string> stringList = new List <string>();

            for (int index = 0; index < files.Length; ++index)
            {
                stringList.Add("Content/People/" + Path.GetFileName(files[index].Name));
            }
            if (Settings.EnableDLC && DLC1SessionUpgrader.HasDLC1Installed)
            {
                foreach (FileSystemInfo file in new DirectoryInfo("Content/DLC/People").GetFiles("*.xml"))
                {
                    stringList.Add("Content/DLC/People/" + Path.GetFileName(file.Name));
                }
                People.PeopleWereGeneratedWithDLCAdditions = true;
            }
            for (int index = 0; index < stringList.Count; ++index)
            {
                Person person = People.loadPersonFromFile(LocalizedFileLoader.GetLocalizedFilepath(stringList[index]));
                if (person != null)
                {
                    People.all.Add(person);
                    ++num;
                }
                else
                {
                    Console.WriteLine("Person Load Error: " + stringList[index]);
                }
            }
            for (int index = num; index < 200; ++index)
            {
                bool   male    = Utils.flipCoin();
                string fName   = male ? People.maleNames[Utils.random.Next(People.maleNames.Length)] : People.femaleNames[Utils.random.Next(People.femaleNames.Length)];
                string surname = People.surnames[Utils.random.Next(People.surnames.Length)];
                People.all.Add(new Person(fName, surname, male, false, UsernameGenerator.getName()));
            }
            People.hackers = new List <Person>();
            People.generatePeopleForList(People.hackers, 10, true);
            People.hubAgents = new List <Person>();
            People.generatePeopleForList(People.hubAgents, 22, true);
        }
Ejemplo n.º 5
0
        public static void LoadIntoOS(string filepath, object OSobj)
        {
            OS os = (OS)OSobj;

            using (FileStream fileStream = File.OpenRead(LocalizedFileLoader.GetLocalizedFilepath(Utils.GetFileLoadPrefix() + filepath)))
            {
                RunnableConditionalActions conditionalActions = RunnableConditionalActions.Deserialize(XmlReader.Create((Stream)fileStream));
                for (int index = 0; index < conditionalActions.Actions.Count; ++index)
                {
                    os.ConditionalActions.Actions.Add(conditionalActions.Actions[index]);
                }
            }
            if (os.ConditionalActions.IsUpdating)
            {
                return;
            }
            os.ConditionalActions.Update(0.0f, (object)os);
        }
Ejemplo n.º 6
0
        public static void UpgradeSession(object osobj, bool needsNodeInjection)
        {
            OS os = (OS)osobj;

            MemoryDumpInjector.InjectMemory(LocalizedFileLoader.GetLocalizedFilepath("Content/DLC/Missions/Injections/MemoryDumps/GibsonLink.xml"), (object)Programs.getComputer(os, "polarSnakeDest"));
            MemoryDumpInjector.InjectMemory(LocalizedFileLoader.GetLocalizedFilepath("Content/DLC/Missions/Injections/MemoryDumps/NaixHome.xml"), (object)Programs.getComputer(os, "naixGateway"));
            MemoryDumpInjector.InjectMemory(LocalizedFileLoader.GetLocalizedFilepath("Content/DLC/Missions/Injections/MemoryDumps/BitDropBox.xml"), (object)Programs.getComputer(os, "BitWorkServer"));
            MemoryDumpInjector.InjectMemory(LocalizedFileLoader.GetLocalizedFilepath("Content/DLC/Missions/Injections/MemoryDumps/ExpandKeysInjection.xml"), (object)Programs.getComputer(os, "portcrack01"));
            if (os.thisComputer.Memory == null)
            {
                os.thisComputer.Memory = new MemoryContents();
            }
            os.allFactions.factions.Add("Bibliotheque", (Faction)CustomFaction.ParseFromFile("Content/DLC/DLCFaction.xml"));
            if (needsNodeInjection)
            {
                if (People.all == null)
                {
                    People.init();
                }
                else if (!People.PeopleWereGeneratedWithDLCAdditions)
                {
                    People.LoadInDLCPeople();
                }
                List <string> dlcList = BootLoadList.getDLCList();
                for (int index = 0; index < dlcList.Count; ++index)
                {
                    Computer.loadFromFile(dlcList[index]);
                }
                ComputerLoader.postAllLoadedActions();
            }
            Computer computer = Programs.getComputer(os, "ispComp");

            if (!computer.ports.Contains(443))
            {
                computer.ports.Add(443);
            }
            if (computer.ports.Contains(6881))
            {
                return;
            }
            computer.ports.Add(6881);
        }
Ejemplo n.º 7
0
        public static void runScript(string scriptName, object os, string sourceCompReplacer = null, string targetCompReplacer = null)
        {
            string[] separator = new string[4] {
                " $#%#$\r\n", " $#%#$\n", "$#%#$\r\n", "$#%#$\n"
            };
            string localizedFilepath = LocalizedFileLoader.GetLocalizedFilepath(Utils.GetFileLoadPrefix() + scriptName);

            if (!File.Exists(localizedFilepath))
            {
                localizedFilepath = LocalizedFileLoader.GetLocalizedFilepath("Content/" + scriptName);
            }
            string str = Utils.readEntireFile(localizedFilepath);

            if (sourceCompReplacer != null)
            {
                str = str.Replace("[SOURCE_COMP]", sourceCompReplacer);
            }
            if (targetCompReplacer != null)
            {
                str = str.Replace("[TARGET_COMP]", targetCompReplacer);
            }
            string[] script = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            if (!OS.TestingPassOnly)
            {
                Thread thread = new Thread((ThreadStart)(() => HackerScriptExecuter.executeThreadedScript(script, (OS)os)))
                {
                    IsBackground = true, CurrentCulture = Game1.culture, CurrentUICulture = Game1.culture
                };
                thread.IsBackground = true;
                thread.Name         = "OpposingHackerThread";
                thread.Start();
            }
            else
            {
                HackerScriptExecuter.executeThreadedScript(script, (OS)os);
            }
        }
 public static void CopyHelpFile()
 {
     try
     {
         if (File.Exists(HostileHackerBreakinSequence.HelpFilePath))
         {
             return;
         }
         File.Copy(LocalizedFileLoader.GetLocalizedFilepath("Content/DLC/Misc/" + (Environment.OSVersion.Platform == PlatformID.Win32NT ? "Win_AllyHelpFile.txt" : "Unix_AllyHelpFile.txt")), HostileHackerBreakinSequence.HelpFilePath);
         if (Environment.OSVersion.Platform != PlatformID.Win32NT)
         {
             Process.Start("chmod", " -x " + HostileHackerBreakinSequence.HelpFilePath);
         }
     }
     catch (UnauthorizedAccessException ex)
     {
         Utils.AppendToErrorFile("HHBreakinSequence error : Insufficient permissions for folder access.\r\n" + Utils.GenerateReportFromException((Exception)ex));
         Console.WriteLine("HHSequence Error " + Utils.GenerateReportFromException((Exception)ex));
     }
     catch (Exception ex)
     {
         Console.WriteLine("HHSequence Error " + Utils.GenerateReportFromException(ex));
     }
 }
 public static string GetHelpText()
 {
     return(File.ReadAllText(LocalizedFileLoader.GetLocalizedFilepath("Content/DLC/Misc/" + (Environment.OSVersion.Platform == PlatformID.Win32NT ? "Win_AllyHelpFile.txt" : "Unix_AllyHelpFile.txt"))));
 }
Ejemplo n.º 10
0
 public static string Read(string filepath)
 {
     return(LocalizedFileLoader.FilterStringForLocalization(File.ReadAllText(LocalizedFileLoader.GetLocalizedFilepath(filepath))));
 }