diff --git a/packages/communication/src/index.ts b/packages/communication/src/index.ts index 02a98fc..752a2cb 100644 --- a/packages/communication/src/index.ts +++ b/packages/communication/src/index.ts @@ -22,6 +22,7 @@ export * from './messages/incoming/crafting'; export * from './messages/incoming/desktop'; export * from './messages/incoming/friendlist'; export * from './messages/incoming/furnieditor'; +export * from './messages/incoming/furniture'; export * from './messages/incoming/game'; export * from './messages/incoming/game/directory'; export * from './messages/incoming/game/lobby'; @@ -181,6 +182,7 @@ export * from './messages/parser/crafting'; export * from './messages/parser/desktop'; export * from './messages/parser/friendlist'; export * from './messages/parser/furnieditor'; +export * from './messages/parser/furniture'; export * from './messages/parser/game'; export * from './messages/parser/game/directory'; export * from './messages/parser/game/lobby'; diff --git a/packages/communication/src/messages/incoming/IncomingHeader.ts b/packages/communication/src/messages/incoming/IncomingHeader.ts index 032683f..8cc3b64 100644 --- a/packages/communication/src/messages/incoming/IncomingHeader.ts +++ b/packages/communication/src/messages/incoming/IncomingHeader.ts @@ -493,6 +493,7 @@ export class IncomingHeader public static FURNI_EDITOR_DETAIL_RESULT = 10041; public static FURNI_EDITOR_INTERACTIONS_RESULT = 10043; public static FURNI_EDITOR_RESULT = 10044; + public static FURNITURE_DATA_RELOAD = 10047; // Catalog Admin public static CATALOG_ADMIN_RESULT = 10059; diff --git a/packages/communication/src/messages/incoming/furniture/FurnitureDataReloadEvent.ts b/packages/communication/src/messages/incoming/furniture/FurnitureDataReloadEvent.ts new file mode 100644 index 0000000..a99d7b3 --- /dev/null +++ b/packages/communication/src/messages/incoming/furniture/FurnitureDataReloadEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '@nitrots/api'; +import { MessageEvent } from '@nitrots/events'; +import { FurnitureDataReloadParser } from '../../parser/furniture/FurnitureDataReloadParser'; + +export class FurnitureDataReloadEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, FurnitureDataReloadParser); + } + + public getParser(): FurnitureDataReloadParser + { + return this.parser as FurnitureDataReloadParser; + } +} diff --git a/packages/communication/src/messages/incoming/furniture/index.ts b/packages/communication/src/messages/incoming/furniture/index.ts new file mode 100644 index 0000000..bd1ea9e --- /dev/null +++ b/packages/communication/src/messages/incoming/furniture/index.ts @@ -0,0 +1 @@ +export * from './FurnitureDataReloadEvent'; diff --git a/packages/communication/src/messages/incoming/index.ts b/packages/communication/src/messages/incoming/index.ts index a01ad24..3e12de6 100644 --- a/packages/communication/src/messages/incoming/index.ts +++ b/packages/communication/src/messages/incoming/index.ts @@ -14,6 +14,7 @@ export * from './crafting'; export * from './desktop'; export * from './friendlist'; export * from './furnieditor'; +export * from './furniture'; export * from './game'; export * from './game/directory'; export * from './game/lobby'; diff --git a/packages/communication/src/messages/parser/furniture/FurnitureDataReloadParser.ts b/packages/communication/src/messages/parser/furniture/FurnitureDataReloadParser.ts new file mode 100644 index 0000000..fb5cb05 --- /dev/null +++ b/packages/communication/src/messages/parser/furniture/FurnitureDataReloadParser.ts @@ -0,0 +1,56 @@ +import { IMessageDataWrapper, IMessageParser } from '@nitrots/api'; + +export interface FurnidataDeltaEntry +{ + type: string; // "S" floor | "I" wall + id: number; + classname: string; + name: string; + description: string; +} + +export class FurnitureDataReloadParser implements IMessageParser +{ + private static readonly MAX_ENTRIES = 100000; + + private _mode: number; + private _entries: FurnidataDeltaEntry[]; + + public flush(): boolean + { + this._mode = 0; + this._entries = []; + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + this._mode = wrapper.readInt(); + this._entries = []; + + if(this._mode === 0) + { + let count = wrapper.readInt(); + if(count < 0) count = 0; + if(count > FurnitureDataReloadParser.MAX_ENTRIES) count = FurnitureDataReloadParser.MAX_ENTRIES; + + for(let i = 0; i < count; i++) + { + this._entries.push({ + type: wrapper.readString(), + id: wrapper.readInt(), + classname: wrapper.readString(), + name: wrapper.readString(), + description: wrapper.readString() + }); + } + } + + return true; + } + + public get mode(): number { return this._mode; } + public get entries(): FurnidataDeltaEntry[] { return this._entries; } +} diff --git a/packages/communication/src/messages/parser/furniture/index.ts b/packages/communication/src/messages/parser/furniture/index.ts new file mode 100644 index 0000000..3e010f8 --- /dev/null +++ b/packages/communication/src/messages/parser/furniture/index.ts @@ -0,0 +1 @@ +export * from './FurnitureDataReloadParser'; diff --git a/packages/communication/src/messages/parser/index.ts b/packages/communication/src/messages/parser/index.ts index ccf664c..6cdc929 100644 --- a/packages/communication/src/messages/parser/index.ts +++ b/packages/communication/src/messages/parser/index.ts @@ -13,6 +13,7 @@ export * from './crafting'; export * from './desktop'; export * from './friendlist'; export * from './furnieditor'; +export * from './furniture'; export * from './game'; export * from './game/directory'; export * from './game/lobby';