From b17cd1f2c909df0214f83f049072f0a83fbf1453 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Thu, 14 Sep 2023 12:20:41 +1000 Subject: [PATCH] be a bit more explicit with return types --- src/utils/slpReader.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/slpReader.ts b/src/utils/slpReader.ts index 19de1686..00e61221 100644 --- a/src/utils/slpReader.ts +++ b/src/utils/slpReader.ts @@ -8,6 +8,7 @@ import type { EventPayloadTypes, GameEndType, GameInfoType, + GameStartType, GeckoCodeType, MetadataType, PlacementType, @@ -384,7 +385,7 @@ export function parseMessage(command: Command, payload: Uint8Array): EventPayloa const userId = userIdString ?? ""; const offset = playerIndex * 0x24; - return { + const playerInfo: PlayerType = { playerIndex, port: playerIndex + 1, characterId: readUint8(view, 0x65 + offset), @@ -412,6 +413,7 @@ export function parseMessage(command: Command, payload: Uint8Array): EventPayloa connectCode, userId, }; + return playerInfo; }; const matchIdLength = 51; @@ -423,7 +425,7 @@ export function parseMessage(command: Command, payload: Uint8Array): EventPayloa .shift(); const matchId = matchIdString ?? ""; - return { + const gameSettings: GameStartType = { slpVersion: `${readUint8(view, 0x1)}.${readUint8(view, 0x2)}.${readUint8(view, 0x3)}`, timerType: readUint8(view, 0x5, 0x03), inGameMode: readUint8(view, 0x5, 0xe0), @@ -447,6 +449,7 @@ export function parseMessage(command: Command, payload: Uint8Array): EventPayloa tiebreakerNumber: readUint32(view, 0x2f5), }, }; + return gameSettings; case Command.FRAME_START: return { frame: readInt32(view, 0x1),