mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
cvar write
This commit is contained in:
parent
a55217cc55
commit
35b0bb15ee
3 changed files with 33 additions and 6 deletions
|
|
@ -58,7 +58,7 @@ impl BitWrite<LittleEndian> for ClassInfoMessage {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_say_text2_roundtrip() {
|
||||
fn test_class_info_roundtrip() {
|
||||
crate::test_roundtrip_write(ClassInfoMessage {
|
||||
count: 8,
|
||||
create: true,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use bitbuffer::{BitRead, BitReadStream, Endianness};
|
||||
use bitbuffer::{BitRead, BitReadStream, BitWrite, BitWriteStream, Endianness};
|
||||
|
||||
use crate::ReadResult;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, BitWrite, PartialEq)]
|
||||
pub struct ConVar {
|
||||
key: String,
|
||||
value: String,
|
||||
|
|
@ -20,9 +20,36 @@ impl<E: Endianness> BitRead<'_, E> for ConVar {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BitRead)]
|
||||
#[derive(Debug, BitRead, PartialEq)]
|
||||
pub struct SetConVarMessage {
|
||||
length: u8,
|
||||
#[size = "length"]
|
||||
vars: Vec<ConVar>,
|
||||
}
|
||||
|
||||
impl<E: Endianness> BitWrite<E> for SetConVarMessage {
|
||||
fn write(&self, stream: &mut BitWriteStream<E>) -> ReadResult<()> {
|
||||
self.length.write(stream)?;
|
||||
self.vars.write(stream)
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn test_set_con_var_roundtrip() {
|
||||
crate::test_roundtrip_write(SetConVarMessage {
|
||||
length: 0,
|
||||
vars: Vec::new(),
|
||||
});
|
||||
crate::test_roundtrip_write(SetConVarMessage {
|
||||
length: 2,
|
||||
vars: vec![
|
||||
ConVar {
|
||||
key: "foo1".to_string(),
|
||||
value: "bar1".to_string(),
|
||||
},
|
||||
ConVar {
|
||||
key: "foo2".to_string(),
|
||||
value: "bar2".to_string(),
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue