Exemplo n.º 1
0
 public DesignEditor(int RaceID, ref StarsHostEditor obj)
 {
     base.Load += new EventHandler(this.DesignEditor_Load);
     this.Hulls = new object[0x24];
     this.InitializeComponent();
     this.CurrentRaceID = RaceID;
     this.SHE = obj;
 }
Exemplo n.º 2
0
 private void Button3_Click(object sender, EventArgs e)
 {
     StarsHostEditor editor = new StarsHostEditor();
     editor.Load(@"C:\openwar\Files\game.hst");
     editor.SwapPlanets(0x13, 0x16);
     editor.SwapPlanets(0x130, 40);
     editor.SwapPlanets(0x14e, 0x3b);
     editor.SwapPlanets(0x149, 0x2a);
     editor.SwapPlanets(0x8f, 0x131);
     editor.SwapPlanets(0x30, 320);
     editor.SwapPlanets(0xf5, 0x151);
     editor.SwapPlanets(0x13d, 0x129);
     editor.SwapPlanets(0x156, 10);
     editor.SwapPlanets(0x9a, 0x11);
     editor.SwapPlanets(0xf3, 30);
     editor.SwapPlanets(0x152, 0x2d);
     editor.SwapPlanets(0xc6, 0x160);
     editor.SwapPlanets(0x54, 0x15b);
     editor.SwapPlanets(50, 0x141);
     editor.SwapPlanets(11, 0x14b);
     editor.SaveHST(@"c:\openwar\files\game2.hst");
     editor.Save(@"C:\openwar\Files\game.hst", false);
     Interaction.Beep();
 }
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 Button1_Click_1(object sender, EventArgs e)
 {
     object obj4;
     object obj7;
     int right = 0;
     int num3 = 0;
     int num2 = 0;
     StreamWriter writer = File.CreateText(@"c:\stars\mttest\mttest.txt");
     if (ObjectFlowControl.ForLoopControl.ForLoopInitObj(obj4, 100, 100.999, 0.001, ref obj7, ref obj4))
     {
         do
         {
             object instance = new StarsHostEditor();
             foreach (string str in Strings.Split("hst,m1,x1,xy", ",", -1, CompareMethod.Binary))
             {
                 File.Copy(@"c:\stars\mttest\original\game." + str, @"c:\stars\mttest\game." + str, true);
             }
             NewLateBinding.LateCall(instance, null, "load", new object[] { @"c:\stars\mttest\game.hst" }, null, null, null, true);
             Race race = (Race) NewLateBinding.LateIndexGet(RuntimeHelpers.GetObjectValue(NewLateBinding.LateGet(instance, null, "races", new object[0], null, null, null)), new object[] { 0 }, null);
             race.xMTItemBitmap = 0;
             NewLateBinding.LateCall(instance, null, "save", new object[] { @"c:\stars\mttest\game.hst" }, null, null, null, true);
             Process process = new Process();
             ProcessStartInfo startInfo = new ProcessStartInfo();
             startInfo.Arguments = @"-g c:\stars\mttest\game.hst";
             startInfo.FileName = @"c:\stars\starsjrc4.exe";
             startInfo.WorkingDirectory = @"c:\stars\mttest";
             startInfo.ErrorDialog = true;
             startInfo.CreateNoWindow = true;
             startInfo.WindowStyle = ProcessWindowStyle.Hidden;
             Process.Start(startInfo).WaitForExit(0xea60);
             StarsHostEditor editor = new StarsHostEditor();
             editor.Load(@"c:\stars\mttest\game.hst");
             Race race2 = (Race) NewLateBinding.LateIndexGet(editor.Races(), new object[] { 0 }, null);
             int left = ((((race2.xEnergyLevel + race2.xWeaponsLevel) + race2.xPropulsionLevel) + race2.xConstructionLevel) + race2.xElectronicsLevel) + race2.xBiologyLevel;
             num2 |= race2.xMTItemBitmap;
             writer.WriteLine(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(obj4, ","), Operators.SubtractObject(left, Conversion.Int(RuntimeHelpers.GetObjectValue(obj4)))), ","), race2.xMTItemBitmap));
             if (race2.xMTItemBitmap != 0)
             {
                 right++;
             }
             num3 = Conversions.ToInteger(Operators.SubtractObject(num3 + left, Conversion.Int(RuntimeHelpers.GetObjectValue(obj4))));
             this.Text = Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.DivideObject(Conversion.Int(Operators.MultiplyObject(obj4, 0x3e8)), 0x3e8), ","), Operators.SubtractObject(left, Conversion.Int(RuntimeHelpers.GetObjectValue(obj4)))), ","), race2.xMTItemBitmap), ",TL"), num3), ",MTc"), right), ",MTi"), num2));
         }
         while (ObjectFlowControl.ForLoopControl.ForNextCheckObj(obj4, obj7, ref obj4));
     }
     writer.Close();
     Interaction.MsgBox("Done", MsgBoxStyle.ApplicationModal, null);
 }
Exemplo n.º 5
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();
        }