From c8434dfd4c61e97b02189eeaec9675db383f4e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 22 Oct 2020 16:14:32 +0200 Subject: [PATCH 1/2] Renaming test file --- back/tests/{WorldTest.ts => GameRoomTest.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename back/tests/{WorldTest.ts => GameRoomTest.ts} (99%) diff --git a/back/tests/WorldTest.ts b/back/tests/GameRoomTest.ts similarity index 99% rename from back/tests/WorldTest.ts rename to back/tests/GameRoomTest.ts index a4161bf5..80926644 100644 --- a/back/tests/WorldTest.ts +++ b/back/tests/GameRoomTest.ts @@ -11,7 +11,7 @@ function createMockUser(userId: number): ExSocketInterface { } as ExSocketInterface; } -describe("World", () => { +describe("GameRoom", () => { it("should connect user1 and user2", () => { let connectCalledNumber: number = 0; const connect: ConnectCallback = (user: User, group: Group): void => { From b7854dfb90880aefa6416b1a31b586c88daa8b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 22 Oct 2020 16:15:30 +0200 Subject: [PATCH 2/2] When a user moves, do not trigger group creation In order to avoid triggering group creation when walking next to someone we should avoid creating a group unless the user stops next to the other members of the group. --- back/src/Model/GameRoom.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index e0474e1d..5b42f418 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -56,7 +56,7 @@ export class GameRoom { this.anonymous = isRoomAnonymous(roomId); this.tags = []; this.policyType = GameRoomPolicyTypes.ANONYMUS_POLICY; - + if (this.anonymous) { this.roomSlug = extractRoomSlugPublicRoomId(this.roomId); } else { @@ -65,8 +65,8 @@ export class GameRoom { this.organizationSlug = organizationSlug; this.worldSlug = worldSlug; } - - + + this.users = new Map(); this.groups = new Set(); this.connectCallback = connectCallback; @@ -138,6 +138,12 @@ export class GameRoom { if (user.group === undefined) { // If the user is not part of a group: // should he join a group? + + // If the user is moving, don't try to join + if (user.getPosition().moving) { + return; + } + const closestItem: User|Group|null = this.searchClosestAvailableUserOrGroup(user); if (closestItem !== null) { @@ -275,7 +281,7 @@ export class GameRoom { return this.itemsState; } - + setViewport(socket : Identificable, viewport: ViewportInterface): Movable[] { const user = this.users.get(socket.userId); if(typeof user === 'undefined') {