From c5a35016d15aebab7e81c809759aa398d6834112 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Thu, 12 Jan 2023 23:40:43 +0200 Subject: [PATCH] Valve Protocol: Players with no name (name length == 0), are no more added to players details --- src/protocols/valve/protocol.rs | 36 +++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/protocols/valve/protocol.rs b/src/protocols/valve/protocol.rs index b7e9b8c..014066b 100644 --- a/src/protocols/valve/protocol.rs +++ b/src/protocols/valve/protocol.rs @@ -366,19 +366,29 @@ impl ValveProtocol { for _ in 0..count { buffer.move_position_ahead(1); //skip the index byte - players.push(ServerPlayer { - name: buffer.get_string_utf8()?, - score: buffer.get_u32()?, - duration: buffer.get_f32()?, - deaths: match *app == SteamID::TS.as_app() { - false => None, - true => Some(buffer.get_u32()?) - }, - money: match *app == SteamID::TS.as_app() { - false => None, - true => Some(buffer.get_u32()?) - } - }); + + let name = buffer.get_string_utf8()?; + let score = buffer.get_u32()?; + let duration = buffer.get_f32()?; + + let deaths = match *app == SteamID::TS.as_app() { + false => None, + true => Some(buffer.get_u32()?) + }; + let money = match *app == SteamID::TS.as_app() { + false => None, + true => Some(buffer.get_u32()?) + }; + + if name.len() > 0 { + players.push(ServerPlayer { + name, + score, + duration, + deaths, + money + }); + } } Ok(players)