From 398be02486adb6d70534ec17e68c5d6ea2df8073 Mon Sep 17 00:00:00 2001
From: Dennis Postma <dennis@directonline.io>
Date: Tue, 4 Jun 2024 19:57:42 +0200
Subject: [PATCH] Small bug fix

---
 src/stores/zone.ts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/stores/zone.ts b/src/stores/zone.ts
index ad850be..c3de41d 100644
--- a/src/stores/zone.ts
+++ b/src/stores/zone.ts
@@ -27,8 +27,12 @@ export const useZoneStore = defineStore('zone', {
       this.characters = this.characters.filter((c: Character) => c.id !== character.id)
     },
     updateCharacter(character: Character) {
-      const index = this.characters.findIndex((c: Character) => c.id === character.id)
-      this.characters[index] = character
+      const index = this.characters.findIndex((c) => c.id === character.id)
+      if (index !== -1) {
+        this.characters[index] = character
+      } else {
+        console.error(`Character with id ${character.id} not found`)
+      }
     }
   }
 })