public int LoadXFile(string filename)
        {
            Decryptor decryptor = new Decryptor();
            int index = -1;
            byte[] sourceArray = decryptor.OpenFile(filename);
            int num3 = 0;
            XFile file = new XFile();
            do
            {
                int length = sourceArray[num3 + 0] + ((sourceArray[num3 + 1] & 3) * 0x100);
                double num5 = Conversion.Int((double) (((double) sourceArray[num3 + 1]) / 4.0));
                byte[] destinationArray = new byte[(length - 1) + 1];
                if (length > 0)
                {
                    Array.Copy(sourceArray, num3 + 2, destinationArray, 0, length);
                }
                double num8 = num5;
                switch (num8)
                {
                    case 0.0:
                    case 9.0:
                        break;

                    case 8.0:
                    {
                        Header header = new Header(destinationArray);
                        index = header.PlayerID;
                        break;
                    }
                    case 27.0:
                    {
                        Design design = new Design(destinationArray, 0x1b);
                        design.Dirty = true;
                        if (design.DesignID < 0x10)
                        {
                            if (design.DeletedDesign)
                            {
                                this.Races[index].ShipDesigns[design.DesignID] = null;
                            }
                            else
                            {
                                this.Races[index].ShipDesigns[design.DesignID] = design;
                            }
                        }
                        else if (design.DeletedDesign)
                        {
                            this.Races[index].StarbaseDesigns[design.DesignID - 0x10] = null;
                        }
                        else
                        {
                            this.Races[index].StarbaseDesigns[design.DesignID - 0x10] = design;
                        }
                        break;
                    }
                    default:
                        if (num8 == 29.0)
                        {
                            int num6 = (destinationArray[0] + (destinationArray[1] * 0x100)) & 0x3ff;
                            this.Planets[num6].ProductionQueue = new QueueItem[((int) Math.Round((double) ((((double) (destinationArray.Length - 2)) / 4.0) - 1.0))) + 1];
                            int num9 = destinationArray.Length - 1;
                            for (int i = 2; i <= num9; i += 4)
                            {
                                byte[] data = new byte[] { destinationArray[i], destinationArray[i + 1], destinationArray[i + 2], destinationArray[i + 3] };
                                QueueItem item = new QueueItem(data);
                                this.Planets[num6].ProductionQueue[(int) Math.Round((double) (((double) (i - 2)) / 4.0))] = item;
                            }
                        }
                        else
                        {
                            Debug.Print(Conversions.ToString(num5));
                        }
                        break;
                }
                num3 = (num3 + 2) + length;
            }
            while (num3 < sourceArray.Length);
            return index;
        }
        public object xCheckXFile(string Filename)
        {
            string str = "";
            int num = this.LoadXFile(Filename);
            byte[] sourceArray = new Decryptor().OpenFile(Filename);
            int num2 = 0;
            XFile file = new XFile();
            do
            {
                int length = sourceArray[num2 + 0] + ((sourceArray[num2 + 1] & 3) * 0x100);
                double num4 = Conversion.Int((double) (((double) sourceArray[num2 + 1]) / 4.0));
                byte[] destinationArray = new byte[(length - 1) + 1];
                if (length > 0)
                {
                    Array.Copy(sourceArray, num2 + 2, destinationArray, 0, length);
                }
                switch (num4)
                {
                    case 0.0:
                    case 9.0:
                        break;

                    case 8.0:
                    {
                        Header header = new Header(destinationArray);
                        file.AddObject(header);
                        break;
                    }
                    case 27.0:
                    {
                        Design design = new Design(destinationArray, 0x1b);
                        file.AddObject(design);
                        break;
                    }
                    default:
                        Debug.Print(Conversions.ToString(num4));
                        break;
                }
                num2 = (num2 + 2) + length;
            }
            while (num2 < sourceArray.Length);
            Debug.Print("");
            if (!this.Settings.Allow22OrMoreSuperlatinumInASlot[file.PlayerID])
            {
                int index = 0;
                do
                {
                    if (file.Designs[index] != null)
                    {
                        Design design2 = file.Designs[index];
                        foreach (DesignSlot slot in design2.Slots)
                        {
                            if ((slot != null) && (((slot.CategoryID == 8) & (slot.ItemID == 11)) & (slot.Count >= 0x16)))
                            {
                                str = str + "You are not allowed to have 22 Superlatinum in one slot on the " + design2.Name + " design\r\n";
                            }
                        }
                    }
                    index++;
                }
                while (index <= 0x19);
            }
            if (!this.Settings.AllowTenthStarbaseSlotToBeUsed[file.PlayerID] && (file.Designs[0x19] != null))
            {
                str = str + "You are not allowed to use the 10th Starbase design slot\r\n";
            }
            return str;
        }
        public object LoadHSTFile(string Filename)
        {
            byte[] sourceArray = new Decryptor().OpenFile(Filename);
            int num2 = 0;
            do
            {
                int planetID;
                int length = sourceArray[num2 + 0] + ((sourceArray[num2 + 1] & 3) * 0x100);
                double num4 = Conversion.Int((double) (((double) sourceArray[num2 + 1]) / 4.0));
                byte[] destinationArray = new byte[(length - 1) + 1];
                if (length > 0)
                {
                    Array.Copy(sourceArray, num2 + 2, destinationArray, 0, length);
                }
                double num6 = num4;
                switch (num6)
                {
                    case 0.0:
                    case 9.0:
                    case 16.0:
                    case 20.0:
                    case 26.0:
                        break;

                    case 6.0:
                        Race race;
                        this.Races[race.RaceID] = new Race(destinationArray);
                        break;

                    case 8.0:
                    {
                        Header header = new Header(destinationArray);
                        break;
                    }
                    case 13.0:
                    {
                        Planet planet = new Planet(destinationArray);
                        planet.X = this.Planets[planet.PlanetID].X;
                        planet.Y = this.Planets[planet.PlanetID].Y;
                        planet.NameID = this.Planets[planet.PlanetID].NameID;
                        planet.ProductionQueue = null;
                        planetID = planet.PlanetID;
                        break;
                    }
                    case 28.0:
                    {
                        Planet planet2 = this.Planets[planetID];
                        planet2.ProductionQueue = new QueueItem[((int) Math.Round((double) ((((double) destinationArray.Length) / 4.0) - 1.0))) + 1];
                        int num7 = destinationArray.Length - 1;
                        for (int i = 0; i <= num7; i += 4)
                        {
                            byte[] data = new byte[] { destinationArray[i], destinationArray[i + 1], destinationArray[i + 2], destinationArray[i + 3] };
                            QueueItem item = new QueueItem(data);
                            planet2.ProductionQueue[(int) Math.Round((double) (((double) i) / 4.0))] = item;
                        }
                        break;
                    }
                    default:
                        if ((num6 != 30.0) && (num6 != 43.0))
                        {
                            Debug.Print(Conversions.ToString(num4));
                        }
                        break;
                }
                num2 = (num2 + 2) + length;
            }
            while (num2 < sourceArray.Length);
            return 0;
        }