예제 #1
0
 public static Computer load(XmlReader reader, OS os)
 {
     while (reader.Name != "computer")
         reader.Read();
     reader.MoveToAttribute("name");
     var compName = reader.ReadContentAsString();
     reader.MoveToAttribute("ip");
     var compIP = reader.ReadContentAsString();
     reader.MoveToAttribute("type");
     var compType = (byte) reader.ReadContentAsInt();
     reader.MoveToAttribute("spec");
     var str1 = reader.ReadContentAsString();
     reader.MoveToAttribute("id");
     var str2 = reader.ReadContentAsString();
     string str3 = null;
     if (reader.MoveToAttribute("devices"))
         str3 = reader.ReadContentAsString();
     string str4 = null;
     if (reader.MoveToAttribute("icon"))
         str4 = reader.ReadContentAsString();
     while (reader.Name != "location")
         reader.Read();
     reader.MoveToAttribute("x");
     var x = reader.ReadContentAsFloat();
     reader.MoveToAttribute("y");
     var y = reader.ReadContentAsFloat();
     while (reader.Name != "security")
         reader.Read();
     reader.MoveToAttribute("level");
     var seclevel = reader.ReadContentAsInt();
     reader.MoveToAttribute("traceTime");
     var num1 = reader.ReadContentAsFloat();
     reader.MoveToAttribute("portsToCrack");
     var num2 = reader.ReadContentAsInt();
     reader.MoveToAttribute("adminIP");
     var str5 = reader.ReadContentAsString();
     var time = -1f;
     if (reader.MoveToAttribute("proxyTime"))
         time = reader.ReadContentAsFloat();
     while (reader.Name != "admin")
         reader.Read();
     reader.MoveToAttribute("type");
     var str6 = reader.ReadContentAsString();
     reader.MoveToAttribute("resetPass");
     var flag1 = reader.ReadContentAsBoolean();
     reader.MoveToAttribute("isSuper");
     var flag2 = reader.ReadContentAsBoolean();
     Administrator administrator = null;
     switch (str6)
     {
         case "fast":
             administrator = new FastBasicAdministrator();
             break;
         case "basic":
             administrator = new BasicAdministrator();
             break;
     }
     if (administrator != null)
         administrator.ResetsPassword = flag1;
     if (administrator != null)
         administrator.IsSuper = flag2;
     while (reader.Name != "links")
         reader.Read();
     var strArray = reader.ReadElementContentAsString().Split();
     Firewall firewall = null;
     while (reader.Name != "portsOpen" && reader.Name != "firewall")
         reader.Read();
     if (reader.Name == "firewall")
         firewall = Firewall.load(reader);
     while (reader.Name != "portsOpen")
         reader.Read();
     var portsList = reader.ReadElementContentAsString();
     var computer = new Computer(compName, compIP, new Vector2(x, y), seclevel, compType, os);
     computer.firewall = firewall;
     computer.admin = administrator;
     if (time > 0.0)
     {
         computer.addProxy(time);
     }
     else
     {
         computer.hasProxy = false;
         computer.proxyActive = false;
     }
     while (reader.Name != "users")
         reader.Read();
     computer.users.Clear();
     while (!(reader.Name == "users") || reader.NodeType != XmlNodeType.EndElement)
     {
         if (reader.Name == "user")
         {
             var userDetail = UserDetail.loadUserDetail(reader);
             if (userDetail.name.ToLower() == "admin")
                 computer.adminPass = userDetail.pass;
             computer.users.Add(userDetail);
         }
         reader.Read();
     }
     while (reader.Name != "daemons")
         reader.Read();
     reader.Read();
     while (!(reader.Name == "daemons") || reader.NodeType != XmlNodeType.EndElement)
     {
         if (reader.Name == "MailServer")
         {
             reader.MoveToAttribute("name");
             var name = reader.ReadContentAsString();
             var mailServer = new MailServer(computer, name, os);
             computer.daemons.Add(mailServer);
             if (reader.MoveToAttribute("color"))
             {
                 var newThemeColor = Utils.convertStringToColor(reader.ReadContentAsString());
                 mailServer.setThemeColor(newThemeColor);
             }
         }
         else if (reader.Name == "MissionListingServer")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             reader.MoveToAttribute("group");
             var group = reader.ReadContentAsString();
             reader.MoveToAttribute("public");
             var _isPublic = reader.ReadContentAsString().ToLower().Equals("true");
             reader.MoveToAttribute("assign");
             var _isAssigner = reader.ReadContentAsString().ToLower().Equals("true");
             var missionListingServer = new MissionListingServer(computer, serviceName, group, os, _isPublic,
                 _isAssigner);
             computer.daemons.Add(missionListingServer);
         }
         else if (reader.Name == "AddEmailServer")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             var addEmailDaemon = new AddEmailDaemon(computer, serviceName, os);
             computer.daemons.Add(addEmailDaemon);
         }
         else if (reader.Name == "MessageBoard")
         {
             reader.MoveToAttribute("name");
             var str7 = reader.ReadContentAsString();
             var messageBoardDaemon = new MessageBoardDaemon(computer, os);
             messageBoardDaemon.name = str7;
             computer.daemons.Add(messageBoardDaemon);
         }
         else if (reader.Name == "WebServer")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             reader.MoveToAttribute("url");
             var pageFileLocation = reader.ReadContentAsString();
             var webServerDaemon = new WebServerDaemon(computer, serviceName, os, pageFileLocation);
             computer.daemons.Add(webServerDaemon);
         }
         else if (reader.Name == "OnlineWebServer")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             reader.MoveToAttribute("url");
             var url = reader.ReadContentAsString();
             var onlineWebServerDaemon = new OnlineWebServerDaemon(computer, serviceName, os);
             onlineWebServerDaemon.setURL(url);
             computer.daemons.Add(onlineWebServerDaemon);
         }
         else if (reader.Name == "AcademicDatabse")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             var academicDatabaseDaemon = new AcademicDatabaseDaemon(computer, serviceName, os);
             computer.daemons.Add(academicDatabaseDaemon);
         }
         else if (reader.Name == "MissionHubServer")
         {
             var missionHubServer = new MissionHubServer(computer, "unknown", "unknown", os);
             computer.daemons.Add(missionHubServer);
         }
         else if (reader.Name == "DeathRowDatabase")
         {
             var rowDatabaseDaemon = new DeathRowDatabaseDaemon(computer, "Death Row Database", os);
             computer.daemons.Add(rowDatabaseDaemon);
         }
         else if (reader.Name == "MedicalDatabase")
         {
             var medicalDatabaseDaemon = new MedicalDatabaseDaemon(computer, os);
             computer.daemons.Add(medicalDatabaseDaemon);
         }
         else if (reader.Name == "HeartMonitor")
         {
             var str7 = "UNKNOWN";
             if (reader.MoveToAttribute("patient"))
                 str7 = reader.ReadContentAsString();
             computer.daemons.Add(new HeartMonitorDaemon(computer, os)
             {
                 PatientID = str7
             });
         }
         else if (reader.Name.Equals("PointClicker"))
         {
             var pointClickerDaemon = new PointClickerDaemon(computer, "Point Clicker!", os);
             computer.daemons.Add(pointClickerDaemon);
         }
         else if (reader.Name.Equals("ispSystem"))
         {
             var ispDaemon = new ISPDaemon(computer, os);
             computer.daemons.Add(ispDaemon);
         }
         else if (reader.Name.Equals("porthackheart"))
         {
             var porthackHeartDaemon = new PorthackHeartDaemon(computer, os);
             computer.daemons.Add(porthackHeartDaemon);
         }
         else if (reader.Name.Equals("SongChangerDaemon"))
         {
             var songChangerDaemon = new SongChangerDaemon(computer, os);
             computer.daemons.Add(songChangerDaemon);
         }
         else if (reader.Name == "UploadServerDaemon")
         {
             string str7;
             var input = str7 = "";
             var foldername = str7;
             var serviceName = str7;
             if (reader.MoveToAttribute("name"))
                 serviceName = reader.ReadContentAsString();
             if (reader.MoveToAttribute("foldername"))
                 foldername = reader.ReadContentAsString();
             if (reader.MoveToAttribute("color"))
                 input = reader.ReadContentAsString();
             var needsAuthentication = false;
             if (reader.MoveToAttribute("needsAuh"))
                 needsAuthentication = reader.ReadContentAsBoolean();
             var themeColor = Color.White;
             if (input != "")
                 themeColor = Utils.convertStringToColor(input);
             var uploadServerDaemon = new UploadServerDaemon(computer, serviceName, themeColor, os, foldername,
                 needsAuthentication);
             computer.daemons.Add(uploadServerDaemon);
         }
         reader.Read();
     }
     computer.files = FileSystem.load(reader);
     computer.traceTime = num1;
     computer.portsNeededForCrack = num2;
     computer.adminIP = str5;
     computer.idName = str2;
     computer.icon = str4;
     computer.attatchedDeviceIDs = str3;
     for (var index = 0; index < strArray.Length; ++index)
     {
         if (strArray[index] != "")
             computer.links.Add(Convert.ToInt32(strArray[index]));
     }
     if (portsList.Length > 0)
         ComputerLoader.loadPortsIntoComputer(portsList, computer);
     if (str1 == "mail")
         os.netMap.mailServer = computer;
     else if (str1 == "player")
         os.thisComputer = computer;
     return computer;
 }
예제 #2
0
        public static Computer load(XmlReader reader, OS os)
        {
            while (reader.Name != "computer")
            {
                reader.Read();
            }
            reader.MoveToAttribute("name");
            var compName = reader.ReadContentAsString();

            reader.MoveToAttribute("ip");
            var compIP = reader.ReadContentAsString();

            reader.MoveToAttribute("type");
            var compType = (byte)reader.ReadContentAsInt();

            reader.MoveToAttribute("spec");
            var str1 = reader.ReadContentAsString();

            reader.MoveToAttribute("id");
            var    str2 = reader.ReadContentAsString();
            string str3 = null;

            if (reader.MoveToAttribute("devices"))
            {
                str3 = reader.ReadContentAsString();
            }
            string str4 = null;

            if (reader.MoveToAttribute("icon"))
            {
                str4 = reader.ReadContentAsString();
            }
            while (reader.Name != "location")
            {
                reader.Read();
            }
            reader.MoveToAttribute("x");
            var x = reader.ReadContentAsFloat();

            reader.MoveToAttribute("y");
            var y = reader.ReadContentAsFloat();

            while (reader.Name != "security")
            {
                reader.Read();
            }
            reader.MoveToAttribute("level");
            var seclevel = reader.ReadContentAsInt();

            reader.MoveToAttribute("traceTime");
            var num1 = reader.ReadContentAsFloat();

            reader.MoveToAttribute("portsToCrack");
            var num2 = reader.ReadContentAsInt();

            reader.MoveToAttribute("adminIP");
            var str5 = reader.ReadContentAsString();
            var time = -1f;

            if (reader.MoveToAttribute("proxyTime"))
            {
                time = reader.ReadContentAsFloat();
            }
            while (reader.Name != "admin")
            {
                reader.Read();
            }
            reader.MoveToAttribute("type");
            var str6 = reader.ReadContentAsString();

            reader.MoveToAttribute("resetPass");
            var flag1 = reader.ReadContentAsBoolean();

            reader.MoveToAttribute("isSuper");
            var           flag2         = reader.ReadContentAsBoolean();
            Administrator administrator = null;

            switch (str6)
            {
            case "fast":
                administrator = new FastBasicAdministrator();
                break;

            case "basic":
                administrator = new BasicAdministrator();
                break;
            }
            if (administrator != null)
            {
                administrator.ResetsPassword = flag1;
            }
            if (administrator != null)
            {
                administrator.IsSuper = flag2;
            }
            while (reader.Name != "links")
            {
                reader.Read();
            }
            var      strArray = reader.ReadElementContentAsString().Split();
            Firewall firewall = null;

            while (reader.Name != "portsOpen" && reader.Name != "firewall")
            {
                reader.Read();
            }
            if (reader.Name == "firewall")
            {
                firewall = Firewall.load(reader);
            }
            while (reader.Name != "portsOpen")
            {
                reader.Read();
            }
            var portsList = reader.ReadElementContentAsString();
            var computer  = new Computer(compName, compIP, new Vector2(x, y), seclevel, compType, os);

            computer.firewall = firewall;
            computer.admin    = administrator;
            if (time > 0.0)
            {
                computer.addProxy(time);
            }
            else
            {
                computer.hasProxy    = false;
                computer.proxyActive = false;
            }
            while (reader.Name != "users")
            {
                reader.Read();
            }
            computer.users.Clear();
            while (!(reader.Name == "users") || reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.Name == "user")
                {
                    var userDetail = UserDetail.loadUserDetail(reader);
                    if (userDetail.name.ToLower() == "admin")
                    {
                        computer.adminPass = userDetail.pass;
                    }
                    computer.users.Add(userDetail);
                }
                reader.Read();
            }
            while (reader.Name != "daemons")
            {
                reader.Read();
            }
            reader.Read();
            while (!(reader.Name == "daemons") || reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.Name == "MailServer")
                {
                    reader.MoveToAttribute("name");
                    var name       = reader.ReadContentAsString();
                    var mailServer = new MailServer(computer, name, os);
                    computer.daemons.Add(mailServer);
                    if (reader.MoveToAttribute("color"))
                    {
                        var newThemeColor = Utils.convertStringToColor(reader.ReadContentAsString());
                        mailServer.setThemeColor(newThemeColor);
                    }
                }
                else if (reader.Name == "MissionListingServer")
                {
                    reader.MoveToAttribute("name");
                    var serviceName = reader.ReadContentAsString();
                    reader.MoveToAttribute("group");
                    var group = reader.ReadContentAsString();
                    reader.MoveToAttribute("public");
                    var _isPublic = reader.ReadContentAsString().ToLower().Equals("true");
                    reader.MoveToAttribute("assign");
                    var _isAssigner          = reader.ReadContentAsString().ToLower().Equals("true");
                    var missionListingServer = new MissionListingServer(computer, serviceName, group, os, _isPublic,
                                                                        _isAssigner);
                    computer.daemons.Add(missionListingServer);
                }
                else if (reader.Name == "AddEmailServer")
                {
                    reader.MoveToAttribute("name");
                    var serviceName    = reader.ReadContentAsString();
                    var addEmailDaemon = new AddEmailDaemon(computer, serviceName, os);
                    computer.daemons.Add(addEmailDaemon);
                }
                else if (reader.Name == "MessageBoard")
                {
                    reader.MoveToAttribute("name");
                    var str7 = reader.ReadContentAsString();
                    var messageBoardDaemon = new MessageBoardDaemon(computer, os);
                    messageBoardDaemon.name = str7;
                    computer.daemons.Add(messageBoardDaemon);
                }
                else if (reader.Name == "WebServer")
                {
                    reader.MoveToAttribute("name");
                    var serviceName = reader.ReadContentAsString();
                    reader.MoveToAttribute("url");
                    var pageFileLocation = reader.ReadContentAsString();
                    var webServerDaemon  = new WebServerDaemon(computer, serviceName, os, pageFileLocation);
                    computer.daemons.Add(webServerDaemon);
                }
                else if (reader.Name == "OnlineWebServer")
                {
                    reader.MoveToAttribute("name");
                    var serviceName = reader.ReadContentAsString();
                    reader.MoveToAttribute("url");
                    var url = reader.ReadContentAsString();
                    var onlineWebServerDaemon = new OnlineWebServerDaemon(computer, serviceName, os);
                    onlineWebServerDaemon.setURL(url);
                    computer.daemons.Add(onlineWebServerDaemon);
                }
                else if (reader.Name == "AcademicDatabse")
                {
                    reader.MoveToAttribute("name");
                    var serviceName            = reader.ReadContentAsString();
                    var academicDatabaseDaemon = new AcademicDatabaseDaemon(computer, serviceName, os);
                    computer.daemons.Add(academicDatabaseDaemon);
                }
                else if (reader.Name == "MissionHubServer")
                {
                    var missionHubServer = new MissionHubServer(computer, "unknown", "unknown", os);
                    computer.daemons.Add(missionHubServer);
                }
                else if (reader.Name == "DeathRowDatabase")
                {
                    var rowDatabaseDaemon = new DeathRowDatabaseDaemon(computer, "Death Row Database", os);
                    computer.daemons.Add(rowDatabaseDaemon);
                }
                else if (reader.Name == "MedicalDatabase")
                {
                    var medicalDatabaseDaemon = new MedicalDatabaseDaemon(computer, os);
                    computer.daemons.Add(medicalDatabaseDaemon);
                }
                else if (reader.Name == "HeartMonitor")
                {
                    var str7 = "UNKNOWN";
                    if (reader.MoveToAttribute("patient"))
                    {
                        str7 = reader.ReadContentAsString();
                    }
                    computer.daemons.Add(new HeartMonitorDaemon(computer, os)
                    {
                        PatientID = str7
                    });
                }
                else if (reader.Name.Equals("PointClicker"))
                {
                    var pointClickerDaemon = new PointClickerDaemon(computer, "Point Clicker!", os);
                    computer.daemons.Add(pointClickerDaemon);
                }
                else if (reader.Name.Equals("ispSystem"))
                {
                    var ispDaemon = new ISPDaemon(computer, os);
                    computer.daemons.Add(ispDaemon);
                }
                else if (reader.Name.Equals("porthackheart"))
                {
                    var porthackHeartDaemon = new PorthackHeartDaemon(computer, os);
                    computer.daemons.Add(porthackHeartDaemon);
                }
                else if (reader.Name.Equals("SongChangerDaemon"))
                {
                    var songChangerDaemon = new SongChangerDaemon(computer, os);
                    computer.daemons.Add(songChangerDaemon);
                }
                else if (reader.Name == "UploadServerDaemon")
                {
                    string str7;
                    var    input       = str7 = "";
                    var    foldername  = str7;
                    var    serviceName = str7;
                    if (reader.MoveToAttribute("name"))
                    {
                        serviceName = reader.ReadContentAsString();
                    }
                    if (reader.MoveToAttribute("foldername"))
                    {
                        foldername = reader.ReadContentAsString();
                    }
                    if (reader.MoveToAttribute("color"))
                    {
                        input = reader.ReadContentAsString();
                    }
                    var needsAuthentication = false;
                    if (reader.MoveToAttribute("needsAuh"))
                    {
                        needsAuthentication = reader.ReadContentAsBoolean();
                    }
                    var themeColor = Color.White;
                    if (input != "")
                    {
                        themeColor = Utils.convertStringToColor(input);
                    }
                    var uploadServerDaemon = new UploadServerDaemon(computer, serviceName, themeColor, os, foldername,
                                                                    needsAuthentication);
                    computer.daemons.Add(uploadServerDaemon);
                }
                reader.Read();
            }
            computer.files               = FileSystem.load(reader);
            computer.traceTime           = num1;
            computer.portsNeededForCrack = num2;
            computer.adminIP             = str5;
            computer.idName              = str2;
            computer.icon = str4;
            computer.attatchedDeviceIDs = str3;
            for (var index = 0; index < strArray.Length; ++index)
            {
                if (strArray[index] != "")
                {
                    computer.links.Add(Convert.ToInt32(strArray[index]));
                }
            }
            if (portsList.Length > 0)
            {
                ComputerLoader.loadPortsIntoComputer(portsList, computer);
            }
            if (str1 == "mail")
            {
                os.netMap.mailServer = computer;
            }
            else if (str1 == "player")
            {
                os.thisComputer = computer;
            }
            return(computer);
        }
예제 #3
0
 public static object loadComputer(string filename)
 {
     var rdr = XmlReader.Create(TitleContainer.OpenStream(filename));
     var str1 = "UNKNOWN";
     var compName = "UNKNOWN";
     string str2 = null;
     var seclevel = 0;
     byte compType = 1;
     var flag1 = true;
     var compIP = NetworkMap.generateRandomIP();
     while (rdr.Name != "Computer")
         rdr.Read();
     if (rdr.MoveToAttribute("id"))
         str1 = rdr.ReadContentAsString();
     if (rdr.MoveToAttribute("name"))
         compName = rdr.ReadContentAsString();
     if (rdr.MoveToAttribute("security"))
         seclevel = rdr.ReadContentAsInt();
     if (rdr.MoveToAttribute("type"))
         compType = (byte) rdr.ReadContentAsInt();
     if (rdr.MoveToAttribute("ip"))
         compIP = rdr.ReadContentAsString();
     if (rdr.MoveToAttribute("icon"))
         str2 = rdr.ReadContentAsString();
     if (rdr.MoveToAttribute("allowsDefaultBootModule"))
         flag1 = rdr.ReadContentAsBoolean();
     var computer1 = new Computer(compName, compIP, os.netMap.getRandomPosition(), seclevel, compType, os);
     computer1.idName = str1;
     computer1.AllowsDefaultBootModule = flag1;
     computer1.icon = str2;
     if (computer1.type == 4)
     {
         var folder = computer1.files.root.searchForFolder("home");
         if (folder != null)
         {
             folder.files.Clear();
             folder.folders.Clear();
         }
     }
     while (rdr.Name != "Computer")
     {
         if (rdr.Name.Equals("file"))
         {
             var path = !rdr.MoveToAttribute("path") ? "home" : rdr.ReadContentAsString();
             var str3 = filter(!rdr.MoveToAttribute("name") ? "Data" : rdr.ReadContentAsString());
             var num = (int) rdr.MoveToContent();
             var s = rdr.ReadElementContentAsString();
             if (s.Equals(""))
                 s = Computer.generateBinaryString(500);
             var dataEntry = filter(s);
             var folderFromPath = computer1.getFolderFromPath(path, true);
             if (folderFromPath.searchForFile(str3) != null)
                 folderFromPath.searchForFile(str3).data = dataEntry;
             else
                 folderFromPath.files.Add(new FileEntry(dataEntry, str3));
         }
         if (rdr.Name.Equals("encryptedFile"))
         {
             var flag2 = false;
             var path = !rdr.MoveToAttribute("path") ? "home" : rdr.ReadContentAsString();
             var s1 = !rdr.MoveToAttribute("name") ? "Data" : rdr.ReadContentAsString();
             var header = !rdr.MoveToAttribute("header") ? "ERROR" : rdr.ReadContentAsString();
             var ipLink = !rdr.MoveToAttribute("ip") ? "ERROR" : rdr.ReadContentAsString();
             var pass = !rdr.MoveToAttribute("pass") ? "" : rdr.ReadContentAsString();
             var fileExtension = !rdr.MoveToAttribute("extension") ? null : rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("double"))
                 flag2 = rdr.ReadContentAsBoolean();
             var str3 = filter(s1);
             var num = (int) rdr.MoveToContent();
             var s2 = rdr.ReadElementContentAsString();
             if (s2.Equals(""))
                 s2 = Computer.generateBinaryString(500);
             var data = filter(s2);
             if (flag2)
                 data = FileEncrypter.EncryptString(data, header, ipLink, pass, fileExtension);
             var dataEntry = FileEncrypter.EncryptString(data, header, ipLink, pass,
                 flag2 ? "_LAYER2.dec" : fileExtension);
             var folderFromPath = computer1.getFolderFromPath(path, true);
             if (folderFromPath.searchForFile(str3) != null)
                 folderFromPath.searchForFile(str3).data = dataEntry;
             else
                 folderFromPath.files.Add(new FileEntry(dataEntry, str3));
         }
         else if (rdr.Name.Equals("ports"))
         {
             var num = (int) rdr.MoveToContent();
             loadPortsIntoComputer(rdr.ReadElementContentAsString(), computer1);
         }
         else if (rdr.Name.Equals("positionNear"))
         {
             var ip_Or_ID_or_Name = "";
             if (rdr.MoveToAttribute("target"))
                 ip_Or_ID_or_Name = rdr.ReadContentAsString();
             var num = 0;
             var total = 3;
             if (rdr.MoveToAttribute("position"))
                 num = rdr.ReadContentAsInt();
             var positionNumber = num + 1;
             if (rdr.MoveToAttribute("total"))
                 total = rdr.ReadContentAsInt();
             var computer2 = Programs.getComputer(os, ip_Or_ID_or_Name);
             if (computer2 != null)
                 computer1.location = computer2.location +
                                      Corporation.getNearbyNodeOffset(computer2.location, positionNumber, total,
                                          os.netMap);
         }
         else if (rdr.Name.Equals("proxy"))
         {
             var num = 1f;
             if (rdr.MoveToAttribute("time"))
                 num = rdr.ReadContentAsFloat();
             if (num > 0.0)
             {
                 computer1.addProxy(Computer.BASE_PROXY_TICKS*num);
             }
             else
             {
                 computer1.hasProxy = false;
                 computer1.proxyActive = false;
             }
         }
         else if (rdr.Name.Equals("portsForCrack"))
         {
             var num = -1;
             if (rdr.MoveToAttribute("val"))
                 num = rdr.ReadContentAsInt();
             if (num != -1)
                 computer1.portsNeededForCrack = num - 1;
         }
         else if (rdr.Name.Equals("firewall"))
         {
             var level = 1;
             if (rdr.MoveToAttribute("level"))
                 level = rdr.ReadContentAsInt();
             if (level > 0)
             {
                 string solution = null;
                 var additionalTime = 0.0f;
                 if (rdr.MoveToAttribute("solution"))
                     solution = rdr.ReadContentAsString();
                 if (rdr.MoveToAttribute("additionalTime"))
                     additionalTime = rdr.ReadContentAsFloat();
                 if (solution != null)
                     computer1.addFirewall(level, solution, additionalTime);
                 else
                     computer1.addFirewall(level);
             }
             else
                 computer1.firewall = null;
         }
         else if (rdr.Name.Equals("link"))
         {
             var ip_Or_ID_or_Name = "";
             if (rdr.MoveToAttribute("target"))
                 ip_Or_ID_or_Name = rdr.ReadContentAsString();
             var computer2 = Programs.getComputer(os, ip_Or_ID_or_Name);
             if (computer2 != null)
                 computer1.links.Add(os.netMap.nodes.IndexOf(computer2));
         }
         else if (rdr.Name.Equals("dlink"))
         {
             var comp = "";
             if (rdr.MoveToAttribute("target"))
                 comp = rdr.ReadContentAsString();
             var local = computer1;
             postAllLoadedActions += () =>
             {
                 var computer2 = Programs.getComputer(os, comp);
                 if (computer2 == null)
                     return;
                 local.links.Add(os.netMap.nodes.IndexOf(computer2));
             };
         }
         else if (rdr.Name.Equals("trace"))
         {
             var num = 1f;
             if (rdr.MoveToAttribute("time"))
                 num = rdr.ReadContentAsFloat();
             computer1.traceTime = num;
         }
         else if (rdr.Name.Equals("adminPass"))
         {
             string newPass = null;
             if (rdr.MoveToAttribute("pass"))
                 newPass = rdr.ReadContentAsString();
             if (newPass == null)
                 newPass = PortExploits.getRandomPassword();
             computer1.setAdminPassword(newPass);
         }
         else if (rdr.Name.Equals("admin"))
         {
             var str3 = "basic";
             var flag2 = true;
             var flag3 = false;
             if (rdr.MoveToAttribute("type"))
                 str3 = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("resetPassword"))
                 flag2 = rdr.ReadContentAsBoolean();
             if (rdr.MoveToAttribute("isSuper"))
                 flag3 = rdr.ReadContentAsBoolean();
             switch (str3)
             {
                 case "fast":
                     computer1.admin = new FastBasicAdministrator();
                     break;
                 default:
                     computer1.admin = new BasicAdministrator();
                     break;
             }
             computer1.admin.ResetsPassword = flag2;
             computer1.admin.IsSuper = flag3;
         }
         else if (rdr.Name.Equals("ExternalCounterpart"))
         {
             var serverName = "";
             var idName = "";
             if (rdr.MoveToAttribute("id"))
                 serverName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("name"))
                 idName = rdr.ReadContentAsString();
             var externalCounterpart = new ExternalCounterpart(idName,
                 ExternalCounterpart.getIPForServerName(serverName));
             computer1.externalCounterpart = externalCounterpart;
         }
         else if (rdr.Name.Equals("account"))
         {
             byte accountType = 0;
             string s1;
             var s2 = s1 = "ERROR";
             if (rdr.MoveToAttribute("username"))
                 s2 = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("password"))
                 s1 = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("type"))
                 accountType = (byte) rdr.ReadContentAsInt();
             var user = filter(s2);
             var password = filter(s1);
             var flag2 = false;
             for (var index = 0; index < computer1.users.Count; ++index)
             {
                 var userDetail = computer1.users[index];
                 if (userDetail.name.Equals(user))
                 {
                     userDetail.pass = password;
                     userDetail.type = accountType;
                     computer1.users[index] = userDetail;
                     if (user.Equals("admin"))
                         computer1.adminPass = password;
                     flag2 = true;
                 }
             }
             if (!flag2)
             {
                 var userDetail = new UserDetail(user, password, accountType);
                 computer1.users.Add(userDetail);
             }
         }
         else if (rdr.Name.Equals("missionListingServer"))
         {
             var flag2 = false;
             var _isPublic = false;
             string serviceName;
             var group = serviceName = "ERROR";
             if (rdr.MoveToAttribute("name"))
                 serviceName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("group"))
                 group = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("assigner"))
                 flag2 = rdr.ReadContentAsBoolean();
             if (rdr.MoveToAttribute("public"))
                 _isPublic = rdr.ReadContentAsBoolean();
             computer1.daemons.Add(new MissionListingServer(computer1, serviceName, group, os, _isPublic, false)
             {
                 missionAssigner = flag2
             });
         }
         else if (rdr.Name.Equals("mailServer"))
         {
             var name = "Mail Server";
             if (rdr.MoveToAttribute("name"))
                 name = rdr.ReadContentAsString();
             var ms = new MailServer(computer1, name, os);
             if (rdr.MoveToAttribute("color"))
                 ms.setThemeColor(Utils.convertStringToColor(rdr.ReadContentAsString()));
             while (!(rdr.Name == "mailServer") || rdr.IsStartElement())
             {
                 if (rdr.Name == "email")
                 {
                     var sender = "UNKNOWN";
                     string str3 = null;
                     var subject = "UNKNOWN";
                     if (rdr.MoveToAttribute("sender"))
                         sender = rdr.ReadContentAsString();
                     if (rdr.MoveToAttribute("recipient"))
                         str3 = rdr.ReadContentAsString();
                     if (rdr.MoveToAttribute("subject"))
                         subject = rdr.ReadContentAsString();
                     var num = (int) rdr.MoveToContent();
                     var body = rdr.ReadElementContentAsString();
                     if (str3 != null)
                     {
                         var email = MailServer.generateEmail(subject, body, sender);
                         var recp = str3;
                         ms.setupComplete += () => ms.addMail(email, recp);
                     }
                 }
                 rdr.Read();
             }
             computer1.daemons.Add(ms);
         }
         else if (rdr.Name.Equals("addEmailDaemon"))
         {
             var addEmailDaemon = new AddEmailDaemon(computer1, "Final Task", os);
             computer1.daemons.Add(addEmailDaemon);
         }
         else if (rdr.Name.Equals("deathRowDatabase"))
         {
             var rowDatabaseDaemon = new DeathRowDatabaseDaemon(computer1, "Death Row Database", os);
             computer1.daemons.Add(rowDatabaseDaemon);
         }
         else if (rdr.Name.Equals("ispSystem"))
         {
             var ispDaemon = new ISPDaemon(computer1, os);
             computer1.daemons.Add(ispDaemon);
         }
         else if (rdr.Name.Equals("messageBoard"))
         {
             var messageBoardDaemon = new MessageBoardDaemon(computer1, os);
             var str3 = "Anonymous";
             if (rdr.MoveToAttribute("name"))
                 str3 = rdr.ReadContentAsString();
             messageBoardDaemon.name = str3;
             while (!(rdr.Name == "messageBoard") || rdr.IsStartElement())
             {
                 if (rdr.Name == "thread")
                 {
                     var num = (int) rdr.MoveToContent();
                     var filename1 = rdr.ReadElementContentAsString();
                     if (filename1 != null)
                         messageBoardDaemon.AddThread(Utils.readEntireFile(filename1));
                 }
                 rdr.Read();
             }
             computer1.daemons.Add(messageBoardDaemon);
         }
         else if (rdr.Name.Equals("addAvconDemoEndDaemon"))
         {
             var avconDemoEndDaemon = new AvconDemoEndDaemon(computer1, "Demo End", os);
             computer1.daemons.Add(avconDemoEndDaemon);
         }
         else if (rdr.Name.Equals("addWebServer"))
         {
             var serviceName = "Web Server";
             string pageFileLocation = null;
             if (rdr.MoveToAttribute("name"))
                 serviceName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("url"))
                 pageFileLocation = rdr.ReadContentAsString();
             var webServerDaemon = new WebServerDaemon(computer1, serviceName, os, pageFileLocation);
             webServerDaemon.registerAsDefaultBootDaemon();
             computer1.daemons.Add(webServerDaemon);
         }
         else if (rdr.Name.Equals("addOnlineWebServer"))
         {
             var serviceName = "Web Server";
             string url = null;
             if (rdr.MoveToAttribute("name"))
                 serviceName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("url"))
                 url = rdr.ReadContentAsString();
             var onlineWebServerDaemon = new OnlineWebServerDaemon(computer1, serviceName, os);
             if (url != null)
                 onlineWebServerDaemon.setURL(url);
             onlineWebServerDaemon.registerAsDefaultBootDaemon();
             computer1.daemons.Add(onlineWebServerDaemon);
         }
         else if (rdr.Name.Equals("uploadServerDaemon"))
         {
             var serviceName = "File Upload Server";
             string foldername = null;
             var input = "0,94,38";
             var needsAuthentication = false;
             if (rdr.MoveToAttribute("name"))
                 serviceName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("folder"))
                 foldername = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("color"))
                 input = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("needsAuth"))
                 needsAuthentication = rdr.ReadContentAsString().ToLower() == "true";
             var themeColor = Utils.convertStringToColor(input);
             var uploadServerDaemon = new UploadServerDaemon(computer1, serviceName, themeColor, os, foldername,
                 needsAuthentication);
             uploadServerDaemon.registerAsDefaultBootDaemon();
             computer1.daemons.Add(uploadServerDaemon);
         }
         else if (rdr.Name.Equals("MedicalDatabase"))
         {
             var medicalDatabaseDaemon = new MedicalDatabaseDaemon(computer1, os);
             computer1.daemons.Add(medicalDatabaseDaemon);
         }
         else if (rdr.Name.Equals("HeartMonitor"))
         {
             var str3 = "UNKNOWN";
             if (rdr.MoveToAttribute("patient"))
                 str3 = rdr.ReadContentAsString();
             computer1.daemons.Add(new HeartMonitorDaemon(computer1, os)
             {
                 PatientID = str3
             });
         }
         else if (rdr.Name.Equals("PointClicker"))
         {
             var pointClickerDaemon = new PointClickerDaemon(computer1, "Point Clicker!", os);
             computer1.daemons.Add(pointClickerDaemon);
         }
         else if (rdr.Name.Equals("PorthackHeart"))
         {
             var porthackHeartDaemon = new PorthackHeartDaemon(computer1, os);
             computer1.daemons.Add(porthackHeartDaemon);
         }
         else if (rdr.Name.Equals("SongChangerDaemon"))
         {
             var songChangerDaemon = new SongChangerDaemon(computer1, os);
             computer1.daemons.Add(songChangerDaemon);
         }
         else if (rdr.Name.Equals("eosDevice"))
             EOSComp.AddEOSComp(rdr, computer1, os);
         rdr.Read();
     }
     computer1.initDaemons();
     os.netMap.nodes.Add(computer1);
     return computer1;
 }