Implement freeze

This commit is contained in:
Simon Bruder 2020-06-26 21:16:09 +02:00
parent dc27f999c5
commit b7f60302ee
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
2 changed files with 26 additions and 31 deletions

View file

@ -32,8 +32,6 @@ Batch conversion is possible with the included shell script `batch_convert.sh`
* Since *osu!mania* does not support shock arrows, it either ignores them or
(by default) replaces them with a two-key combination (↑↓ or ←→); you can
change this with the (`--shock-action` option)
* Freezes do not work (I do not know how to get the start time yet) and
therefore are disabled in code (`ddr::ssq::FREEZE`)
* Known problems listed for unxwb (for wave banks without entry names having
2 entries, which often are preview and full song, the longest one is used by
default).

View file

@ -13,7 +13,6 @@ use crate::mini_parser::{MiniParser, MiniParserError};
use crate::utils;
const MEASURE_LENGTH: i32 = 4096;
const FREEZE: bool = false;
#[derive(Error, Debug)]
pub enum Error {
@ -231,6 +230,10 @@ impl Chart {
let mut parsed_steps = Vec::new();
// indices of (normal) steps that start a freeze (they are not needed after processing all
// steps as they are already included in the freezes)
let mut freeze_steps = Vec::new();
for step in 0..count {
let beats = measure_to_beats(measures[step]);
@ -256,12 +259,10 @@ impl Chart {
continue;
}
if FREEZE {
match Self::find_last(parsed_steps.clone(), &row) {
Some(last_step) => {
parsed_steps.push(Step::Freeze {
start: if let Step::Step { beats, .. } = parsed_steps[last_step]
{
start: if let Step::Step { beats, .. } = parsed_steps[last_step] {
beats
} else {
unreachable!()
@ -270,19 +271,13 @@ impl Chart {
row,
});
parsed_steps.remove(last_step);
freeze_steps.push(last_step);
}
None => {
warn!(
"Could not find previous step for freeze, adding normal step"
);
warn!("Could not find previous step for freeze, adding normal step");
parsed_steps.push(Step::Step { beats, row });
}
}
} else {
trace!("Freeze disabled, adding normal step");
parsed_steps.push(Step::Step { beats, row });
}
} else {
debug!(
"Encountered unknown extra step with type {}, ignoring",
@ -300,6 +295,12 @@ impl Chart {
}
}
// remove steps that start a freeze
freeze_steps.dedup();
for i in freeze_steps.iter().rev() {
parsed_steps.remove(*i);
}
debug!("Parsed {} steps", parsed_steps.len());
Ok(Self {
@ -376,10 +377,6 @@ pub struct SSQ {
impl SSQ {
pub fn parse(data: &[u8]) -> Result<Self, Error> {
debug!(
"Configuration: measure length: {}, use freezes: {}",
MEASURE_LENGTH, FREEZE
);
let mut cursor = Cursor::new(data);
let mut ssq = Self {