Esempio n. 1
0
        public static CollectionDb Read(string path)
        {
            var db = new CollectionDb();

            using (CustomReader r = new CustomReader(File.OpenRead(path))) {
                db.OsuVersion = r.ReadInt32();
                int amount = r.ReadInt32();

                for (int i = 0; i < amount; i++)
                {
                    var c = new Collection();
                    c.Md5Hashes = new List <string>();
                    c.Name      = r.ReadString();
                    int amount2 = r.ReadInt32();
                    for (int j = 0; j < amount2; j++)
                    {
                        c.Md5Hashes.Add(r.ReadString());
                    }

                    db.Collections.Add(c);
                }
            }

            return(db);
        }
Esempio n. 2
0
        public static Replay ReadFromReader(CustomReader r, bool readScoreId = false)
        {
            Replay replay = new Replay {
                GameMode    = (GameMode)r.ReadByte(),
                OsuVersion  = r.ReadInt32(),
                BeatmapHash = r.ReadString(),
                PlayerName  = r.ReadString(),
                ReplayHash  = r.ReadString(),

                Count300  = r.ReadUInt16(),
                Count100  = r.ReadUInt16(),
                Count50   = r.ReadUInt16(),
                CountGeki = r.ReadUInt16(),
                CountKatu = r.ReadUInt16(),
                CountMiss = r.ReadUInt16(),

                Score      = r.ReadInt32(),
                Combo      = r.ReadUInt16(),
                FullCombo  = r.ReadBoolean(),
                Mods       = (Mods)r.ReadInt32(),
                LifeGraph  = r.ReadString(),
                TimePlayed = r.ReadDateTime(),
                ReplayData = r.ReadBytes(),
                ScoreId    = readScoreId ? r.ReadInt64() : -1
            };

            return(replay);
        }
Esempio n. 3
0
        public static OsuDb Read(string path)
        {
            OsuDb db = new OsuDb();

            using (CustomReader r = new CustomReader(File.OpenRead(path)))
            {
                db.OsuVersion        = r.ReadInt32();
                db.FolderCount       = r.ReadInt32();
                db.AccountUnlocked   = r.ReadBoolean();
                db.AccountUnlockDate = r.ReadDateTime();
                db.AccountName       = 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  = r.ReadInt32();

                    var entry = BeatmapEntry.ReadFromReader(r, db.OsuVersion);
                    db.Beatmaps.Add(entry);
                    if (r.BaseStream.Position != currentIndex + entryLength + 4)
                    {
                        Debug.Fail(
                            $"Length doesn't match, {r.BaseStream.Position} instead of expected {currentIndex + entryLength + 4}");
                    }
                }
                db.AccountRank = (PlayerRank)r.ReadByte();
            }
            return(db);
        }
Esempio n. 4
0
        public static ScoresDb Read(string path)
        {
            var db = new ScoresDb();

            using (CustomReader r = new CustomReader(File.OpenRead(path)))
            {
                db.OsuVersion = r.ReadInt32();
                int amount = r.ReadInt32();

                for (int i = 0; i < amount; i++)
                {
                    string md5 = r.ReadString();

                    Tuple <string, List <Replay> > tuple = new Tuple <string, List <Replay> >(md5, new List <Replay>());

                    int amount2 = r.ReadInt32();
                    for (int j = 0; j < amount2; j++)
                    {
                        tuple.Item2.Add(Replay.ReadFromReader(r, true));
                    }

                    db.Beatmaps.Add(tuple.Item1, tuple.Item2);
                }
            }

            return(db);
        }
Esempio n. 5
0
        public DateTime Unknown1;         //TODO: name this. Last update time?

        public static Player ReadFromReader(CustomReader r)
        {
            Player p = new Player();

            p.PlayerId    = r.ReadInt32();
            p.PlayerName  = r.ReadString();
            p.UtcOffset   = r.ReadByte();
            p.CountryByte = r.ReadByte();   //TODO: turn into enum?

            byte b = r.ReadByte();

            p.PlayerRank = (PlayerRank)(b & -225);
            p.GameMode   = (GameMode)((b & 224) >> 5);
            Debug.Assert((byte)p.GameMode <= 3, $"GameMode is byte {(byte)p.GameMode}, should be between 0 and 3");

            p.Longitude  = r.ReadSingle();
            p.Latitude   = r.ReadSingle();
            p.GlobalRank = r.ReadInt32();
            p.Unknown1   = r.ReadDateTime();

            return(p);
        }
Esempio n. 6
0
        public static BeatmapEntry ReadFromReader(CustomReader r, int version = 20160729)
        {
            BeatmapEntry e = new BeatmapEntry();

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

            //Debug.WriteLine($"{e.Artist} - {e.Title} [{e.Difficulty}]");

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

            //Debug.WriteLine("Last modified: " + e.LastModifiedTime + ", ranked status is " + e.RankedStatus);

            if (version >= 20140609)
            {
                e.DiffAR = r.ReadSingle();
                e.DiffCS = r.ReadSingle();
                e.DiffHP = r.ReadSingle();
                e.DiffOD = r.ReadSingle();
            }
            else
            {
                e.DiffAR = r.ReadByte();
                e.DiffCS = r.ReadByte();
                e.DiffHP = r.ReadByte();
                e.DiffOD = r.ReadByte();
            }

            //Debug.WriteLine($"AR: {e.DiffAR} CS: {e.DiffCS} HP: {e.DiffHP} OD: {e.DiffOD}");

            e.SliderVelocity = r.ReadDouble();

            if (version >= 20140609)
            {
                e.DiffStarRatingStandard = r.ReadModsDoubleDictionary();
                e.DiffStarRatingTaiko    = r.ReadModsDoubleDictionary();
                e.DiffStarRatingCtB      = r.ReadModsDoubleDictionary();
                e.DiffStarRatingMania    = r.ReadModsDoubleDictionary();
            }

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

            e.TimingPoints = r.ReadTimingPointList();
            e.BeatmapId    = r.ReadInt32();
            e.BeatmapSetId = r.ReadInt32();
            e.ThreadId     = r.ReadInt32(); //no idea what this is

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

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

            //Debug.WriteLine("gamemode: " + e.GameMode);


            e.SongSource = r.ReadString();
            e.SongTags   = r.ReadString();

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

            //Debug.WriteLine("Last played: " + e.LastPlayed);

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



            //Debug.WriteLine("Last osu! repo check: " + e.LastCheckAgainstOsuRepo);

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



            //Debug.WriteLine("Mania scroll speed: " + e.ManiaScrollSpeed);
            //Debug.WriteLine("---");

            return(e);
        }