Skip to content

Commit

Permalink
Revert "fix(junowen): remove unnecerassy seed sync"
Browse files Browse the repository at this point in the history
This reverts commit edf6dfb.
  • Loading branch information
progre committed Oct 12, 2023
1 parent bb373d8 commit f421d4e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
11 changes: 9 additions & 2 deletions junowen-lib/src/th19.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,16 @@ impl Th19 {
u32_prop!(0x1a2478, difficulty_cursor, set_difficulty_cursor);

pointer!(0x_1ae3a0, input_devices, input_devices_mut, InputDevices);
u16_prop!(0x1ae410, rand_seed1, set_rand_seed1);
u16_prop!(0x1ae410, rand_seed1, set_rand_seed1); // 同一フレームでも変わる可能性あり ここを起点にdesyncする?
u32_prop!(0x1ae414, rand_seed5, set_rand_seed5); // 公式にsyncしてない 遅いほうだけ書き換わる?0,0 時に複数回書き換わるが、その後は変わらない?
// 0x1ae418: unknown
pointer!(0x_1ae41c, app, app_mut, App);
u16_prop!(0x1ae430, rand_seed2, set_rand_seed2);
u16_prop!(0x1ae420, rand_seed4, set_rand_seed4); // frame 依存?
u32_prop!(0x1ae424, rand_seed6, set_rand_seed6); // 公式にsyncしてない 書き換えが稀
u16_prop!(0x1ae428, rand_seed3, set_rand_seed3); // frame 依存 0x1ae410 のコピー?
u32_prop!(0x1ae42c, rand_seed7, set_rand_seed7); // frame 依存 インクリメント
u16_prop!(0x1ae430, rand_seed2, set_rand_seed2); // frame 依存 0x1ae420 のコピー?
u32_prop!(0x1ae434, rand_seed8, set_rand_seed8); // frame 依存 インクリメント
ptr_opt!(0x_1ae464, round, Round);
pointer!(0x_1ae60c, player_name, PlayerName);
value!(0x200850, p1_input, Input);
Expand Down
6 changes: 6 additions & 0 deletions junowen/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ pub struct MatchInitial {
pub struct RoundInitial {
pub seed1: u16,
pub seed2: u16,
pub seed3: u16,
pub seed4: u16,
pub seed5: u32,
pub seed6: u32,
pub seed7: u32,
pub seed8: u32,
}

pub async fn create_session(
Expand Down
12 changes: 12 additions & 0 deletions junowen/src/state/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,24 @@ pub fn on_round_over(session: &mut Session, th19: &mut Th19) -> Result<(), RecvE
let init = session.init_round(Some(RoundInitial {
seed1: th19.rand_seed1().unwrap(),
seed2: th19.rand_seed2().unwrap(),
seed3: th19.rand_seed3().unwrap(),
seed4: th19.rand_seed4().unwrap(),
seed5: th19.rand_seed5().unwrap(),
seed6: th19.rand_seed6().unwrap(),
seed7: th19.rand_seed7().unwrap(),
seed8: th19.rand_seed8().unwrap(),
}))?;
assert!(init.is_none());
} else {
let init = session.init_round(None)?.unwrap();
th19.set_rand_seed1(init.seed1).unwrap();
th19.set_rand_seed2(init.seed2).unwrap();
th19.set_rand_seed3(init.seed3).unwrap();
th19.set_rand_seed4(init.seed4).unwrap();
th19.set_rand_seed5(init.seed5).unwrap();
th19.set_rand_seed6(init.seed6).unwrap();
th19.set_rand_seed7(init.seed7).unwrap();
th19.set_rand_seed8(init.seed8).unwrap();
}
Ok(())
}
12 changes: 12 additions & 0 deletions junowen/src/state/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ pub fn on_input_players(
let opt = session.init_round(Some(RoundInitial {
seed1: th19.rand_seed1().unwrap(),
seed2: th19.rand_seed2().unwrap(),
seed3: th19.rand_seed3().unwrap(),
seed4: th19.rand_seed4().unwrap(),
seed5: th19.rand_seed5().unwrap(),
seed6: th19.rand_seed6().unwrap(),
seed7: th19.rand_seed7().unwrap(),
seed8: th19.rand_seed8().unwrap(),
}))?;
debug_assert!(opt.is_none());
} else {
Expand All @@ -48,6 +54,12 @@ pub fn on_input_players(
let init = session.init_round(None)?.unwrap();
th19.set_rand_seed1(init.seed1).unwrap();
th19.set_rand_seed2(init.seed2).unwrap();
th19.set_rand_seed3(init.seed3).unwrap();
th19.set_rand_seed4(init.seed4).unwrap();
th19.set_rand_seed5(init.seed5).unwrap();
th19.set_rand_seed6(init.seed6).unwrap();
th19.set_rand_seed7(init.seed7).unwrap();
th19.set_rand_seed8(init.seed8).unwrap();
}
}

Expand Down

0 comments on commit f421d4e

Please sign in to comment.