diff --git a/game.js b/game.js index 7bd4956..3fbe7cd 100644 --- a/game.js +++ b/game.js @@ -20,7 +20,7 @@ class Game extends GameBasic { } async updateLeaderboard() { let jason = await db.all('SELECT * FROM stats ORDER BY CAST(ko AS REAL) DESC LIMIT 1000'); - + let scoresOld = this.scores || []; let scores = {}; @@ -38,7 +38,7 @@ class Game extends GameBasic { let s = Object.entries(scores).sort((a, b) => b[1] - a[1]).filter(a => a[1] > 5); for (let x in s) { - let jk = jason.filter(y => y.ip == s[x][0]).map(y => y.ko).sort((a,b) => b - a); + let jk = jason.filter(y => y.ip == s[x][0]).map(y => y.ko).sort((a, b) => b - a); s[x].push(jk.join(', ')); } @@ -46,7 +46,7 @@ class Game extends GameBasic { this.scores = s; s = [...s]; - s.length = Math.min(s.length,10); + s.length = Math.min(s.length, 10); let message = []; @@ -119,7 +119,7 @@ class Game extends GameBasic { basic[posn] = sround(posp); } } - let str = JSON.stringify(basic,null); + let str = JSON.stringify(basic, null); entList.push({ entity, str, basic }); } @@ -221,31 +221,33 @@ class Game extends GameBasic { async authUser(ws, data) { ws.token = data; - let f = new FormData(); - f.append('token', ws.token); - - let j = await fetch("https://bg.dervland.net/api/form/auth_api/", - { - "method": "post", - "body": f - } - ); - - j = await j.text(); + let j = false; try { - j = JSON.parse(j); + j = await fetch("https://nbg.dervland.net/auth.php", + { + "method": "get", + "headers": { + "cookie": `token=${data}` + } + } + ); + + j = await j.text(); + } catch (err) { - j = {}; + j = false; } - if (j.username == '!nobody' || !j.username) return; + j = j.replaceAll(/\s+/g,''); - if (this.ws.findIndex(x => x.username == j.username && x.ent.health > 0) != -1) { - console.log(`Player ${ws.ent.you} uses username ${j.username} illegally`) + if (!j || j == '') return; + + if (this.ws.findIndex(x => x.username == j && x.ent.health > 0) != -1) { + console.log(`Player ${ws.ent.you} uses username ${j} illegally`) return; } - ws.ent.username = ws.username = j.username; + ws.ent.username = ws.username = j; console.log(`Player ${ws.ent.you} uses username ${ws.username}`) } diff --git a/static/index.html b/static/index.html index 752452d..a7f6acc 100644 --- a/static/index.html +++ b/static/index.html @@ -12,7 +12,7 @@

The left mouse button is the only input. No keyboard, moving the mouse, or anything else.

Click to launch... figure out the rest of the combos yourself.

Created by 08draven - Log in + Log in