public beatmapInfo findByHash(string hash) { foreach (beatmapInfo beatmap in beatmaps) { if (hash == beatmap.beatmapHash) { return(beatmap); } } beatmapInfo fakeoutput = new beatmapInfo(); fakeoutput.songTitle = "Not found"; return(fakeoutput); }
int loadReplays(string directory) { toolStripStatusLabel1.Text = "Loading osu! Replay files..."; var watch = System.Diagnostics.Stopwatch.StartNew(); string[] files = GetFiles(directory, "*.osr").ToArray <string>(); foreach (string file in files) { using (BinaryReader b = new BinaryReader(File.Open(file, FileMode.Open))) { int gamemode = b.ReadByte(); // (byte) game mode int gameversion = b.ReadInt32(); // (int) game version b.ReadByte(); // useless byte string songmd5 = b.ReadString(); // (string) song md5 hash b.ReadByte(); // useless byte string player = b.ReadString(); // (string) username b.ReadByte(); // useless byte b.ReadString(); // replay hash (useless) short s300 = b.ReadInt16(); // (short) amount of 300s short s100 = b.ReadInt16(); // (short) amount of 100s short s50 = b.ReadInt16(); // (short) amount of 50s short sGeki = b.ReadInt16(); // (short) amount of Gekis (special 300s) short sKatu = b.ReadInt16(); // (short) amount of Katus (special 100s) short misses = b.ReadInt16(); // (short) amount of misses int score = b.ReadInt32(); // (int) score short combo = b.ReadInt16(); // (short) combo byte fc = b.ReadByte(); // (byte) full combo (0=no,1=yes) int mods = b.ReadInt32(); // (int) mods b.Close(); beatmapInfo beatmap = database.findByHash(songmd5); string date = File.GetCreationTime(file).ToString("yyyy-MM-dd HH:mm:ss"); float accuracy = (float)(s50 * 50 + s100 * 100 + s300 * 300) / ((float)(misses + s50 + s100 + s300) * 300) * 100; string accuracyText = accuracy.ToString("N2") + "%"; dataGridView1.Rows.Add(new object[] { file, date, player, beatmap.songTitle, beatmap.artist, beatmap.difficultyName, OsuMods.ToString(mods), accuracyText, score, combo, s300, sGeki, s100, sKatu, s50, misses, beatmap.creator }); dataGridView1.Sort(Timestamp, ListSortDirection.Descending); } } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; toolStripStatusLabel1.Text = "Loaded " + files.Count() + " replays in " + elapsedMs + "ms!"; return(files.Count()); }
public osuDatabase(string filename) { using (BinaryReader b = new BinaryReader(File.Open(filename, FileMode.Open))) { osuVersion = b.ReadInt32(); folderCount = b.ReadInt32(); accountUnlocked = b.ReadBoolean(); b.ReadBytes(9); // Read past unlock DateTime playerName = b.ReadString(); numberOfBeatmaps = b.ReadInt32(); beatmaps = new List <beatmapInfo>(); for (int i = 0; i < numberOfBeatmaps; i++) { beatmapInfo beatmap = new beatmapInfo(); beatmap.size = b.ReadInt32(); if (b.ReadByte() == 0x0B) { beatmap.artist = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.artistUnicode = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.songTitle = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.songTitleUnicode = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.creator = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.difficultyName = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.audioFile = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.beatmapHash = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.osuFile = b.ReadString(); } beatmap.rankedStatus = b.ReadByte(); beatmap.hitCircles = b.ReadInt16(); beatmap.sliders = b.ReadInt16(); beatmap.spinners = b.ReadInt16(); beatmap.modificationTime = b.ReadInt64(); beatmap.approachRate = b.ReadSingle(); beatmap.circleSize = b.ReadSingle(); beatmap.hpDrain = b.ReadSingle(); beatmap.difficultyScore = b.ReadSingle(); beatmap.sliderVelocity = b.ReadDouble(); int amountOfPairs = b.ReadInt32(); beatmap.starRatingStandard = new List <IntDouble>(); for (int j = 0; j < amountOfPairs; j++) { IntDouble pair = new IntDouble(b.ReadBytes(14)); beatmap.starRatingStandard.Add(pair); } amountOfPairs = b.ReadInt32(); beatmap.starRatingTaiko = new List <IntDouble>(); for (int j = 0; j < amountOfPairs; j++) { IntDouble pair = new IntDouble(b.ReadBytes(14)); beatmap.starRatingTaiko.Add(pair); } amountOfPairs = b.ReadInt32(); beatmap.starRatingCTB = new List <IntDouble>(); for (int j = 0; j < amountOfPairs; j++) { IntDouble pair = new IntDouble(b.ReadBytes(14)); beatmap.starRatingCTB.Add(pair); } amountOfPairs = b.ReadInt32(); beatmap.starRatingMania = new List <IntDouble>(); for (int j = 0; j < amountOfPairs; j++) { IntDouble pair = new IntDouble(b.ReadBytes(14)); beatmap.starRatingMania.Add(pair); } beatmap.drainTime = b.ReadInt32(); beatmap.totalTime = b.ReadInt32(); beatmap.previewTime = b.ReadInt32(); beatmap.timingPoints = new List <TimingPoint>(); int amountOfTimingPoints = b.ReadInt32(); for (int j = 0; j < amountOfTimingPoints; j++) { TimingPoint timingPoint = new TimingPoint(b.ReadBytes(17)); beatmap.timingPoints.Add(timingPoint); } beatmap.id = b.ReadInt32(); beatmap.setId = b.ReadInt32(); beatmap.threadId = b.ReadInt32(); beatmap.gradeStandard = b.ReadByte(); beatmap.gradeTaiko = b.ReadByte(); beatmap.gradeCTB = b.ReadByte(); beatmap.gradeMania = b.ReadByte(); beatmap.localOffset = b.ReadInt16(); beatmap.stackLeniency = b.ReadSingle(); beatmap.gameMode = b.ReadByte(); if (b.ReadByte() == 0x0B) { beatmap.source = b.ReadString(); } if (b.ReadByte() == 0x0B) { beatmap.tags = b.ReadString(); } beatmap.onlineOffset = b.ReadInt16(); if (b.ReadByte() == 0x0B) { beatmap.font = b.ReadString(); } beatmap.unplayed = b.ReadBoolean(); beatmap.lastPlayed = b.ReadInt64(); beatmap.osz2 = b.ReadBoolean(); if (b.ReadByte() == 0x0B) { beatmap.folder = b.ReadString(); } beatmap.repoTime = b.ReadInt64(); beatmap.ignoreSounds = b.ReadBoolean(); beatmap.ignoreSkin = b.ReadBoolean(); beatmap.disableStoryboard = b.ReadBoolean(); beatmap.disableVideo = b.ReadBoolean(); beatmap.visualOverride = b.ReadBoolean(); beatmap.lastModificationTime = b.ReadInt32(); beatmap.maniaScrollSpeed = b.ReadByte(); beatmaps.Add(beatmap); } validatorByte = b.ReadByte(); b.Close(); } }