From eabcb0aad872110af14ee09de3915cbe471f3cea Mon Sep 17 00:00:00 2001 From: CriticalFloof Date: Fri, 1 Dec 2023 23:36:42 -0500 Subject: [PATCH 1/5] Fix Crash related to getPawn Attempting to call getPawn on a player in spectator mode would cause the regex to fail a match and crash. --- src/omegga/player.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omegga/player.ts b/src/omegga/player.ts index 847d13e..6faea59 100644 --- a/src/omegga/player.ts +++ b/src/omegga/player.ts @@ -347,7 +347,7 @@ class Player implements OmeggaPlayer { async getPawn(): Promise { // given a player controller, match the player's pawn const pawnRegExp = new RegExp( - `^(?\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = BP_FigureV2_C'.+?:PersistentLevel.(?BP_FigureV2_C_\\d+)'` + `^(?\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = (?:BP_FigureV2_C'.+:PersistentLevel\\.)?(?BP_FigureV2_C_\\d+|None)'?` ); // wait for the pawn watcher to return a pawn From 76c0e96ce4f5aef7b6da997376476ccc13268525 Mon Sep 17 00:00:00 2001 From: CriticalFloof Date: Sat, 2 Dec 2023 22:08:52 -0500 Subject: [PATCH 2/5] Change getPosition to handle spectators Calling getPosition() on a spectator should return undefined with this change. --- src/omegga/player.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/omegga/player.ts b/src/omegga/player.ts index 6faea59..f2214f1 100644 --- a/src/omegga/player.ts +++ b/src/omegga/player.ts @@ -364,14 +364,14 @@ class Player implements OmeggaPlayer { return pawn; } - async getPosition(): Promise<[number, number, number]> { + async getPosition(): Promise<[number, number, number] | undefined> { // this is here because my text editor had weird syntax highlighting glitches when the other omeggas were replaced with this.#omegga... // guess the code is "too new" :egg: const omegga = this.#omegga; // given a player controller, match the player's pawn const pawnRegExp = new RegExp( - `BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = BP_FigureV2_C'.+?:PersistentLevel.(?BP_FigureV2_C_\\d+)'` + `^(?\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = (?:BP_FigureV2_C'.+:PersistentLevel\\.)?(?BP_FigureV2_C_\\d+|None)'?` ); // wait for the pawn watcher to return a pawn @@ -379,14 +379,14 @@ class Player implements OmeggaPlayer { { groups: { pawn }, }, - ] = await omegga.addWatcher(pawnRegExp, { - // request the pawn for this player's controller (should only be one) - exec: () => - omegga.writeln( - `GetAll BP_PlayerController_C Pawn Name=${this.controller}` - ), - timeoutDelay: 100, - }); + // pawnRegExp + ] = await omegga.watchLogChunk( + 'GetAll BP_PlayerController_C Pawn Name=' + this.controller, + pawnRegExp, + { first: 'index', timeoutDelay: 100 } + ); + + if(pawn === "None") return; // given a player's pawn, match the player's position const posRegExp = new RegExp( From de046eae198d476da6abcce12fceb1cb8bf5df71 Mon Sep 17 00:00:00 2001 From: CriticalFloof Date: Sat, 2 Dec 2023 22:30:58 -0500 Subject: [PATCH 3/5] getPawn Expected Return Change Calling getPawn on a player still returns a string representing the pawn. Calling getPawn on a spectator will return undefined with this change. --- src/omegga/player.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/omegga/player.ts b/src/omegga/player.ts index f2214f1..7ef2789 100644 --- a/src/omegga/player.ts +++ b/src/omegga/player.ts @@ -344,7 +344,7 @@ class Player implements OmeggaPlayer { ); } - async getPawn(): Promise { + async getPawn(): Promise { // given a player controller, match the player's pawn const pawnRegExp = new RegExp( `^(?\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = (?:BP_FigureV2_C'.+:PersistentLevel\\.)?(?BP_FigureV2_C_\\d+|None)'?` @@ -361,6 +361,8 @@ class Player implements OmeggaPlayer { { first: 'index', timeoutDelay: 500 } ); + if(pawn === "None") return; + return pawn; } From 704b06e9de670414b9099b68e978a1437effa080 Mon Sep 17 00:00:00 2001 From: CriticalFloof Date: Sun, 3 Dec 2023 01:57:03 -0500 Subject: [PATCH 4/5] Formatting Fixes --- src/omegga/player.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/omegga/player.ts b/src/omegga/player.ts index 7ef2789..8cb1698 100644 --- a/src/omegga/player.ts +++ b/src/omegga/player.ts @@ -361,7 +361,7 @@ class Player implements OmeggaPlayer { { first: 'index', timeoutDelay: 500 } ); - if(pawn === "None") return; + if (pawn === 'None') return; return pawn; } @@ -381,14 +381,13 @@ class Player implements OmeggaPlayer { { groups: { pawn }, }, - // pawnRegExp ] = await omegga.watchLogChunk( 'GetAll BP_PlayerController_C Pawn Name=' + this.controller, pawnRegExp, { first: 'index', timeoutDelay: 100 } ); - if(pawn === "None") return; + if (pawn === 'None') return; // given a player's pawn, match the player's position const posRegExp = new RegExp( From 45f62102f920006b759aafe75000f3b35eb5cae4 Mon Sep 17 00:00:00 2001 From: CriticalFloof Date: Sun, 3 Dec 2023 02:03:18 -0500 Subject: [PATCH 5/5] Change undefined returns to null. --- src/omegga/player.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/omegga/player.ts b/src/omegga/player.ts index 8cb1698..7e8a044 100644 --- a/src/omegga/player.ts +++ b/src/omegga/player.ts @@ -344,7 +344,7 @@ class Player implements OmeggaPlayer { ); } - async getPawn(): Promise { + async getPawn(): Promise { // given a player controller, match the player's pawn const pawnRegExp = new RegExp( `^(?\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = (?:BP_FigureV2_C'.+:PersistentLevel\\.)?(?BP_FigureV2_C_\\d+|None)'?` @@ -361,12 +361,12 @@ class Player implements OmeggaPlayer { { first: 'index', timeoutDelay: 500 } ); - if (pawn === 'None') return; + if (pawn === 'None') return null; return pawn; } - async getPosition(): Promise<[number, number, number] | undefined> { + async getPosition(): Promise<[number, number, number] | null> { // this is here because my text editor had weird syntax highlighting glitches when the other omeggas were replaced with this.#omegga... // guess the code is "too new" :egg: const omegga = this.#omegga; @@ -387,7 +387,7 @@ class Player implements OmeggaPlayer { { first: 'index', timeoutDelay: 100 } ); - if (pawn === 'None') return; + if (pawn === 'None') return null; // given a player's pawn, match the player's position const posRegExp = new RegExp(