From 1e8ccf0fd3c99f964fdb2f78377d2d7afd71d8ef Mon Sep 17 00:00:00 2001 From: Bill Date: Sun, 22 Aug 2021 18:37:49 -0400 Subject: [PATCH] Add avatar packets --- src/nitro/communication/NitroMessages.ts | 7 +-- .../messages/incoming/IncomingHeader.ts | 1 + .../ChangeUserNameResultMessageEvent.ts | 24 ++++----- .../avatar/CheckUserNameResultMessageEvent.ts | 16 ++++++ .../incoming/avatar/FigureUpdateEvent.ts | 16 ++++++ .../messages/incoming/avatar/OutfitData.ts | 30 +++++++++++ .../incoming/avatar/WardrobeMessageEvent.ts | 16 ++++++ .../messages/incoming/avatar/index.ts | 4 ++ .../incoming/user/data/UserFigureEvent.ts | 16 ------ .../ChangeUserNameResultMessageParser.ts | 52 +++++++++++++++++++ ...ts => CheckUserNameResultMessageParser.ts} | 6 +-- .../parser/avatar/FigureUpdateParser.ts | 38 ++++++++++++++ .../parser/avatar/WardrobeMessageParser.ts | 45 ++++++++++++++++ .../messages/parser/avatar/index.ts | 5 +- 14 files changed, 241 insertions(+), 35 deletions(-) create mode 100644 src/nitro/communication/messages/incoming/avatar/CheckUserNameResultMessageEvent.ts create mode 100644 src/nitro/communication/messages/incoming/avatar/FigureUpdateEvent.ts create mode 100644 src/nitro/communication/messages/incoming/avatar/OutfitData.ts create mode 100644 src/nitro/communication/messages/incoming/avatar/WardrobeMessageEvent.ts delete mode 100644 src/nitro/communication/messages/incoming/user/data/UserFigureEvent.ts create mode 100644 src/nitro/communication/messages/parser/avatar/ChangeUserNameResultMessageParser.ts rename src/nitro/communication/messages/parser/avatar/{ChangeNameUpdateParser.ts => CheckUserNameResultMessageParser.ts} (90%) create mode 100644 src/nitro/communication/messages/parser/avatar/FigureUpdateParser.ts create mode 100644 src/nitro/communication/messages/parser/avatar/WardrobeMessageParser.ts diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index 6991273d..f1bafbdf 100644 --- a/src/nitro/communication/NitroMessages.ts +++ b/src/nitro/communication/NitroMessages.ts @@ -1,5 +1,5 @@ import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration'; -import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, AddJukeboxDiskComposer, ApproveNameMessageComposer, AvailabilityTimeMessageEvent, BadgeReceivedEvent, BonusRareInfoMessageEvent, CatalogApproveNameResultEvent, ChangeUserNameResultMessageEvent, ClubGiftNotificationEvent, FurnitureGuildInfoComposer, GetBonusRareInfoMessageComposer, GetJukeboxPlayListMessageComposer, GetNowPlayingMessageComposer, GetOfficialSongIdMessageComposer, GetSongInfoMessageComposer, GetSoundMachinePlayListMessageComposer, GetUserSongDisksMessageComposer, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, InterstitialMessageEvent, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, MaintenanceStatusMessageEvent, MysteryBoxKeysEvent, NowPlayingMessageEvent, OfficialSongIdMessageEvent, PetExperienceEvent, PetMountComposer, PetSupplementComposer, PlayListMessageEvent, PlayListSongAddedMessageEvent, RemoveAllRightsMessageComposer, RemoveJukeboxDiskComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, RoomAdErrorEvent, RoomUnitGiveHandItemPetComposer, SellablePetPalettesEvent, TogglePetBreedingComposer, TogglePetRidingComposer, TraxSongInfoMessageEvent, UnseenResetCategoryComposer, UnseenResetItemsComposer, UsePetProductComposer, UserSongDisksInventoryMessageEvent } from './messages'; +import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, AddJukeboxDiskComposer, ApproveNameMessageComposer, AvailabilityTimeMessageEvent, BadgeReceivedEvent, BonusRareInfoMessageEvent, CatalogApproveNameResultEvent, ChangeUserNameResultMessageEvent, CheckUserNameResultMessageEvent, ClubGiftNotificationEvent, FigureUpdateEvent, FurnitureGuildInfoComposer, GetBonusRareInfoMessageComposer, GetJukeboxPlayListMessageComposer, GetNowPlayingMessageComposer, GetOfficialSongIdMessageComposer, GetSongInfoMessageComposer, GetSoundMachinePlayListMessageComposer, GetUserSongDisksMessageComposer, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, InterstitialMessageEvent, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, MaintenanceStatusMessageEvent, MysteryBoxKeysEvent, NowPlayingMessageEvent, OfficialSongIdMessageEvent, PetExperienceEvent, PetMountComposer, PetSupplementComposer, PlayListMessageEvent, PlayListSongAddedMessageEvent, RemoveAllRightsMessageComposer, RemoveJukeboxDiskComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, RoomAdErrorEvent, RoomUnitGiveHandItemPetComposer, SellablePetPalettesEvent, TogglePetBreedingComposer, TogglePetRidingComposer, TraxSongInfoMessageEvent, UnseenResetCategoryComposer, UnseenResetItemsComposer, UsePetProductComposer, UserSongDisksInventoryMessageEvent, WardrobeMessageEvent } from './messages'; import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent'; import { CameraPublishStatusMessageEvent } from './messages/incoming/camera/CameraPublishStatusMessageEvent'; import { CameraPurchaseOKMessageEvent } from './messages/incoming/camera/CameraPurchaseOKMessageEvent'; @@ -214,7 +214,6 @@ import { UserPerksEvent } from './messages/incoming/user/access/UserPerksEvent'; import { UserPermissionsEvent } from './messages/incoming/user/access/UserPermissionsEvent'; import { RelationshipStatusInfoEvent } from './messages/incoming/user/data/RelationshipStatusInfoEvent'; import { UserCurrentBadgesEvent } from './messages/incoming/user/data/UserCurrentBadgesEvent'; -import { UserFigureEvent } from './messages/incoming/user/data/UserFigureEvent'; import { UserInfoEvent } from './messages/incoming/user/data/UserInfoEvent'; import { UserNameChangeMessageEvent } from './messages/incoming/user/data/UserNameChangeMessageEvent'; import { UserProfileEvent } from './messages/incoming/user/data/UserProfileEvent'; @@ -490,6 +489,9 @@ export class NitroMessages implements IMessageConfiguration // AVATAR this._events.set(IncomingHeader.USER_CHANGE_NAME, ChangeUserNameResultMessageEvent); + this._events.set(IncomingHeader.CHECK_USER_NAME, CheckUserNameResultMessageEvent); + this._events.set(IncomingHeader.USER_FIGURE, FigureUpdateEvent); + this._events.set(IncomingHeader.USER_OUTFITS, WardrobeMessageEvent); // CATALOG this._events.set(IncomingHeader.CATALOG_CLUB, CatalogClubEvent); @@ -744,7 +746,6 @@ export class NitroMessages implements IMessageConfiguration // DATA this._events.set(IncomingHeader.USER_BADGES_CURRENT, UserCurrentBadgesEvent); - this._events.set(IncomingHeader.USER_FIGURE, UserFigureEvent); this._events.set(IncomingHeader.USER_INFO, UserInfoEvent); this._events.set(IncomingHeader.UNIT_CHANGE_NAME, UserNameChangeMessageEvent); this._events.set(IncomingHeader.USER_SETTINGS, UserSettingsEvent); diff --git a/src/nitro/communication/messages/incoming/IncomingHeader.ts b/src/nitro/communication/messages/incoming/IncomingHeader.ts index d8689ada..56d16e90 100644 --- a/src/nitro/communication/messages/incoming/IncomingHeader.ts +++ b/src/nitro/communication/messages/incoming/IncomingHeader.ts @@ -288,4 +288,5 @@ export class IncomingHeader public static PLAYLIST_SONG_ADDED = 1140; public static TRAX_SONG_INFO = 3365; public static USER_SONG_DISKS_INVENTORY = 2602; + public static CHECK_USER_NAME = 563; } diff --git a/src/nitro/communication/messages/incoming/avatar/ChangeUserNameResultMessageEvent.ts b/src/nitro/communication/messages/incoming/avatar/ChangeUserNameResultMessageEvent.ts index 297b8b21..d75817fa 100644 --- a/src/nitro/communication/messages/incoming/avatar/ChangeUserNameResultMessageEvent.ts +++ b/src/nitro/communication/messages/incoming/avatar/ChangeUserNameResultMessageEvent.ts @@ -1,25 +1,25 @@ import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; -import { ChangeNameUpdateParser } from '../../parser/avatar/ChangeNameUpdateParser'; +import { ChangeUserNameResultMessageParser } from '../../parser/avatar/ChangeUserNameResultMessageParser'; export class ChangeUserNameResultMessageEvent extends MessageEvent implements IMessageEvent { - public static NAME_OK: number = 0; - public static ERROR_NAME_REQUIRED: number = 1; - public static ERROR_NAME_TOO_SHORT: number = 2; - public static ERROR_NAME_TOO_LONG: number = 3; - public static ERROR_NAME_NOT_VALID: number = 4; - public static ERROR_NAME_IN_USE: number = 5; - public static ERROR_NAME_CHANGE_NOT_ALLOWED: number = 6; - public static ERROR_MERGE_HOTEL_DOWN: number = 7; + public static NAME_OK: number = 0; + public static ERROR_NAME_REQUIRED: number = 1; + public static ERROR_NAME_TOO_SHORT: number = 2; + public static ERROR_NAME_TOO_LONG: number = 3; + public static ERROR_NAME_NOT_VALID: number = 4; + public static ERROR_NAME_IN_USE: number = 5; + public static ERROR_NAME_CHANGE_NOT_ALLOWED: number = 6; + public static ERROR_MERGE_HOTEL_DOWN: number = 7; constructor(callBack: Function) { - super(callBack, ChangeNameUpdateParser); + super(callBack, ChangeUserNameResultMessageParser); } - public getParser(): ChangeNameUpdateParser + public getParser(): ChangeUserNameResultMessageParser { - return this.parser as ChangeNameUpdateParser; + return this.parser as ChangeUserNameResultMessageParser; } } diff --git a/src/nitro/communication/messages/incoming/avatar/CheckUserNameResultMessageEvent.ts b/src/nitro/communication/messages/incoming/avatar/CheckUserNameResultMessageEvent.ts new file mode 100644 index 00000000..598f5a47 --- /dev/null +++ b/src/nitro/communication/messages/incoming/avatar/CheckUserNameResultMessageEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { CheckUserNameResultMessageParser } from '../../parser/avatar/CheckUserNameResultMessageParser'; + +export class CheckUserNameResultMessageEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, CheckUserNameResultMessageParser); + } + + public getParser(): CheckUserNameResultMessageParser + { + return this.parser as CheckUserNameResultMessageParser; + } +} diff --git a/src/nitro/communication/messages/incoming/avatar/FigureUpdateEvent.ts b/src/nitro/communication/messages/incoming/avatar/FigureUpdateEvent.ts new file mode 100644 index 00000000..876cea76 --- /dev/null +++ b/src/nitro/communication/messages/incoming/avatar/FigureUpdateEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { FigureUpdateParser } from '../../parser'; + +export class FigureUpdateEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, FigureUpdateParser); + } + + public getParser(): FigureUpdateParser + { + return this.parser as FigureUpdateParser; + } +} diff --git a/src/nitro/communication/messages/incoming/avatar/OutfitData.ts b/src/nitro/communication/messages/incoming/avatar/OutfitData.ts new file mode 100644 index 00000000..9c29c36c --- /dev/null +++ b/src/nitro/communication/messages/incoming/avatar/OutfitData.ts @@ -0,0 +1,30 @@ +import { IMessageDataWrapper } from '../../../../../core'; + +export class OutfitData +{ + private _slotId: number; + private _figureString: string; + private _gender: string; + + constructor(wrapper: IMessageDataWrapper) + { + this._slotId = wrapper.readInt(); + this._figureString = wrapper.readString(); + this._gender = wrapper.readString(); + } + + public get slotId(): number + { + return this._slotId; + } + + public get figureString(): string + { + return this._figureString; + } + + public get gender(): string + { + return this._gender; + } +} diff --git a/src/nitro/communication/messages/incoming/avatar/WardrobeMessageEvent.ts b/src/nitro/communication/messages/incoming/avatar/WardrobeMessageEvent.ts new file mode 100644 index 00000000..511aadcc --- /dev/null +++ b/src/nitro/communication/messages/incoming/avatar/WardrobeMessageEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { WardrobeMessageParser } from '../../parser'; + +export class WardrobeMessageEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, WardrobeMessageParser); + } + + public getParser(): WardrobeMessageParser + { + return this.parser as WardrobeMessageParser; + } +} diff --git a/src/nitro/communication/messages/incoming/avatar/index.ts b/src/nitro/communication/messages/incoming/avatar/index.ts index 53faf063..0c23b82c 100644 --- a/src/nitro/communication/messages/incoming/avatar/index.ts +++ b/src/nitro/communication/messages/incoming/avatar/index.ts @@ -1 +1,5 @@ export * from './ChangeUserNameResultMessageEvent'; +export * from './CheckUserNameResultMessageEvent'; +export * from './FigureUpdateEvent'; +export * from './OutfitData'; +export * from './WardrobeMessageEvent'; diff --git a/src/nitro/communication/messages/incoming/user/data/UserFigureEvent.ts b/src/nitro/communication/messages/incoming/user/data/UserFigureEvent.ts deleted file mode 100644 index 1bfbd732..00000000 --- a/src/nitro/communication/messages/incoming/user/data/UserFigureEvent.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent'; -import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent'; -import { UserFigureParser } from '../../../parser/user/data/UserFigureParser'; - -export class UserFigureEvent extends MessageEvent implements IMessageEvent -{ - constructor(callBack: Function) - { - super(callBack, UserFigureParser); - } - - public getParser(): UserFigureParser - { - return this.parser as UserFigureParser; - } -} \ No newline at end of file diff --git a/src/nitro/communication/messages/parser/avatar/ChangeUserNameResultMessageParser.ts b/src/nitro/communication/messages/parser/avatar/ChangeUserNameResultMessageParser.ts new file mode 100644 index 00000000..15a8bb19 --- /dev/null +++ b/src/nitro/communication/messages/parser/avatar/ChangeUserNameResultMessageParser.ts @@ -0,0 +1,52 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; + +export class ChangeUserNameResultMessageParser implements IMessageParser +{ + private _resultCode: number; + private _name: string; + private _nameSuggestions: string[]; + + public flush(): boolean + { + this._resultCode = -1; + this._name = ''; + this._nameSuggestions = []; + + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + this._resultCode = wrapper.readInt(); + this._name = wrapper.readString(); + + let totalSuggestions = wrapper.readInt(); + + while(totalSuggestions > 0) + { + this._nameSuggestions.push(wrapper.readString()); + + totalSuggestions--; + } + + return true; + } + + public get resultCode(): number + { + return this._resultCode; + } + + public get name(): string + { + return this._name; + } + + public get nameSuggestions(): string[] + { + return this._nameSuggestions; + } +} diff --git a/src/nitro/communication/messages/parser/avatar/ChangeNameUpdateParser.ts b/src/nitro/communication/messages/parser/avatar/CheckUserNameResultMessageParser.ts similarity index 90% rename from src/nitro/communication/messages/parser/avatar/ChangeNameUpdateParser.ts rename to src/nitro/communication/messages/parser/avatar/CheckUserNameResultMessageParser.ts index 1624c314..727f1efc 100644 --- a/src/nitro/communication/messages/parser/avatar/ChangeNameUpdateParser.ts +++ b/src/nitro/communication/messages/parser/avatar/CheckUserNameResultMessageParser.ts @@ -1,11 +1,11 @@ import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; -export class ChangeNameUpdateParser implements IMessageParser +export class CheckUserNameResultMessageParser implements IMessageParser { private _resultCode: number; private _name: string; - private _nameSuggestions; + private _nameSuggestions: string[]; public flush(): boolean { @@ -49,4 +49,4 @@ export class ChangeNameUpdateParser implements IMessageParser { return this._nameSuggestions; } -} \ No newline at end of file +} diff --git a/src/nitro/communication/messages/parser/avatar/FigureUpdateParser.ts b/src/nitro/communication/messages/parser/avatar/FigureUpdateParser.ts new file mode 100644 index 00000000..da40ecd3 --- /dev/null +++ b/src/nitro/communication/messages/parser/avatar/FigureUpdateParser.ts @@ -0,0 +1,38 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; + +export class FigureUpdateParser implements IMessageParser +{ + private _figure: string; + private _gender: string; + + public flush(): boolean + { + this._figure = ''; + this._gender = ''; + + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + this._figure = wrapper.readString(); + this._gender = wrapper.readString(); + + if(this._gender) this._gender = this._gender.toUpperCase(); + + return true; + } + + public get figure(): string + { + return this._figure; + } + + public get gender(): string + { + return this._gender; + } +} diff --git a/src/nitro/communication/messages/parser/avatar/WardrobeMessageParser.ts b/src/nitro/communication/messages/parser/avatar/WardrobeMessageParser.ts new file mode 100644 index 00000000..710318e9 --- /dev/null +++ b/src/nitro/communication/messages/parser/avatar/WardrobeMessageParser.ts @@ -0,0 +1,45 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; +import { OutfitData } from '../../incoming'; + +export class WardrobeMessageParser implements IMessageParser +{ + private _state: number; + private _outfits: OutfitData[]; + + public flush(): boolean + { + this._state = 0; + this._outfits = []; + + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + this._state = wrapper.readInt(); + + let count = wrapper.readInt(); + + while(count > 0) + { + this._outfits.push(new OutfitData(wrapper)); + + count--; + } + + return true; + } + + public get state(): number + { + return this._state; + } + + public get outfits(): OutfitData[] + { + return this._outfits; + } +} diff --git a/src/nitro/communication/messages/parser/avatar/index.ts b/src/nitro/communication/messages/parser/avatar/index.ts index bd135d97..fa085295 100644 --- a/src/nitro/communication/messages/parser/avatar/index.ts +++ b/src/nitro/communication/messages/parser/avatar/index.ts @@ -1 +1,4 @@ -export * from './ChangeNameUpdateParser'; +export * from './ChangeUserNameResultMessageParser'; +export * from './CheckUserNameResultMessageParser'; +export * from './FigureUpdateParser'; +export * from './WardrobeMessageParser';