Пример #1
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                // Do screwy .net stuff
                ListViewItem lvi = (ListViewItem)listView1.SelectedItems[0];
                H3GameObject obj = (H3GameObject)lvi.Tag;

                // Load Data to Frontend

                // Load Idents
                txtGameIdent.Text   = "0x" + obj.GameIdent.ToString("X");
                txtTagFilename.Text = trueTaglist.IniReadValue(gamestateHeader.trueMapName, obj.GameIdent.ToString("X"));
                txtDatum.Text       = obj.linkedData.DatumSaltIndex.ToString("X");

                // Load BoundingBox (max)
                txtBBX1.Text = Convert.ToString(obj.BoundingBoxX1);
                txtBBY1.Text = Convert.ToString(obj.BoundingBoxY1);
                txtBBZ1.Text = Convert.ToString(obj.BoundingBoxZ1);

                // Load BoundingBox (min)
                txtBBX2.Text = Convert.ToString(obj.BoundingBoxX2);
                txtBBY2.Text = Convert.ToString(obj.BoundingBoxY2);
                txtBBZ2.Text = Convert.ToString(obj.BoundingBoxZ2);

                // Load Parent Position
                txtPosX.Text = Convert.ToString(obj.PositionX);
                txtPosY.Text = Convert.ToString(obj.PositionY);
                txtPosZ.Text = Convert.ToString(obj.PositionZ);
            }
            catch (Exception ex)
            {
            }
        }
Пример #2
0
        private void addLinkedChunkOffsetToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            H3GameObject gameObj = (H3GameObject)listView1.SelectedItems[0].Tag;

            string byteData = gameObj.linkedData.MahOffsat.ToString("X");

            Clipboard.SetText(byteData);

            toolStripStatusLabel2.Text = "Added linked chunk offset to Clipboard...";
        }
Пример #3
0
        private void addIdentToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            H3GameObject gameObj = (H3GameObject)listView1.SelectedItems[0].Tag;

            string byteData = gameObj.GameIdent.ToString("X");

            Clipboard.SetText(byteData);

            toolStripStatusLabel2.Text = "Added gameIdent to Clipboard...";
        }
Пример #4
0
        private void addByteDataToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            H3GameObject gameObj = (H3GameObject)listView1.SelectedItems[0].Tag;

            string byteData = gameObj.linkedData.DatumSaltIndex.ToString("X") + gameObj.linkedData.TagGroup.ToString("X") +
                              gameObj.linkedData.Unk3.ToString("X") + gameObj.linkedData.Unk4.ToString("X") + gameObj.linkedData.PoolOffset.ToString("X") +
                              gameObj.linkedData.Unk4.ToString("X") + gameObj.linkedData.Unk6.ToString("X"); Clipboard.SetText(byteData);

            toolStripStatusLabel2.Text = "Added linked bytedata to Clipboard...";
        }
Пример #5
0
        private void openLinkedByteDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            H3GameObject gameObj = (H3GameObject)listView1.SelectedItems[0].Tag;

            string byteData = gameObj.linkedData.DatumSaltIndex.ToString("X") + gameObj.linkedData.TagGroup.ToString("X") +
                              gameObj.linkedData.Unk3.ToString("X") + gameObj.linkedData.Unk4.ToString("X") + gameObj.linkedData.PoolOffset.ToString("X") +
                              gameObj.linkedData.Unk4.ToString("X") + gameObj.linkedData.Unk6.ToString("X");

            MessageBox.Show("Chunk linked Bytedata;\n\n" + byteData);
        }
Пример #6
0
        void loadSave()
        {
            // Load into Stream
            MemoryStream stream = new MemoryStream(File.ReadAllBytes(textBox1.Text));

            // Load into Aaron's nice Liberty IO
            streamReader = new SaveReader(stream);

            // Verify Valid Container
            byte[] header = new byte[4];
            streamReader.Seek(0, SeekOrigin.Begin);
            streamReader.ReadBlock(header, 0, 4);
            if (header[0] != 0x4E || header[1] != 0xB2 || header[2] != 0xC1 || header[3] != 0x86)
            {
                throw new ArgumentException("The file format is invalid: bad header\r\nShould be 4E B2 C1 86");
            }

            if (stream.Length != 0x7E0000)
            {
                throw new ArgumentException("The file format is invalid: incorrect file size\r\nExpected 0x7E0000 but got 0x" + stream.Length.ToString("X"));
            }

            // Load Header
            streamReader.Seek(0x08, SeekOrigin.Begin);
            gamestateHeader.mapScenarioName = streamReader.ReadAscii();
            streamReader.Seek(0x0108, SeekOrigin.Begin);
            gamestateHeader.relativeEngineBuild = streamReader.ReadAscii();
            streamReader.Seek(0x0154, SeekOrigin.Begin);
            gamestateHeader.mapDiskDirectory1 = streamReader.ReadAscii();
            streamReader.Seek(0xE6D9, SeekOrigin.Begin);
            gamestateHeader.player1GT1 = streamReader.ReadUTF16();
            streamReader.Seek(0xE70F, SeekOrigin.Begin);
            gamestateHeader.player1ST1 = streamReader.ReadUTF16();
            streamReader.Seek(0xE7A1, SeekOrigin.Begin);
            gamestateHeader.player1GT2 = streamReader.ReadUTF16();
            streamReader.Seek(0x3E0290, SeekOrigin.Begin);
            gamestateHeader.mapDiskDirectory2 = streamReader.ReadUTF16();

            string[] tmp = gamestateHeader.mapScenarioName.Split('\\');
            gamestateHeader.trueMapName = tmp[2];
            tmp = null;

            // Get Relative taglist
            trueTaglist = new Liberty.classInfo.iniFile(iniFolderPath + "map-" + gamestateHeader.trueMapName + ".tagCDB");

            // Load LinkObjects
            streamReader.Seek(0x46A0F4, SeekOrigin.Begin);
            linkObjects.Clear();
            for (int i = 0; i < 2048; i++)
            {
                streamReader.Seek(0x46A0F4 + (16 * i), SeekOrigin.Begin);

                LinkObjectTable linkObj = new LinkObjectTable();
                linkObj.MahOffsat = stream.Position;

                linkObj.DatumSaltIndex = (uint)(streamReader.ReadUInt16() << 16 | i);
                //linkObj.Unk1 =
                streamReader.ReadByte();
                linkObj.TagGroup   = (byte)streamReader.ReadByte();
                linkObj.Unk3       = streamReader.ReadUInt16();
                linkObj.Unk4       = streamReader.ReadUInt16();
                linkObj.PoolOffset = streamReader.ReadUInt32();
                linkObj.Unk6       = streamReader.ReadUInt32();

                streamReader.Seek(0x4721F4 + linkObj.PoolOffset, SeekOrigin.Begin);
                UInt32 gid = streamReader.ReadUInt32();
                if (gid != 0x0)
                {
                    linkObjects.Add(linkObj);
                }
            }

            IdentParents[0]  = 0;
            IdentParents[1]  = 1;
            IdentParents[2]  = 2;
            IdentParents[3]  = 3;
            IdentParents[4]  = 4;
            IdentParents[5]  = 5;
            IdentParents[6]  = 6;
            IdentParents[7]  = 7;
            IdentParents[8]  = 8;
            IdentParents[9]  = 9;
            IdentParents[10] = 10;
            IdentParents[11] = 11;
            IdentParents[13] = 13;

            foreach (LinkObjectTable linkedObjects in linkObjects)
            {
                //if (!((IList<int>)IdentParents).Contains((int)linkedObjects.TagGroup))
                {
                    if (!linkedObjects.PoolOffset.Equals(0))
                    {
                        H3GameObject h3g = new H3GameObject();
                        streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset - 16, SeekOrigin.Begin);
                        h3g.objectSizeWithLink = streamReader.ReadUInt32();
                        h3g.objectDatumIndex   = streamReader.ReadUInt32();

                        streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset, SeekOrigin.Begin);
                        h3g.linkedData = linkedObjects;
                        h3g.GameIdent  = streamReader.ReadUInt32();

                        streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset + 0x20, SeekOrigin.Begin);
                        h3g.BoundingBoxX1 = streamReader.ReadFloat();
                        h3g.BoundingBoxY1 = streamReader.ReadFloat();
                        h3g.BoundingBoxZ1 = streamReader.ReadFloat();

                        streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset + 0x30, SeekOrigin.Begin);
                        h3g.BoundingBoxX2 = streamReader.ReadFloat();
                        h3g.BoundingBoxY2 = streamReader.ReadFloat();
                        h3g.BoundingBoxZ2 = streamReader.ReadFloat();

                        streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset + 0x40, SeekOrigin.Begin);
                        h3g.PositionX = streamReader.ReadFloat();
                        h3g.PositionY = streamReader.ReadFloat();
                        h3g.PositionZ = streamReader.ReadFloat();

                        switch (h3g.linkedData.TagGroup)
                        {
                        case (byte)TagGroup.Weap:
                            H3WeaponObject h3w = new H3WeaponObject();
                            streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset + 0x23A, SeekOrigin.Begin);
                            h3w.ExternalAmmo = streamReader.ReadInt16();
                            streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset + 0x23E, SeekOrigin.Begin);
                            h3w.ClipAmmo = streamReader.ReadInt16();

                            h3g.weaponData = h3w;
                            h3g.bipedData  = null;
                            break;

                        case (byte)TagGroup.Bipd:
                            H3BipedObject h3b = new H3BipedObject();
                            streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset + 0x17C, SeekOrigin.Begin);
                            h3b.PlayerIndex = streamReader.ReadUInt16();

                            streamReader.Seek(0x4721F4 + linkedObjects.PoolOffset + 0x28C, SeekOrigin.Begin);
                            h3b.FragNade   = (sbyte)streamReader.ReadSByte();
                            h3b.PlasmaNade = (sbyte)streamReader.ReadSByte();
                            h3b.SpikeNade  = (sbyte)streamReader.ReadSByte();
                            h3b.FireNade   = (sbyte)streamReader.ReadSByte();

                            h3g.bipedData  = h3b;
                            h3g.weaponData = null;
                            break;
                        }
                        gameObjects.Add(h3g);
                    }
                }
            }

            foreach (H3GameObject gameObj in gameObjects)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text = trueTaglist.IniReadValue(gamestateHeader.trueMapName, gameObj.GameIdent.ToString("X"));
                lvi.SubItems.Add(gameObj.GameIdent.ToString("X"));
                lvi.SubItems.Add(gameObj.linkedData.TagGroup.ToString());
                lvi.SubItems.Add(gameObj.linkedData.DatumSaltIndex.ToString("X"));
                lvi.Tag = gameObj;

                listView1.Items.Add(lvi);
            }

            toolStripStatusLabel2.Text = "Loaded gamestate file... hehe :3";
        }