From d6e8bd522ff8df10f20fee88eb2cb6bb2bb2a467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 24 Dec 2021 14:07:29 +0100 Subject: [PATCH] Fixing issue if group was deleted when out of bounds. --- back/src/Model/GameRoom.ts | 1 - back/src/Model/Group.ts | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index ff8b7cf0..aefade43 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -312,7 +312,6 @@ export class GameRoom { } group.leave(user); if (group.isEmpty()) { - this.positionNotifier.leave(group); group.destroy(); if (!this.groups.has(group)) { throw new Error(`Could not find group ${group.getId()} referenced by user ${user.id} in World.`); diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index c35ac7a8..0782bd1b 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -141,6 +141,10 @@ export class Group implements Movable { * Usually used when there is only one user left. */ destroy(): void { + if (!this.outOfBounds) { + this.positionNotifier.leave(this); + } + for (const user of this.users) { this.leave(user); }