mirror of
https://git.mentality.rip/numas13/xash3d-master.git
synced 2025-02-02 02:04:16 +00:00
protocol: fix converting version to key value
This commit is contained in:
parent
2299010d97
commit
60d8d81d44
@ -146,7 +146,11 @@ impl PutKeyValue for Version {
|
|||||||
) -> Result<&'b mut crate::cursor::CursorMut<'a>, Error> {
|
) -> Result<&'b mut crate::cursor::CursorMut<'a>, Error> {
|
||||||
cur.put_key_value(self.major)?
|
cur.put_key_value(self.major)?
|
||||||
.put_u8(b'.')?
|
.put_u8(b'.')?
|
||||||
.put_key_value(self.minor)
|
.put_key_value(self.minor)?;
|
||||||
|
if self.patch > 0 {
|
||||||
|
cur.put_u8(b'.')?.put_key_value(self.patch)?;
|
||||||
|
}
|
||||||
|
Ok(cur)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,6 +315,9 @@ mod tests {
|
|||||||
b"\\clver\\0.20" => {
|
b"\\clver\\0.20" => {
|
||||||
clver: Some(Version::new(0, 20)),
|
clver: Some(Version::new(0, 20)),
|
||||||
}
|
}
|
||||||
|
b"\\clver\\0.19.3" => {
|
||||||
|
clver: Some(Version::with_patch(0, 19, 3)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
parse_dedicated(flags_mask: FilterFlags::DEDICATED) {
|
parse_dedicated(flags_mask: FilterFlags::DEDICATED) {
|
||||||
b"\\dedicated\\0" => {}
|
b"\\dedicated\\0" => {}
|
||||||
@ -391,6 +398,16 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn version_to_key_value() {
|
||||||
|
let mut buf = [0; 64];
|
||||||
|
let n = CursorMut::new(&mut buf[..])
|
||||||
|
.put_key_value(Version::with_patch(0, 19, 3))
|
||||||
|
.unwrap()
|
||||||
|
.pos();
|
||||||
|
assert_eq!(&buf[..n], b"0.19.3");
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! servers {
|
macro_rules! servers {
|
||||||
($($addr:expr => $info:expr $(=> $func:expr)?)+) => (
|
($($addr:expr => $info:expr $(=> $func:expr)?)+) => (
|
||||||
[$({
|
[$({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user