Skip to content

Commit

Permalink
be a bit more explicit with return types
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceau committed Sep 14, 2023
1 parent fcf58c5 commit b17cd1f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/slpReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
EventPayloadTypes,
GameEndType,
GameInfoType,
GameStartType,
GeckoCodeType,
MetadataType,
PlacementType,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -412,6 +413,7 @@ export function parseMessage(command: Command, payload: Uint8Array): EventPayloa
connectCode,
userId,
};
return playerInfo;
};

const matchIdLength = 51;
Expand All @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit b17cd1f

Please sign in to comment.