Skip to content

Commit a639f7f

Browse files
Mivikclaude
andcommitted
fix: instant death triggering on retry in exercise mode
In exercise mode, after retry, judge.update was called with res.time = exercise_range.start while note pointers were reset to 0, causing all notes before the range start to be marked as Miss and immediately triggering instant death. Fix by adding Judge::advance_to which pre-marks notes before the given time as Judged and advances the pointers, called after reset in exercise mode. Also guard the instant death check to State::Playing only. Closes #755 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 64de0fb commit a639f7f

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

prpr/src/judge.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,22 @@ impl Judge {
328328
self.judgements.borrow_mut().clear();
329329
}
330330

331+
/// Advance note pointers past notes before time `t`, marking them as judged.
332+
/// Used in exercise mode to skip notes before the exercise range start.
333+
pub fn advance_to(&mut self, chart: &mut Chart, t: f64) {
334+
for (line, (idx, st)) in chart.lines.iter_mut().zip(self.notes.iter_mut()) {
335+
while *st < idx.len() {
336+
let note = &mut line.notes[idx[*st] as usize];
337+
if note.time as f64 >= t {
338+
break;
339+
}
340+
note.judge = JudgeStatus::Judged;
341+
*st += 1;
342+
}
343+
}
344+
self.last_time = t;
345+
}
346+
331347
pub fn commit(&mut self, t: f64, what: Judgement, line_id: u32, note_id: u32, diff: f64) {
332348
self.judgements.borrow_mut().push((t, line_id, note_id, Ok(what)));
333349
self.inner.commit(what, diff);

prpr/src/scene/game.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ impl GameScene {
625625
}
626626
Some(0) => {
627627
reset!(self, res, tm);
628+
if self.mode == GameMode::Exercise {
629+
self.judge.advance_to(&mut self.chart, self.exercise_range.start);
630+
}
628631
#[cfg(target_env = "ohos")]
629632
miniquad::native::set_interceptor_state(true);
630633
}
@@ -1066,6 +1069,7 @@ impl Scene for GameScene {
10661069
WHITE
10671070
};
10681071
if !self.dead
1072+
&& matches!(self.state, State::Playing)
10691073
&& (self.res.config.mods.contains(Mods::INSTANT_DEATH_AP) && counts[1] + counts[2] + counts[3] > 0
10701074
|| self.res.config.mods.contains(Mods::INSTANT_DEATH_FC) && counts[2] + counts[3] > 0)
10711075
{

0 commit comments

Comments
 (0)