Beispiel #1
0
        public void Open(string filename)
        {
            BlockReader = new GDBlockReader();
            using (BlockReader.File = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read), ASCIIEncoding.ASCII))
            {
                FileName = filename;
                UInt32 n, ver;
                BlockReader.read_key();

                if (BlockReader.read_int() != 2)
                {
                    throw new IOException();
                }

                GDBlock b = new GDBlock();

                if (BlockReader.read_block_start(ref b) != 18)
                {
                    throw new IOException();
                }
                ver = BlockReader.read_int();
                if (ver < 4)                 // version
                {
                    throw new IOException("Version Mismatch <4");
                }
                n = BlockReader.next_int();
                if (n != 0)
                {
                    throw new IOException();
                }

                mod = BlockReader.read_str();
                if (ver >= 5)
                {
                    BlockReader.read_byte();
                }
                n    = BlockReader.read_int();
                Bags = new List <GDStashBag>((int)n);

                for (int i = 0; i < n; i++)
                {
                    GDStashBag bag = new GDStashBag();
                    bag.Read(this.BlockReader, this);
                    bag.Index = i;
                    Bags.Add(bag);
                }

                BlockReader.read_block_end(ref b);
            }
        }
Beispiel #2
0
        //respawn_list respawns;
        //teleport_list teleports;
        //marker_list markers;
        //shrine_list shrines;
        //character_skills skills;
        //lore_notes notes;
        //faction_pack factions;
        //ui_settings ui;
        //tutorial_pages tutorials;
        //play_stats stats;

        //void read(const char*);
        //void write(const char*);

        public void read(string filename)
        {
            GDBlockReader gdbr = new GDBlockReader();

            using (gdbr.File = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read), ASCIIEncoding.ASCII))
            {
                uint n, ver;
                gdbr.read_key();

                if (gdbr.read_int() != 0x58434447)
                {
                    throw new IOException();
                }

                ver = gdbr.read_int();
                if (ver != 1 && ver != 2)
                {
                    throw new IOException("Unsupported Version");
                }
                //read Header
                hdr.read(ref gdbr);
                if (ver == 2)
                {
                    gdbr.read_byte();
                }

                n = gdbr.next_int();
                if (n != 0)
                {
                    throw new IOException();
                }

                ver = gdbr.read_int();
                if (ver < 6)                 // version
                {
                    throw new IOException("Version Mismatch reading Player file, ver<6");
                }

                id.read(ref gdbr);

                info.read(ref gdbr);
                bio.read(ref gdbr);
                inv.read(ref gdbr);

                //foreach (GDStashItem item in inv.Items)
                //{
                //	item.FriendlyName = hdr.name;
                //}

                stash.read(ref gdbr);

                //foreach (GDStashItem item in stash.Items)
                //{
                //	item.FriendlyName = hdr.name;
                //}

                //respawns.read(this);
                //teleports.read(this);
                //markers.read(this);
                //shrines.read(this);
                //skills.read(this);
                //notes.read(this);
                //factions.read(this);
                //ui.read(this);
                //tutorials.read(this);
                //stats.read(this);

                gdbr.File.Close();
            }
        }