From 996bdaa457f04f8b65b4018193ace54ccec953c1 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Thu, 14 Jan 2021 22:06:18 +0100
Subject: [PATCH] Better fix to remove corrupted games vs computer

---
 client/src/components/ComputerGame.vue | 2 +-
 client/src/views/Rules.vue             | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/client/src/components/ComputerGame.vue b/client/src/components/ComputerGame.vue
index 72e4f5e3..9cd5f9b1 100644
--- a/client/src/components/ComputerGame.vue
+++ b/client/src/components/ComputerGame.vue
@@ -61,7 +61,7 @@ export default {
   methods: {
     launchGame: function(game) {
       this.compWorker.postMessage(["scripts", this.gameInfo.vname]);
-      if (!game || !V.IsGoodFen(game.fen)) {
+      if (!game) {
         game = {
           vname: this.gameInfo.vname,
           fenStart: V.GenRandInitFen(this.st.settings.randomness),
diff --git a/client/src/views/Rules.vue b/client/src/views/Rules.vue
index dc96ffb4..c069eb29 100644
--- a/client/src/views/Rules.vue
+++ b/client/src/views/Rules.vue
@@ -120,7 +120,12 @@ export default {
       this.gameInfo.mode = mode;
       if (this.gameInfo.mode == "versus") {
         CompgameStorage.get(this.gameInfo.vname, (game) => {
-          // NOTE: game might be null
+          // NOTE: game might be null (if none stored yet)
+          if (!!game && !V.IsGoodFen(game.fen)) {
+            // Some issues with stored game: delete
+            CompgameStorage.remove(game.vname);
+            game = null;
+          }
           this.$refs["compgame"].launchGame(game);
         });
       }
-- 
2.44.0