mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
ignore empty text messages
This commit is contained in:
parent
bb79d269d8
commit
c2fe8eca07
4 changed files with 14 additions and 0 deletions
BIN
data/emptysaytext.dem
Normal file
BIN
data/emptysaytext.dem
Normal file
Binary file not shown.
1
data/emptysaytext.json
Normal file
1
data/emptysaytext.json
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -120,6 +120,7 @@ pub enum ChatMessageKind {
|
||||||
#[serde(rename = "TF_Chat_AllSpec")]
|
#[serde(rename = "TF_Chat_AllSpec")]
|
||||||
ChatAllSpec,
|
ChatAllSpec,
|
||||||
NameChange,
|
NameChange,
|
||||||
|
Empty,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BitRead<'_, LittleEndian> for ChatMessageKind {
|
impl BitRead<'_, LittleEndian> for ChatMessageKind {
|
||||||
|
|
@ -153,6 +154,17 @@ impl BitRead<'_, LittleEndian> for SayText2Message {
|
||||||
let (kind, from, text): (ChatMessageKind, Option<String>, String) =
|
let (kind, from, text): (ChatMessageKind, Option<String>, String) =
|
||||||
if stream.read::<u8>()? == 1 {
|
if stream.read::<u8>()? == 1 {
|
||||||
let first = stream.read::<u8>()?;
|
let first = stream.read::<u8>()?;
|
||||||
|
|
||||||
|
if stream.bits_left() == 0 {
|
||||||
|
return Ok(SayText2Message {
|
||||||
|
client,
|
||||||
|
raw,
|
||||||
|
kind: ChatMessageKind::Empty,
|
||||||
|
from: None,
|
||||||
|
text: String::new(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if first == 7 {
|
if first == 7 {
|
||||||
let _color = stream.read_string(Some(6))?;
|
let _color = stream.read_string(Some(6))?;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ use tf_demo_parser::{Demo, DemoParser, MatchState};
|
||||||
#[test_case("data/nousers.dem", "data/nousers.json"; "nousers.dem")]
|
#[test_case("data/nousers.dem", "data/nousers.json"; "nousers.dem")]
|
||||||
#[test_case("data/decal.dem", "data/decal.json"; "decal.dem")]
|
#[test_case("data/decal.dem", "data/decal.json"; "decal.dem")]
|
||||||
#[test_case("data/saytext2.dem", "data/saytext2.json"; "saytext2.dem")]
|
#[test_case("data/saytext2.dem", "data/saytext2.json"; "saytext2.dem")]
|
||||||
|
#[test_case("data/emptysaytext.dem", "data/emptysaytext.json"; "emptysaytext.dem")]
|
||||||
fn snapshot_test(input_file: &str, snapshot_file: &str) {
|
fn snapshot_test(input_file: &str, snapshot_file: &str) {
|
||||||
let file = fs::read(input_file).expect("Unable to read file");
|
let file = fs::read(input_file).expect("Unable to read file");
|
||||||
let demo = Demo::new(&file);
|
let demo = Demo::new(&file);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue