Skip to content

Commit

Permalink
Upgraded to 0.0.5b6
Browse files Browse the repository at this point in the history
Just a small update to fix a bug which caused the server to crash after reloading slither.io
  • Loading branch information
RowanHarley authored Aug 15, 2016
1 parent 4e09cef commit 1c1e049
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 1c1e049

Please sign in to comment.