Exemplo n.º 1
0
        public void Save(FileOutput o, FileOutput h, FileOutput s, FileOutput d)
        {
            o.writeInt(8 + 16 * (nodes.Count + 1));
            o.writeInt(nodes.Count);

            BSTNode root = new BSTNode();

            foreach (TreeNode n in nodes)
            {
            }

            // create root node
            o.writeShort(0xFFFF); o.writeShort(0xFFFF);
            o.writeShort(0x01);
            o.writeShort(0x00);
            o.writeInt(0);
            o.writeInt(0);

            // make this into binary search tree
            foreach (TreeNode n in nodes)
            {
                o.writeInt(0); // search value
                o.writeShort(0x00);
                o.writeShort(0x01);
                o.writeOffset(s.getStringOffset(n.Text), s);
                o.writeOffset(h.size(), h);
            }
        }
Exemplo n.º 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);
        }