mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-18 09:35:50 +00:00
[Protocol] Replace some usage of remaining_length with the more appropiate is_remaining_empty
This commit is contained in:
parent
8fe521749a
commit
dd80d6309f
4 changed files with 6 additions and 6 deletions
|
|
@ -64,7 +64,7 @@ fn parse_players_and_teams(packet: Vec<u8>) -> GDResult<Vec<Player>> {
|
|||
let count = buf.get_u16()?;
|
||||
let mut players = Vec::with_capacity(count as usize);
|
||||
|
||||
while buf.remaining_length() > 0 {
|
||||
while !buf.is_remaining_empty() {
|
||||
players.push(Player {
|
||||
name: buf.get_string_utf8()?,
|
||||
steam_id: buf.get_string_utf8()?,
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ pub(crate) fn data_to_map(packet: &[u8]) -> GDResult<(HashMap<String, String>, V
|
|||
let mut vars = HashMap::new();
|
||||
|
||||
let mut buf = Bufferer::new_with_data(Endianess::Big, packet);
|
||||
while buf.remaining_length() > 0 {
|
||||
while !buf.is_remaining_empty() {
|
||||
let key = buf.get_string_utf8()?;
|
||||
if key.is_empty() {
|
||||
break;
|
||||
|
|
@ -214,7 +214,7 @@ fn parse_players_and_teams(packets: Vec<Vec<u8>>) -> GDResult<(Vec<Player>, Vec<
|
|||
for packet in packets {
|
||||
let mut buf = Bufferer::new_with_data(Endianess::Little, &packet);
|
||||
|
||||
while buf.remaining_length() > 0 {
|
||||
while !buf.is_remaining_empty() {
|
||||
if buf.get_u8()? < 3 {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ fn parse_players_and_teams(packets: Vec<Vec<u8>>) -> GDResult<(Vec<Player>, Vec<
|
|||
false => &mut teams_data,
|
||||
};
|
||||
|
||||
while buf.remaining_length() > 0 {
|
||||
while !buf.is_remaining_empty() {
|
||||
let item = buf.get_string_utf8()?;
|
||||
if item.is_empty() {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ fn get_server_vars(bufferer: &mut Bufferer) -> GDResult<HashMap<String, String>>
|
|||
let mut values = HashMap::new();
|
||||
|
||||
let mut done_processing_vars = false;
|
||||
while !done_processing_vars && bufferer.remaining_length() > 0 {
|
||||
while !done_processing_vars && !bufferer.is_remaining_empty() {
|
||||
let key = bufferer.get_string_utf8()?;
|
||||
let value = bufferer.get_string_utf8_optional()?;
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ impl ValveMasterServer {
|
|||
}
|
||||
|
||||
let mut ips: Vec<(IpAddr, u16)> = Vec::new();
|
||||
while buf.remaining_length() > 0 {
|
||||
while !buf.is_remaining_empty() {
|
||||
let ip = IpAddr::V4(Ipv4Addr::new(
|
||||
buf.get_u8()?,
|
||||
buf.get_u8()?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue