From 1c1e049c188bc4d1dc5261caa30f88867bb3ac5f Mon Sep 17 00:00:00 2001 From: Rowan Harley Date: Mon, 15 Aug 2016 18:29:05 +0200 Subject: [PATCH] Upgraded to 0.0.5b6 Just a small update to fix a bug which caused the server to crash after reloading slither.io --- index.js | 19 ++++++++++--------- package.json | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 1aceef6..e5a5afe 100644 --- a/index.js +++ b/index.js @@ -57,15 +57,14 @@ function handleConnection (conn) { } catch (e) { console.log('[ERROR] ' + e); } - - function close (id) { - console.log('[DEBUG] Connection closed.'); - clearInterval(conn.snake.update); - delete clients[id]; - } - conn.on('message', handleMessage.bind(this, conn)); + conn.on('message', handleMessage.bind(this, conn)); conn.on('error', close.bind(conn.id)); - conn.on('close', close.bind(conn.id)); + conn.on('close', function(){ + console.log('[DEBUG] Connection closed.'); + messages.end.build(2); + clearInterval(conn.snake.update); + delete clients[conn.id]; + }); } function handleMessage (conn, data) { var firstByte, name, radians, secondByte, skin, speed, value, x, y; @@ -123,7 +122,9 @@ function handleMessage (conn, data) { var R = config['gameRadius']; var r = (Math.pow((conn.snake.body.x - R), 2)) + (Math.pow((conn.snake.body.y - R), 2)); - if (r > Math.pow(R, 2)) {console.log('[DEBUG] Outside of Radius'); + if (r > Math.pow(R, 2)) { + // console.log("[TEST] " + r + " < " + R^2); + console.log('[DEBUG] Outside of Radius'); var arr = new Uint8Array(6); message.writeInt8(2, arr, "s".charCodeAt(0)); message.writeInt16(3, arr, conn.id); diff --git a/package.json b/package.json index a023173..2f24387 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Slither-Server", "description": "A Server for Slither.io", - "version": "0.0.5b5", + "version": "0.0.5b6", "repository": { "type": "git", "url": "https://github.com/RowanHarley/Slither-Server"