Add spawn points (#71)
Reviewed-on: #71 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #71.
This commit is contained in:
+14
-3
@@ -140,7 +140,7 @@ fn validate(replay: &Replay) -> Result<(), String> {
|
||||
));
|
||||
}
|
||||
if replay.players_are_invalid() {
|
||||
return Err("replay player handles must cover 0..player_count".into());
|
||||
return Err("replay player handles must be unique".into());
|
||||
}
|
||||
if replay.frames.is_empty() {
|
||||
return Err("replay must contain at least one frame".into());
|
||||
@@ -169,7 +169,16 @@ fn validate(replay: &Replay) -> Result<(), String> {
|
||||
if replay
|
||||
.frames
|
||||
.iter()
|
||||
.any(|frame| frame.inputs.len() != replay.match_config.players.len())
|
||||
.any(|frame| {
|
||||
frame.inputs.len()
|
||||
!= replay
|
||||
.match_config
|
||||
.players
|
||||
.iter()
|
||||
.map(|player| player.handle)
|
||||
.max()
|
||||
.map_or(0, |handle| handle + 1)
|
||||
})
|
||||
{
|
||||
return Err("replay frame input count does not match player count".into());
|
||||
}
|
||||
@@ -185,7 +194,9 @@ impl Replay {
|
||||
.map(|player| player.handle)
|
||||
.collect();
|
||||
handles.sort_unstable();
|
||||
handles != (0..handles.len()).collect::<Vec<_>>()
|
||||
handles.is_empty()
|
||||
|| handles.windows(2).any(|handles| handles[0] == handles[1])
|
||||
|| handles.last() == Some(&usize::MAX)
|
||||
}
|
||||
|
||||
fn frame(&self, frame: i32) -> Option<&ReplayFrame> {
|
||||
|
||||
Reference in New Issue
Block a user