Add the ability to respawn and improve controller port mapping (#72)
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:
+4
-14
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user