Add the ability to respawn and improve controller port mapping (#72)
CI / build-and-test (push) Successful in 2m2s
CI / production-build (push) Successful in 12m18s

Reviewed-on: #72
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #72.
This commit is contained in:
2026-09-27 11:54:08 +00:00
committed by EIREXE
parent bb238d2cbc
commit 6f1d8a7706
15 changed files with 438 additions and 85 deletions
+4 -14
View File
@@ -17,7 +17,7 @@ use crate::{
};
const MAGIC: &[u8; 8] = b"SPRPLY01";
pub const REPLAY_VERSION: u32 = 2;
pub const REPLAY_VERSION: u32 = 3;
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, ValueEnum)]
pub enum ReplayFormat {
@@ -169,16 +169,7 @@ fn validate(replay: &Replay) -> Result<(), String> {
if replay
.frames
.iter()
.any(|frame| {
frame.inputs.len()
!= replay
.match_config
.players
.iter()
.map(|player| player.handle)
.max()
.map_or(0, |handle| handle + 1)
})
.any(|frame| frame.inputs.len() != replay.match_config.players.len())
{
return Err("replay frame input count does not match player count".into());
}
@@ -194,9 +185,7 @@ impl Replay {
.map(|player| player.handle)
.collect();
handles.sort_unstable();
handles.is_empty()
|| handles.windows(2).any(|handles| handles[0] == handles[1])
|| handles.last() == Some(&usize::MAX)
handles.is_empty() || !handles.into_iter().eq(0..self.match_config.players.len())
}
fn frame(&self, frame: i32) -> Option<&ReplayFrame> {
@@ -385,6 +374,7 @@ mod tests {
stage: StageId::TestStage,
players: vec![MatchPlayer {
handle: 0,
controller_port: 0,
fighter: FighterId::TestFighter,
}],
rules: MatchRules::Timed {