Example #1
0
        public void writeOutput(FileOutput d)
        {
            foreach (int key in offsetCalculation.Keys)
            {
                if (offsetCalculation[key] == d)
                {
                    writeIntAt((peekIntAt(key) + size()) - key, key);
                }
            }

            foreach (int key in d.offsetCalculation.Keys)
            {
                offsetCalculation.Add(key, d.offsetCalculation[key]);
            }

            foreach (byte b in d.data)
            {
                data.Add(b);
            }
        }
Example #2
0
        public void Rebuild(string fname)
        {
            FileOutput o = new FileOutput();
            FileOutput h = new FileOutput();
            FileOutput d = new FileOutput();
            FileOutput s = new FileOutput();

            // bfres header
            o.writeString("FRES");
            o.writeByte(verNumA);
            o.writeByte(verNumB);
            o.writeByte(verNumC);
            o.writeByte(verNumD);
            o.writeShort(0xFEFF); // endianness
            o.writeShort(0x0010); // version number? 0x0010
            int fileSize = o.size();

            o.writeInt(0);          // file length
            o.writeInt(0x00002000); // file alignment usuallt 0x00002000
            o.writeOffset(s.getStringOffset(Text), s);

            int stringTableSize = o.size();

            o.writeInt(0);
            int stringTableOffset = o.size();

            o.writeInt(0);

            o.writeInt(0); o.writeInt(0); o.writeInt(0); o.writeInt(0);
            o.writeInt(0); o.writeInt(0); o.writeInt(0); o.writeInt(0);
            o.writeInt(0); o.writeInt(0); o.writeInt(0); o.writeInt(0);

            o.writeShort(0); o.writeShort(0); o.writeShort(0); o.writeShort(0);
            o.writeShort(0); o.writeShort(0); o.writeShort(0); o.writeShort(0);
            o.writeShort(0); o.writeShort(0); o.writeShort(0); o.writeShort(0);

            foreach (TreeNode n in Nodes)
            {
                if (n.Text.Equals("FMDLs"))
                {
                    o.writeIntAt(o.size(), 0x20);
                    o.writeShortAt(n.Nodes.Count, 0x50);

                    IndexGroup group = new IndexGroup();
                    // create an index group and save it
                    foreach (FMDL mdl in n.Nodes)
                    {
                        group.nodes.Add(mdl);
                    }
                    group.Save(o, h, s, d);
                }
            }

            o.writeOutput(h);
            o.writeIntAt(o.size(), stringTableOffset);
            o.writeIntAt(s.size(), stringTableSize);
            o.writeOutput(s);
            o.writeOutput(d);
            o.writeIntAt(o.size(), fileSize);
            o.save(fname);
        }
Example #3
0
 public void writeOffset(int i, FileOutput o)
 {
     offsetCalculation.Add(data.Count, o);
     writeInt(i);
 }