From f138654ccb9866d0ea40b5ead75e2443aca1362c Mon Sep 17 00:00:00 2001 From: Asraelite Date: Sat, 2 Apr 2016 18:43:11 +0100 Subject: [PATCH] fix game crashing on ship destruction --- public/static/js/wingbase/world/world.js | 2 ++ server/game/room/index.js | 2 +- server/game/room/world/index.js | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/public/static/js/wingbase/world/world.js b/public/static/js/wingbase/world/world.js index a6eb408..0fda3db 100644 --- a/public/static/js/wingbase/world/world.js +++ b/public/static/js/wingbase/world/world.js @@ -66,6 +66,8 @@ class World { body.update(data.slice(i, i + body.interface.size)); } else if (discharge) { discharge.update(data.slice(i, i + 2)); + } else { + return; } i += body.interface.size; diff --git a/server/game/room/index.js b/server/game/room/index.js index c85d3c9..ec022fb 100644 --- a/server/game/room/index.js +++ b/server/game/room/index.js @@ -13,7 +13,7 @@ class Room { this.teamB = new Set(); this.world = new World(this); this.name = (Math.random() * 100000 | 0).toString(36); - this.tps = wingbase.args.development ? 5 : 60; + this.tps = wingbase.args.development ? 60 : 60; this.idGenerator = (function*() { let i = 0; diff --git a/server/game/room/world/index.js b/server/game/room/world/index.js index 93a6805..f786ed9 100644 --- a/server/game/room/world/index.js +++ b/server/game/room/world/index.js @@ -89,6 +89,8 @@ class World { applyDelta(data, bodyPos) { data = data.map(v => +(v.toFixed(3))); this.players.forEach(player => { + if (!player.ship) + return; let dx = player.ship.pos.x - bodyPos.x; let dy = player.ship.pos.y - bodyPos.y; if (dx * dx + dy * dy < 900) @@ -132,6 +134,7 @@ class World { } removeBody(body) { + if(!body) return; body.destruct(); this.bodies.delete(body); this.asteroids.delete(body);