From 45bf3b862d45bd925380f9d5be68b823b6df4998 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 28 May 2022 03:00:00 +0200 Subject: fully implement server+player counts --- src/app/launcher.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/launcher.js b/src/app/launcher.js index f426775..719048e 100644 --- a/src/app/launcher.js +++ b/src/app/launcher.js @@ -116,8 +116,15 @@ async function loadServers() { serverstatus.classList.add("checking"); try { - let servers = await (await fetch("https://northstar.tf/client/servers/")).json(); + let servers = await (await fetch("https://northstar.tf/client/servers")).json(); masterserver = true; + + playercount = 0; + servercount = servers.length; + + for (let i = 0; i < servers.length; i++) { + playercount += servers[i].playerCount + } }catch (err) { playercount = 0; servercount = 0; @@ -126,7 +133,7 @@ async function loadServers() { serverstatus.classList.remove("checking"); - if (servercount == 0) {masterserver = false} + if (servercount == 0 || ! servercount || ! playercount) {masterserver = false} if (masterserver) { serverstatus.classList.add("up"); -- cgit v1.2.3