mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
Merge pull request 'Fix parsing of SayText2 messages starting with color codes other than \x01' (#7) from pet0r/demostf-parser:broaden_saytext_detection into master
Reviewed-on: https://codeberg.org/demostf/parser/pulls/7
This commit is contained in:
commit
4b7a0c7320
1 changed files with 10 additions and 7 deletions
|
|
@ -297,15 +297,17 @@ impl BitRead<'_, LittleEndian> for SayText2Message {
|
||||||
fn read(stream: &mut Stream) -> ReadResult<Self> {
|
fn read(stream: &mut Stream) -> ReadResult<Self> {
|
||||||
let client = EntityId::from(stream.read::<u8>()? as u32);
|
let client = EntityId::from(stream.read::<u8>()? as u32);
|
||||||
let raw = stream.read()?;
|
let raw = stream.read()?;
|
||||||
let (kind, from, text): (ChatMessageKind, Option<MaybeUtf8String>, MaybeUtf8String) =
|
let (kind, from, text): (ChatMessageKind, Option<MaybeUtf8String>, MaybeUtf8String) = {
|
||||||
if stream.read::<u8>()? == 1 {
|
let next_byte = stream.read::<u8>()?;
|
||||||
stream.set_pos(stream.pos() - 8)?;
|
stream.set_pos(stream.pos() - 8)?;
|
||||||
|
if next_byte > 0 && next_byte <= 8 {
|
||||||
|
// Starts with a color code (\x01-\x08) rather than a kind
|
||||||
|
// string like "TF_Chat_All", so this is the simplified format
|
||||||
|
// where the message body is just raw colored text without
|
||||||
|
// kind/from fields.
|
||||||
let text: MaybeUtf8String = stream.read()?;
|
let text: MaybeUtf8String = stream.read()?;
|
||||||
(ChatMessageKind::ChatAll, None, text)
|
(ChatMessageKind::ChatAll, None, text)
|
||||||
} else {
|
} else {
|
||||||
stream.set_pos(stream.pos() - 8)?;
|
|
||||||
|
|
||||||
let kind = stream.read()?;
|
let kind = stream.read()?;
|
||||||
let from = stream.read()?;
|
let from = stream.read()?;
|
||||||
let text = stream.read()?;
|
let text = stream.read()?;
|
||||||
|
|
@ -315,6 +317,7 @@ impl BitRead<'_, LittleEndian> for SayText2Message {
|
||||||
let _: u16 = stream.read()?;
|
let _: u16 = stream.read()?;
|
||||||
}
|
}
|
||||||
(kind, Some(from), text)
|
(kind, Some(from), text)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(SayText2Message {
|
Ok(SayText2Message {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue