Example #1
0
 public override void Deserialize(SerializationReader reader)
 {
     coderack = (Coderack)reader.ReadPointer(); // coderack = CType(info.GetValue("coderack", GetType(Coderack)), Coderack)
     salience = reader.ReadDouble();            // salience = info.GetDouble("salience")
     space    = reader.ReadInt32();             // space = info.GetInt32("space")
     time     = reader.ReadInt32();             // time = info.GetInt32("time")
     reader.ReadDictionary(children);           // children = CType(info.GetValue("children", GetType(Dictionary(Of String, Codelet))), Dictionary(Of String, Codelet))
     watched = reader.ReadBoolean();            // watched = info.GetBoolean("watched")
     immune  = reader.ReadBoolean();            // immune = info.GetBoolean("immune")
 }
Example #2
0
        /// <summary>
        /// Parses osu!.db file.
        /// </summary>
        /// <param name="stream">Stream containing osu!.db data.</param>
        /// <returns>A usable <see cref="OsuDatabase"/>.</returns>
        public static OsuDatabase DecodeOsu(Stream stream)
        {
            OsuDatabase db = new OsuDatabase();

            using (var r = new SerializationReader(stream))
            {
                db.OsuVersion      = r.ReadInt32();
                db.FolderCount     = r.ReadInt32();
                db.AccountUnlocked = r.ReadBoolean();
                db.UnlockDate      = r.ReadDateTime();
                db.PlayerName      = r.ReadString();
                int beatmapCount = r.ReadInt32();
                db.BeatmapCount = beatmapCount;

                for (int i = 0; i < beatmapCount; i++)
                {
                    DbBeatmap beatmap = new DbBeatmap();

                    if (db.OsuVersion < 20191106)
                    {
                        beatmap.BytesOfBeatmapEntry = r.ReadInt32();
                    }

                    beatmap.Artist            = r.ReadString();
                    beatmap.ArtistUnicode     = r.ReadString();
                    beatmap.Title             = r.ReadString();
                    beatmap.TitleUnicode      = r.ReadString();
                    beatmap.Creator           = r.ReadString();
                    beatmap.Difficulty        = r.ReadString();
                    beatmap.AudioFileName     = r.ReadString();
                    beatmap.MD5Hash           = r.ReadString();
                    beatmap.FileName          = r.ReadString();
                    beatmap.RankedStatus      = (RankedStatus)r.ReadByte();
                    beatmap.CirclesCount      = r.ReadUInt16();
                    beatmap.SlidersCount      = r.ReadUInt16();
                    beatmap.SpinnersCount     = r.ReadUInt16();
                    beatmap.LastModifiedTime  = r.ReadDateTime();
                    beatmap.ApproachRate      = db.OsuVersion >= 20140609 ? r.ReadSingle() : r.ReadByte();
                    beatmap.CircleSize        = db.OsuVersion >= 20140609 ? r.ReadSingle() : r.ReadByte();
                    beatmap.HPDrain           = db.OsuVersion >= 20140609 ? r.ReadSingle() : r.ReadByte();
                    beatmap.OverallDifficulty = db.OsuVersion >= 20140609 ? r.ReadSingle() : r.ReadByte();
                    beatmap.SliderVelocity    = r.ReadDouble();

                    if (db.OsuVersion >= 20140609)
                    {
                        beatmap.StandardStarRating = r.ReadDictionary <Mods, double>();
                        beatmap.TaikoStarRating    = r.ReadDictionary <Mods, double>();
                        beatmap.CatchStarRating    = r.ReadDictionary <Mods, double>();
                        beatmap.ManiaStarRating    = r.ReadDictionary <Mods, double>();
                    }

                    beatmap.DrainTime        = r.ReadInt32();
                    beatmap.TotalTime        = r.ReadInt32();
                    beatmap.AudioPreviewTime = r.ReadInt32();

                    int timingPointsCount = r.ReadInt32();
                    for (int j = 0; j < timingPointsCount; j++)
                    {
                        DbTimingPoint timingPoint = new DbTimingPoint();
                        timingPoint.BPM       = r.ReadDouble();
                        timingPoint.Offset    = r.ReadDouble();
                        timingPoint.Inherited = r.ReadBoolean();
                        beatmap.TimingPoints.Add(timingPoint);
                    }

                    beatmap.BeatmapId                 = r.ReadInt32();
                    beatmap.BeatmapSetId              = r.ReadInt32();
                    beatmap.ThreadId                  = r.ReadInt32();
                    beatmap.StandardGrade             = (Grade)r.ReadByte();
                    beatmap.TaikoGrade                = (Grade)r.ReadByte();
                    beatmap.CatchGrade                = (Grade)r.ReadByte();
                    beatmap.ManiaGrade                = (Grade)r.ReadByte();
                    beatmap.LocalOffset               = r.ReadInt16();
                    beatmap.StackLeniency             = r.ReadSingle();
                    beatmap.Ruleset                   = (Ruleset)r.ReadByte();
                    beatmap.Source                    = r.ReadString();
                    beatmap.Tags                      = r.ReadString();
                    beatmap.OnlineOffset              = r.ReadInt16();
                    beatmap.TitleFont                 = r.ReadString();
                    beatmap.IsUnplayed                = r.ReadBoolean();
                    beatmap.LastPlayed                = r.ReadDateTime();
                    beatmap.IsOsz2                    = r.ReadBoolean();
                    beatmap.FolderName                = r.ReadString();
                    beatmap.LastCheckedAgainstOsuRepo = r.ReadDateTime();
                    beatmap.IgnoreBeatmapSound        = r.ReadBoolean();
                    beatmap.IgnoreBeatmapSkin         = r.ReadBoolean();
                    beatmap.DisableStoryboard         = r.ReadBoolean();
                    beatmap.DisableVideo              = r.ReadBoolean();
                    beatmap.VisualOverride            = r.ReadBoolean();
                    if (db.OsuVersion < 20140609)
                    {
                        r.BaseStream.Seek(sizeof(short), SeekOrigin.Current); //let's skip this unknown variable
                    }
                    r.BaseStream.Seek(sizeof(int), SeekOrigin.Current);       //and this one
                    beatmap.ManiaScrollSpeed = r.ReadByte();

                    db.Beatmaps.Add(beatmap);
                }

                db.Permissions = (Permissions)r.ReadInt32();
            }

            return(db);
        }
Example #3
0
        public void ReadFromStream(SerializationReader r)
        {
            Artist = r.ReadString();
            if (_version >= OsuVersions.FirstOsz2)
            {
                ArtistUnicode = r.ReadString();
            }
            Title = r.ReadString();
            if (_version >= OsuVersions.FirstOsz2)
            {
                TitleUnicode = r.ReadString();
            }
            Creator         = r.ReadString();
            Version         = r.ReadString();
            AudioFileName   = r.ReadString();
            BeatmapChecksum = r.ReadString();   //always 32 in length, so the 2 preceding bytes in the file are practically wasting space
            BeatmapFileName = r.ReadString();

            RankedStatus     = (SubmissionStatus)r.ReadByte();
            CountHitCircles  = r.ReadUInt16();
            CountSliders     = r.ReadUInt16();
            CountSpinners    = r.ReadUInt16();
            LastModifiedTime = r.ReadDateTime();

            if (_version >= OsuVersions.FloatDifficultyValues)
            {
                ApproachRate     = r.ReadSingle();
                CircleSize       = r.ReadSingle();
                HPDrainRate      = r.ReadSingle();
                OveralDifficulty = r.ReadSingle();
            }
            else
            {
                ApproachRate     = r.ReadByte();
                CircleSize       = r.ReadByte();
                HPDrainRate      = r.ReadByte();
                OveralDifficulty = r.ReadByte();
            }

            SliderVelocity = r.ReadDouble();

            if (_version >= OsuVersions.FloatDifficultyValues)
            {
                DiffStarRatingStandard = r.ReadDictionary <Mods, double>();
                DiffStarRatingTaiko    = r.ReadDictionary <Mods, double>();
                DiffStarRatingCtB      = r.ReadDictionary <Mods, double>();
                DiffStarRatingMania    = r.ReadDictionary <Mods, double>();

                // TODO: there may be different reading behavior for versions before 20190204, 20200916, 20200504 and 20191024 here.
            }

            DrainTimeSeconds = r.ReadInt32();
            TotalTime        = r.ReadInt32();
            AudioPreviewTime = r.ReadInt32();

            TimingPoints = r.ReadSerializableList <TimingPoint>();
            BeatmapId    = r.ReadInt32();
            BeatmapSetId = r.ReadInt32();
            ThreadId     = r.ReadInt32();

            GradeStandard = (Ranking)r.ReadByte();
            GradeTaiko    = (Ranking)r.ReadByte();
            GradeCtB      = (Ranking)r.ReadByte();
            GradeMania    = (Ranking)r.ReadByte();

            OffsetLocal   = r.ReadInt16();
            StackLeniency = r.ReadSingle();
            GameMode      = (GameMode)r.ReadByte();

            SongSource   = r.ReadString();
            SongTags     = r.ReadString();
            OffsetOnline = r.ReadInt16();
            TitleFont    = r.ReadString();
            Unplayed     = r.ReadBoolean();
            LastPlayed   = r.ReadDateTime();

            IsOsz2     = r.ReadBoolean();
            FolderName = r.ReadString();
            LastCheckAgainstOsuRepo = r.ReadDateTime();

            IgnoreBeatmapSounds = r.ReadBoolean();
            IgnoreBeatmapSkin   = r.ReadBoolean();
            DisableStoryBoard   = r.ReadBoolean();
            DisableVideo        = r.ReadBoolean();
            VisualOverride      = r.ReadBoolean();
            if (_version < OsuVersions.FloatDifficultyValues)
            {
                OldUnknown1 = r.ReadInt16();
            }
            LastEditTime     = r.ReadInt32();
            ManiaScrollSpeed = r.ReadByte();
        }
        public void ReadFromStream(SerializationReader r)
        {
            int length = 0;

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

            Artist          = r.ReadString();
            ArtistUnicode   = r.ReadString();
            Title           = r.ReadString();
            TitleUnicode    = r.ReadString();
            Creator         = r.ReadString();
            Version         = r.ReadString();
            AudioFileName   = r.ReadString();
            BeatmapChecksum = r.ReadString();   //always 32 in length, so the 2 preceding bytes in the file are practically wasting space
            BeatmapFileName = r.ReadString();

            RankedStatus     = (SubmissionStatus)r.ReadByte();
            CountHitCircles  = r.ReadUInt16();
            CountSliders     = r.ReadUInt16();
            CountSpinners    = r.ReadUInt16();
            LastModifiedTime = r.ReadDateTime();

            if (_version >= 20140609)
            {
                ApproachRate     = r.ReadSingle();
                CircleSize       = r.ReadSingle();
                HPDrainRate      = r.ReadSingle();
                OveralDifficulty = r.ReadSingle();
            }
            else
            {
                ApproachRate     = r.ReadByte();
                CircleSize       = r.ReadByte();
                HPDrainRate      = r.ReadByte();
                OveralDifficulty = r.ReadByte();
            }

            SliderVelocity = r.ReadDouble();

            if (_version >= 20140609)
            {
                DiffStarRatingStandard = r.ReadDictionary <Mods, double>();
                DiffStarRatingTaiko    = r.ReadDictionary <Mods, double>();
                DiffStarRatingCtB      = r.ReadDictionary <Mods, double>();
                DiffStarRatingMania    = r.ReadDictionary <Mods, double>();
            }

            DrainTimeSeconds = r.ReadInt32();
            TotalTime        = r.ReadInt32();
            AudioPreviewTime = r.ReadInt32();

            TimingPoints = r.ReadSerializableList <TimingPoint>();
            BeatmapId    = r.ReadInt32();
            BeatmapSetId = r.ReadInt32();
            ThreadId     = r.ReadInt32();

            GradeStandard = (Ranking)r.ReadByte();
            GradeTaiko    = (Ranking)r.ReadByte();
            GradeCtB      = (Ranking)r.ReadByte();
            GradeMania    = (Ranking)r.ReadByte();

            OffsetLocal   = r.ReadInt16();
            StackLeniency = r.ReadSingle();
            GameMode      = (GameMode)r.ReadByte();

            SongSource   = r.ReadString();
            SongTags     = r.ReadString();
            OffsetOnline = r.ReadInt16();
            TitleFont    = r.ReadString();
            Unplayed     = r.ReadBoolean();
            LastPlayed   = r.ReadDateTime();

            IsOsz2     = r.ReadBoolean();
            FolderName = r.ReadString();
            LastCheckAgainstOsuRepo = r.ReadDateTime();

            IgnoreBeatmapSounds = r.ReadBoolean();
            IgnoreBeatmapSkin   = r.ReadBoolean();
            DisableStoryBoard   = r.ReadBoolean();
            DisableVideo        = r.ReadBoolean();
            VisualOverride      = r.ReadBoolean();
            if (_version < 20140609)
            {
                OldUnknown1 = r.ReadInt16();
            }
            Unknown2         = r.ReadInt32();
            ManiaScrollSpeed = r.ReadByte();

            Debug.Assert(!_readLength || length == r.BaseStream.Position - startPosition); //could throw error here
        }
Example #5
0
 public override void Deserialize(SerializationReader reader)
 {
     coderack = (Coderack) reader.ReadPointer();    // coderack = CType(info.GetValue("coderack", GetType(Coderack)), Coderack)
     salience = reader.ReadDouble();  // salience = info.GetDouble("salience")
     space = reader.ReadInt32();  // space = info.GetInt32("space")
     time = reader.ReadInt32();   // time = info.GetInt32("time")
     reader.ReadDictionary(children); // children = CType(info.GetValue("children", GetType(Dictionary(Of String, Codelet))), Dictionary(Of String, Codelet))
     watched = reader.ReadBoolean();  // watched = info.GetBoolean("watched")
     immune = reader.ReadBoolean();   // immune = info.GetBoolean("immune")
 }