public SkyrimSavegame Read(String label, FileStream fileStream)
        {
            br = new SkyrimBinaryReader(fileStream);

            char[] magic = br.ReadChars(13);

            UInt32 headerSize = br.ReadUInt32();

            Print("magic", new string(magic));
            Print("headerSize", headerSize);

            Header header = ReadHeader();

            header.Print();
            ReadScreenshot(header);

            byte   formVersion    = br.ReadByte(); //uint8
            UInt32 pluginInfoSize = br.ReadUInt32();

            Print("formVersion", formVersion);
            Print("pluginInfoSize", pluginInfoSize);

            //PluginInfo pluginInfo = ReadPluginInfo();

            //skip pluginInfo
            br.ReadBytes((int)pluginInfoSize);

            FileLocationTable fileLocationTable = ReadFileLocationTable();

            fileLocationTable.Print();

            GlobalDataType[] globalDataTable1 = ReadGlobalDataTable(9); //Types 0 to 8.
            //GlobalDataType[] globalDataTable2 = ReadGlobalDataTable(15); //Types 100 to 114.


            SkyrimSavegame savegame = new SkyrimSavegame(label);

            savegame.header            = header;
            savegame.formVersion       = formVersion;
            savegame.fileLocationTable = fileLocationTable;
            savegame.globalDataTable1  = globalDataTable1;
            //savegame.globalDataTable2 = globalDataTable2;

            foreach (var ms in savegame.GetMiscStats().OrderBy(p => p.category).ThenBy(n => n.name))
            {
                Print("stats", "cat({0}).{1} = {2}", ms.category, ms.name, ms.value);
            }

            return(savegame);
        }
        private StatisticValue[] ParseStats(SkyrimSavegame savegame)
        {
            List <StatisticValue> stats = new List <StatisticValue>();
            var orderedMiscStats        = savegame.GetMiscStats().OrderBy(p => p.category).ThenBy(n => n.name);

            foreach (var ms in orderedMiscStats)
            {
                StatisticValue sv = new StatisticValue();

                StatisticCategoryType catType = (StatisticCategoryType)ms.category;

                sv.CategoryId = (int)catType;
                sv.Name       = ms.name;
                sv.Value      = ms.value;

                stats.Add(sv);
            }
            return(stats.ToArray());
        }
        public SkyrimSavegame Read(String label, FileStream fileStream)
        {
            br = new SkyrimBinaryReader(fileStream);

            char[] magic = br.ReadChars(13);

            UInt32 headerSize = br.ReadUInt32();

            Print("magic", new string(magic));
            Print("headerSize", headerSize);

            Header header = ReadHeader();
            header.Print();
            ReadScreenshot(header);

            byte formVersion = br.ReadByte(); //uint8
            UInt32 pluginInfoSize = br.ReadUInt32();

            Print("formVersion", formVersion);
            Print("pluginInfoSize", pluginInfoSize);

            //PluginInfo pluginInfo = ReadPluginInfo();

            //skip pluginInfo
            br.ReadBytes((int) pluginInfoSize);

            FileLocationTable fileLocationTable = ReadFileLocationTable();
            fileLocationTable.Print();

            GlobalDataType[] globalDataTable1 = ReadGlobalDataTable(9); //Types 0 to 8.
            //GlobalDataType[] globalDataTable2 = ReadGlobalDataTable(15); //Types 100 to 114.

            SkyrimSavegame savegame = new SkyrimSavegame(label);
            savegame.header = header;
            savegame.formVersion = formVersion;
            savegame.fileLocationTable = fileLocationTable;
            savegame.globalDataTable1 = globalDataTable1;
            //savegame.globalDataTable2 = globalDataTable2;

            foreach (var ms in savegame.GetMiscStats().OrderBy(p => p.category).ThenBy(n => n.name))
            {
                Print("stats", "cat({0}).{1} = {2}", ms.category, ms.name, ms.value);
            }

            return savegame;
        }