From 7634a71b00160d04b8a6a0eae58d4a8ed539990d Mon Sep 17 00:00:00 2001
From: Alex <atm2g19@soton.ac.uk>
Date: Sat, 4 Apr 2020 21:20:45 +0100
Subject: [PATCH] minor bugfix: undefined player id from socket

---
 src/games/battleships.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/games/battleships.ts b/src/games/battleships.ts
index f37c66f..a30e9aa 100644
--- a/src/games/battleships.ts
+++ b/src/games/battleships.ts
@@ -335,6 +335,7 @@ const battleships : GameConstructor = class battleships implements Game{
 
     leave(sock_id : string){
         let player = this.getPlayer(sock_id);
+        if(!player) return;
         this.players = this.players.filter(p => p==player?0:1);
         let game_id = player.game_id;
         this.db.query(`SELECT data_key, data_value FROM game_data WHERE game_id = ${game_id} AND data_key = 0;`)
-- 
GitLab