Remove U3 type for osu beatmap
It did not do any checking and looked weird. What *is* the right way to ensure the value only has 3 bytes while still allowing the user to pass a normal primitive or newtype wrapper around a primitive (and not e.g. a [bool; 3])?
This commit is contained in:
parent
95f4a4c60c
commit
0ad0d503a2
|
@ -14,7 +14,7 @@ pub type SampleIndex = u16;
|
||||||
|
|
||||||
pub type Time = u32;
|
pub type Time = u32;
|
||||||
|
|
||||||
fn assemble_hit_object_type(hit_object_type: u8, new_combo: bool, skip_combo_colours: U3) -> u8 {
|
fn assemble_hit_object_type(hit_object_type: u8, new_combo: bool, skip_combo_colours: u8) -> u8 {
|
||||||
let hit_object_type = 1u8 << hit_object_type;
|
let hit_object_type = 1u8 << hit_object_type;
|
||||||
let new_combo = if new_combo { 0b0000_0010_u8 } else { 0u8 };
|
let new_combo = if new_combo { 0b0000_0010_u8 } else { 0u8 };
|
||||||
let skip_combo_colours = (skip_combo_colours & 0b_0000_0111u8) << 1;
|
let skip_combo_colours = (skip_combo_colours & 0b_0000_0111u8) << 1;
|
||||||
|
@ -384,9 +384,6 @@ impl fmt::Display for HitSample {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Three bit integer
|
|
||||||
pub type U3 = u8;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum HitObject {
|
pub enum HitObject {
|
||||||
HitCircle {
|
HitCircle {
|
||||||
|
@ -395,7 +392,7 @@ pub enum HitObject {
|
||||||
time: Time,
|
time: Time,
|
||||||
hit_sound: HitSound,
|
hit_sound: HitSound,
|
||||||
new_combo: bool,
|
new_combo: bool,
|
||||||
skip_combo_colours: U3,
|
skip_combo_colours: u8,
|
||||||
hit_sample: HitSample,
|
hit_sample: HitSample,
|
||||||
},
|
},
|
||||||
Slider {
|
Slider {
|
||||||
|
@ -404,7 +401,7 @@ pub enum HitObject {
|
||||||
time: Time,
|
time: Time,
|
||||||
hit_sound: HitSound,
|
hit_sound: HitSound,
|
||||||
new_combo: bool,
|
new_combo: bool,
|
||||||
skip_combo_colours: U3,
|
skip_combo_colours: u8,
|
||||||
curve_type: char,
|
curve_type: char,
|
||||||
curve_points: Vec<(DecimalOsuPixel, DecimalOsuPixel)>,
|
curve_points: Vec<(DecimalOsuPixel, DecimalOsuPixel)>,
|
||||||
slides: u8,
|
slides: u8,
|
||||||
|
@ -417,7 +414,7 @@ pub enum HitObject {
|
||||||
time: Time,
|
time: Time,
|
||||||
hit_sound: HitSound,
|
hit_sound: HitSound,
|
||||||
new_combo: bool,
|
new_combo: bool,
|
||||||
skip_combo_colours: U3,
|
skip_combo_colours: u8,
|
||||||
end_time: Time,
|
end_time: Time,
|
||||||
hit_sample: HitSample,
|
hit_sample: HitSample,
|
||||||
},
|
},
|
||||||
|
@ -427,7 +424,7 @@ pub enum HitObject {
|
||||||
time: Time,
|
time: Time,
|
||||||
hit_sound: HitSound,
|
hit_sound: HitSound,
|
||||||
new_combo: bool,
|
new_combo: bool,
|
||||||
skip_combo_colours: U3,
|
skip_combo_colours: u8,
|
||||||
end_time: Time,
|
end_time: Time,
|
||||||
hit_sample: HitSample,
|
hit_sample: HitSample,
|
||||||
},
|
},
|
||||||
|
|
Reference in a new issue