Skip to content

Commit

Permalink
Update has_bot_players() to detect bots that join mid-game.
Browse files Browse the repository at this point in the history
  • Loading branch information
vikpe committed Jun 28, 2024
1 parent 8ec57e2 commit 9905192
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ categories = ["parsing"]
keywords = ["demos", "mvd", "parser", "quake", "quakeworld"]
repository = "https://github.com/vikpe/mvdparser"
authors = ["Viktor Persson <viktor.persson@arcsin.se>"]
version = "0.15.1"
version = "0.15.2"
edition = "2021"
license = "MIT"
include = [
Expand Down
7 changes: 6 additions & 1 deletion src/clients.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use bstr::ByteSlice;
use quake_text::unicode;

use crate::client::Client;
Expand All @@ -18,7 +19,11 @@ pub fn clients(data: &[u8]) -> Result<Vec<Client>> {
}

pub fn has_bot_players(data: &[u8]) -> Result<bool> {
Ok(player_clients(data)?.iter().any(|c| c.is_bot))
if player_clients(data)?.iter().any(|c| c.is_bot) {
return Ok(true);
}

Ok(data.rfind(br#""bot": {"#).is_some())
}

pub fn has_human_players(data: &[u8]) -> Result<bool> {
Expand Down

0 comments on commit 9905192

Please sign in to comment.