Exemplo n.º 1
0
        private void cmbDesignList_SelectedIndexChanged(object sender, EventArgs e)
        {
            Design design = new Design();
            design.xShipHullID = 2;
            if (this.radExistingDesigns.Checked)
            {
                int num = 0;
                if (this.radShips.Checked)
                {
                    int num2 = 0;
                    do
                    {
                        object[] arguments = new object[] { num2 };
                        bool[] copyBack = new bool[] { true };
                        if (copyBack[0])
                        {
                            num2 = (int) Conversions.ChangeType(RuntimeHelpers.GetObjectValue(arguments[0]), typeof(int));
                        }
                        if (NewLateBinding.LateGet(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { this.CurrentRaceID }, null), null, "xshipdesigns", arguments, null, null, copyBack) != null)
                        {
                            num++;
                            if (num == (this.cmbDesignList.SelectedIndex + 1))
                            {
                                object[] objArray = new object[] { num2 };
                                copyBack = new bool[] { true };
                                if (copyBack[0])
                                {
                                    num2 = (int) Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray[0]), typeof(int));
                                }
                                design = (Design) NewLateBinding.LateGet(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { this.CurrentRaceID }, null), null, "xshipdesigns", objArray, null, null, copyBack);
                            }
                        }
                        num2++;
                    }
                    while (num2 <= 15);
                }
                else
                {
                    int num3 = 0x10;
                    do
                    {
                        if (NewLateBinding.LateGet(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { this.CurrentRaceID }, null), null, "xstarbasedesigns", new object[] { num3 - 0x10 }, null, null, null) != null)
                        {
                            num++;
                            if (num == (this.cmbDesignList.SelectedIndex + 1))
                            {
                                design = (Design) NewLateBinding.LateGet(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { this.CurrentRaceID }, null), null, "xstarbasedesigns", new object[] { num3 - 0x10 }, null, null, null);
                            }
                        }
                        num3++;
                    }
                    while (num3 <= 0x19);
                }
            }
            for (int i = this.Controls.Count - 1; i >= 0; i += -1)
            {
                if ((this.Controls[i].GetType().Name == "Panel") && (this.Controls[i].Name.Substring(0, 4) == "Slot"))
                {
                    this.Controls.Remove(this.Controls[i]);
                }
            }
            string[] strArray = Strings.Split(Conversions.ToString(this.Hulls[design.xShipHullID]), ",", -1, CompareMethod.Binary);
            int num8 = (int) Math.Round((double) (Conversion.Int((double) (((double) (strArray.Length - 1)) / 6.0)) - 1.0));
            for (int j = 0; j <= num8; j++)
            {
                string str;
                Panel panel = new Panel();
                panel.BackColor = Color.Gray;
                Bitmap bitmap = new Bitmap(Conversions.ToInteger(strArray[(j * 6) + 5]), Conversions.ToInteger(strArray[(j * 6) + 6]), PixelFormat.Format24bppRgb);
                Image image = bitmap;
                Graphics graphics = Graphics.FromImage(image);
                Font font = new Font("Arial", 10f, FontStyle.Regular);
                graphics.Clear(Color.Gray);
                if (Conversions.ToDouble(strArray[(j * 6) + 1]) == 1.0)
                {
                    str = "Engine\r\n\r\n\r\n";
                    str = str + "Needs " + strArray[(j * 6) + 2];
                }
                else
                {
                    str = "";
                    int num6 = Conversions.ToInteger(strArray[(j * 6) + 1]);
                    switch (num6)
                    {
                        case -1:
                            str = "Cargo\r\n" + strArray[(j * 6) + 2] + "kT\r\n\r\n";
                            graphics.Clear(Color.White);
                            break;

                        case 0:
                            if (Conversions.ToDouble(strArray[(j * 6) + 2]) == 0.0)
                            {
                                str = "Unlimited\r\nSpace\r\nDock\r\n";
                            }
                            else
                            {
                                str = strArray[(j * 6) + 2] + "kT\r\nSpace\r\nDock\r\n";
                            }
                            graphics.Clear(Color.White);
                            break;

                        case 2:
                            str = "Scanner\r\n\r\n\r\n";
                            break;

                        case 4:
                            str = "Shield\r\n\r\n\r\n";
                            break;

                        case 8:
                            str = "Armor\r\n\r\n\r\n";
                            break;

                        case 12:
                            str = "Shield\r\nor\r\nArmor\r\n";
                            break;

                        case 0x10:
                            str = "Beam\r\n\r\n\r\n";
                            break;

                        case 0x20:
                            str = "Torpedo\r\n\r\n\r\n";
                            break;

                        case 0x30:
                            str = "Weapon\r\n\r\n\r\n";
                            break;

                        case 0x40:
                            str = "Bomb\r\n\r\n\r\n";
                            break;

                        case 0x80:
                            str = "Mining\r\nRobots\r\n\r\n";
                            break;

                        case 0x100:
                            str = "Mine\r\n\r\n\r\n";
                            break;

                        case 0x200:
                            str = "Orbital\r\n\r\n\r\n";
                            break;

                        case 0x800:
                            str = "Elect\r\n\r\n\r\n";
                            break;

                        case 0xa00:
                            str = "Orbital\r\nor\r\nElectrical\r\n";
                            break;

                        case 0x1000:
                            str = "Mech\r\n\r\n\r\n";
                            break;

                        case 0x1800:
                            str = "Elect\r\nMech\r\n\r\n";
                            break;

                        case 0x1802:
                            str = "Scanner\r\nElect\r\nMech\r\n";
                            break;

                        default:
                            str = "Unknown\r\nCat " + Conversions.ToString(num6) + "\r\n\r\n";
                            break;
                    }
                    if (num6 > 0)
                    {
                        str = str + "up to " + strArray[(j * 6) + 2];
                    }
                }
                string[] strArray2 = Strings.Split(str, "\r\n", -1, CompareMethod.Binary);
                int num10 = strArray2.Length - 1;
                for (int k = 0; k <= num10; k++)
                {
                    SizeF ef = graphics.MeasureString(strArray2[k], font, 0x40);
                    graphics.DrawString(strArray2[k], font, Brushes.Black, (float) ((Conversions.ToDouble(strArray[(j * 6) + 5]) - ef.Width) / 2.0), (float) (k * 15));
                }
                panel.BackgroundImage = image;
                panel.Left = (int) Math.Round((double) (235.0 + Conversions.ToDouble(strArray[(j * 6) + 3])));
                panel.Top = (int) Math.Round((double) (50.0 + Conversions.ToDouble(strArray[(j * 6) + 4])));
                panel.Width = Conversions.ToInteger(strArray[(j * 6) + 5]);
                panel.Height = Conversions.ToInteger(strArray[(j * 6) + 6]);
                panel.BorderStyle = BorderStyle.FixedSingle;
                panel.AllowDrop = true;
                panel.Name = "Slot" + Conversions.ToString(j);
                this.Controls.Add(panel);
            }
        }
Exemplo n.º 2
0
        private void ReadBlock(byte[] file, ref int hstPosition, ref byte[] Data, ref int type, ref int Size)
        {
            Size = file[hstPosition + 0] + ((file[hstPosition + 1] & 3) * 0x100);
            type = (int)Math.Round(Conversion.Int((double)(((double)file[hstPosition + 1]) / 4.0)));
            try
            {
                Design design;
                int    num3;
                Data = new byte[(Size - 1) + 1];
                if (Size > 0)
                {
                    Array.Copy(file, hstPosition + 2, Data, 0, Size);
                }
                switch (type)
                {
                case 8:
                {
                    int start = 12;
                    this.xTurnNo = Conversions.ToInteger(functions.GetBytes(Data, ref start, 2));
                    goto Label_0375;
                }

                case 13:
                {
                    int    num    = Data[0] + ((Data[1] & 3) * 0x100);
                    Planet planet = (Planet)this.Planets()["ID" + Conversions.ToString(num)];
                    planet.PlanetData = Data;
                    goto Label_0375;
                }

                case 0x10:
                {
                    Fleet item = new Fleet(Data);
                    this.Fleets().Add(item, null, null, null);
                    goto Label_0375;
                }

                case 0x11:
                {
                    EnemyFleet fleet2 = new EnemyFleet(Data);
                    this.Enemyfleets().Add(fleet2, null, null, null);
                    goto Label_0375;
                }

                case 0x1a:
                    design = new Design(Data);
                    if (!design.Starbase)
                    {
                        break;
                    }
                    this.StarbaseDesigns().Add(design, null, null, null);
                    goto Label_0375;

                case 0x2b:
                {
                    int num2 = 0;
                    if (this.Type43CountPos != -1)
                    {
                        goto Label_01FC;
                    }
                    this.Type43CountPos = Conversions.ToInteger(functions.GetBytes(Data, ref num2, 2));
                    goto Label_0375;
                }

                case 0x2d:
                {
                    Score score = new Score(Data);
                    score.YearNo = this.TurnNo + 0x960;
                    this.Scores().Add(score, null, null, null);
                    goto Label_0375;
                }

                default:
                    goto Label_0375;
                }
                this.ShipDesigns().Add(design, null, null, null);
                goto Label_0375;
Label_01FC:
                num3 = Data[0] + (Data[1] * 0x100);
                if ((num3 >= 0) & (num3 <= 0x1fff))
                {
                    Minefield minefield = new Minefield(Data);
                    this.MineFields().Add(minefield, null, null, null);
                }
                if ((num3 >= 0x2000) & (num3 <= 0x4000))
                {
                    AtlantisSoftware.Salvage salvage = new AtlantisSoftware.Salvage(Data);
                    this.Salvage().Add(salvage, null, null, null);
                }
                if ((num3 >= 0x4000) & (num3 <= 0x5f9f))
                {
                    Wormhole wormhole = new Wormhole(Data);
                    this.WormHoles().Add(wormhole, null, null, null);
                }
                if ((num3 >= 0x6000) & (num3 <= 0x6fff))
                {
                    MT mt = new MT(Data);
                    this.MTs().Add(mt, null, null, null);
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                this.Errors().Add("Error decoding block in .m file at file position:" + Conversions.ToString((int)hstPosition) + ", type:" + Conversions.ToString((int)type) + ", Size:" + Conversions.ToString((int)Size), null, null, null);
                ProjectData.ClearProjectError();
            }
Label_0375:
            hstPosition = (hstPosition + 2) + Size;
        }
Exemplo n.º 3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            int num15;
            try
            {
                object obj2;
                ProjectData.ClearProjectError();
                int num14 = 2;
                if (this.cmbGamesList.SelectedIndex >= 0)
                {
                    obj2 = "Error creating StarHostEditorObject";
                    this.SHE = new StarsHostEditor();
                    obj2 = "Error processing .xy file";
                    this.SHE.CreateHST(this.XYFile);
                    obj2 = "Error processing Race file";
                    int num6 = this.SHE.xPlayerCount - 1;
                    for (int i = 0; i <= num6; i++)
                    {
                        if (!Operators.ConditionalCompareObjectEqual(this.Players[i, 0], "", false))
                        {
                            obj2 = "Error importing Race file for player " + Conversions.ToString((int) (i + 1));
                            this.SHE.ImportRaceFile(Conversions.ToString(this.Players[i, 0]), i + 1);
                        }
                        obj2 = "Error processing Race file for player " + Conversions.ToString((int) (i + 1));
                        Race race = (Race) NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { i }, null);
                        race.xEnergyLevel = Conversions.ToInteger(this.Players[i, 1]);
                        race.xWeaponsLevel = Conversions.ToInteger(this.Players[i, 2]);
                        race.xPropulsionLevel = Conversions.ToInteger(this.Players[i, 3]);
                        race.xConstructionLevel = Conversions.ToInteger(this.Players[i, 4]);
                        race.xElectronicsLevel = Conversions.ToInteger(this.Players[i, 5]);
                        race.xBiologyLevel = Conversions.ToInteger(this.Players[i, 6]);
                    }
                    if (this.HFiles != null)
                    {
                        foreach (string str in this.HFiles)
                        {
                            obj2 = "Error processing H File (" + str + ")";
                            this.SHE.ImportMFile(str);
                        }
                    }
                    if (this.MFiles != null)
                    {
                        foreach (string str2 in this.MFiles)
                        {
                            obj2 = "Error processing M File (" + str2 + ")";
                            this.SHE.ImportMFile(str2);
                        }
                    }
                    if (this.PFiles != null)
                    {
                        foreach (string str3 in this.PFiles)
                        {
                            obj2 = "Error processing P File (" + str3 + ")";
                            this.SHE.ImportPFile(str3);
                        }
                    }
                    if (this.HFiles != null)
                    {
                        foreach (string str4 in this.HFiles)
                        {
                            obj2 = "Error processing H File (" + str4 + ")";
                            this.SHE.ImportMFile(str4);
                        }
                    }
                    if (this.MFiles != null)
                    {
                        foreach (string str5 in this.MFiles)
                        {
                            obj2 = "Error processing M File (" + str5 + ")";
                            this.SHE.ImportMFile(str5);
                        }
                    }
                    obj2 = "Error processing ship design changes";
                    int num2 = 0;
                    do
                    {
                        obj2 = "Error processing ship design changes for player " + Conversions.ToString((int) (num2 + 1));
                        int num3 = 0;
                        do
                        {
                            obj2 = "Error processing ship design for slot " + Conversions.ToString((int) (num3 + 1)) + " changes for player " + Conversions.ToString((int) (num2 + 1));
                            if (this.ShipDesigns[(num2 * 0x1a) + num3] != null)
                            {
                                Design design = this.ShipDesigns[(num2 * 0x1a) + num3];
                                NewLateBinding.LateSetComplex(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { num2 }, null), null, "xshipdesigns", new object[] { num3, design }, null, null, false, true);
                            }
                            num3++;
                        }
                        while (num3 <= 15);
                        num2++;
                    }
                    while (num2 <= 15);
                    obj2 = "Error processing starbase design changes";
                    int num4 = 0;
                    do
                    {
                        obj2 = "Error processing starbase design changes for player " + Conversions.ToString((int) (num4 + 1));
                        int num5 = 0;
                        do
                        {
                            obj2 = "Error processing starbase design for slot " + Conversions.ToString((int) (num5 + 1)) + " changes for player " + Conversions.ToString((int) (num4 + 1));
                            if (this.ShipDesigns[((num4 * 0x1a) + 0x10) + num5] != null)
                            {
                                Design design2 = this.ShipDesigns[((num4 * 0x1a) + 0x10) + num5];
                                NewLateBinding.LateSetComplex(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { num4 }, null), null, "xstarbasedesigns", new object[] { num5, design2 }, null, null, false, true);
                            }
                            num5++;
                        }
                        while (num5 <= 9);
                        num4++;
                    }
                    while (num4 <= 15);
                    obj2 = "Error checking for planets with starbases you no longer have designs for";
                    foreach (Planet planet in this.SHE.Planets())
                    {
                        if (((planet != null) && (planet.StarbaseSlotID >= 0)) && ((planet.OwnerID >= 0) & (planet.OwnerID <= 15)))
                        {
                            Race race2 = (Race) NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { planet.OwnerID }, null);
                            if (race2.xStarbaseDesigns[planet.StarbaseSlotID] == null)
                            {
                                planet.StarbaseSlotID = -1;
                            }
                        }
                    }
                    obj2 = "Error checking for AR planets without starbases";
                    IEnumerator enumerator = ((IEnumerable) this.SHE.Races()).GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        Race current = (Race) enumerator.Current;
                        if ((current != null) && (current.xPRT == 8))
                        {
                            if (current.xStarbaseDesigns[0] == null)
                            {
                                Design design3 = new Design();
                                design3.xShipHullID = 0x20;
                                current.xStarbaseDesigns[0] = design3;
                            }
                            foreach (Planet planet2 in this.SHE.Planets())
                            {
                                if (((planet2 != null) && (planet2.OwnerID == current.RaceID)) && (planet2.StarbaseSlotID < 0))
                                {
                                    planet2.StarbaseSlotID = 0;
                                }
                            }
                        }
                    }
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                    obj2 = "Error saving HST file or associated m files";
                    this.SHE.SaveHST(this.HSTFile);
                    Interaction.MsgBox("Complete", MsgBoxStyle.ApplicationModal, null);
                }
                else
                {
                    Interaction.MsgBox("You have not selected the game to create a .hst for", MsgBoxStyle.ApplicationModal, null);
                }
                goto Label_06A4;
            Label_064F:
                Interaction.MsgBox(RuntimeHelpers.GetObjectValue(obj2), MsgBoxStyle.ApplicationModal, null);
                goto Label_06A4;
            Label_065F:
                num15 = -1;
                switch (num14)
                {
                    case 0:
                    case 1:
                        goto Label_0699;

                    case 2:
                        goto Label_064F;
                }
            }
            catch (object obj1) when (?)
            {
                ProjectData.SetProjectError((Exception) obj1);
                goto Label_065F;
            }
            Label_0699:
            throw ProjectData.CreateProjectError(-2146828237);
            Label_06A4:
            if (num15 != 0)
            {
                ProjectData.ClearProjectError();
            }
        }
Exemplo n.º 4
0
        private void cmbGamesList_SelectedIndexChanged(object sender, EventArgs e)
        {
            object obj2;
            this.cmbRaces.SelectedIndex = 0;
            this.PFiles = null;
            this.HFiles = null;
            this.MFiles = null;
            this.ShipDesigns = new Design[0x1a0];
            this.SHE = new StarsHostEditor();
            if (this.cmbGamesList.SelectedIndex >= 0)
            {
                IEnumerator enumerator;
                obj2 = "Error decoding xml file";
                int num2 = 0;
                do
                {
                    this.Players[num2, 0] = "";
                    this.Players[num2, 1] = 0x1a;
                    this.Players[num2, 2] = 0x1a;
                    this.Players[num2, 3] = 0x1a;
                    this.Players[num2, 4] = 0x1a;
                    this.Players[num2, 5] = 0x1a;
                    this.Players[num2, 6] = 0x1a;
                    num2++;
                }
                while (num2 <= 15);
                int selectedIndex = this.cmbGamesList.SelectedIndex;
                try
                {
                    enumerator = this.GamesElement.ChildNodes[selectedIndex].GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        XmlNode current = (XmlNode) enumerator.Current;
                        string str8 = Strings.UCase(current.Name);
                        if (str8 == "XYFILE")
                        {
                            obj2 = "Error Processing xml file for XYFile";
                            this.XYFile = current.Attributes["file"].Value;
                        }
                        else
                        {
                            switch (str8)
                            {
                                case "HSTFILE":
                                    obj2 = "Error Processing xml file for HSTFile";
                                    this.HSTFile = current.Attributes["file"].Value;
                                    break;

                                case "PLAYER":
                                {
                                    IEnumerator enumerator2;
                                    obj2 = "Error Processing xml file for Player definition";
                                    string str = current.Attributes["no"].Value;
                                    try
                                    {
                                        enumerator2 = current.ChildNodes.GetEnumerator();
                                        while (enumerator2.MoveNext())
                                        {
                                            XmlNode node2 = (XmlNode) enumerator2.Current;
                                            switch (Strings.UCase(node2.Name))
                                            {
                                                case "RACEFILE":
                                                {
                                                    obj2 = "Error Processing xml file for Race file for player " + str;
                                                    this.Players[(int) Math.Round((double) (Conversions.ToDouble(str) - 1.0)), 0] = node2.Attributes["file"].Value;
                                                    continue;
                                                }
                                                case "ENERGY":
                                                {
                                                    obj2 = "Error Processing xml file for Energy Level for player " + str;
                                                    this.Players[(int) Math.Round((double) (Conversions.ToDouble(str) - 1.0)), 1] = node2.Attributes["value"].Value;
                                                    continue;
                                                }
                                                case "WEAPONS":
                                                {
                                                    obj2 = "Error Processing xml file for Weapons Level for player " + str;
                                                    this.Players[(int) Math.Round((double) (Conversions.ToDouble(str) - 1.0)), 2] = node2.Attributes["value"].Value;
                                                    continue;
                                                }
                                                case "PROPULSION":
                                                {
                                                    obj2 = "Error Processing xml file for Propulsion Level for player " + str;
                                                    this.Players[(int) Math.Round((double) (Conversions.ToDouble(str) - 1.0)), 3] = node2.Attributes["value"].Value;
                                                    continue;
                                                }
                                                case "CONSTRUCTION":
                                                {
                                                    obj2 = "Error Processing xml file for Construction Level for player " + str;
                                                    this.Players[(int) Math.Round((double) (Conversions.ToDouble(str) - 1.0)), 4] = node2.Attributes["value"].Value;
                                                    continue;
                                                }
                                                case "ELECTRONICS":
                                                {
                                                    obj2 = "Error Processing xml file for Electronics Level for player " + str;
                                                    this.Players[(int) Math.Round((double) (Conversions.ToDouble(str) - 1.0)), 5] = node2.Attributes["value"].Value;
                                                    continue;
                                                }
                                                case "BIOLOGY":
                                                {
                                                    obj2 = "Error Processing xml file for Biology Level for player " + str;
                                                    this.Players[(int) Math.Round((double) (Conversions.ToDouble(str) - 1.0)), 6] = node2.Attributes["value"].Value;
                                                    continue;
                                                }
                                                case "SHIPDESIGN":
                                                {
                                                    IEnumerator enumerator3;
                                                    obj2 = "Error Processing xml file for Ship Design for player " + str;
                                                    string str2 = node2.Attributes["value"].Value;
                                                    string str3 = node2.Attributes["slots"].Value;
                                                    Design design = new Design();
                                                    design.xDesignID = (int) Math.Round((double) (Conversions.ToDouble(str2) - 1.0));
                                                    design.Slots = new DesignSlot[((int) Math.Round((double) (Conversions.ToDouble(str3) - 1.0))) + 1];
                                                    try
                                                    {
                                                        enumerator3 = node2.ChildNodes.GetEnumerator();
                                                        while (enumerator3.MoveNext())
                                                        {
                                                            XmlNode node3 = (XmlNode) enumerator3.Current;
                                                            string str10 = Strings.UCase(node3.Name);
                                                            if (str10 == "SLOT")
                                                            {
                                                                string str4 = node3.Attributes["no"].Value;
                                                                DesignSlot slot = new DesignSlot();
                                                                slot.xItemCategory = Conversions.ToInteger(node3.Attributes["categoryid"].Value);
                                                                slot.xItemID = Conversions.ToInteger(node3.Attributes["itemid"].Value);
                                                                slot.xItemCount = Conversions.ToInteger(node3.Attributes["itemcount"].Value);
                                                                design.Slots[(int) Math.Round((double) (Conversions.ToDouble(str4) - 1.0))] = slot;
                                                            }
                                                            else
                                                            {
                                                                if (str10 == "HULL")
                                                                {
                                                                    design.xShipHullID = Conversions.ToInteger(node3.Attributes["value"].Value);
                                                                    continue;
                                                                }
                                                                if (str10 == "NAME")
                                                                {
                                                                    design.xName = node3.Attributes["value"].Value;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    finally
                                                    {
                                                        if (enumerator3 is IDisposable)
                                                        {
                                                            (enumerator3 as IDisposable).Dispose();
                                                        }
                                                    }
                                                    this.ShipDesigns[(int) Math.Round((double) ((((Conversions.ToDouble(str) - 1.0) * 26.0) + Conversions.ToDouble(str2)) - 1.0))] = design;
                                                    continue;
                                                }
                                                case "STARBASEDESIGN":
                                                {
                                                    IEnumerator enumerator4;
                                                    obj2 = "Error Processing xml file for Starbase Design for player " + str;
                                                    string str5 = node2.Attributes["value"].Value;
                                                    string str6 = node2.Attributes["slots"].Value;
                                                    Design design2 = new Design();
                                                    design2.xDesignID = (int) Math.Round((double) (Conversions.ToDouble(str5) - 1.0));
                                                    design2.Slots = new DesignSlot[((int) Math.Round((double) (Conversions.ToDouble(str6) - 1.0))) + 1];
                                                    try
                                                    {
                                                        enumerator4 = node2.ChildNodes.GetEnumerator();
                                                        while (enumerator4.MoveNext())
                                                        {
                                                            XmlNode node4 = (XmlNode) enumerator4.Current;
                                                            string str11 = Strings.UCase(node4.Name);
                                                            if (str11 == "SLOT")
                                                            {
                                                                string str7 = node4.Attributes["no"].Value;
                                                                DesignSlot slot2 = new DesignSlot();
                                                                slot2.xItemCategory = Conversions.ToInteger(node4.Attributes["categoryid"].Value);
                                                                slot2.xItemID = Conversions.ToInteger(node4.Attributes["itemid"].Value);
                                                                slot2.xItemCount = Conversions.ToInteger(node4.Attributes["itemcount"].Value);
                                                                design2.Slots[(int) Math.Round((double) (Conversions.ToDouble(str7) - 1.0))] = slot2;
                                                            }
                                                            else
                                                            {
                                                                if (str11 == "HULL")
                                                                {
                                                                    design2.xShipHullID = Conversions.ToInteger(node4.Attributes["value"].Value);
                                                                    continue;
                                                                }
                                                                if (str11 == "NAME")
                                                                {
                                                                    design2.xName = node4.Attributes["value"].Value;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    finally
                                                    {
                                                        if (enumerator4 is IDisposable)
                                                        {
                                                            (enumerator4 as IDisposable).Dispose();
                                                        }
                                                    }
                                                    this.ShipDesigns[(int) Math.Round((double) (((((Conversions.ToDouble(str) - 1.0) * 26.0) + 16.0) + Conversions.ToDouble(str5)) - 1.0))] = design2;
                                                    break;
                                                }
                                            }
                                        }
                                        continue;
                                    }
                                    finally
                                    {
                                        if (enumerator2 is IDisposable)
                                        {
                                            (enumerator2 as IDisposable).Dispose();
                                        }
                                    }
                                    break;
                                }
                                case "MFILE":
                                {
                                    obj2 = "Error Processing xml file for MFile";
                                    if (this.MFiles == null)
                                    {
                                        this.MFiles = new string[1];
                                    }
                                    else
                                    {
                                        this.MFiles = (string[]) Utils.CopyArray((Array) this.MFiles, new string[this.MFiles.Length + 1]);
                                    }
                                    this.MFiles[this.MFiles.Length - 1] = current.Attributes["file"].Value;
                                    continue;
                                }
                                case "HFILE":
                                {
                                    obj2 = "Error Processing xml file for HFile";
                                    if (this.HFiles == null)
                                    {
                                        this.HFiles = new string[1];
                                    }
                                    else
                                    {
                                        this.HFiles = (string[]) Utils.CopyArray((Array) this.HFiles, new string[this.HFiles.Length + 1]);
                                    }
                                    this.HFiles[this.HFiles.Length - 1] = current.Attributes["file"].Value;
                                    continue;
                                }
                                case "PFILE":
                                {
                                    obj2 = "Error Processing xml file for PFile";
                                    if (this.PFiles == null)
                                    {
                                        this.PFiles = new string[1];
                                    }
                                    else
                                    {
                                        this.PFiles = (string[]) Utils.CopyArray((Array) this.PFiles, new string[this.PFiles.Length + 1]);
                                    }
                                    this.PFiles[this.PFiles.Length - 1] = current.Attributes["file"].Value;
                                    continue;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
            obj2 = "Error creating StarHostEditorObject";
            this.SHE = new StarsHostEditor();
        }
Exemplo n.º 5
0
        private void ReadBlock(byte[] file, ref int hstPosition, ref byte[] Data, ref int type, ref int Size)
        {
            Size = file[hstPosition + 0] + ((file[hstPosition + 1] & 3) * 0x100);
            type = (int) Math.Round(Conversion.Int((double) (((double) file[hstPosition + 1]) / 4.0)));
            try
            {
                Design design;
                int num3;
                Data = new byte[(Size - 1) + 1];
                if (Size > 0)
                {
                    Array.Copy(file, hstPosition + 2, Data, 0, Size);
                }
                switch (type)
                {
                    case 8:
                    {
                        int start = 12;
                        this.xTurnNo = Conversions.ToInteger(functions.GetBytes(Data, ref start, 2));
                        goto Label_0375;
                    }
                    case 13:
                    {
                        int num = Data[0] + ((Data[1] & 3) * 0x100);
                        Planet planet = (Planet) this.Planets()["ID" + Conversions.ToString(num)];
                        planet.PlanetData = Data;
                        goto Label_0375;
                    }
                    case 0x10:
                    {
                        Fleet item = new Fleet(Data);
                        this.Fleets().Add(item, null, null, null);
                        goto Label_0375;
                    }
                    case 0x11:
                    {
                        EnemyFleet fleet2 = new EnemyFleet(Data);
                        this.Enemyfleets().Add(fleet2, null, null, null);
                        goto Label_0375;
                    }
                    case 0x1a:
                        design = new Design(Data);
                        if (!design.Starbase)
                        {
                            break;
                        }
                        this.StarbaseDesigns().Add(design, null, null, null);
                        goto Label_0375;

                    case 0x2b:
                    {
                        int num2 = 0;
                        if (this.Type43CountPos != -1)
                        {
                            goto Label_01FC;
                        }
                        this.Type43CountPos = Conversions.ToInteger(functions.GetBytes(Data, ref num2, 2));
                        goto Label_0375;
                    }
                    case 0x2d:
                    {
                        Score score = new Score(Data);
                        score.YearNo = this.TurnNo + 0x960;
                        this.Scores().Add(score, null, null, null);
                        goto Label_0375;
                    }
                    default:
                        goto Label_0375;
                }
                this.ShipDesigns().Add(design, null, null, null);
                goto Label_0375;
            Label_01FC:
                num3 = Data[0] + (Data[1] * 0x100);
                if ((num3 >= 0) & (num3 <= 0x1fff))
                {
                    Minefield minefield = new Minefield(Data);
                    this.MineFields().Add(minefield, null, null, null);
                }
                if ((num3 >= 0x2000) & (num3 <= 0x4000))
                {
                    AtlantisSoftware.Salvage salvage = new AtlantisSoftware.Salvage(Data);
                    this.Salvage().Add(salvage, null, null, null);
                }
                if ((num3 >= 0x4000) & (num3 <= 0x5f9f))
                {
                    Wormhole wormhole = new Wormhole(Data);
                    this.WormHoles().Add(wormhole, null, null, null);
                }
                if ((num3 >= 0x6000) & (num3 <= 0x6fff))
                {
                    MT mt = new MT(Data);
                    this.MTs().Add(mt, null, null, null);
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                this.Errors().Add("Error decoding block in .m file at file position:" + Conversions.ToString((int) hstPosition) + ", type:" + Conversions.ToString((int) type) + ", Size:" + Conversions.ToString((int) Size), null, null, null);
                ProjectData.ClearProjectError();
            }
        Label_0375:
            hstPosition = (hstPosition + 2) + Size;
        }
Exemplo n.º 6
0
        private void cmbDesignList_SelectedIndexChanged(object sender, EventArgs e)
        {
            Design design = new Design();

            design.xShipHullID = 2;
            if (this.radExistingDesigns.Checked)
            {
                int num = 0;
                if (this.radShips.Checked)
                {
                    int num2 = 0;
                    do
                    {
                        object[] arguments = new object[] { num2 };
                        bool[]   copyBack  = new bool[] { true };
                        if (copyBack[0])
                        {
                            num2 = (int)Conversions.ChangeType(RuntimeHelpers.GetObjectValue(arguments[0]), typeof(int));
                        }
                        if (NewLateBinding.LateGet(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { this.CurrentRaceID }, null), null, "xshipdesigns", arguments, null, null, copyBack) != null)
                        {
                            num++;
                            if (num == (this.cmbDesignList.SelectedIndex + 1))
                            {
                                object[] objArray = new object[] { num2 };
                                copyBack = new bool[] { true };
                                if (copyBack[0])
                                {
                                    num2 = (int)Conversions.ChangeType(RuntimeHelpers.GetObjectValue(objArray[0]), typeof(int));
                                }
                                design = (Design)NewLateBinding.LateGet(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { this.CurrentRaceID }, null), null, "xshipdesigns", objArray, null, null, copyBack);
                            }
                        }
                        num2++;
                    }while (num2 <= 15);
                }
                else
                {
                    int num3 = 0x10;
                    do
                    {
                        if (NewLateBinding.LateGet(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { this.CurrentRaceID }, null), null, "xstarbasedesigns", new object[] { num3 - 0x10 }, null, null, null) != null)
                        {
                            num++;
                            if (num == (this.cmbDesignList.SelectedIndex + 1))
                            {
                                design = (Design)NewLateBinding.LateGet(NewLateBinding.LateIndexGet(this.SHE.Races(), new object[] { this.CurrentRaceID }, null), null, "xstarbasedesigns", new object[] { num3 - 0x10 }, null, null, null);
                            }
                        }
                        num3++;
                    }while (num3 <= 0x19);
                }
            }
            for (int i = this.Controls.Count - 1; i >= 0; i += -1)
            {
                if ((this.Controls[i].GetType().Name == "Panel") && (this.Controls[i].Name.Substring(0, 4) == "Slot"))
                {
                    this.Controls.Remove(this.Controls[i]);
                }
            }
            string[] strArray = Strings.Split(Conversions.ToString(this.Hulls[design.xShipHullID]), ",", -1, CompareMethod.Binary);
            int      num8     = (int)Math.Round((double)(Conversion.Int((double)(((double)(strArray.Length - 1)) / 6.0)) - 1.0));

            for (int j = 0; j <= num8; j++)
            {
                string str;
                Panel  panel = new Panel();
                panel.BackColor = Color.Gray;
                Bitmap   bitmap   = new Bitmap(Conversions.ToInteger(strArray[(j * 6) + 5]), Conversions.ToInteger(strArray[(j * 6) + 6]), PixelFormat.Format24bppRgb);
                Image    image    = bitmap;
                Graphics graphics = Graphics.FromImage(image);
                Font     font     = new Font("Arial", 10f, FontStyle.Regular);
                graphics.Clear(Color.Gray);
                if (Conversions.ToDouble(strArray[(j * 6) + 1]) == 1.0)
                {
                    str = "Engine\r\n\r\n\r\n";
                    str = str + "Needs " + strArray[(j * 6) + 2];
                }
                else
                {
                    str = "";
                    int num6 = Conversions.ToInteger(strArray[(j * 6) + 1]);
                    switch (num6)
                    {
                    case -1:
                        str = "Cargo\r\n" + strArray[(j * 6) + 2] + "kT\r\n\r\n";
                        graphics.Clear(Color.White);
                        break;

                    case 0:
                        if (Conversions.ToDouble(strArray[(j * 6) + 2]) == 0.0)
                        {
                            str = "Unlimited\r\nSpace\r\nDock\r\n";
                        }
                        else
                        {
                            str = strArray[(j * 6) + 2] + "kT\r\nSpace\r\nDock\r\n";
                        }
                        graphics.Clear(Color.White);
                        break;

                    case 2:
                        str = "Scanner\r\n\r\n\r\n";
                        break;

                    case 4:
                        str = "Shield\r\n\r\n\r\n";
                        break;

                    case 8:
                        str = "Armor\r\n\r\n\r\n";
                        break;

                    case 12:
                        str = "Shield\r\nor\r\nArmor\r\n";
                        break;

                    case 0x10:
                        str = "Beam\r\n\r\n\r\n";
                        break;

                    case 0x20:
                        str = "Torpedo\r\n\r\n\r\n";
                        break;

                    case 0x30:
                        str = "Weapon\r\n\r\n\r\n";
                        break;

                    case 0x40:
                        str = "Bomb\r\n\r\n\r\n";
                        break;

                    case 0x80:
                        str = "Mining\r\nRobots\r\n\r\n";
                        break;

                    case 0x100:
                        str = "Mine\r\n\r\n\r\n";
                        break;

                    case 0x200:
                        str = "Orbital\r\n\r\n\r\n";
                        break;

                    case 0x800:
                        str = "Elect\r\n\r\n\r\n";
                        break;

                    case 0xa00:
                        str = "Orbital\r\nor\r\nElectrical\r\n";
                        break;

                    case 0x1000:
                        str = "Mech\r\n\r\n\r\n";
                        break;

                    case 0x1800:
                        str = "Elect\r\nMech\r\n\r\n";
                        break;

                    case 0x1802:
                        str = "Scanner\r\nElect\r\nMech\r\n";
                        break;

                    default:
                        str = "Unknown\r\nCat " + Conversions.ToString(num6) + "\r\n\r\n";
                        break;
                    }
                    if (num6 > 0)
                    {
                        str = str + "up to " + strArray[(j * 6) + 2];
                    }
                }
                string[] strArray2 = Strings.Split(str, "\r\n", -1, CompareMethod.Binary);
                int      num10     = strArray2.Length - 1;
                for (int k = 0; k <= num10; k++)
                {
                    SizeF ef = graphics.MeasureString(strArray2[k], font, 0x40);
                    graphics.DrawString(strArray2[k], font, Brushes.Black, (float)((Conversions.ToDouble(strArray[(j * 6) + 5]) - ef.Width) / 2.0), (float)(k * 15));
                }
                panel.BackgroundImage = image;
                panel.Left            = (int)Math.Round((double)(235.0 + Conversions.ToDouble(strArray[(j * 6) + 3])));
                panel.Top             = (int)Math.Round((double)(50.0 + Conversions.ToDouble(strArray[(j * 6) + 4])));
                panel.Width           = Conversions.ToInteger(strArray[(j * 6) + 5]);
                panel.Height          = Conversions.ToInteger(strArray[(j * 6) + 6]);
                panel.BorderStyle     = BorderStyle.FixedSingle;
                panel.AllowDrop       = true;
                panel.Name            = "Slot" + Conversions.ToString(j);
                this.Controls.Add(panel);
            }
        }