From 90e26bb442e120fb499d0d429e8c477d44e1935e Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Mon, 25 Dec 2023 22:31:48 +0200 Subject: [PATCH] fix: remove another instance of adding empty player objects valve Related: #389 --- protocols/valve.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/protocols/valve.js b/protocols/valve.js index fc9fb249..800091b3 100644 --- a/protocols/valve.js +++ b/protocols/valve.js @@ -427,13 +427,12 @@ export default class valve extends Core { }) delete state.raw.players const numBots = state.raw.numbots || 0 - while (state.bots.length < numBots) { - if (sortedPlayers.length) state.bots.push(sortedPlayers.pop()) - else state.bots.push({}) + + while (state.bots.length < numBots && sortedPlayers.length) { + state.bots.push(sortedPlayers.pop()) } - while (state.players.length < state.numplayers - numBots || sortedPlayers.length) { - if (sortedPlayers.length) state.players.push(sortedPlayers.pop()) - else state.players.push({}) + while ((state.players.length < state.numplayers - numBots || sortedPlayers.length) && sortedPlayers.length) { + state.players.push(sortedPlayers.pop()) } }