From 5e1106e488d0683e4bb4e3f3633416b9c0261bd9 Mon Sep 17 00:00:00 2001 From: Holly Date: Fri, 6 Oct 2023 09:48:31 +0100 Subject: [PATCH] Give types to all functions in OsuPacketWriter --- server/interfaces/ChannelData.ts | 5 +++ server/interfaces/OsuPacketWriter.ts | 52 +++++++++++++------------ server/interfaces/ReplayFrameData.ts | 7 ++++ server/interfaces/ScoreFrameData.ts | 17 ++++++++ server/interfaces/SpectateFramesData.ts | 10 +++++ server/interfaces/UserPresenceData.ts | 12 ++++++ server/interfaces/UserQuitData.ts | 4 ++ tooling/mangle.ts | 2 +- 8 files changed, 84 insertions(+), 25 deletions(-) create mode 100644 server/interfaces/ChannelData.ts create mode 100644 server/interfaces/ReplayFrameData.ts create mode 100644 server/interfaces/ScoreFrameData.ts create mode 100644 server/interfaces/SpectateFramesData.ts create mode 100644 server/interfaces/UserPresenceData.ts create mode 100644 server/interfaces/UserQuitData.ts diff --git a/server/interfaces/ChannelData.ts b/server/interfaces/ChannelData.ts new file mode 100644 index 0000000..0761580 --- /dev/null +++ b/server/interfaces/ChannelData.ts @@ -0,0 +1,5 @@ +export default interface ChannelData { + channelName: string, + channelTopic: string, + channelUserCount: number +} \ No newline at end of file diff --git a/server/interfaces/OsuPacketWriter.ts b/server/interfaces/OsuPacketWriter.ts index 7d64f4a..faf5f26 100644 --- a/server/interfaces/OsuPacketWriter.ts +++ b/server/interfaces/OsuPacketWriter.ts @@ -1,7 +1,11 @@ +import ChannelData from "./ChannelData" import MatchData from "./MatchData" import MatchScoreData from "./MatchScoreData" import MessageData from "./MessageData" +import SpectateFramesData from "./SpectateFramesData" import StatusUpdateData from "./StatusUpdateData" +import UserPresenceData from "./UserPresenceData" +import UserQuitData from "./UserQuitData" export default interface OsuPacketWriter { // Functions @@ -9,36 +13,36 @@ export default interface OsuPacketWriter { CommandError() : OsuPacketWriter, SendMessage(data:MessageData) : OsuPacketWriter, Ping() : OsuPacketWriter, - HandleIrcChangeUsername(data:any) : OsuPacketWriter, + HandleIrcChangeUsername(data:string) : OsuPacketWriter, HandleIrcQuit() : OsuPacketWriter, HandleOsuUpdate(data:StatusUpdateData) : OsuPacketWriter, - HandleUserQuit(data:any) : OsuPacketWriter, - SpectatorJoined(data:any) : OsuPacketWriter, - SpectatorLeft(data:any) : OsuPacketWriter, - SpectateFrames(data:any) : OsuPacketWriter, + HandleUserQuit(data:UserQuitData) : OsuPacketWriter, + SpectatorJoined(data:number) : OsuPacketWriter, + SpectatorLeft(data:number) : OsuPacketWriter, + SpectateFrames(data:SpectateFramesData) : OsuPacketWriter, VersionUpdate() : OsuPacketWriter, - SpectatorCantSpectate(data:any) : OsuPacketWriter, + SpectatorCantSpectate(data:number) : OsuPacketWriter, GetAttention() : OsuPacketWriter, Announce(data:string) : OsuPacketWriter, MatchUpdate(data:MatchData) : OsuPacketWriter, MatchNew(data:MatchData) : OsuPacketWriter, - MatchDisband(data:any) : OsuPacketWriter, + MatchDisband(data:number) : OsuPacketWriter, MatchJoinSuccess(data:MatchData) : OsuPacketWriter, MatchJoinFail() : OsuPacketWriter, FellowSpectatorJoined(data:number) : OsuPacketWriter, FellowSpectatorLeft(data:number) : OsuPacketWriter, MatchStart(data:MatchData) : OsuPacketWriter, MatchScoreUpdate(data:MatchScoreData) : OsuPacketWriter, - MatchTransferHost(data:any) : OsuPacketWriter, + MatchTransferHost() : OsuPacketWriter, MatchAllPlayersLoaded() : OsuPacketWriter, - MatchPlayerFailed(data:any) : OsuPacketWriter, + MatchPlayerFailed(data:number) : OsuPacketWriter, MatchComplete() : OsuPacketWriter, MatchSkip() : OsuPacketWriter, Unauthorised() : OsuPacketWriter, - ChannelJoinSuccess(data:any) : OsuPacketWriter, - ChannelAvailable(data:any) : OsuPacketWriter, - ChannelRevoked(data:any) : OsuPacketWriter, - ChannelAvailableAutojoin(data:any) : OsuPacketWriter, + ChannelJoinSuccess(data:string) : OsuPacketWriter, + ChannelAvailable(data:ChannelData) : OsuPacketWriter, + ChannelRevoked(data:string) : OsuPacketWriter, + ChannelAvailableAutojoin(data:ChannelData) : OsuPacketWriter, BeatmapInfoReply() : OsuPacketWriter, LoginPermissions(data:number) : OsuPacketWriter, FriendsList(data:Array) : OsuPacketWriter, @@ -46,22 +50,22 @@ export default interface OsuPacketWriter { TitleUpdate(data:string) : OsuPacketWriter, Monitor() : OsuPacketWriter, MatchPlayerSkipped(data:number) : OsuPacketWriter, - UserPresence(data:any) : OsuPacketWriter, + UserPresence(data:UserPresenceData) : OsuPacketWriter, Restart(data:number) : OsuPacketWriter, - Invite(data:any) : OsuPacketWriter, + Invite(data:MessageData) : OsuPacketWriter, ChannelListingComplete() : OsuPacketWriter, - MatchChangePassword(data:any) : OsuPacketWriter, - BanInfo(data:any) : OsuPacketWriter, - UserSilenced(data:any) : OsuPacketWriter, - UserPresenceSingle(data:any) : OsuPacketWriter, - UserPresenceBundle(data:any) : OsuPacketWriter, - UserPMBlocked(data:any) : OsuPacketWriter, - TargetIsSilenced(data:any) : OsuPacketWriter, + MatchChangePassword(data:string) : OsuPacketWriter, + BanInfo(data:number) : OsuPacketWriter, + UserSilenced(data:number) : OsuPacketWriter, + UserPresenceSingle(data:number) : OsuPacketWriter, + UserPresenceBundle(data:Array) : OsuPacketWriter, + UserPMBlocked(data:MessageData) : OsuPacketWriter, + TargetIsSilenced(data:MessageData) : OsuPacketWriter, VersionUpdateForced() : OsuPacketWriter, - SwitchServer(data:any) : OsuPacketWriter, + SwitchServer(data:number) : OsuPacketWriter, AccountRestricted() : OsuPacketWriter, RTX(data:string) : OsuPacketWriter, - SwitchTourneyServer(data:any) : OsuPacketWriter + SwitchTourneyServer(data:string) : OsuPacketWriter toBuffer : Buffer } \ No newline at end of file diff --git a/server/interfaces/ReplayFrameData.ts b/server/interfaces/ReplayFrameData.ts new file mode 100644 index 0000000..6d0aec5 --- /dev/null +++ b/server/interfaces/ReplayFrameData.ts @@ -0,0 +1,7 @@ +export default interface ReplayFrameData { + buttonState: number, + bt: number, + mouseX: number, + mouseY: number, + time: number +} \ No newline at end of file diff --git a/server/interfaces/ScoreFrameData.ts b/server/interfaces/ScoreFrameData.ts new file mode 100644 index 0000000..af8792b --- /dev/null +++ b/server/interfaces/ScoreFrameData.ts @@ -0,0 +1,17 @@ +export default interface ScoreFrameData { + time: number, + id: number, + count300: number, + count100: number, + count50: number, + countGeki: number, + countKatu: number, + countMiss: number, + totalScore: number, + maxCombo: number, + currentCombo: number, + perfect: boolean, + currentHp: number, + tagByte: number, + usingScoreV2: boolean, +} \ No newline at end of file diff --git a/server/interfaces/SpectateFramesData.ts b/server/interfaces/SpectateFramesData.ts new file mode 100644 index 0000000..e2d4c87 --- /dev/null +++ b/server/interfaces/SpectateFramesData.ts @@ -0,0 +1,10 @@ +import MatchScoreData from "./MatchScoreData"; +import ReplayFrameData from "./ReplayFrameData"; +import ScoreFrameData from "./ScoreFrameData"; + +export default interface SpectateFramesData { + extra: number, + replayFrames: Array, + action: number, + scoreFrame: ScoreFrameData +} \ No newline at end of file diff --git a/server/interfaces/UserPresenceData.ts b/server/interfaces/UserPresenceData.ts new file mode 100644 index 0000000..0958374 --- /dev/null +++ b/server/interfaces/UserPresenceData.ts @@ -0,0 +1,12 @@ +import { Permissions } from "../enums/Permissions"; + +export default interface UserPresenceData { + userId: number, + username: string, + timezone: number, + countryId: number, + permissions: Permissions, + longitude: number, + latitude: number, + rank: number +} \ No newline at end of file diff --git a/server/interfaces/UserQuitData.ts b/server/interfaces/UserQuitData.ts new file mode 100644 index 0000000..7c7d2a7 --- /dev/null +++ b/server/interfaces/UserQuitData.ts @@ -0,0 +1,4 @@ +export default interface UserQuitData { + userId: number, + state: number +} \ No newline at end of file diff --git a/tooling/mangle.ts b/tooling/mangle.ts index c117282..14f8580 100644 --- a/tooling/mangle.ts +++ b/tooling/mangle.ts @@ -1,7 +1,7 @@ import { readFileSync, writeFileSync } from "fs"; import { minify } from "terser"; -const DISABLE = true; +const DISABLE = false; writeFileSync("./build/.MANGLED", `${DISABLE}`); if (DISABLE) {