From f561b91e2fc17120d75b37bdc93f9fb6966186d0 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 5 Jun 2021 23:48:44 -0400 Subject: [PATCH] Update packets --- src/nitro/communication/NitroMessages.ts | 3 +- .../messages/incoming/IncomingHeader.ts | 1 + .../incoming/room/engine/ObjectData.ts | 30 ++++++++++++++ .../room/engine/ObjectsDataUpdateEvent.ts | 16 ++++++++ .../messages/incoming/room/engine/index.ts | 2 + .../room/engine/ObjectsDataUpdateParser.ts | 41 +++++++++++++++++++ .../room/engine/ObjectsRollingParser.ts | 4 +- .../parser/room/engine/RoomCreatedParser.ts | 4 +- .../messages/parser/room/engine/index.ts | 1 + .../subscription/UserSubscriptionParser.ts | 23 ++++++----- src/nitro/room/RoomMessageHandler.ts | 16 ++++++++ 11 files changed, 125 insertions(+), 16 deletions(-) create mode 100644 src/nitro/communication/messages/incoming/room/engine/ObjectData.ts create mode 100644 src/nitro/communication/messages/incoming/room/engine/ObjectsDataUpdateEvent.ts create mode 100644 src/nitro/communication/messages/parser/room/engine/ObjectsDataUpdateParser.ts diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index 54ad2d5e..0d71f390 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 { ApproveNameMessageComposer, CatalogApproveNameResultEvent, SellablePetPalettesEvent } from './messages'; +import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, ObjectsDataUpdateEvent, SellablePetPalettesEvent } from './messages'; import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent'; import { ChangeNameUpdateEvent } from './messages/incoming/avatar/ChangeNameUpdateEvent'; import { CatalogClubEvent } from './messages/incoming/catalog/CatalogClubEvent'; @@ -593,6 +593,7 @@ export class NitroMessages implements IMessageConfiguration this._events.set(IncomingHeader.LOVELOCK_FURNI_FINISHED, LoveLockFurniFinishedEvent); this._events.set(IncomingHeader.LOVELOCK_FURNI_FRIEND_COMFIRMED, LoveLockFurniFriendConfirmedEvent); this._events.set(IncomingHeader.LOVELOCK_FURNI_START, LoveLockFurniStartEvent); + this._events.set(IncomingHeader.OBJECTS_DATA_UPDATE, ObjectsDataUpdateEvent); // FLOOR this._events.set(IncomingHeader.FURNITURE_FLOOR_ADD, FurnitureFloorAddEvent); diff --git a/src/nitro/communication/messages/incoming/IncomingHeader.ts b/src/nitro/communication/messages/incoming/IncomingHeader.ts index 35522812..fac838bb 100644 --- a/src/nitro/communication/messages/incoming/IncomingHeader.ts +++ b/src/nitro/communication/messages/incoming/IncomingHeader.ts @@ -247,4 +247,5 @@ export class IncomingHeader public static MARKETPLACE_AFTER_ORDER_STATUS = 2032; public static CATALOG_RECEIVE_PET_BREEDS = 3331; public static CATALOG_APPROVE_NAME_RESULT = 1503; + public static OBJECTS_DATA_UPDATE = 1453; } diff --git a/src/nitro/communication/messages/incoming/room/engine/ObjectData.ts b/src/nitro/communication/messages/incoming/room/engine/ObjectData.ts new file mode 100644 index 00000000..64a6fe46 --- /dev/null +++ b/src/nitro/communication/messages/incoming/room/engine/ObjectData.ts @@ -0,0 +1,30 @@ +import { IObjectData } from '../../../../../room'; + +export class ObjectData +{ + private _id: number = 0; + private _state: number = 0; + private _data: IObjectData; + + constructor(id: number, state: number, objectData: IObjectData) + { + this._id = id; + this._state = state; + this._data = objectData; + } + + public get id(): number + { + return this._id; + } + + public get state(): number + { + return this._state; + } + + public get data(): IObjectData + { + return this._data; + } +} diff --git a/src/nitro/communication/messages/incoming/room/engine/ObjectsDataUpdateEvent.ts b/src/nitro/communication/messages/incoming/room/engine/ObjectsDataUpdateEvent.ts new file mode 100644 index 00000000..2a6035a2 --- /dev/null +++ b/src/nitro/communication/messages/incoming/room/engine/ObjectsDataUpdateEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent'; +import { ObjectsDataUpdateParser } from '../../../parser/room/engine/ObjectsDataUpdateParser'; + +export class ObjectsDataUpdateEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, ObjectsDataUpdateParser); + } + + public getParser(): ObjectsDataUpdateParser + { + return this.parser as ObjectsDataUpdateParser; + } +} diff --git a/src/nitro/communication/messages/incoming/room/engine/index.ts b/src/nitro/communication/messages/incoming/room/engine/index.ts index efa236d4..efc44418 100644 --- a/src/nitro/communication/messages/incoming/room/engine/index.ts +++ b/src/nitro/communication/messages/incoming/room/engine/index.ts @@ -1,2 +1,4 @@ +export * from './ObjectData'; +export * from './ObjectsDataUpdateEvent'; export * from './ObjectsRollingEvent'; export * from './RoomCreatedEvent'; diff --git a/src/nitro/communication/messages/parser/room/engine/ObjectsDataUpdateParser.ts b/src/nitro/communication/messages/parser/room/engine/ObjectsDataUpdateParser.ts new file mode 100644 index 00000000..2fc9ce0c --- /dev/null +++ b/src/nitro/communication/messages/parser/room/engine/ObjectsDataUpdateParser.ts @@ -0,0 +1,41 @@ +import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../../core/communication/messages/IMessageParser'; +import { ObjectData } from '../../../incoming/room/engine/ObjectData'; +import { FurnitureDataParser } from '../furniture/FurnitureDataParser'; + +export class ObjectsDataUpdateParser implements IMessageParser +{ + private _objects: ObjectData[]; + + public flush(): boolean + { + this._objects = []; + + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + let totalObjects = wrapper.readInt(); + + while(totalObjects > 0) + { + const id = wrapper.readInt(); + const stuffData = FurnitureDataParser.parseObjectData(wrapper); + const state = parseFloat(stuffData.getLegacyString()); + + this._objects.push(new ObjectData(id, state, stuffData)); + + totalObjects--; + } + + return true; + } + + public get objects(): ObjectData[] + { + return this._objects; + } +} diff --git a/src/nitro/communication/messages/parser/room/engine/ObjectsRollingParser.ts b/src/nitro/communication/messages/parser/room/engine/ObjectsRollingParser.ts index 4e971c31..925b4f95 100644 --- a/src/nitro/communication/messages/parser/room/engine/ObjectsRollingParser.ts +++ b/src/nitro/communication/messages/parser/room/engine/ObjectsRollingParser.ts @@ -21,7 +21,7 @@ export class ObjectsRollingParser implements IMessageParser public parse(wrapper: IMessageDataWrapper): boolean { - if(!wrapper) return; + if(!wrapper) return false; const x = wrapper.readInt(); const y = wrapper.readInt(); @@ -79,4 +79,4 @@ export class ObjectsRollingParser implements IMessageParser { return this._unitRolling; } -} \ No newline at end of file +} diff --git a/src/nitro/communication/messages/parser/room/engine/RoomCreatedParser.ts b/src/nitro/communication/messages/parser/room/engine/RoomCreatedParser.ts index 4e14ece8..7b524d74 100644 --- a/src/nitro/communication/messages/parser/room/engine/RoomCreatedParser.ts +++ b/src/nitro/communication/messages/parser/room/engine/RoomCreatedParser.ts @@ -16,7 +16,7 @@ export class RoomCreatedParser implements IMessageParser public parse(wrapper: IMessageDataWrapper): boolean { - if(!wrapper) return; + if(!wrapper) return false; this._roomId = wrapper.readInt(); this._roomName = wrapper.readString(); @@ -33,4 +33,4 @@ export class RoomCreatedParser implements IMessageParser { return this._roomName; } -} \ No newline at end of file +} diff --git a/src/nitro/communication/messages/parser/room/engine/index.ts b/src/nitro/communication/messages/parser/room/engine/index.ts index faa96179..775700d3 100644 --- a/src/nitro/communication/messages/parser/room/engine/index.ts +++ b/src/nitro/communication/messages/parser/room/engine/index.ts @@ -1,2 +1,3 @@ +export * from './ObjectsDataUpdateParser'; export * from './ObjectsRollingParser'; export * from './RoomCreatedParser'; diff --git a/src/nitro/communication/messages/parser/user/inventory/subscription/UserSubscriptionParser.ts b/src/nitro/communication/messages/parser/user/inventory/subscription/UserSubscriptionParser.ts index 9d9cdcf2..f47ab7af 100644 --- a/src/nitro/communication/messages/parser/user/inventory/subscription/UserSubscriptionParser.ts +++ b/src/nitro/communication/messages/parser/user/inventory/subscription/UserSubscriptionParser.ts @@ -18,16 +18,16 @@ export class UserSubscriptionParser implements IMessageParser public flush(): boolean { - this._name = null; - this._days = 0; - this._int1 = 0; - this._months = 0; - this._years = 0; - this._hasEverBeenMember = false; - this._isVip = false; - this._pastClubDays = 0; - this._pastVIPDays = 0; - this._totalSeconds = 0; + this._name = null; + this._days = 0; + this._int1 = 0; + this._months = 0; + this._years = 0; + this._hasEverBeenMember = false; + this._isVip = false; + this._pastClubDays = 0; + this._pastVIPDays = 0; + this._totalSeconds = 0; return true; } @@ -45,7 +45,8 @@ export class UserSubscriptionParser implements IMessageParser this._isVip = wrapper.readBoolean(); this._pastClubDays = wrapper.readInt(); this._pastVIPDays = wrapper.readInt(); - this._totalSeconds = wrapper.readInt(); + + if(wrapper.bytesAvailable) this._totalSeconds = wrapper.readInt(); return true; } diff --git a/src/nitro/room/RoomMessageHandler.ts b/src/nitro/room/RoomMessageHandler.ts index f04469aa..8cc609dd 100644 --- a/src/nitro/room/RoomMessageHandler.ts +++ b/src/nitro/room/RoomMessageHandler.ts @@ -3,6 +3,7 @@ import { IConnection } from '../../core/communication/connections/IConnection'; import { IVector3D } from '../../room/utils/IVector3D'; import { Vector3d } from '../../room/utils/Vector3d'; import { PetType } from '../avatar/pets/PetType'; +import { ObjectsDataUpdateEvent } from '../communication'; import { ObjectsRollingEvent } from '../communication/messages/incoming/room/engine/ObjectsRollingEvent'; import { FurnitureFloorAddEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorAddEvent'; import { FurnitureFloorEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorEvent'; @@ -113,6 +114,7 @@ export class RoomMessageHandler extends Disposable this._connection.addMessageEvent(new RoomThicknessEvent(this.onRoomThicknessEvent.bind(this))); this._connection.addMessageEvent(new RoomDoorEvent(this.onRoomDoorEvent.bind(this))); this._connection.addMessageEvent(new ObjectsRollingEvent(this.onRoomRollingEvent.bind(this))); + this._connection.addMessageEvent(new ObjectsDataUpdateEvent(this.onObjectsDataUpdateEvent.bind(this))); this._connection.addMessageEvent(new FurnitureAliasesEvent(this.onFurnitureAliasesEvent.bind(this))); this._connection.addMessageEvent(new FurnitureFloorAddEvent(this.onFurnitureFloorAddEvent.bind(this))); this._connection.addMessageEvent(new FurnitureFloorEvent(this.onFurnitureFloorEvent.bind(this))); @@ -459,6 +461,20 @@ export class RoomMessageHandler extends Disposable } } + private onObjectsDataUpdateEvent(event: ObjectsDataUpdateEvent): void + { + if(!(event instanceof ObjectsDataUpdateEvent) || !event.connection || !this._roomCreator) return; + + const parser = event.getParser(); + + if(!parser) return; + + for(const object of parser.objects) + { + this._roomCreator.updateRoomObjectFloor(this._currentRoomId, object.id, null, null, object.state, object.data); + } + } + private onFurnitureAliasesEvent(event: FurnitureAliasesEvent): void { if(!(event instanceof FurnitureAliasesEvent) || !event.connection || !this._roomCreator) return;