chore: add all avalilable fields to beatmap struct
This commit is contained in:
1 parent
bf4ce18671
commit
251bf8177c
1 file changed
+166
-52
+166
-52
@@ -1,7 +1,8 @@
|
|||||||
use std::io::{Cursor, Read};
|
use std::io::{Cursor, Read};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{Result, anyhow};
|
||||||
use byteorder::{LittleEndian, ReadBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub struct OsuReader {
|
pub struct OsuReader {
|
||||||
cursor: Cursor<Vec<u8>>,
|
cursor: Cursor<Vec<u8>>,
|
||||||
@@ -89,13 +90,66 @@ pub struct TimingPoint {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Beatmap {
|
pub struct Beatmap {
|
||||||
pub artist_name: Option<String>,
|
pub artist_name: Option<String>,
|
||||||
|
pub artist_unicode: Option<String>,
|
||||||
pub song_title: Option<String>,
|
pub song_title: Option<String>,
|
||||||
|
pub song_title_unicode: Option<String>,
|
||||||
|
pub creator: Option<String>,
|
||||||
pub difficulty: Option<String>,
|
pub difficulty: Option<String>,
|
||||||
|
pub audio: Option<String>,
|
||||||
pub md5: Option<String>,
|
pub md5: Option<String>,
|
||||||
|
pub osu_file_name: Option<String>,
|
||||||
|
|
||||||
|
pub ranked_status: u8,
|
||||||
|
pub hitcircles: i16,
|
||||||
|
pub slider_count: i16,
|
||||||
|
pub spinner_count: i16,
|
||||||
|
pub last_modification: i64,
|
||||||
|
|
||||||
|
pub approach_rate: f32,
|
||||||
|
pub circle_size: f32,
|
||||||
|
pub hp_drain: f32,
|
||||||
|
pub overall_difficulty: f32,
|
||||||
|
pub slider_velocity: f64,
|
||||||
|
|
||||||
|
pub difficulties: HashMap<i32, f64>,
|
||||||
|
|
||||||
|
pub drain_time: i32,
|
||||||
|
pub total_time: i32,
|
||||||
|
pub preview_offset: i32,
|
||||||
|
|
||||||
pub beatmap_id: i32,
|
pub beatmap_id: i32,
|
||||||
pub beatmapset_id: i32,
|
pub beatmapset_id: i32,
|
||||||
|
pub thread_id: i32,
|
||||||
|
|
||||||
|
pub grade_standard: u8,
|
||||||
|
pub grade_taiko: u8,
|
||||||
|
pub grade_catch: u8,
|
||||||
|
pub grade_mania: u8,
|
||||||
|
|
||||||
|
pub local_beatmap_offset: i16,
|
||||||
|
pub stack_leniency: f32,
|
||||||
|
|
||||||
pub mode: u8,
|
pub mode: u8,
|
||||||
|
pub song_source: Option<String>,
|
||||||
|
pub song_tags: Option<String>,
|
||||||
|
|
||||||
|
pub online_beatmap_offset: i16,
|
||||||
|
pub title_font: Option<String>,
|
||||||
|
|
||||||
|
pub unplayed: bool,
|
||||||
|
pub last_played: i64,
|
||||||
|
pub osz2: bool,
|
||||||
|
pub folder_name: Option<String>,
|
||||||
|
pub last_checked_against_repository: i64,
|
||||||
|
|
||||||
|
pub ignore_sound: bool,
|
||||||
|
pub ignore_skin: bool,
|
||||||
|
pub disable_storyboard: bool,
|
||||||
|
pub disable_video: bool,
|
||||||
|
pub visual_override: bool,
|
||||||
|
|
||||||
|
pub last_modification_time: i32,
|
||||||
|
pub mania_scroll_speed: u8,
|
||||||
|
|
||||||
pub timing_points: Vec<TimingPoint>,
|
pub timing_points: Vec<TimingPoint>,
|
||||||
}
|
}
|
||||||
@@ -135,52 +189,70 @@ pub fn parse_osudb(bytes: Vec<u8>) -> Result<OsuDbData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let artist_name = reader.read_string()?;
|
let artist_name = reader.read_string()?;
|
||||||
reader.read_string()?; // artist unicode
|
let artist_unicode = reader.read_string()?;
|
||||||
let song_title = reader.read_string()?;
|
let song_title = reader.read_string()?;
|
||||||
reader.read_string()?; // title unicode
|
let song_title_unicode = reader.read_string()?;
|
||||||
reader.read_string()?; // creator
|
let creator = reader.read_string()?;
|
||||||
let difficulty = reader.read_string()?;
|
let difficulty = reader.read_string()?;
|
||||||
reader.read_string()?; // audio
|
let audio = reader.read_string()?;
|
||||||
let md5 = reader.read_string()?;
|
let md5 = reader.read_string()?;
|
||||||
reader.read_string()?; // osu file name
|
let osu_file_name = reader.read_string()?;
|
||||||
|
|
||||||
reader.read_u8()?; // ranked
|
let ranked_status = reader.read_u8()?;
|
||||||
reader.read_i16()?;
|
let hitcircles = reader.read_i16()?;
|
||||||
reader.read_i16()?;
|
let slider_count = reader.read_i16()?;
|
||||||
reader.read_i16()?;
|
let spinner_count = reader.read_i16()?;
|
||||||
reader.read_i64()?; // last modification
|
let last_modification = reader.read_i64()?;
|
||||||
|
|
||||||
if osuver < 20140609 {
|
let approach_rate = if osuver < 20140609 {
|
||||||
reader.read_u8()?;
|
reader.read_u8()? as f32
|
||||||
reader.read_u8()?;
|
|
||||||
reader.read_u8()?;
|
|
||||||
reader.read_u8()?;
|
|
||||||
} else {
|
} else {
|
||||||
reader.read_f32()?;
|
reader.read_f32()?
|
||||||
reader.read_f32()?;
|
};
|
||||||
reader.read_f32()?;
|
|
||||||
reader.read_f32()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.read_f64()?; // slider velocity
|
let circle_size = if osuver < 20140609 {
|
||||||
|
reader.read_u8()? as f32
|
||||||
|
} else {
|
||||||
|
reader.read_f32()?
|
||||||
|
};
|
||||||
|
|
||||||
|
let hp_drain = if osuver < 20140609 {
|
||||||
|
reader.read_u8()? as f32
|
||||||
|
} else {
|
||||||
|
reader.read_f32()?
|
||||||
|
};
|
||||||
|
|
||||||
|
let overall_difficulty = if osuver < 20140609 {
|
||||||
|
reader.read_u8()? as f32
|
||||||
|
} else {
|
||||||
|
reader.read_f32()?
|
||||||
|
};
|
||||||
|
|
||||||
|
let slider_velocity = reader.read_f64()?;
|
||||||
|
|
||||||
|
let mut difficulties: HashMap<i32, f64> = HashMap::new();
|
||||||
|
|
||||||
|
if osuver >= 20140609 {
|
||||||
for _ in 0..4 {
|
for _ in 0..4 {
|
||||||
let len = reader.read_i32()?;
|
let len = reader.read_i32()?;
|
||||||
for _ in 0..len {
|
for _ in 0..len {
|
||||||
reader.read_u8()?;
|
reader.read_u8()?;
|
||||||
reader.read_i32()?;
|
let mode = reader.read_i32()?;
|
||||||
reader.read_u8()?;
|
reader.read_u8()?;
|
||||||
if osuver > 20250107 {
|
let diff = if osuver > 20250107 {
|
||||||
reader.read_f32()?;
|
reader.read_f32()? as f64
|
||||||
} else {
|
} else {
|
||||||
reader.read_f64()?;
|
reader.read_f64()?
|
||||||
|
};
|
||||||
|
|
||||||
|
difficulties.insert(mode, diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.read_i32()?; // drain
|
let drain_time = reader.read_i32()?;
|
||||||
reader.read_i32()?; // total
|
let total_time = reader.read_i32()?;
|
||||||
reader.read_i32()?; // preview
|
let preview_offset = reader.read_i32()?;
|
||||||
|
|
||||||
let timing_len = reader.read_i32()?;
|
let timing_len = reader.read_i32()?;
|
||||||
let mut timing_points = Vec::new();
|
let mut timing_points = Vec::new();
|
||||||
@@ -194,50 +266,92 @@ pub fn parse_osudb(bytes: Vec<u8>) -> Result<OsuDbData> {
|
|||||||
|
|
||||||
let beatmap_id = reader.read_i32()?;
|
let beatmap_id = reader.read_i32()?;
|
||||||
let beatmapset_id = reader.read_i32()?;
|
let beatmapset_id = reader.read_i32()?;
|
||||||
reader.read_i32()?; // thread id
|
let thread_id = reader.read_i32()?;
|
||||||
|
|
||||||
reader.read_u8()?;
|
let grade_standard = reader.read_u8()?;
|
||||||
reader.read_u8()?;
|
let grade_taiko = reader.read_u8()?;
|
||||||
reader.read_u8()?;
|
let grade_catch = reader.read_u8()?;
|
||||||
reader.read_u8()?;
|
let grade_mania = reader.read_u8()?;
|
||||||
|
|
||||||
reader.read_i16()?;
|
let local_beatmap_offset = reader.read_i16()?;
|
||||||
reader.read_f32()?;
|
let stack_leniency = reader.read_f32()?;
|
||||||
|
|
||||||
let mode = reader.read_u8()?;
|
let mode = reader.read_u8()?;
|
||||||
reader.read_string()?;
|
let song_source = reader.read_string()?;
|
||||||
reader.read_string()?;
|
let song_tags = reader.read_string()?;
|
||||||
|
|
||||||
reader.read_i16()?;
|
let online_beatmap_offset = reader.read_i16()?;
|
||||||
reader.read_string()?;
|
let title_font = reader.read_string()?;
|
||||||
|
|
||||||
reader.read_bool()?;
|
let unplayed = reader.read_bool()?;
|
||||||
reader.read_i64()?;
|
let last_played = reader.read_i64()?;
|
||||||
reader.read_bool()?;
|
let osz2 = reader.read_bool()?;
|
||||||
reader.read_string()?;
|
let folder_name = reader.read_string()?;
|
||||||
reader.read_i64()?;
|
let last_checked_against_repository = reader.read_i64()?;
|
||||||
|
|
||||||
reader.read_bool()?;
|
let ignore_sound = reader.read_bool()?;
|
||||||
reader.read_bool()?;
|
let ignore_skin = reader.read_bool()?;
|
||||||
reader.read_bool()?;
|
let disable_storyboard = reader.read_bool()?;
|
||||||
reader.read_bool()?;
|
let disable_video = reader.read_bool()?;
|
||||||
reader.read_bool()?;
|
let visual_override = reader.read_bool()?;
|
||||||
|
|
||||||
if osuver < 20140609 {
|
if osuver < 20140609 {
|
||||||
reader.read_i16()?;
|
reader.read_i16()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.read_i32()?;
|
let last_modification_time = reader.read_i32()?;
|
||||||
reader.read_u8()?;
|
let mania_scroll_speed = reader.read_u8()?;
|
||||||
|
|
||||||
beatmaps.push(Beatmap {
|
beatmaps.push(Beatmap {
|
||||||
artist_name,
|
artist_name,
|
||||||
|
artist_unicode,
|
||||||
song_title,
|
song_title,
|
||||||
|
song_title_unicode,
|
||||||
|
creator,
|
||||||
difficulty,
|
difficulty,
|
||||||
|
audio,
|
||||||
md5,
|
md5,
|
||||||
|
osu_file_name,
|
||||||
|
ranked_status,
|
||||||
|
hitcircles,
|
||||||
|
slider_count,
|
||||||
|
spinner_count,
|
||||||
|
last_modification,
|
||||||
|
approach_rate,
|
||||||
|
circle_size,
|
||||||
|
hp_drain,
|
||||||
|
overall_difficulty,
|
||||||
|
slider_velocity,
|
||||||
|
difficulties,
|
||||||
|
drain_time,
|
||||||
|
total_time,
|
||||||
|
preview_offset,
|
||||||
beatmap_id,
|
beatmap_id,
|
||||||
beatmapset_id,
|
beatmapset_id,
|
||||||
|
thread_id,
|
||||||
|
grade_standard,
|
||||||
|
grade_taiko,
|
||||||
|
grade_catch,
|
||||||
|
grade_mania,
|
||||||
|
local_beatmap_offset,
|
||||||
|
stack_leniency,
|
||||||
mode,
|
mode,
|
||||||
|
song_source,
|
||||||
|
song_tags,
|
||||||
|
online_beatmap_offset,
|
||||||
|
title_font,
|
||||||
|
unplayed,
|
||||||
|
last_played,
|
||||||
|
osz2,
|
||||||
|
folder_name,
|
||||||
|
last_checked_against_repository,
|
||||||
|
ignore_sound,
|
||||||
|
ignore_skin,
|
||||||
|
disable_storyboard,
|
||||||
|
disable_video,
|
||||||
|
visual_override,
|
||||||
|
last_modification_time,
|
||||||
|
mania_scroll_speed,
|
||||||
timing_points,
|
timing_points,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user