mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
[Protocol] Remove bufferer::remaining_data_vec function and replace its usage
This commit is contained in:
parent
d61085b1ab
commit
8fe521749a
4 changed files with 5 additions and 7 deletions
|
|
@ -166,8 +166,6 @@ impl Bufferer {
|
||||||
|
|
||||||
pub fn remaining_data(&self) -> &[u8] { &self.data[self.position ..] }
|
pub fn remaining_data(&self) -> &[u8] { &self.data[self.position ..] }
|
||||||
|
|
||||||
pub fn remaining_data_vec(&self) -> Vec<u8> { self.remaining_data().to_vec() }
|
|
||||||
|
|
||||||
pub fn remaining_length(&self) -> usize { self.data.len() - self.position }
|
pub fn remaining_length(&self) -> usize { self.data.len() - self.position }
|
||||||
|
|
||||||
pub fn is_remaining_empty(&self) -> bool { self.remaining_length() == 0 }
|
pub fn is_remaining_empty(&self) -> bool { self.remaining_length() == 0 }
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ impl GameSpy3 {
|
||||||
|
|
||||||
if self.single_packets {
|
if self.single_packets {
|
||||||
buf.move_position_ahead(11);
|
buf.move_position_ahead(11);
|
||||||
return Ok(vec![buf.remaining_data_vec()]);
|
return Ok(vec![buf.remaining_data().to_vec()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if buf.get_string_utf8()? != "splitnum" {
|
if buf.get_string_utf8()? != "splitnum" {
|
||||||
|
|
@ -159,7 +159,7 @@ impl GameSpy3 {
|
||||||
values.push(Vec::new());
|
values.push(Vec::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
values[packet_id] = buf.remaining_data_vec();
|
values[packet_id] = buf.remaining_data().to_vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
if values.iter().any(|v| v.is_empty()) {
|
if values.iter().any(|v| v.is_empty()) {
|
||||||
|
|
@ -185,7 +185,7 @@ pub(crate) fn data_to_map(packet: &[u8]) -> GDResult<(HashMap<String, String>, V
|
||||||
vars.insert(key, value);
|
vars.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((vars, buf.remaining_data_vec()))
|
Ok((vars, buf.remaining_data().to_vec()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If there are parsing problems using the `query` function, you can directly
|
/// If there are parsing problems using the `query` function, you can directly
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ impl SplitPacket {
|
||||||
compressed,
|
compressed,
|
||||||
decompressed_size,
|
decompressed_size,
|
||||||
uncompressed_crc32,
|
uncompressed_crc32,
|
||||||
payload: buffer.remaining_data_vec(),
|
payload: buffer.remaining_data().to_vec(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ impl Packet {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
header: buffer.get_u32()?,
|
header: buffer.get_u32()?,
|
||||||
kind: buffer.get_u8()?,
|
kind: buffer.get_u8()?,
|
||||||
payload: buffer.remaining_data_vec(),
|
payload: buffer.remaining_data().to_vec(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue