From bd99b0e611dc487cd167f94ca0e35d4e439987e6 Mon Sep 17 00:00:00 2001 From: 200Tigersbloxed <45884377+200Tigersbloxed@users.noreply.github.com> Date: Mon, 28 Dec 2020 02:57:17 -0500 Subject: [PATCH] 12.28.2020-prerelease.01 + Attempted fix for Server Crashing on Host Leaving --- beep.js | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/beep.js b/beep.js index a84244c..16a663c 100644 --- a/beep.js +++ b/beep.js @@ -295,14 +295,41 @@ io.on('connection', (socket) => { // make sure there was a player before continuing if(!failedToFindPlayer){ if(inRound){ - if(host.toLowerCase() == plrwholeft.toLowerCase()){ - EndRound() - // thats it + try{ + if(host.toLowerCase() == plrwholeft.toLowerCase()){ + EndRound() + // thats it + } + } + catch{ + try{ + if(host == null || host == undefined){ + EndRound() + } + } + catch{ + // just end the round at this point + EndRound() + } } - if(currentPlayer.toLowerCase() == plrwholeft.toLowerCase()){ - // okay so we can just pick a new person - EndPlayerTurn() - // thats it + + try{ + if(currentPlayer.toLowerCase() == plrwholeft.toLowerCase()){ + // okay so we can just pick a new person + EndPlayerTurn() + // thats it + } + } + catch{ + try{ + if(currentPlayer == null || currentPlayer == undefined){ + EndPlayerTurn() + } + } + catch{ + // just end the round at this point + EndRound() + } } } // remove them from the list