Exemple #1
0
        static OsuDb ReadDb(string path)
        {
            OsuDb db = new OsuDb();

            using (var r = new SerializationReader(File.OpenRead(path)))
            {
                db.OsuVersion = r.ReadInt32();
                r.ReadInt32();
                r.ReadBoolean();
                r.ReadDateTime();
                r.ReadString();
                db.Beatmaps = new List <BeatmapEntry>();
                int length = r.ReadInt32();
                for (int i = 0; i < length; i++)
                {
                    int       currentIndex     = (int)r.BaseStream.Position;
                    int       entryLength      = 0;
                    const int lengthOsuVersion = 20191107;
                    if (db.OsuVersion < lengthOsuVersion)
                    {
                        entryLength = r.ReadInt32();
                    }
                    db.Beatmaps.Add(ReadFromReader(r, false, db.OsuVersion));
                    if (db.OsuVersion < lengthOsuVersion && r.BaseStream.Position != currentIndex + entryLength + 4)
                    {
                        Debug.Fail($"Length doesn't match, {r.BaseStream.Position} instead of expected {currentIndex + entryLength + 4}");
                    }
                }
                r.ReadByte();
            }
            return(db);
        }
Exemple #2
0
        public static BeatmapEntry ReadFromReader(SerializationReader r, bool readLength = true, int version = 20160729)
        {
            BeatmapEntry e = new BeatmapEntry();

            int length = 0;

            if (readLength)
            {
                length = r.ReadInt32();
            }
            int startPosition = (int)r.BaseStream.Position;

            r.ReadString();
            r.ReadString();
            r.ReadString();
            r.ReadString();
            r.ReadString();
            r.ReadString();
            r.ReadString();
            e.BeatmapChecksum = r.ReadString();
            e.BeatmapFileName = r.ReadString();
            r.ReadByte();
            r.ReadUInt16();
            r.ReadUInt16();
            r.ReadUInt16();
            r.ReadDateTime();
            if (version >= 20140609)
            {
                r.ReadSingle();
                r.ReadSingle();
                r.ReadSingle();
                r.ReadSingle();
            }
            else
            {
                r.ReadByte();
                r.ReadByte();
                r.ReadByte();
                r.ReadByte();
            }

            r.ReadDouble();

            if (version >= 20140609)
            {
                r.ReadDictionary <Mods, double>();
                r.ReadDictionary <Mods, double>();
                r.ReadDictionary <Mods, double>();
                r.ReadDictionary <Mods, double>();
            }
            r.ReadInt32();
            r.ReadInt32();
            r.ReadInt32();
            r.ReadSerializableList <TimingPoint>();
            r.ReadInt32();
            r.ReadInt32();
            r.ReadInt32();
            r.ReadByte();
            r.ReadByte();
            r.ReadByte();
            r.ReadByte();
            r.ReadInt16();
            r.ReadSingle();
            r.ReadByte();
            r.ReadString();
            r.ReadString();
            r.ReadInt16();
            r.ReadString();
            r.ReadBoolean();
            r.ReadDateTime();
            r.ReadBoolean();
            e.FolderName = r.ReadString();
            r.ReadDateTime();
            r.ReadBoolean();
            r.ReadBoolean();
            r.ReadBoolean();
            r.ReadBoolean();
            r.ReadBoolean();
            if (version < 20140609)
            {
                r.ReadInt16();
            }
            r.ReadInt32();
            r.ReadByte();

            int endPosition = (int)r.BaseStream.Position;

            Debug.Assert(!readLength || length == endPosition - startPosition);

            return(e);
        }
Exemple #3
0
 public void ReadFromStream(SerializationReader r)
 {
     MsPerQuarter = r.ReadDouble();
     Time         = r.ReadDouble();
     TimingChange = r.ReadBoolean();
 }