From ae74c0354d7e8a274053028f75be2507ffd0c092 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 20 Oct 2021 01:19:14 -0400 Subject: [PATCH 1/2] Rename packet --- src/nitro/communication/NitroMessages.ts | 4 ++-- .../{FurnitureState2Event.ts => DiceValueMessageEvent.ts} | 2 +- .../messages/incoming/room/furniture/index.ts | 2 +- src/nitro/room/RoomMessageHandler.ts | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) rename src/nitro/communication/messages/incoming/room/furniture/{FurnitureState2Event.ts => DiceValueMessageEvent.ts} (85%) diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index 6dc528ae..711644c7 100644 --- a/src/nitro/communication/NitroMessages.ts +++ b/src/nitro/communication/NitroMessages.ts @@ -151,6 +151,7 @@ import { RoomUsersWithRightsEvent } from './messages/incoming/room/data/RoomUser import { ObjectsDataUpdateEvent } from './messages/incoming/room/engine/ObjectsDataUpdateEvent'; import { ObjectsRollingEvent } from './messages/incoming/room/engine/ObjectsRollingEvent'; import { RoomCreatedEvent } from './messages/incoming/room/engine/RoomCreatedEvent'; +import { DiceValueMessageEvent } from './messages/incoming/room/furniture/DiceValueMessageEvent'; import { FurnitureFloorAddEvent } from './messages/incoming/room/furniture/floor/FurnitureFloorAddEvent'; import { FurnitureFloorEvent } from './messages/incoming/room/furniture/floor/FurnitureFloorEvent'; import { FurnitureFloorRemoveEvent } from './messages/incoming/room/furniture/floor/FurnitureFloorRemoveEvent'; @@ -160,7 +161,6 @@ import { FurnitureDataEvent } from './messages/incoming/room/furniture/Furniture import { FurnitureItemDataEvent } from './messages/incoming/room/furniture/FurnitureItemDataEvent'; import { FurniturePostItStickyPoleOpenEvent } from './messages/incoming/room/furniture/FurniturePostItStickyPoleOpenEvent'; import { FurnitureStackHeightEvent } from './messages/incoming/room/furniture/FurnitureStackHeightEvent'; -import { FurnitureState2Event } from './messages/incoming/room/furniture/FurnitureState2Event'; import { FurnitureStateEvent } from './messages/incoming/room/furniture/FurnitureStateEvent'; import { GroupFurniContextMenuInfoMessageEvent } from './messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent'; import { LoveLockFurniFinishedEvent } from './messages/incoming/room/furniture/LoveLockFurniFinishedEvent'; @@ -752,7 +752,7 @@ export class NitroMessages implements IMessageConfiguration this._events.set(IncomingHeader.ITEM_STACK_HELPER, FurnitureStackHeightEvent); this._events.set(IncomingHeader.FURNITURE_STATE, FurnitureStateEvent); this._events.set(IncomingHeader.ITEM_DIMMER_SETTINGS, RoomDimmerPresetsEvent); - this._events.set(IncomingHeader.FURNITURE_STATE_2, FurnitureState2Event); + this._events.set(IncomingHeader.FURNITURE_STATE_2, DiceValueMessageEvent); 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); diff --git a/src/nitro/communication/messages/incoming/room/furniture/FurnitureState2Event.ts b/src/nitro/communication/messages/incoming/room/furniture/DiceValueMessageEvent.ts similarity index 85% rename from src/nitro/communication/messages/incoming/room/furniture/FurnitureState2Event.ts rename to src/nitro/communication/messages/incoming/room/furniture/DiceValueMessageEvent.ts index 799edab6..4b331398 100644 --- a/src/nitro/communication/messages/incoming/room/furniture/FurnitureState2Event.ts +++ b/src/nitro/communication/messages/incoming/room/furniture/DiceValueMessageEvent.ts @@ -2,7 +2,7 @@ import { IMessageEvent } from '../../../../../../core/communication/messages/IMe import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent'; import { FurnitureState2Parser } from '../../../parser/room/furniture/FurnitureState2Parser'; -export class FurnitureState2Event extends MessageEvent implements IMessageEvent +export class DiceValueMessageEvent extends MessageEvent implements IMessageEvent { constructor(callBack: Function) { diff --git a/src/nitro/communication/messages/incoming/room/furniture/index.ts b/src/nitro/communication/messages/incoming/room/furniture/index.ts index 83bfaddb..be7d5cb1 100644 --- a/src/nitro/communication/messages/incoming/room/furniture/index.ts +++ b/src/nitro/communication/messages/incoming/room/furniture/index.ts @@ -1,10 +1,10 @@ +export * from './DiceValueMessageEvent'; export * from './floor'; export * from './FurnitureAliasesEvent'; export * from './FurnitureDataEvent'; export * from './FurnitureItemDataEvent'; export * from './FurniturePostItStickyPoleOpenEvent'; export * from './FurnitureStackHeightEvent'; -export * from './FurnitureState2Event'; export * from './FurnitureStateEvent'; export * from './GroupFurniContextMenuInfoMessageEvent'; export * from './LoveLockFurniFinishedEvent'; diff --git a/src/nitro/room/RoomMessageHandler.ts b/src/nitro/room/RoomMessageHandler.ts index 6c81e86a..d7477081 100644 --- a/src/nitro/room/RoomMessageHandler.ts +++ b/src/nitro/room/RoomMessageHandler.ts @@ -5,6 +5,7 @@ import { Vector3d } from '../../room/utils/Vector3d'; import { PetType } from '../avatar/pets/PetType'; import { ObjectsDataUpdateEvent, PetExperienceEvent } from '../communication'; import { ObjectsRollingEvent } from '../communication/messages/incoming/room/engine/ObjectsRollingEvent'; +import { DiceValueMessageEvent } from '../communication/messages/incoming/room/furniture/DiceValueMessageEvent'; import { FurnitureFloorAddEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorAddEvent'; import { FurnitureFloorEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorEvent'; import { FurnitureFloorRemoveEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorRemoveEvent'; @@ -12,7 +13,6 @@ import { FurnitureFloorUpdateEvent } from '../communication/messages/incoming/ro import { FurnitureAliasesEvent } from '../communication/messages/incoming/room/furniture/FurnitureAliasesEvent'; import { FurnitureDataEvent } from '../communication/messages/incoming/room/furniture/FurnitureDataEvent'; import { FurnitureItemDataEvent } from '../communication/messages/incoming/room/furniture/FurnitureItemDataEvent'; -import { FurnitureState2Event } from '../communication/messages/incoming/room/furniture/FurnitureState2Event'; import { FurnitureStateEvent } from '../communication/messages/incoming/room/furniture/FurnitureStateEvent'; import { FurnitureWallAddEvent } from '../communication/messages/incoming/room/furniture/wall/FurnitureWallAddEvent'; import { FurnitureWallEvent } from '../communication/messages/incoming/room/furniture/wall/FurnitureWallEvent'; @@ -144,7 +144,7 @@ export class RoomMessageHandler extends Disposable this._connection.addMessageEvent(new PetFigureUpdateEvent(this.onPetFigureUpdateEvent.bind(this))); this._connection.addMessageEvent(new PetExperienceEvent(this.onPetExperienceEvent.bind(this))); this._connection.addMessageEvent(new YouArePlayingGameEvent(this.onYouArePlayingGameEvent.bind(this))); - this._connection.addMessageEvent(new FurnitureState2Event(this.onFurnitureState2Event.bind(this))); + this._connection.addMessageEvent(new DiceValueMessageEvent(this.onDiceValueMessageEvent.bind(this))); this._connection.addMessageEvent(new IgnoreResultEvent(this.onIgnoreResultEvent.bind(this))); } @@ -645,9 +645,9 @@ export class RoomMessageHandler extends Disposable this._roomCreator.updateRoomObjectFloor(this._currentRoomId, parser.itemId, null, null, parser.state, new LegacyDataType()); } - private onFurnitureState2Event(event: FurnitureState2Event): void + private onDiceValueMessageEvent(event: DiceValueMessageEvent): void { - if(!(event instanceof FurnitureState2Event) || !event.connection || !this._roomCreator) return; + if(!(event instanceof DiceValueMessageEvent) || !event.connection || !this._roomCreator) return; const parser = event.getParser(); From 595f39f9bf301986585b6c7ceacc99bc7a9410a1 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 20 Oct 2021 01:19:43 -0400 Subject: [PATCH 2/2] Update color converter --- src/room/utils/ColorConverter.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/room/utils/ColorConverter.ts b/src/room/utils/ColorConverter.ts index 2c86a4dd..88c80b68 100644 --- a/src/room/utils/ColorConverter.ts +++ b/src/room/utils/ColorConverter.ts @@ -14,11 +14,26 @@ export class ColorConverter return out; } + public static hex2rgba(hex: number, out: Array | Float32Array = []): Array | Float32Array + { + out[0] = ((hex >> 16) & 0xFF) / 255; + out[1] = ((hex >> 8) & 0xFF) / 255; + out[2] = (hex & 0xFF) / 255; + out[3] = (hex & 0xFF); + + return out; + } + public static rgb2hex(rgb: number[] | Float32Array): number { return (((rgb[0] * 255) << 16) + ((rgb[1] * 255) << 8) + (rgb[2] * 255 | 0)); } + public static rgba2hex(rgb: number[] | Float32Array): number + { + return (((rgb[0] * 255) << 16) + ((rgb[1] * 255) << 8) + (rgb[2] * 255 | 0) + (rgb[3] | 0)); + } + public static rgbStringToHex(rgb: string): string { const extracted = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);