Eslint --fix

This commit is contained in:
Bill 2022-07-24 23:17:40 -04:00
parent bd75d42271
commit e1f1b22a1f
21 changed files with 1244 additions and 1243 deletions

View File

@ -34,33 +34,33 @@ export class AssetManager extends Disposable implements IAssetManager
public getTexture(name: string): Texture<Resource> public getTexture(name: string): Texture<Resource>
{ {
if (!name) return null; if(!name) return null;
const existing = this._textures.get(name); const existing = this._textures.get(name);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public setTexture(name: string, texture: Texture<Resource>): void public setTexture(name: string, texture: Texture<Resource>): void
{ {
if (!name || !texture) return; if(!name || !texture) return;
this._textures.set(name, texture); this._textures.set(name, texture);
} }
public getAsset(name: string): IGraphicAsset public getAsset(name: string): IGraphicAsset
{ {
if (!name) return null; if(!name) return null;
for (const collection of this._collections.values()) for(const collection of this._collections.values())
{ {
if (!collection) continue; if(!collection) continue;
const existing = collection.getAsset(name); const existing = collection.getAsset(name);
if (!existing) continue; if(!existing) continue;
return existing; return existing;
} }
@ -70,24 +70,24 @@ export class AssetManager extends Disposable implements IAssetManager
public getCollection(name: string): IGraphicAssetCollection public getCollection(name: string): IGraphicAssetCollection
{ {
if (!name) return null; if(!name) return null;
const existing = this._collections.get(name); const existing = this._collections.get(name);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public createCollection(data: IAssetData, spritesheet: Spritesheet): IGraphicAssetCollection public createCollection(data: IAssetData, spritesheet: Spritesheet): IGraphicAssetCollection
{ {
if (!data) return null; if(!data) return null;
const collection = new GraphicAssetCollection(data, spritesheet); const collection = new GraphicAssetCollection(data, spritesheet);
if (collection) if(collection)
{ {
for (const [name, texture] of collection.textures.entries()) this.setTexture(name, texture); for(const [name, texture] of collection.textures.entries()) this.setTexture(name, texture);
this._collections.set(collection.name, collection); this._collections.set(collection.name, collection);
} }
@ -102,7 +102,7 @@ export class AssetManager extends Disposable implements IAssetManager
public downloadAssets(assetUrls: string[], cb: (status: boolean) => void): void public downloadAssets(assetUrls: string[], cb: (status: boolean) => void): void
{ {
if (!assetUrls || !assetUrls.length) if(!assetUrls || !assetUrls.length)
{ {
cb(true); cb(true);
@ -111,9 +111,9 @@ export class AssetManager extends Disposable implements IAssetManager
const loader = new Loader(); const loader = new Loader();
for (const url of assetUrls) for(const url of assetUrls)
{ {
if (!url) continue; if(!url) continue;
loader loader
.add({ .add({
@ -128,7 +128,7 @@ export class AssetManager extends Disposable implements IAssetManager
const onDownloaded = (status: boolean, url: string) => const onDownloaded = (status: boolean, url: string) =>
{ {
if (!status) if(!status)
{ {
this._logger.error('Failed to download asset', url); this._logger.error('Failed to download asset', url);
@ -141,7 +141,7 @@ export class AssetManager extends Disposable implements IAssetManager
remaining--; remaining--;
if (!remaining) if(!remaining)
{ {
loader.destroy(); loader.destroy();
@ -153,11 +153,11 @@ export class AssetManager extends Disposable implements IAssetManager
loader.load((loader, resources) => loader.load((loader, resources) =>
{ {
for (const key in resources) for(const key in resources)
{ {
const resource = resources[key]; const resource = resources[key];
if (!resource || resource.error || !resource.xhr) if(!resource || resource.error || !resource.xhr)
{ {
onDownloaded(false, resource.url); onDownloaded(false, resource.url);
@ -166,7 +166,7 @@ export class AssetManager extends Disposable implements IAssetManager
const resourceType = (resource.xhr.getResponseHeader('Content-Type') || 'application/octet-stream'); const resourceType = (resource.xhr.getResponseHeader('Content-Type') || 'application/octet-stream');
if (resourceType === 'application/octet-stream') if(resourceType === 'application/octet-stream')
{ {
const nitroBundle = new NitroBundle(resource.data); const nitroBundle = new NitroBundle(resource.data);
@ -178,12 +178,12 @@ export class AssetManager extends Disposable implements IAssetManager
continue; continue;
} }
if ((resourceType === 'image/png') || (resourceType === 'image/jpeg') || (resourceType === 'image/gif')) if((resourceType === 'image/png') || (resourceType === 'image/jpeg') || (resourceType === 'image/gif'))
{ {
const base64 = ArrayBufferToBase64(resource.data); const base64 = ArrayBufferToBase64(resource.data);
const baseTexture = new BaseTexture(`data:${resourceType};base64,${base64}`); const baseTexture = new BaseTexture(`data:${resourceType};base64,${base64}`);
if (baseTexture.valid) if(baseTexture.valid)
{ {
const texture = new Texture(baseTexture); const texture = new Texture(baseTexture);
@ -215,7 +215,7 @@ export class AssetManager extends Disposable implements IAssetManager
{ {
const spritesheetData = data.spritesheet; const spritesheetData = data.spritesheet;
if (!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length) if(!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length)
{ {
this.createCollection(data, null); this.createCollection(data, null);
@ -236,7 +236,7 @@ export class AssetManager extends Disposable implements IAssetManager
}); });
}; };
if (baseTexture.valid) if(baseTexture.valid)
{ {
createAsset(); createAsset();
} }

View File

@ -30,7 +30,7 @@ export class NitroLogger implements INitroLogger
public printMessage(modus: string, ...message: any[]): void public printMessage(modus: string, ...message: any[]): void
{ {
if (!this._print) return; if(!this._print) return;
NitroLogger.log(this._name, modus, ...message); NitroLogger.log(this._name, modus, ...message);
} }
@ -39,7 +39,7 @@ export class NitroLogger implements INitroLogger
{ {
const logPrefix = `[Nitro] [${name}]`; const logPrefix = `[Nitro] [${name}]`;
switch (modus) switch(modus)
{ {
case 'error': case 'error':
console.error(logPrefix, ...message); console.error(logPrefix, ...message);

View File

@ -53,7 +53,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
public init(socketUrl: string): void public init(socketUrl: string): void
{ {
if (this._stateListener) if(this._stateListener)
{ {
this._stateListener.connectionInit(socketUrl); this._stateListener.connectionInit(socketUrl);
} }
@ -76,13 +76,13 @@ export class SocketConnection extends EventDispatcher implements IConnection
public onReady(): void public onReady(): void
{ {
if (this._isReady) return; if(this._isReady) return;
this._isReady = true; this._isReady = true;
if (this._pendingServerMessages && this._pendingServerMessages.length) this.processWrappers(...this._pendingServerMessages); if(this._pendingServerMessages && this._pendingServerMessages.length) this.processWrappers(...this._pendingServerMessages);
if (this._pendingClientMessages && this._pendingClientMessages.length) this.send(...this._pendingClientMessages); if(this._pendingClientMessages && this._pendingClientMessages.length) this.send(...this._pendingClientMessages);
this._pendingServerMessages = []; this._pendingServerMessages = [];
this._pendingClientMessages = []; this._pendingClientMessages = [];
@ -90,7 +90,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private createSocket(socketUrl: string): void private createSocket(socketUrl: string): void
{ {
if (!socketUrl) return; if(!socketUrl) return;
this.destroySocket(); this.destroySocket();
@ -105,14 +105,14 @@ export class SocketConnection extends EventDispatcher implements IConnection
private destroySocket(): void private destroySocket(): void
{ {
if (!this._socket) return; if(!this._socket) return;
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen); this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen);
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose); this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose);
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_ERROR, this.onError); this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_ERROR, this.onError);
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_MESSAGE, this.onMessage); this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_MESSAGE, this.onMessage);
if (this._socket.readyState === WebSocket.OPEN) this._socket.close(); if(this._socket.readyState === WebSocket.OPEN) this._socket.close();
this._socket = null; this._socket = null;
} }
@ -134,7 +134,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private onMessage(event: MessageEvent): void private onMessage(event: MessageEvent): void
{ {
if (!event) return; if(!event) return;
//this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event); //this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event);
@ -162,28 +162,28 @@ export class SocketConnection extends EventDispatcher implements IConnection
public send(...composers: IMessageComposer<unknown[]>[]): boolean public send(...composers: IMessageComposer<unknown[]>[]): boolean
{ {
if (this.disposed || !composers) return false; if(this.disposed || !composers) return false;
composers = [...composers]; composers = [...composers];
if (this._isAuthenticated && !this._isReady) if(this._isAuthenticated && !this._isReady)
{ {
if (!this._pendingClientMessages) this._pendingClientMessages = []; if(!this._pendingClientMessages) this._pendingClientMessages = [];
this._pendingClientMessages.push(...composers); this._pendingClientMessages.push(...composers);
return false; return false;
} }
for (const composer of composers) for(const composer of composers)
{ {
if (!composer) continue; if(!composer) continue;
const header = this._messages.getComposerId(composer); const header = this._messages.getComposerId(composer);
if (header === -1) if(header === -1)
{ {
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log(`Unknown Composer: ${composer.constructor.name}`); if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log(`Unknown Composer: ${composer.constructor.name}`);
continue; continue;
} }
@ -191,14 +191,14 @@ export class SocketConnection extends EventDispatcher implements IConnection
const message = composer.getMessageArray(); const message = composer.getMessageArray();
const encoded = this._codec.encode(header, message); const encoded = this._codec.encode(header, message);
if (!encoded) if(!encoded)
{ {
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('Encoding Failed', composer.constructor.name); if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('Encoding Failed', composer.constructor.name);
continue; continue;
} }
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('OutgoingComposer', header, composer.constructor.name, message); if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('OutgoingComposer', header, composer.constructor.name, message);
this.write(encoded.getBuffer()); this.write(encoded.getBuffer());
} }
@ -208,7 +208,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private write(buffer: ArrayBuffer): void private write(buffer: ArrayBuffer): void
{ {
if (this._socket.readyState !== WebSocket.OPEN) return; if(this._socket.readyState !== WebSocket.OPEN) return;
this._socket.send(buffer); this._socket.send(buffer);
} }
@ -230,11 +230,11 @@ export class SocketConnection extends EventDispatcher implements IConnection
{ {
const wrappers = this.splitReceivedMessages(); const wrappers = this.splitReceivedMessages();
if (!wrappers || !wrappers.length) return; if(!wrappers || !wrappers.length) return;
if (this._isAuthenticated && !this._isReady) if(this._isAuthenticated && !this._isReady)
{ {
if (!this._pendingServerMessages) this._pendingServerMessages = []; if(!this._pendingServerMessages) this._pendingServerMessages = [];
this._pendingServerMessages.push(...wrappers); this._pendingServerMessages.push(...wrappers);
@ -246,17 +246,17 @@ export class SocketConnection extends EventDispatcher implements IConnection
private processWrappers(...wrappers: IMessageDataWrapper[]): void private processWrappers(...wrappers: IMessageDataWrapper[]): void
{ {
if (!wrappers || !wrappers.length) return; if(!wrappers || !wrappers.length) return;
for (const wrapper of wrappers) for(const wrapper of wrappers)
{ {
if (!wrapper) continue; if(!wrapper) continue;
const messages = this.getMessagesForWrapper(wrapper); const messages = this.getMessagesForWrapper(wrapper);
if (!messages || !messages.length) continue; if(!messages || !messages.length) continue;
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser); if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser);
this.handleMessages(...messages); this.handleMessages(...messages);
} }
@ -264,7 +264,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private splitReceivedMessages(): IMessageDataWrapper[] private splitReceivedMessages(): IMessageDataWrapper[]
{ {
if (!this._dataBuffer || !this._dataBuffer.byteLength) return null; if(!this._dataBuffer || !this._dataBuffer.byteLength) return null;
return this._codec.decode(this); return this._codec.decode(this);
} }
@ -281,13 +281,13 @@ export class SocketConnection extends EventDispatcher implements IConnection
private getMessagesForWrapper(wrapper: IMessageDataWrapper): IMessageEvent[] private getMessagesForWrapper(wrapper: IMessageDataWrapper): IMessageEvent[]
{ {
if (!wrapper) return null; if(!wrapper) return null;
const events = this._messages.getEvents(wrapper.header); const events = this._messages.getEvents(wrapper.header);
if (!events || !events.length) if(!events || !events.length)
{ {
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper); if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper);
return; return;
} }
@ -297,9 +297,9 @@ export class SocketConnection extends EventDispatcher implements IConnection
//@ts-ignore //@ts-ignore
const parser = new events[0].parserClass(); const parser = new events[0].parserClass();
if (!parser || !parser.flush() || !parser.parse(wrapper)) return null; if(!parser || !parser.flush() || !parser.parse(wrapper)) return null;
for (const event of events) (event.parser = parser); for(const event of events) (event.parser = parser);
} }
catch (e) catch (e)
@ -316,33 +316,33 @@ export class SocketConnection extends EventDispatcher implements IConnection
{ {
messages = [...messages]; messages = [...messages];
for (const message of messages) for(const message of messages)
{ {
if (!message) continue; if(!message) continue;
message.connection = this; message.connection = this;
if (message.callBack) message.callBack(message); if(message.callBack) message.callBack(message);
} }
} }
public registerMessages(configuration: IMessageConfiguration): void public registerMessages(configuration: IMessageConfiguration): void
{ {
if (!configuration) return; if(!configuration) return;
this._messages.registerMessages(configuration); this._messages.registerMessages(configuration);
} }
public addMessageEvent(event: IMessageEvent): void public addMessageEvent(event: IMessageEvent): void
{ {
if (!event || !this._messages) return; if(!event || !this._messages) return;
this._messages.registerMessageEvent(event); this._messages.registerMessageEvent(event);
} }
public removeMessageEvent(event: IMessageEvent): void public removeMessageEvent(event: IMessageEvent): void
{ {
if (!event || !this._messages) return; if(!event || !this._messages) return;
this._messages.removeMessageEvent(event); this._messages.removeMessageEvent(event);
} }

View File

@ -28,11 +28,11 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public addEventListener(type: string, callback: Function): void public addEventListener(type: string, callback: Function): void
{ {
if (!type || !callback) return; if(!type || !callback) return;
const existing = this._listeners.get(type); const existing = this._listeners.get(type);
if (!existing) if(!existing)
{ {
this._listeners.set(type, [callback]); this._listeners.set(type, [callback]);
@ -44,19 +44,19 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public removeEventListener(type: string, callback: any): void public removeEventListener(type: string, callback: any): void
{ {
if (!type || !callback) return; if(!type || !callback) return;
const existing = this._listeners.get(type); const existing = this._listeners.get(type);
if (!existing || !existing.length) return; if(!existing || !existing.length) return;
for (const [i, cb] of existing.entries()) for(const [i, cb] of existing.entries())
{ {
if (!cb || (cb !== callback)) continue; if(!cb || (cb !== callback)) continue;
existing.splice(i, 1); existing.splice(i, 1);
if (!existing.length) this._listeners.delete(type); if(!existing.length) this._listeners.delete(type);
return; return;
} }
@ -64,9 +64,9 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public dispatchEvent(event: NitroEvent): boolean public dispatchEvent(event: NitroEvent): boolean
{ {
if (!event) return false; if(!event) return false;
if (Nitro.instance.getConfiguration<boolean>('system.dispatcher.log')) this._logger.log('Dispatched Event', event.type); if(Nitro.instance.getConfiguration<boolean>('system.dispatcher.log')) this._logger.log('Dispatched Event', event.type);
this.processEvent(event); this.processEvent(event);
@ -77,18 +77,18 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
{ {
const existing = this._listeners.get(event.type); const existing = this._listeners.get(event.type);
if (!existing || !existing.length) return; if(!existing || !existing.length) return;
const callbacks = []; const callbacks = [];
for (const callback of existing) for(const callback of existing)
{ {
if (!callback) continue; if(!callback) continue;
callbacks.push(callback); callbacks.push(callback);
} }
while (callbacks.length) while(callbacks.length)
{ {
const callback = callbacks.shift(); const callback = callbacks.shift();

View File

@ -66,7 +66,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
request.onloadend = e => request.onloadend = e =>
{ {
if (request.responseText) if(request.responseText)
{ {
const data = JSON.parse(request.responseText); const data = JSON.parse(request.responseText);
@ -94,16 +94,16 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private processFigureMap(data: any): void private processFigureMap(data: any): void
{ {
if (!data) return; if(!data) return;
for (const library of data) for(const library of data)
{ {
if (!library) continue; if(!library) continue;
const id = (library.id as string); const id = (library.id as string);
const revision = (library.revision || ''); const revision = (library.revision || '');
if (this._libraryNames.indexOf(id) >= 0) continue; if(this._libraryNames.indexOf(id) >= 0) continue;
this._libraryNames.push(id); this._libraryNames.push(id);
@ -111,7 +111,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
downloadLibrary.addEventListener(AvatarRenderLibraryEvent.DOWNLOAD_COMPLETE, this.onLibraryLoaded); downloadLibrary.addEventListener(AvatarRenderLibraryEvent.DOWNLOAD_COMPLETE, this.onLibraryLoaded);
for (const part of library.parts) for(const part of library.parts)
{ {
const id = (part.id as string); const id = (part.id as string);
const type = (part.type as string); const type = (part.type as string);
@ -119,7 +119,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
let existing = this._figureMap.get(partString); let existing = this._figureMap.get(partString);
if (!existing) existing = []; if(!existing) existing = [];
existing.push(downloadLibrary); existing.push(downloadLibrary);
@ -130,9 +130,9 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private onAvatarRenderReady(event: NitroEvent): void private onAvatarRenderReady(event: NitroEvent): void
{ {
if (!event) return; if(!event) return;
for (const [container, listener] of this._pendingContainers) for(const [container, listener] of this._pendingContainers)
{ {
this.downloadAvatarFigure(container, listener); this.downloadAvatarFigure(container, listener);
} }
@ -142,34 +142,34 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private onLibraryLoaded(event: AvatarRenderLibraryEvent): void private onLibraryLoaded(event: AvatarRenderLibraryEvent): void
{ {
if (!event || !event.library) return; if(!event || !event.library) return;
const loadedFigures: string[] = []; const loadedFigures: string[] = [];
for (const [figure, libraries] of this._incompleteFigures.entries()) for(const [figure, libraries] of this._incompleteFigures.entries())
{ {
let isReady = true; let isReady = true;
for (const library of libraries) for(const library of libraries)
{ {
if (!library || library.isLoaded) continue; if(!library || library.isLoaded) continue;
isReady = false; isReady = false;
break; break;
} }
if (isReady) if(isReady)
{ {
loadedFigures.push(figure); loadedFigures.push(figure);
const listeners = this._figureListeners.get(figure); const listeners = this._figureListeners.get(figure);
if (listeners) if(listeners)
{ {
for (const listener of listeners) for(const listener of listeners)
{ {
if (!listener || listener.disposed) continue; if(!listener || listener.disposed) continue;
listener.resetFigure(figure); listener.resetFigure(figure);
} }
@ -181,22 +181,22 @@ export class AvatarAssetDownloadManager extends EventDispatcher
} }
} }
for (const figure of loadedFigures) for(const figure of loadedFigures)
{ {
if (!figure) continue; if(!figure) continue;
this._incompleteFigures.delete(figure); this._incompleteFigures.delete(figure);
} }
let index = 0; let index = 0;
while (index < this._currentDownloads.length) while(index < this._currentDownloads.length)
{ {
const download = this._currentDownloads[index]; const download = this._currentDownloads[index];
if (download) if(download)
{ {
if (download.libraryName === event.library.libraryName) this._currentDownloads.splice(index, 1); if(download.libraryName === event.library.libraryName) this._currentDownloads.splice(index, 1);
} }
index++; index++;
@ -207,19 +207,19 @@ export class AvatarAssetDownloadManager extends EventDispatcher
{ {
const libraries = this._missingMandatoryLibs.slice(); const libraries = this._missingMandatoryLibs.slice();
for (const library of libraries) for(const library of libraries)
{ {
if (!library) continue; if(!library) continue;
const map = this._figureMap.get(library); const map = this._figureMap.get(library);
if (map) for (const avatar of map) avatar && this.downloadLibrary(avatar); if(map) for(const avatar of map) avatar && this.downloadLibrary(avatar);
} }
} }
public isAvatarFigureContainerReady(container: IAvatarFigureContainer): boolean public isAvatarFigureContainerReady(container: IAvatarFigureContainer): boolean
{ {
if (!this._isReady || !this._structure.renderManager.isReady) if(!this._isReady || !this._structure.renderManager.isReady)
{ {
return false; return false;
} }
@ -233,38 +233,38 @@ export class AvatarAssetDownloadManager extends EventDispatcher
{ {
const pendingLibraries: AvatarAssetDownloadLibrary[] = []; const pendingLibraries: AvatarAssetDownloadLibrary[] = [];
if (!container || !this._structure) return pendingLibraries; if(!container || !this._structure) return pendingLibraries;
const figureData = this._structure.figureData; const figureData = this._structure.figureData;
if (!figureData) return pendingLibraries; if(!figureData) return pendingLibraries;
const setKeys = container.getPartTypeIds(); const setKeys = container.getPartTypeIds();
for (const key of setKeys) for(const key of setKeys)
{ {
const set = figureData.getSetType(key); const set = figureData.getSetType(key);
if (!set) continue; if(!set) continue;
const figurePartSet = set.getPartSet(container.getPartSetId(key)); const figurePartSet = set.getPartSet(container.getPartSetId(key));
if (!figurePartSet) continue; if(!figurePartSet) continue;
for (const part of figurePartSet.parts) for(const part of figurePartSet.parts)
{ {
if (!part) continue; if(!part) continue;
const name = (part.type + ':' + part.id); const name = (part.type + ':' + part.id);
const existing = this._figureMap.get(name); const existing = this._figureMap.get(name);
if (existing === undefined) continue; if(existing === undefined) continue;
for (const library of existing) for(const library of existing)
{ {
if (!library || library.isLoaded) continue; if(!library || library.isLoaded) continue;
if (pendingLibraries.indexOf(library) >= 0) continue; if(pendingLibraries.indexOf(library) >= 0) continue;
pendingLibraries.push(library); pendingLibraries.push(library);
} }
@ -276,7 +276,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void
{ {
if (!this._isReady || !this._structure.renderManager.isReady) if(!this._isReady || !this._structure.renderManager.isReady)
{ {
this._pendingContainers.push([container, listener]); this._pendingContainers.push([container, listener]);
@ -286,13 +286,13 @@ export class AvatarAssetDownloadManager extends EventDispatcher
const figure = container.getFigureString(); const figure = container.getFigureString();
const pendingLibraries = this.getAvatarFigurePendingLibraries(container); const pendingLibraries = this.getAvatarFigurePendingLibraries(container);
if (pendingLibraries && pendingLibraries.length) if(pendingLibraries && pendingLibraries.length)
{ {
if (listener && !listener.disposed) if(listener && !listener.disposed)
{ {
let listeners = this._figureListeners.get(figure); let listeners = this._figureListeners.get(figure);
if (!listeners) if(!listeners)
{ {
listeners = []; listeners = [];
@ -304,24 +304,24 @@ export class AvatarAssetDownloadManager extends EventDispatcher
this._incompleteFigures.set(figure, pendingLibraries); this._incompleteFigures.set(figure, pendingLibraries);
for (const library of pendingLibraries) for(const library of pendingLibraries)
{ {
if (!library) continue; if(!library) continue;
this.downloadLibrary(library); this.downloadLibrary(library);
} }
} }
else else
{ {
if (listener && !listener.disposed) listener.resetFigure(figure); if(listener && !listener.disposed) listener.resetFigure(figure);
} }
} }
private downloadLibrary(library: AvatarAssetDownloadLibrary): void private downloadLibrary(library: AvatarAssetDownloadLibrary): void
{ {
if (!library || library.isLoaded) return; if(!library || library.isLoaded) return;
if ((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return; if((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return;
this._pendingDownloadQueue.push(library); this._pendingDownloadQueue.push(library);
@ -330,7 +330,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private processDownloadQueue(): void private processDownloadQueue(): void
{ {
while (this._pendingDownloadQueue.length) while(this._pendingDownloadQueue.length)
{ {
const library = this._pendingDownloadQueue[0]; const library = this._pendingDownloadQueue[0];

View File

@ -86,7 +86,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
this._aliasCollection.init(); this._aliasCollection.init();
if (!this._avatarAssetDownloadManager) if(!this._avatarAssetDownloadManager)
{ {
this._avatarAssetDownloadManager = new AvatarAssetDownloadManager(Nitro.instance.core.asset, this._structure); this._avatarAssetDownloadManager = new AvatarAssetDownloadManager(Nitro.instance.core.asset, this._structure);
@ -94,7 +94,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
this._avatarAssetDownloadManager.addEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded); this._avatarAssetDownloadManager.addEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded);
} }
if (!this._effectAssetDownloadManager) if(!this._effectAssetDownloadManager)
{ {
this._effectAssetDownloadManager = new EffectAssetDownloadManager(Nitro.instance.core.asset, this._structure); this._effectAssetDownloadManager = new EffectAssetDownloadManager(Nitro.instance.core.asset, this._structure);
@ -107,14 +107,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public onDispose(): void public onDispose(): void
{ {
if (this._avatarAssetDownloadManager) if(this._avatarAssetDownloadManager)
{ {
this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.DOWNLOADER_READY, this.onAvatarAssetDownloaderReady); this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.DOWNLOADER_READY, this.onAvatarAssetDownloaderReady);
this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded); this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded);
} }
if (this._effectAssetDownloadManager) if(this._effectAssetDownloadManager)
{ {
this._effectAssetDownloadManager.removeEventListener(EffectAssetDownloadManager.DOWNLOADER_READY, this.onEffectAssetDownloaderReady); this._effectAssetDownloadManager.removeEventListener(EffectAssetDownloadManager.DOWNLOADER_READY, this.onEffectAssetDownloaderReady);
@ -124,7 +124,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadGeometry(): void private loadGeometry(): void
{ {
if (!this._structure) return; if(!this._structure) return;
this._structure.initGeometry(HabboAvatarGeometry.geometry); this._structure.initGeometry(HabboAvatarGeometry.geometry);
@ -135,7 +135,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadPartSets(): void private loadPartSets(): void
{ {
if (!this._structure) return; if(!this._structure) return;
this._structure.initPartSets(HabboAvatarPartSets.partSets); this._structure.initPartSets(HabboAvatarPartSets.partSets);
@ -148,7 +148,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
const defaultActions = Nitro.instance.getConfiguration<string>('avatar.default.actions'); const defaultActions = Nitro.instance.getConfiguration<string>('avatar.default.actions');
if (defaultActions) this._structure.initActions(Nitro.instance.core.asset, defaultActions); if(defaultActions) this._structure.initActions(Nitro.instance.core.asset, defaultActions);
const request = new XMLHttpRequest(); const request = new XMLHttpRequest();
@ -160,7 +160,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
request.onloadend = e => request.onloadend = e =>
{ {
if (!this._structure) return; if(!this._structure) return;
this._structure.updateActions(JSON.parse(request.responseText)); this._structure.updateActions(JSON.parse(request.responseText));
@ -183,7 +183,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadAnimations(): void private loadAnimations(): void
{ {
if (!this._structure) return; if(!this._structure) return;
this._structure.initAnimation(HabboAvatarAnimations.animations); this._structure.initAnimation(HabboAvatarAnimations.animations);
@ -196,14 +196,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
const defaultFigureData = Nitro.instance.getConfiguration<IFigureData>('avatar.default.figuredata'); const defaultFigureData = Nitro.instance.getConfiguration<IFigureData>('avatar.default.figuredata');
if (!defaultFigureData || (typeof defaultFigureData === 'string')) if(!defaultFigureData || (typeof defaultFigureData === 'string'))
{ {
this.logger.error('XML figuredata is no longer supported'); this.logger.error('XML figuredata is no longer supported');
return; return;
} }
if (this._structure) this._structure.initFigureData(defaultFigureData); if(this._structure) this._structure.initFigureData(defaultFigureData);
const structureDownloader = new AvatarStructureDownload(Nitro.instance.getConfiguration<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData)); const structureDownloader = new AvatarStructureDownload(Nitro.instance.getConfiguration<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData));
@ -221,7 +221,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onAvatarAssetDownloaderReady(event: NitroEvent): void private onAvatarAssetDownloaderReady(event: NitroEvent): void
{ {
if (!event) return; if(!event) return;
this._figureMapReady = true; this._figureMapReady = true;
@ -230,14 +230,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onAvatarAssetDownloaded(event: NitroEvent): void private onAvatarAssetDownloaded(event: NitroEvent): void
{ {
if (!event) return; if(!event) return;
this._aliasCollection.reset(); this._aliasCollection.reset();
} }
private onEffectAssetDownloaderReady(event: NitroEvent): void private onEffectAssetDownloaderReady(event: NitroEvent): void
{ {
if (!event) return; if(!event) return;
this._effectMapReady = true; this._effectMapReady = true;
@ -246,20 +246,20 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onEffectAssetDownloaded(event: NitroEvent): void private onEffectAssetDownloaded(event: NitroEvent): void
{ {
if (!event) return; if(!event) return;
this._aliasCollection.reset(); this._aliasCollection.reset();
} }
private checkReady(): void private checkReady(): void
{ {
if (this._isReady) return; if(this._isReady) return;
if (!this._geometryReady || !this._partSetsReady || !this._actionsReady || !this._animationsReady || !this._figureMapReady || !this._effectMapReady || !this._structureReady) return; if(!this._geometryReady || !this._partSetsReady || !this._actionsReady || !this._animationsReady || !this._figureMapReady || !this._effectMapReady || !this._structureReady) return;
this._isReady = true; this._isReady = true;
if (this.events) this.events.dispatchEvent(new NitroEvent(AvatarRenderEvent.AVATAR_RENDER_READY)); if(this.events) this.events.dispatchEvent(new NitroEvent(AvatarRenderEvent.AVATAR_RENDER_READY));
} }
public createFigureContainer(figure: string): IAvatarFigureContainer public createFigureContainer(figure: string): IAvatarFigureContainer
@ -269,25 +269,25 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public isFigureContainerReady(container: IAvatarFigureContainer): boolean public isFigureContainerReady(container: IAvatarFigureContainer): boolean
{ {
if (!this._avatarAssetDownloadManager) return false; if(!this._avatarAssetDownloadManager) return false;
return this._avatarAssetDownloadManager.isAvatarFigureContainerReady(container); return this._avatarAssetDownloadManager.isAvatarFigureContainerReady(container);
} }
public createAvatarImage(figure: string, size: string, gender: string, listener: IAvatarImageListener = null, effectListener: IAvatarEffectListener = null): IAvatarImage public createAvatarImage(figure: string, size: string, gender: string, listener: IAvatarImageListener = null, effectListener: IAvatarEffectListener = null): IAvatarImage
{ {
if (!this._structure || !this._avatarAssetDownloadManager) return null; if(!this._structure || !this._avatarAssetDownloadManager) return null;
const figureContainer = new AvatarFigureContainer(figure); const figureContainer = new AvatarFigureContainer(figure);
if (gender) this.validateAvatarFigure(figureContainer, gender); if(gender) this.validateAvatarFigure(figureContainer, gender);
if (this._avatarAssetDownloadManager.isAvatarFigureContainerReady(figureContainer)) if(this._avatarAssetDownloadManager.isAvatarFigureContainerReady(figureContainer))
{ {
return new AvatarImage(this._structure, this._aliasCollection, figureContainer, size, this._effectAssetDownloadManager, effectListener); return new AvatarImage(this._structure, this._aliasCollection, figureContainer, size, this._effectAssetDownloadManager, effectListener);
} }
if (!this._placeHolderFigure) this._placeHolderFigure = new AvatarFigureContainer(AvatarRenderManager.DEFAULT_FIGURE); if(!this._placeHolderFigure) this._placeHolderFigure = new AvatarFigureContainer(AvatarRenderManager.DEFAULT_FIGURE);
this._avatarAssetDownloadManager.downloadAvatarFigure(figureContainer, listener); this._avatarAssetDownloadManager.downloadAvatarFigure(figureContainer, listener);
@ -296,7 +296,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void
{ {
if (!this._avatarAssetDownloadManager) return; if(!this._avatarAssetDownloadManager) return;
this._avatarAssetDownloadManager.downloadAvatarFigure(container, listener); this._avatarAssetDownloadManager.downloadAvatarFigure(container, listener);
} }
@ -307,17 +307,17 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const typeIds = this._structure.getMandatorySetTypeIds(gender, 2); const typeIds = this._structure.getMandatorySetTypeIds(gender, 2);
if (typeIds) if(typeIds)
{ {
const figureData = this._structure.figureData; const figureData = this._structure.figureData;
for (const id of typeIds) for(const id of typeIds)
{ {
if (!container.hasPartType(id)) if(!container.hasPartType(id))
{ {
const figurePartSet = this._structure.getDefaultPartSet(id, gender); const figurePartSet = this._structure.getDefaultPartSet(id, gender);
if (figurePartSet) if(figurePartSet)
{ {
container.updatePart(id, figurePartSet.id, [0]); container.updatePart(id, figurePartSet.id, [0]);
@ -328,15 +328,15 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
const setType = figureData.getSetType(id); const setType = figureData.getSetType(id);
if (setType) if(setType)
{ {
const figurePartSet = setType.getPartSet(container.getPartSetId(id)); const figurePartSet = setType.getPartSet(container.getPartSetId(id));
if (!figurePartSet) if(!figurePartSet)
{ {
const partSet = this._structure.getDefaultPartSet(id, gender); const partSet = this._structure.getDefaultPartSet(id, gender);
if (partSet) if(partSet)
{ {
container.updatePart(id, partSet.id, [0]); container.updatePart(id, partSet.id, [0]);
@ -353,49 +353,49 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[] = null): number public getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[] = null): number
{ {
if (!this._structure) return 0; if(!this._structure) return 0;
const figureData = this._structure.figureData; const figureData = this._structure.figureData;
const parts = Array.from(container.getPartTypeIds()); const parts = Array.from(container.getPartTypeIds());
let clubLevel = 0; let clubLevel = 0;
for (const part of parts) for(const part of parts)
{ {
const set = figureData.getSetType(part); const set = figureData.getSetType(part);
if (!set) continue; if(!set) continue;
const setId = container.getPartSetId(part); const setId = container.getPartSetId(part);
const partSet = set.getPartSet(setId); const partSet = set.getPartSet(setId);
if (partSet) if(partSet)
{ {
clubLevel = Math.max(partSet.clubLevel, clubLevel); clubLevel = Math.max(partSet.clubLevel, clubLevel);
const palette = figureData.getPalette(set.paletteID); const palette = figureData.getPalette(set.paletteID);
const colors = container.getPartColorIds(part); const colors = container.getPartColorIds(part);
for (const colorId of colors) for(const colorId of colors)
{ {
const color = palette.getColor(colorId); const color = palette.getColor(colorId);
if (!color) continue; if(!color) continue;
clubLevel = Math.max(color.clubLevel, clubLevel); clubLevel = Math.max(color.clubLevel, clubLevel);
} }
} }
} }
if (!searchParts) searchParts = this._structure.getBodyPartsUnordered(AvatarSetType.FULL); if(!searchParts) searchParts = this._structure.getBodyPartsUnordered(AvatarSetType.FULL);
for (const part of searchParts) for(const part of searchParts)
{ {
const set = figureData.getSetType(part); const set = figureData.getSetType(part);
if (!set) continue; if(!set) continue;
if (parts.indexOf(part) === -1) clubLevel = Math.max(set.optionalFromClubLevel(gender), clubLevel); if(parts.indexOf(part) === -1) clubLevel = Math.max(set.optionalFromClubLevel(gender), clubLevel);
} }
return clubLevel; return clubLevel;
@ -417,7 +417,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const partSets: IFigurePartSet[] = this.resolveFigureSets(_arg_3); const partSets: IFigurePartSet[] = this.resolveFigureSets(_arg_3);
for (const partSet of partSets) for(const partSet of partSets)
{ {
container.savePartData(partSet.type, partSet.id, container.getColourIds(partSet.type)); container.savePartData(partSet.type, partSet.id, container.getColourIds(partSet.type));
} }
@ -430,11 +430,11 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const structure = this.structureData; const structure = this.structureData;
const partSets: IFigurePartSet[] = []; const partSets: IFigurePartSet[] = [];
for (const _local_4 of k) for(const _local_4 of k)
{ {
const partSet = structure.getFigurePartSet(_local_4); const partSet = structure.getFigurePartSet(_local_4);
if (partSet) partSets.push(partSet); if(partSet) partSets.push(partSet);
} }
return partSets; return partSets;
@ -442,7 +442,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[] public getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[]
{ {
if (!this._structure) return null; if(!this._structure) return null;
return this._structure.getMandatorySetTypeIds(k, _arg_2); return this._structure.getMandatorySetTypeIds(k, _arg_2);
} }
@ -469,7 +469,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public get structureData(): IStructureData public get structureData(): IStructureData
{ {
if (this._structure) return this._structure.figureData; if(this._structure) return this._structure.figureData;
return null; return null;
} }

View File

@ -65,7 +65,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
request.onloadend = e => request.onloadend = e =>
{ {
if (request.responseText) if(request.responseText)
{ {
const data = JSON.parse(request.responseText); const data = JSON.parse(request.responseText);
@ -93,17 +93,17 @@ export class EffectAssetDownloadManager extends EventDispatcher
private processEffectMap(data: any): void private processEffectMap(data: any): void
{ {
if (!data) return; if(!data) return;
for (const effect of data) for(const effect of data)
{ {
if (!effect) continue; if(!effect) continue;
const id = (effect.id as string); const id = (effect.id as string);
const lib = (effect.lib as string); const lib = (effect.lib as string);
const revision = (effect.revision || ''); const revision = (effect.revision || '');
if (this._libraryNames.indexOf(lib) >= 0) continue; if(this._libraryNames.indexOf(lib) >= 0) continue;
this._libraryNames.push(lib); this._libraryNames.push(lib);
@ -113,7 +113,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
let existing = this._effectMap.get(id); let existing = this._effectMap.get(id);
if (!existing) existing = []; if(!existing) existing = [];
existing.push(downloadLibrary); existing.push(downloadLibrary);
@ -123,7 +123,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
public downloadAvatarEffect(id: number, listener: IAvatarEffectListener): void public downloadAvatarEffect(id: number, listener: IAvatarEffectListener): void
{ {
if (!this._isReady || !this._structure.renderManager.isReady) if(!this._isReady || !this._structure.renderManager.isReady)
{ {
this._initDownloadBuffer.push([id, listener]); this._initDownloadBuffer.push([id, listener]);
@ -132,13 +132,13 @@ export class EffectAssetDownloadManager extends EventDispatcher
const pendingLibraries = this.getAvatarEffectPendingLibraries(id); const pendingLibraries = this.getAvatarEffectPendingLibraries(id);
if (pendingLibraries && pendingLibraries.length) if(pendingLibraries && pendingLibraries.length)
{ {
if (listener && !listener.disposed) if(listener && !listener.disposed)
{ {
let listeners = this._effectListeners.get(id.toString()); let listeners = this._effectListeners.get(id.toString());
if (!listeners) listeners = []; if(!listeners) listeners = [];
listeners.push(listener); listeners.push(listener);
@ -147,24 +147,24 @@ export class EffectAssetDownloadManager extends EventDispatcher
this._incompleteEffects.set(id.toString(), pendingLibraries); this._incompleteEffects.set(id.toString(), pendingLibraries);
for (const library of pendingLibraries) for(const library of pendingLibraries)
{ {
if (!library) continue; if(!library) continue;
this.downloadLibrary(library); this.downloadLibrary(library);
} }
} }
else else
{ {
if (listener && !listener.disposed) listener.resetEffect(id); if(listener && !listener.disposed) listener.resetEffect(id);
} }
} }
private onAvatarRenderReady(event: NitroEvent): void private onAvatarRenderReady(event: NitroEvent): void
{ {
if (!event) return; if(!event) return;
for (const [id, listener] of this._initDownloadBuffer) for(const [id, listener] of this._initDownloadBuffer)
{ {
this.downloadAvatarEffect(id, listener); this.downloadAvatarEffect(id, listener);
} }
@ -174,34 +174,34 @@ export class EffectAssetDownloadManager extends EventDispatcher
private onLibraryLoaded(event: AvatarRenderEffectLibraryEvent): void private onLibraryLoaded(event: AvatarRenderEffectLibraryEvent): void
{ {
if (!event || !event.library) return; if(!event || !event.library) return;
const loadedEffects: string[] = []; const loadedEffects: string[] = [];
this._structure.registerAnimation(event.library.animation); this._structure.registerAnimation(event.library.animation);
for (const [id, libraries] of this._incompleteEffects.entries()) for(const [id, libraries] of this._incompleteEffects.entries())
{ {
let isReady = true; let isReady = true;
for (const library of libraries) for(const library of libraries)
{ {
if (!library || library.isLoaded) continue; if(!library || library.isLoaded) continue;
isReady = false; isReady = false;
break; break;
} }
if (isReady) if(isReady)
{ {
loadedEffects.push(id); loadedEffects.push(id);
const listeners = this._effectListeners.get(id); const listeners = this._effectListeners.get(id);
for (const listener of listeners) for(const listener of listeners)
{ {
if (!listener || listener.disposed) continue; if(!listener || listener.disposed) continue;
listener.resetEffect(parseInt(id)); listener.resetEffect(parseInt(id));
} }
@ -212,17 +212,17 @@ export class EffectAssetDownloadManager extends EventDispatcher
} }
} }
for (const id of loadedEffects) this._incompleteEffects.delete(id); for(const id of loadedEffects) this._incompleteEffects.delete(id);
let index = 0; let index = 0;
while (index < this._currentDownloads.length) while(index < this._currentDownloads.length)
{ {
const download = this._currentDownloads[index]; const download = this._currentDownloads[index];
if (download) if(download)
{ {
if (download.libraryName === event.library.libraryName) this._currentDownloads.splice(index, 1); if(download.libraryName === event.library.libraryName) this._currentDownloads.splice(index, 1);
} }
index++; index++;
@ -233,19 +233,19 @@ export class EffectAssetDownloadManager extends EventDispatcher
{ {
const libraries = this._missingMandatoryLibs.slice(); const libraries = this._missingMandatoryLibs.slice();
for (const library of libraries) for(const library of libraries)
{ {
if (!library) continue; if(!library) continue;
const map = this._effectMap.get(library); const map = this._effectMap.get(library);
if (map) for (const effect of map) effect && this.downloadLibrary(effect); if(map) for(const effect of map) effect && this.downloadLibrary(effect);
} }
} }
public isAvatarEffectReady(effect: number): boolean public isAvatarEffectReady(effect: number): boolean
{ {
if (!this._isReady || !this._structure.renderManager.isReady) if(!this._isReady || !this._structure.renderManager.isReady)
{ {
return false; return false;
} }
@ -259,17 +259,17 @@ export class EffectAssetDownloadManager extends EventDispatcher
{ {
const pendingLibraries: EffectAssetDownloadLibrary[] = []; const pendingLibraries: EffectAssetDownloadLibrary[] = [];
if (!this._structure) return pendingLibraries; if(!this._structure) return pendingLibraries;
const libraries = this._effectMap.get(id.toString()); const libraries = this._effectMap.get(id.toString());
if (libraries) if(libraries)
{ {
for (const library of libraries) for(const library of libraries)
{ {
if (!library || library.isLoaded) continue; if(!library || library.isLoaded) continue;
if (pendingLibraries.indexOf(library) === -1) pendingLibraries.push(library); if(pendingLibraries.indexOf(library) === -1) pendingLibraries.push(library);
} }
} }
@ -278,9 +278,9 @@ export class EffectAssetDownloadManager extends EventDispatcher
private downloadLibrary(library: EffectAssetDownloadLibrary): void private downloadLibrary(library: EffectAssetDownloadLibrary): void
{ {
if (!library || library.isLoaded) return; if(!library || library.isLoaded) return;
if ((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return; if((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return;
this._pendingDownloadQueue.push(library); this._pendingDownloadQueue.push(library);
@ -289,7 +289,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
private processDownloadQueue(): void private processDownloadQueue(): void
{ {
while (this._pendingDownloadQueue.length) while(this._pendingDownloadQueue.length)
{ {
const library = this._pendingDownloadQueue[0]; const library = this._pendingDownloadQueue[0];

View File

@ -31,9 +31,9 @@ export class AvatarStructureDownload extends EventDispatcher
{ {
const response = request.responseText; const response = request.responseText;
if (!response || !response.length) throw new Error('invalid_figure_data'); if(!response || !response.length) throw new Error('invalid_figure_data');
if (this._dataReceiver) this._dataReceiver.appendJSON(JSON.parse(response)); if(this._dataReceiver) this._dataReceiver.appendJSON(JSON.parse(response));
this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE)); this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE));
}; };

View File

@ -41,7 +41,7 @@ export class NitroCommunicationDemo extends NitroManager
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (connection) if(connection)
{ {
connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent); connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent); connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
@ -56,7 +56,7 @@ export class NitroCommunicationDemo extends NitroManager
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (connection) if(connection)
{ {
connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent); connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent); connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
@ -74,13 +74,13 @@ export class NitroCommunicationDemo extends NitroManager
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (!connection) return; if(!connection) return;
this._didConnect = true; this._didConnect = true;
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection); this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection);
if (Nitro.instance.getConfiguration<boolean>('system.pong.manually', false)) this.startPonging(); if(Nitro.instance.getConfiguration<boolean>('system.pong.manually', false)) this.startPonging();
this.startHandshake(connection); this.startHandshake(connection);
@ -93,18 +93,18 @@ export class NitroCommunicationDemo extends NitroManager
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (!connection) return; if(!connection) return;
this.stopPonging(); this.stopPonging();
if (this._didConnect) this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, connection); if(this._didConnect) this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, connection);
} }
private onConnectionErrorEvent(event: CloseEvent): void private onConnectionErrorEvent(event: CloseEvent): void
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (!connection) return; if(!connection) return;
this.stopPonging(); this.stopPonging();
@ -113,9 +113,9 @@ export class NitroCommunicationDemo extends NitroManager
private tryAuthentication(connection: IConnection): void private tryAuthentication(connection: IConnection): void
{ {
if (!connection || !this.getSSO()) if(!connection || !this.getSSO())
{ {
if (!this.getSSO()) if(!this.getSSO())
{ {
this.logger.error('Login without an SSO ticket is not supported'); this.logger.error('Login without an SSO ticket is not supported');
} }
@ -130,14 +130,14 @@ export class NitroCommunicationDemo extends NitroManager
private onClientPingEvent(event: ClientPingEvent): void private onClientPingEvent(event: ClientPingEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
this.sendPong(event.connection); this.sendPong(event.connection);
} }
private onAuthenticatedEvent(event: AuthenticatedEvent): void private onAuthenticatedEvent(event: AuthenticatedEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
this.completeHandshake(event.connection); this.completeHandshake(event.connection);
@ -169,7 +169,7 @@ export class NitroCommunicationDemo extends NitroManager
private stopPonging(): void private stopPonging(): void
{ {
if (!this._pongInterval) return; if(!this._pongInterval) return;
clearInterval(this._pongInterval); clearInterval(this._pongInterval);
@ -180,7 +180,7 @@ export class NitroCommunicationDemo extends NitroManager
{ {
connection = ((connection || this._communication.connection) || null); connection = ((connection || this._communication.connection) || null);
if (!connection) return; if(!connection) return;
connection.send(new PongMessageComposer()); connection.send(new PongMessageComposer());
} }

View File

@ -98,7 +98,7 @@ export class RoomContentLoader implements IFurnitureDataListener
this.setFurnitureData(); this.setFurnitureData();
for (const [index, name] of Nitro.instance.getConfiguration<string[]>('pet.types').entries()) this._pets[name] = index; for(const [index, name] of Nitro.instance.getConfiguration<string[]>('pet.types').entries()) this._pets[name] = index;
} }
public dispose(): void public dispose(): void
@ -110,7 +110,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
this._sessionDataManager = sessionData; this._sessionDataManager = sessionData;
if (this._waitingForSessionDataManager) if(this._waitingForSessionDataManager)
{ {
this._waitingForSessionDataManager = false; this._waitingForSessionDataManager = false;
@ -125,7 +125,7 @@ export class RoomContentLoader implements IFurnitureDataListener
private setFurnitureData(): void private setFurnitureData(): void
{ {
if (!this._sessionDataManager) if(!this._sessionDataManager)
{ {
this._waitingForSessionDataManager = true; this._waitingForSessionDataManager = true;
@ -134,7 +134,7 @@ export class RoomContentLoader implements IFurnitureDataListener
const furnitureData = this._sessionDataManager.getAllFurnitureData(this); const furnitureData = this._sessionDataManager.getAllFurnitureData(this);
if (!furnitureData) return; if(!furnitureData) return;
this._sessionDataManager.removePendingFurniDataListener(this); this._sessionDataManager.removePendingFurniDataListener(this);
@ -145,42 +145,42 @@ export class RoomContentLoader implements IFurnitureDataListener
private processFurnitureData(furnitureData: IFurnitureData[]): void private processFurnitureData(furnitureData: IFurnitureData[]): void
{ {
if (!furnitureData) return; if(!furnitureData) return;
for (const furniture of furnitureData) for(const furniture of furnitureData)
{ {
if (!furniture) continue; if(!furniture) continue;
const id = furniture.id; const id = furniture.id;
let className = furniture.className; let className = furniture.className;
if (furniture.hasIndexedColor) className = ((className + '*') + furniture.colorIndex); if(furniture.hasIndexedColor) className = ((className + '*') + furniture.colorIndex);
const revision = furniture.revision; const revision = furniture.revision;
const adUrl = furniture.adUrl; const adUrl = furniture.adUrl;
if (adUrl && adUrl.length > 0) this._objectTypeAdUrls.set(className, adUrl); if(adUrl && adUrl.length > 0) this._objectTypeAdUrls.set(className, adUrl);
let name = furniture.className; let name = furniture.className;
if (furniture.type === FurnitureType.FLOOR) if(furniture.type === FurnitureType.FLOOR)
{ {
this._activeObjectTypes.set(id, className); this._activeObjectTypes.set(id, className);
this._activeObjectTypeIds.set(className, id); this._activeObjectTypeIds.set(className, id);
if (!this._activeObjects[name]) this._activeObjects[name] = 1; if(!this._activeObjects[name]) this._activeObjects[name] = 1;
} }
else if (furniture.type === FurnitureType.WALL) else if(furniture.type === FurnitureType.WALL)
{ {
if (name === 'post.it') if(name === 'post.it')
{ {
className = 'post_it'; className = 'post_it';
name = 'post_it'; name = 'post_it';
} }
if (name === 'post.it.vd') if(name === 'post.it.vd')
{ {
className = 'post_it_vd'; className = 'post_it_vd';
name = 'post_id_vd'; name = 'post_id_vd';
@ -189,12 +189,12 @@ export class RoomContentLoader implements IFurnitureDataListener
this._wallItemTypes.set(id, className); this._wallItemTypes.set(id, className);
this._wallItemTypeIds.set(className, id); this._wallItemTypeIds.set(className, id);
if (!this._wallItems[name]) this._wallItems[name] = 1; if(!this._wallItems[name]) this._wallItems[name] = 1;
} }
const existingRevision = this._furniRevisions.get(name); const existingRevision = this._furniRevisions.get(name);
if (revision > existingRevision) if(revision > existingRevision)
{ {
this._furniRevisions.delete(name); this._furniRevisions.delete(name);
this._furniRevisions.set(name, revision); this._furniRevisions.set(name, revision);
@ -213,7 +213,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
let type = this._wallItemTypes.get(typeId); let type = this._wallItemTypes.get(typeId);
if ((type === 'poster') && (extra !== null)) type = (type + extra); if((type === 'poster') && (extra !== null)) type = (type + extra);
return this.removeColorIndex(type); return this.removeColorIndex(type);
} }
@ -222,7 +222,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const type = this._activeObjectTypes.get(typeId); const type = this._activeObjectTypes.get(typeId);
if (!type) return -1; if(!type) return -1;
return this.getColorIndexFromName(type); return this.getColorIndexFromName(type);
} }
@ -231,29 +231,29 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const type = this._wallItemTypes.get(typeId); const type = this._wallItemTypes.get(typeId);
if (!type) return -1; if(!type) return -1;
return this.getColorIndexFromName(type); return this.getColorIndexFromName(type);
} }
private getColorIndexFromName(name: string): number private getColorIndexFromName(name: string): number
{ {
if (!name) return -1; if(!name) return -1;
const index = name.indexOf('*'); const index = name.indexOf('*');
if (index === -1) return 0; if(index === -1) return 0;
return parseInt(name.substr(index + 1)); return parseInt(name.substr(index + 1));
} }
private removeColorIndex(name: string): string private removeColorIndex(name: string): string
{ {
if (!name) return null; if(!name) return null;
const index = name.indexOf('*'); const index = name.indexOf('*');
if (index === -1) return name; if(index === -1) return name;
return name.substr(0, index); return name.substr(0, index);
} }
@ -262,7 +262,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const value = this._objectTypeAdUrls.get(type); const value = this._objectTypeAdUrls.get(type);
if (!value) return ''; if(!value) return '';
return value; return value;
} }
@ -271,7 +271,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const colorResults = this._petColors.get(petIndex); const colorResults = this._petColors.get(petIndex);
if (!colorResults) return null; if(!colorResults) return null;
return colorResults.get(paletteIndex); return colorResults.get(paletteIndex);
} }
@ -281,11 +281,11 @@ export class RoomContentLoader implements IFurnitureDataListener
const colorResults = this._petColors.get(petIndex); const colorResults = this._petColors.get(petIndex);
const results: PetColorResult[] = []; const results: PetColorResult[] = [];
if (colorResults) if(colorResults)
{ {
for (const result of colorResults.values()) for(const result of colorResults.values())
{ {
if (result.tag === tagName) results.push(result); if(result.tag === tagName) results.push(result);
} }
} }
@ -294,15 +294,15 @@ export class RoomContentLoader implements IFurnitureDataListener
public getCollection(name: string): IGraphicAssetCollection public getCollection(name: string): IGraphicAssetCollection
{ {
if (!name) return null; if(!name) return null;
const existing = this._collections.get(name); const existing = this._collections.get(name);
if (!existing) if(!existing)
{ {
const globalCollection = Nitro.instance.core.asset.getCollection(name); const globalCollection = Nitro.instance.core.asset.getCollection(name);
if (globalCollection) if(globalCollection)
{ {
this._collections.set(name, globalCollection); this._collections.set(name, globalCollection);
@ -317,18 +317,18 @@ export class RoomContentLoader implements IFurnitureDataListener
public getGifCollection(name: string): GraphicAssetGifCollection public getGifCollection(name: string): GraphicAssetGifCollection
{ {
if (!name) return null; if(!name) return null;
return this._gifCollections.get(name) || null; return this._gifCollections.get(name) || null;
} }
public getImage(name: string): HTMLImageElement public getImage(name: string): HTMLImageElement
{ {
if (!name) return null; if(!name) return null;
const existing = this._images.get(name); const existing = this._images.get(name);
if (!existing) return null; if(!existing) return null;
const image = new Image(); const image = new Image();
@ -341,14 +341,14 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const collection = this.getCollection(collectionName); const collection = this.getCollection(collectionName);
if (!collection) return false; if(!collection) return false;
return collection.addAsset(assetName, texture, override, 0, 0, false, false); return collection.addAsset(assetName, texture, override, 0, 0, false, false);
} }
public createGifCollection(collectionName: string, textures: Texture<Resource>[], durations: number[]): GraphicAssetGifCollection public createGifCollection(collectionName: string, textures: Texture<Resource>[], durations: number[]): GraphicAssetGifCollection
{ {
if (!collectionName || !textures || !durations) return null; if(!collectionName || !textures || !durations) return null;
const collection = new GraphicAssetGifCollection(collectionName, textures, durations); const collection = new GraphicAssetGifCollection(collectionName, textures, durations);
@ -359,7 +359,7 @@ export class RoomContentLoader implements IFurnitureDataListener
private createCollection(data: IAssetData, spritesheet: Spritesheet): GraphicAssetCollection private createCollection(data: IAssetData, spritesheet: Spritesheet): GraphicAssetCollection
{ {
if (!data || !spritesheet) return null; if(!data || !spritesheet) return null;
const collection = new GraphicAssetCollection(data, spritesheet); const collection = new GraphicAssetCollection(data, spritesheet);
@ -367,12 +367,12 @@ export class RoomContentLoader implements IFurnitureDataListener
const petIndex = this._pets[collection.name]; const petIndex = this._pets[collection.name];
if (petIndex !== undefined) if(petIndex !== undefined)
{ {
const keys = collection.getPaletteNames(); const keys = collection.getPaletteNames();
const palettes: Map<number, PetColorResult> = new Map(); const palettes: Map<number, PetColorResult> = new Map();
for (const key of keys) for(const key of keys)
{ {
const palette = collection.getPalette(key); const palette = collection.getPalette(key);
const paletteData = data.palettes[key]; const paletteData = data.palettes[key];
@ -395,14 +395,14 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const category = this.getCategoryForType(type); const category = this.getCategoryForType(type);
switch (category) switch(category)
{ {
case RoomObjectCategory.FLOOR: case RoomObjectCategory.FLOOR:
return RoomContentLoader.PLACE_HOLDER; return RoomContentLoader.PLACE_HOLDER;
case RoomObjectCategory.WALL: case RoomObjectCategory.WALL:
return RoomContentLoader.PLACE_HOLDER_WALL; return RoomContentLoader.PLACE_HOLDER_WALL;
default: default:
if (this._pets[type] !== undefined) return RoomContentLoader.PLACE_HOLDER_PET; if(this._pets[type] !== undefined) return RoomContentLoader.PLACE_HOLDER_PET;
return RoomContentLoader.PLACE_HOLDER_DEFAULT; return RoomContentLoader.PLACE_HOLDER_DEFAULT;
} }
@ -410,27 +410,27 @@ export class RoomContentLoader implements IFurnitureDataListener
public getCategoryForType(type: string): number public getCategoryForType(type: string): number
{ {
if (!type) return RoomObjectCategory.MINIMUM; if(!type) return RoomObjectCategory.MINIMUM;
if (this._activeObjects[type] !== undefined) return RoomObjectCategory.FLOOR; if(this._activeObjects[type] !== undefined) return RoomObjectCategory.FLOOR;
if (this._wallItems[type] !== undefined) return RoomObjectCategory.WALL; if(this._wallItems[type] !== undefined) return RoomObjectCategory.WALL;
if (this._pets[type] !== undefined) return RoomObjectCategory.UNIT; if(this._pets[type] !== undefined) return RoomObjectCategory.UNIT;
if (type.indexOf('poster') === 0) return RoomObjectCategory.WALL; if(type.indexOf('poster') === 0) return RoomObjectCategory.WALL;
if (type === 'room') return RoomObjectCategory.ROOM; if(type === 'room') return RoomObjectCategory.ROOM;
if (type === RoomObjectUserType.USER) return RoomObjectCategory.UNIT; if(type === RoomObjectUserType.USER) return RoomObjectCategory.UNIT;
if (type === RoomObjectUserType.PET) return RoomObjectCategory.UNIT; if(type === RoomObjectUserType.PET) return RoomObjectCategory.UNIT;
if (type === RoomObjectUserType.BOT) return RoomObjectCategory.UNIT; if(type === RoomObjectUserType.BOT) return RoomObjectCategory.UNIT;
if (type === RoomObjectUserType.RENTABLE_BOT) return RoomObjectCategory.UNIT; if(type === RoomObjectUserType.RENTABLE_BOT) return RoomObjectCategory.UNIT;
if ((type === RoomContentLoader.TILE_CURSOR) || (type === RoomContentLoader.SELECTION_ARROW)) return RoomObjectCategory.CURSOR; if((type === RoomContentLoader.TILE_CURSOR) || (type === RoomContentLoader.SELECTION_ARROW)) return RoomObjectCategory.CURSOR;
return RoomObjectCategory.MINIMUM; return RoomObjectCategory.MINIMUM;
} }
@ -444,7 +444,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
type = RoomObjectUserType.getRealType(type); type = RoomObjectUserType.getRealType(type);
if (type === RoomObjectVisualizationType.USER) return false; if(type === RoomObjectVisualizationType.USER) return false;
return true; return true;
} }
@ -454,13 +454,13 @@ export class RoomContentLoader implements IFurnitureDataListener
let typeName: string = null; let typeName: string = null;
let assetUrls: string[] = []; let assetUrls: string[] = [];
if (type && (type.indexOf(',') >= 0)) if(type && (type.indexOf(',') >= 0))
{ {
typeName = type; typeName = type;
type = typeName.split(',')[0]; type = typeName.split(',')[0];
} }
if (typeName) if(typeName)
{ {
assetUrls = this.getAssetUrls(typeName, param, true); assetUrls = this.getAssetUrls(typeName, param, true);
} }
@ -469,7 +469,7 @@ export class RoomContentLoader implements IFurnitureDataListener
assetUrls = this.getAssetUrls(type, param, true); assetUrls = this.getAssetUrls(type, param, true);
} }
if (assetUrls && assetUrls.length) if(assetUrls && assetUrls.length)
{ {
const url = assetUrls[0]; const url = assetUrls[0];
@ -505,18 +505,18 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const assetUrls: string[] = this.getAssetUrls(type); const assetUrls: string[] = this.getAssetUrls(type);
if (!assetUrls || !assetUrls.length) return; if(!assetUrls || !assetUrls.length) return;
if ((this._pendingContentTypes.indexOf(type) >= 0) || this.getOrRemoveEventDispatcher(type)) return; if((this._pendingContentTypes.indexOf(type) >= 0) || this.getOrRemoveEventDispatcher(type)) return;
this._pendingContentTypes.push(type); this._pendingContentTypes.push(type);
this._events.set(type, events); this._events.set(type, events);
const loader = new Loader(); const loader = new Loader();
for (const url of assetUrls) for(const url of assetUrls)
{ {
if (!url || !url.length) continue; if(!url || !url.length) continue;
loader loader
.add({ .add({
@ -531,7 +531,7 @@ export class RoomContentLoader implements IFurnitureDataListener
const onDownloaded = (status: boolean, url: string) => const onDownloaded = (status: boolean, url: string) =>
{ {
if (!status) if(!status)
{ {
this._logger.error('Failed to download asset', url); this._logger.error('Failed to download asset', url);
@ -544,13 +544,13 @@ export class RoomContentLoader implements IFurnitureDataListener
remaining--; remaining--;
if (!remaining) if(!remaining)
{ {
loader.destroy(); loader.destroy();
const events = this._events.get(type); const events = this._events.get(type);
if (!events) return; if(!events) return;
events.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_SUCCESS, type)); events.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_SUCCESS, type));
@ -560,11 +560,11 @@ export class RoomContentLoader implements IFurnitureDataListener
loader.load((loader, resources) => loader.load((loader, resources) =>
{ {
for (const key in resources) for(const key in resources)
{ {
const resource = resources[key]; const resource = resources[key];
if (!resource || resource.error || !resource.xhr) if(!resource || resource.error || !resource.xhr)
{ {
onDownloaded(false, resource.url); onDownloaded(false, resource.url);
@ -573,7 +573,7 @@ export class RoomContentLoader implements IFurnitureDataListener
const resourceType = (resource.xhr.getResponseHeader('Content-Type') || 'application/octet-stream'); const resourceType = (resource.xhr.getResponseHeader('Content-Type') || 'application/octet-stream');
if (resourceType === 'application/octet-stream') if(resourceType === 'application/octet-stream')
{ {
const nitroBundle = new NitroBundle(resource.data); const nitroBundle = new NitroBundle(resource.data);
@ -592,7 +592,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const spritesheetData = data.spritesheet; const spritesheetData = data.spritesheet;
if (!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length) if(!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length)
{ {
this.createCollection(data, null); this.createCollection(data, null);
@ -613,7 +613,7 @@ export class RoomContentLoader implements IFurnitureDataListener
}); });
}; };
if (baseTexture.valid) if(baseTexture.valid)
{ {
createAsset(); createAsset();
} }
@ -633,7 +633,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const existing = this._objectAliases.get(name); const existing = this._objectAliases.get(name);
if (!existing) return name; if(!existing) return name;
return existing; return existing;
} }
@ -642,14 +642,14 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const existing = this._objectOriginalNames.get(name); const existing = this._objectOriginalNames.get(name);
if (!existing) return name; if(!existing) return name;
return existing; return existing;
} }
public getAssetUrls(type: string, param: string = null, icon: boolean = false): string[] public getAssetUrls(type: string, param: string = null, icon: boolean = false): string[]
{ {
switch (type) switch(type)
{ {
case RoomContentLoader.PLACE_HOLDER: case RoomContentLoader.PLACE_HOLDER:
return [this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER)]; return [this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER)];
@ -666,13 +666,13 @@ export class RoomContentLoader implements IFurnitureDataListener
default: { default: {
const category = this.getCategoryForType(type); const category = this.getCategoryForType(type);
if ((category === RoomObjectCategory.FLOOR) || (category === RoomObjectCategory.WALL)) if((category === RoomObjectCategory.FLOOR) || (category === RoomObjectCategory.WALL))
{ {
const name = this.getAssetAliasName(type); const name = this.getAssetAliasName(type);
let assetUrl = (icon ? this.getAssetUrlWithFurniIconBase(name) : this.getAssetUrlWithFurniBase(type)); let assetUrl = (icon ? this.getAssetUrlWithFurniIconBase(name) : this.getAssetUrlWithFurniBase(type));
if (icon) if(icon)
{ {
const active = (param && (param !== '') && (this._activeObjectTypeIds.has((name + '*' + param)))); const active = (param && (param !== '') && (this._activeObjectTypeIds.has((name + '*' + param))));
@ -682,7 +682,7 @@ export class RoomContentLoader implements IFurnitureDataListener
return [assetUrl]; return [assetUrl];
} }
if (category === RoomObjectCategory.UNIT) if(category === RoomObjectCategory.UNIT)
{ {
return [this.getAssetUrlWithPetBase(type)]; return [this.getAssetUrlWithPetBase(type)];
} }
@ -697,14 +697,14 @@ export class RoomContentLoader implements IFurnitureDataListener
let assetName: string = null; let assetName: string = null;
let assetUrls: string[] = []; let assetUrls: string[] = [];
if (type && (type.indexOf(',') >= 0)) if(type && (type.indexOf(',') >= 0))
{ {
assetName = type; assetName = type;
type = assetName.split(',')[0]; type = assetName.split(',')[0];
} }
if (assetName) if(assetName)
{ {
assetUrls = this.getAssetUrls(assetName, colorIndex, true); assetUrls = this.getAssetUrls(assetName, colorIndex, true);
} }
@ -713,7 +713,7 @@ export class RoomContentLoader implements IFurnitureDataListener
assetUrls = this.getAssetUrls(type, colorIndex, true); assetUrls = this.getAssetUrls(type, colorIndex, true);
} }
if (assetUrls && assetUrls.length) return assetUrls[0]; if(assetUrls && assetUrls.length) return assetUrls[0];
return null; return null;
} }
@ -742,7 +742,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const model = object && object.model; const model = object && object.model;
if (!model) return; if(!model) return;
model.setValue(RoomObjectVariable.OBJECT_ROOM_ID, roomId); model.setValue(RoomObjectVariable.OBJECT_ROOM_ID, roomId);
} }
@ -751,7 +751,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const existing = this._events.get(type); const existing = this._events.get(type);
if (remove) this._events.delete(type); if(remove) this._events.delete(type);
return existing; return existing;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -74,23 +74,23 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
{ {
const logic = this.getLogicType(type); const logic = this.getLogicType(type);
if (!logic) return null; if(!logic) return null;
const instance = (new logic() as IRoomObjectEventHandler); const instance = (new logic() as IRoomObjectEventHandler);
if (!instance) return null; if(!instance) return null;
instance.eventDispatcher = this._events; instance.eventDispatcher = this._events;
if (!this._cachedEvents.get(type)) if(!this._cachedEvents.get(type))
{ {
this._cachedEvents.set(type, true); this._cachedEvents.set(type, true);
const eventTypes = instance.getEventTypes(); const eventTypes = instance.getEventTypes();
for (const eventType of eventTypes) for(const eventType of eventTypes)
{ {
if (!eventType) continue; if(!eventType) continue;
this.registerEventType(eventType); this.registerEventType(eventType);
} }
@ -101,13 +101,13 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
private registerEventType(type: string): void private registerEventType(type: string): void
{ {
if (this._registeredEvents.get(type)) return; if(this._registeredEvents.get(type)) return;
this._registeredEvents.set(type, true); this._registeredEvents.set(type, true);
for (const func of this._functions) for(const func of this._functions)
{ {
if (!func) continue; if(!func) continue;
this._events.addEventListener(type, func); this._events.addEventListener(type, func);
} }
@ -115,15 +115,15 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public registerEventFunction(func: Function): void public registerEventFunction(func: Function): void
{ {
if (!func) return; if(!func) return;
if (this._functions.indexOf(func) >= 0) return; if(this._functions.indexOf(func) >= 0) return;
this._functions.push(func); this._functions.push(func);
for (const eventType of this._registeredEvents.keys()) for(const eventType of this._registeredEvents.keys())
{ {
if (!eventType) continue; if(!eventType) continue;
this._events.addEventListener(eventType, func); this._events.addEventListener(eventType, func);
} }
@ -131,17 +131,17 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public removeEventFunction(func: Function): void public removeEventFunction(func: Function): void
{ {
if (!func) return; if(!func) return;
const index = this._functions.indexOf(func); const index = this._functions.indexOf(func);
if (index === -1) return; if(index === -1) return;
this._functions.splice(index, 1); this._functions.splice(index, 1);
for (const event of this._registeredEvents.keys()) for(const event of this._registeredEvents.keys())
{ {
if (!event) continue; if(!event) continue;
this._events.removeEventListener(event, func); this._events.removeEventListener(event, func);
} }
@ -149,11 +149,11 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public getLogicType(type: string): typeof RoomObjectLogicBase public getLogicType(type: string): typeof RoomObjectLogicBase
{ {
if (!type) return null; if(!type) return null;
let logic: typeof RoomObjectLogicBase = null; let logic: typeof RoomObjectLogicBase = null;
switch (type) switch(type)
{ {
case RoomObjectLogicType.ROOM: case RoomObjectLogicType.ROOM:
logic = RoomLogic; logic = RoomLogic;
@ -354,7 +354,7 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
break; break;
} }
if (!logic) if(!logic)
{ {
NitroLogger.warn('Unknown Logic', type); NitroLogger.warn('Unknown Logic', type);

View File

@ -63,18 +63,18 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
{ {
const visualization = this.getVisualizationType(type); const visualization = this.getVisualizationType(type);
if (!visualization) return null; if(!visualization) return null;
return new visualization(); return new visualization();
} }
public getVisualizationType(type: string): typeof RoomObjectSpriteVisualization public getVisualizationType(type: string): typeof RoomObjectSpriteVisualization
{ {
if (!type) return null; if(!type) return null;
let visualization: typeof RoomObjectSpriteVisualization = null; let visualization: typeof RoomObjectSpriteVisualization = null;
switch (type) switch(type)
{ {
case RoomObjectVisualizationType.ROOM: case RoomObjectVisualizationType.ROOM:
visualization = RoomVisualization; visualization = RoomVisualization;
@ -185,7 +185,7 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
break; break;
} }
if (!visualization) if(!visualization)
{ {
NitroLogger.log('Unknown Visualization', type); NitroLogger.log('Unknown Visualization', type);
@ -199,11 +199,11 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
{ {
const existing = this._visualizationDatas.get(type); const existing = this._visualizationDatas.get(type);
if (existing) return existing; if(existing) return existing;
let visualizationData: IObjectVisualizationData = null; let visualizationData: IObjectVisualizationData = null;
switch (visualization) switch(visualization)
{ {
case RoomObjectVisualizationType.FURNITURE_STATIC: case RoomObjectVisualizationType.FURNITURE_STATIC:
case RoomObjectVisualizationType.FURNITURE_GIFT_WRAPPED: case RoomObjectVisualizationType.FURNITURE_GIFT_WRAPPED:
@ -255,21 +255,21 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
break; break;
} }
if (!visualizationData) return null; if(!visualizationData) return null;
if (!visualizationData.initialize(asset)) if(!visualizationData.initialize(asset))
{ {
visualizationData.dispose(); visualizationData.dispose();
return null; return null;
} }
if ((visualizationData instanceof AvatarVisualizationData) || (visualizationData instanceof FurnitureMannequinVisualizationData)) if((visualizationData instanceof AvatarVisualizationData) || (visualizationData instanceof FurnitureMannequinVisualizationData))
{ {
visualizationData.avatarManager = Nitro.instance.avatar; visualizationData.avatarManager = Nitro.instance.avatar;
} }
if (RoomObjectVisualizationFactory.CACHING_ENABLED) this._visualizationDatas.set(type, visualizationData); if(RoomObjectVisualizationFactory.CACHING_ENABLED) this._visualizationDatas.set(type, visualizationData);
return visualizationData; return visualizationData;
} }

View File

@ -19,7 +19,7 @@ export class FurnitureYoutubeLogic extends FurnitureLogic
{ {
super.update(time); super.update(time);
if (!this.object.model.getValue<string>(RoomObjectVariable.SESSION_URL_PREFIX)) if(!this.object.model.getValue<string>(RoomObjectVariable.SESSION_URL_PREFIX))
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectDataRequestEvent(RoomObjectDataRequestEvent.RODRE_URL_PREFIX, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectDataRequestEvent(RoomObjectDataRequestEvent.RODRE_URL_PREFIX, this.object));
} }
@ -27,7 +27,7 @@ export class FurnitureYoutubeLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.YOUTUBE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.YOUTUBE, this.object));
} }

View File

@ -14,9 +14,9 @@ export class FurnitureFireworksVisualization extends FurnitureAnimatedVisualizat
this._currentParticleSystem = null; this._currentParticleSystem = null;
if (this._particleSystems) if(this._particleSystems)
{ {
for (const particleSystem of this._particleSystems.getValues()) particleSystem.dispose(); for(const particleSystem of this._particleSystems.getValues()) particleSystem.dispose();
this._particleSystems = null; this._particleSystems = null;
} }
@ -24,25 +24,25 @@ export class FurnitureFireworksVisualization extends FurnitureAnimatedVisualizat
protected updateObject(scale: number, direction: number): boolean protected updateObject(scale: number, direction: number): boolean
{ {
if (super.updateObject(scale, direction)) if(super.updateObject(scale, direction))
{ {
if (!this._particleSystems) if(!this._particleSystems)
{ {
this._Str_18684(); this._Str_18684();
if (this._particleSystems) this._currentParticleSystem = this._particleSystems.getValue(scale); if(this._particleSystems) this._currentParticleSystem = this._particleSystems.getValue(scale);
else NitroLogger.log('ERROR Particle systems could not be read!', this.object.type); else NitroLogger.log('ERROR Particle systems could not be read!', this.object.type);
} }
else else
{ {
if ((scale !== this._scale) || (this._particleSystems.getValue(scale) !== this._currentParticleSystem)) if((scale !== this._scale) || (this._particleSystems.getValue(scale) !== this._currentParticleSystem))
{ {
const particleSystem = this._particleSystems.getValue(scale); const particleSystem = this._particleSystems.getValue(scale);
particleSystem._Str_17988(this._currentParticleSystem); particleSystem._Str_17988(this._currentParticleSystem);
if (this._currentParticleSystem) this._currentParticleSystem.reset(); if(this._currentParticleSystem) this._currentParticleSystem.reset();
this._currentParticleSystem = particleSystem; this._currentParticleSystem = particleSystem;
} }
@ -58,26 +58,26 @@ export class FurnitureFireworksVisualization extends FurnitureAnimatedVisualizat
{ {
super.updateSprites(scale, update, animation); super.updateSprites(scale, update, animation);
if (this._currentParticleSystem) this._currentParticleSystem.updateSprites(); if(this._currentParticleSystem) this._currentParticleSystem.updateSprites();
} }
protected updateAnimation(scale: number): number protected updateAnimation(scale: number): number
{ {
if (this._currentParticleSystem) this._currentParticleSystem.updateAnimation(); if(this._currentParticleSystem) this._currentParticleSystem.updateAnimation();
return super.updateAnimation(scale); return super.updateAnimation(scale);
} }
protected setAnimation(id: number): void protected setAnimation(id: number): void
{ {
if (this._currentParticleSystem) this._currentParticleSystem.setAnimation(id); if(this._currentParticleSystem) this._currentParticleSystem.setAnimation(id);
super.setAnimation(id); super.setAnimation(id);
} }
protected getLayerYOffset(scale: number, direction: number, layerId: number): number protected getLayerYOffset(scale: number, direction: number, layerId: number): number
{ {
if (this._currentParticleSystem && this._currentParticleSystem.controlsSprite(layerId)) if(this._currentParticleSystem && this._currentParticleSystem.controlsSprite(layerId))
{ {
return this._currentParticleSystem.getLayerYOffset(scale, direction, layerId); return this._currentParticleSystem.getLayerYOffset(scale, direction, layerId);
} }
@ -87,15 +87,15 @@ export class FurnitureFireworksVisualization extends FurnitureAnimatedVisualizat
private _Str_18684(): boolean private _Str_18684(): boolean
{ {
if (!this.object || !this.object.model) return false; if(!this.object || !this.object.model) return false;
const fireworksData = this.object.model.getValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA); const fireworksData = this.object.model.getValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA);
if (!fireworksData || !fireworksData.length) return false; if(!fireworksData || !fireworksData.length) return false;
this._particleSystems = new AdvancedMap(); this._particleSystems = new AdvancedMap();
for (const particleData of fireworksData) for(const particleData of fireworksData)
{ {
const size = particleData.size; const size = particleData.size;
const particleSystem = new FurnitureParticleSystem(this); const particleSystem = new FurnitureParticleSystem(this);

View File

@ -14,7 +14,7 @@ export class TileObjectMap
let index = 0; let index = 0;
while (index < _arg_2) while(index < _arg_2)
{ {
this._tileObjectMap.set(index, new Map()); this._tileObjectMap.set(index, new Map());
@ -27,9 +27,9 @@ export class TileObjectMap
public clear(): void public clear(): void
{ {
for (const k of this._tileObjectMap.values()) for(const k of this._tileObjectMap.values())
{ {
if (!k) continue; if(!k) continue;
k.clear(); k.clear();
} }
@ -41,7 +41,7 @@ export class TileObjectMap
{ {
this.clear(); this.clear();
for (const _local_2 of k) this.addRoomObject(_local_2); for(const _local_2 of k) this.addRoomObject(_local_2);
} }
public dispose(): void public dispose(): void
@ -53,11 +53,11 @@ export class TileObjectMap
public getObjectIntTile(k: number, _arg_2: number): IRoomObject public getObjectIntTile(k: number, _arg_2: number): IRoomObject
{ {
if ((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height)) if((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height))
{ {
const existing = this._tileObjectMap.get(_arg_2); const existing = this._tileObjectMap.get(_arg_2);
if (existing) return existing.get(k); if(existing) return existing.get(k);
} }
return null; return null;
@ -65,51 +65,51 @@ export class TileObjectMap
public setObjectInTile(k: number, _arg_2: number, _arg_3: IRoomObject): void public setObjectInTile(k: number, _arg_2: number, _arg_3: IRoomObject): void
{ {
if (!_arg_3.isReady) if(!_arg_3.isReady)
{ {
NitroLogger.log('Assigning non initialized object to tile object map!'); NitroLogger.log('Assigning non initialized object to tile object map!');
return; return;
} }
if ((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height)) if((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height))
{ {
const existing = this._tileObjectMap.get(_arg_2); const existing = this._tileObjectMap.get(_arg_2);
if (existing) existing.set(k, _arg_3); if(existing) existing.set(k, _arg_3);
} }
} }
public addRoomObject(k: IRoomObject): void public addRoomObject(k: IRoomObject): void
{ {
if (!k || !k.model || !k.isReady) return; if(!k || !k.model || !k.isReady) return;
const location = k.getLocation(); const location = k.getLocation();
const direction = k.getDirection(); const direction = k.getDirection();
if (!location || !direction) return; if(!location || !direction) return;
let sizeX = k.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_X); let sizeX = k.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_X);
let sizeY = k.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_Y); let sizeY = k.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_Y);
if (sizeX < 1) sizeX = 1; if(sizeX < 1) sizeX = 1;
if (sizeY < 1) sizeY = 1; if(sizeY < 1) sizeY = 1;
const directionNumber = ((Math.trunc((direction.x + 45)) % 360) / 90); const directionNumber = ((Math.trunc((direction.x + 45)) % 360) / 90);
if ((directionNumber === 1) || (directionNumber === 3)) [sizeX, sizeY] = [sizeY, sizeX]; if((directionNumber === 1) || (directionNumber === 3)) [sizeX, sizeY] = [sizeY, sizeX];
let y = location.y; let y = location.y;
while (y < (location.y + sizeY)) while(y < (location.y + sizeY))
{ {
let x = location.x; let x = location.x;
while (x < (location.x + sizeX)) while(x < (location.x + sizeX))
{ {
const roomObject = this.getObjectIntTile(x, y); const roomObject = this.getObjectIntTile(x, y);
if ((!(roomObject)) || ((!(roomObject === k)) && (roomObject.getLocation().z <= location.z))) if((!(roomObject)) || ((!(roomObject === k)) && (roomObject.getLocation().z <= location.z)))
{ {
this.setObjectInTile(x, y, k); this.setObjectInTile(x, y, k);
} }

View File

@ -76,7 +76,7 @@ export class RoomSession extends Disposable implements IRoomSession
protected onDispose(): void protected onDispose(): void
{ {
if (this._userData) if(this._userData)
{ {
this._userData.dispose(); this._userData.dispose();
@ -88,16 +88,16 @@ export class RoomSession extends Disposable implements IRoomSession
public setConnection(connection: IConnection): void public setConnection(connection: IConnection): void
{ {
if (this._connection || !connection) return; if(this._connection || !connection) return;
this._connection = connection; this._connection = connection;
if (this._userData) this._userData.setConnection(connection); if(this._userData) this._userData.setConnection(connection);
} }
public setControllerLevel(level: number): void public setControllerLevel(level: number): void
{ {
if ((level >= RoomControllerLevel.NONE) && (level <= RoomControllerLevel.MODERATOR)) if((level >= RoomControllerLevel.NONE) && (level <= RoomControllerLevel.MODERATOR))
{ {
this._controllerLevel = level; this._controllerLevel = level;
@ -119,7 +119,7 @@ export class RoomSession extends Disposable implements IRoomSession
public start(): boolean public start(): boolean
{ {
if (this._state !== RoomSessionEvent.CREATED || !this._connection) return false; if(this._state !== RoomSessionEvent.CREATED || !this._connection) return false;
this._state = RoomSessionEvent.STARTED; this._state = RoomSessionEvent.STARTED;
@ -128,7 +128,7 @@ export class RoomSession extends Disposable implements IRoomSession
private enterRoom(): boolean private enterRoom(): boolean
{ {
if (!this._connection) return false; if(!this._connection) return false;
this._connection.send(new RoomEnterComposer(this._roomId, this._password)); this._connection.send(new RoomEnterComposer(this._roomId, this._password));
@ -137,7 +137,7 @@ export class RoomSession extends Disposable implements IRoomSession
public reset(roomId: number): void public reset(roomId: number): void
{ {
if (roomId === this._roomId) return; if(roomId === this._roomId) return;
this._roomId = roomId; this._roomId = roomId;
} }
@ -159,7 +159,7 @@ export class RoomSession extends Disposable implements IRoomSession
public sendChatTypingMessage(isTyping: boolean): void public sendChatTypingMessage(isTyping: boolean): void
{ {
if (isTyping) this._connection.send(new RoomUnitTypingStartComposer()); if(isTyping) this._connection.send(new RoomUnitTypingStartComposer());
else this._connection.send(new RoomUnitTypingStopComposer()); else this._connection.send(new RoomUnitTypingStopComposer());
} }
@ -180,7 +180,7 @@ export class RoomSession extends Disposable implements IRoomSession
public sendSignMessage(sign: number): void public sendSignMessage(sign: number): void
{ {
if ((sign < 0) || (sign > 17)) return; if((sign < 0) || (sign > 17)) return;
this._connection.send(new RoomUnitSignComposer(sign)); this._connection.send(new RoomUnitSignComposer(sign));
} }
@ -255,21 +255,21 @@ export class RoomSession extends Disposable implements IRoomSession
public pickupPet(id: number): void public pickupPet(id: number): void
{ {
if (!this._connection) return; if(!this._connection) return;
this._connection.send(new PetRemoveComposer(id)); this._connection.send(new PetRemoveComposer(id));
} }
public pickupBot(id: number): void public pickupBot(id: number): void
{ {
if (!this._connection) return; if(!this._connection) return;
this._connection.send(new BotRemoveComposer(id)); this._connection.send(new BotRemoveComposer(id));
} }
public requestMoodlightSettings(): void public requestMoodlightSettings(): void
{ {
if (!this._connection) return; if(!this._connection) return;
this._connection.send(new MoodlightSettingsComposer()); this._connection.send(new MoodlightSettingsComposer());
} }

View File

@ -143,14 +143,14 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
{ {
this.destroyFurnitureData(); this.destroyFurnitureData();
if (this._ignoredUsersManager) if(this._ignoredUsersManager)
{ {
this._ignoredUsersManager.dispose(); this._ignoredUsersManager.dispose();
this._ignoredUsersManager = null; this._ignoredUsersManager = null;
} }
if (this._groupInformationManager) if(this._groupInformationManager)
{ {
this._groupInformationManager.dispose(); this._groupInformationManager.dispose();
@ -196,7 +196,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private loadBadgeImageManager(): void private loadBadgeImageManager(): void
{ {
if (this._badgeImageManager) return; if(this._badgeImageManager) return;
this._badgeImageManager = new BadgeImageManager(Nitro.instance.core.asset, this); this._badgeImageManager = new BadgeImageManager(Nitro.instance.core.asset, this);
this._badgeImageManager.init(); this._badgeImageManager.init();
@ -204,34 +204,34 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
public hasProductData(listener: IProductDataListener): boolean public hasProductData(listener: IProductDataListener): boolean
{ {
if (this._productsReady) return true; if(this._productsReady) return true;
if (listener && (this._pendingProductListeners.indexOf(listener) === -1)) this._pendingProductListeners.push(listener); if(listener && (this._pendingProductListeners.indexOf(listener) === -1)) this._pendingProductListeners.push(listener);
return false; return false;
} }
public getAllFurnitureData(listener: IFurnitureDataListener): IFurnitureData[] public getAllFurnitureData(listener: IFurnitureDataListener): IFurnitureData[]
{ {
if (!this._furnitureReady) if(!this._furnitureReady)
{ {
if (this._pendingFurnitureListeners.indexOf(listener) === -1) this._pendingFurnitureListeners.push(listener); if(this._pendingFurnitureListeners.indexOf(listener) === -1) this._pendingFurnitureListeners.push(listener);
return null; return null;
} }
const furnitureData: IFurnitureData[] = []; const furnitureData: IFurnitureData[] = [];
for (const data of this._floorItems.values()) for(const data of this._floorItems.values())
{ {
if (!data) continue; if(!data) continue;
furnitureData.push(data); furnitureData.push(data);
} }
for (const data of this._wallItems.values()) for(const data of this._wallItems.values())
{ {
if (!data) continue; if(!data) continue;
furnitureData.push(data); furnitureData.push(data);
} }
@ -241,18 +241,18 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
public removePendingFurniDataListener(listener: IFurnitureDataListener): void public removePendingFurniDataListener(listener: IFurnitureDataListener): void
{ {
if (!this._pendingFurnitureListeners) return; if(!this._pendingFurnitureListeners) return;
const index = this._pendingFurnitureListeners.indexOf(listener); const index = this._pendingFurnitureListeners.indexOf(listener);
if (index === -1) return; if(index === -1) return;
this._pendingFurnitureListeners.splice(index, 1); this._pendingFurnitureListeners.splice(index, 1);
} }
private onUserFigureEvent(event: FigureUpdateEvent): void private onUserFigureEvent(event: FigureUpdateEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
this._figure = event.getParser().figure; this._figure = event.getParser().figure;
this._gender = event.getParser().gender; this._gender = event.getParser().gender;
@ -262,13 +262,13 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private onUserInfoEvent(event: UserInfoEvent): void private onUserInfoEvent(event: UserInfoEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
this.resetUserInfo(); this.resetUserInfo();
const userInfo = event.getParser().userInfo; const userInfo = event.getParser().userInfo;
if (!userInfo) return; if(!userInfo) return;
this._userId = userInfo.userId; this._userId = userInfo.userId;
this._name = userInfo.username; this._name = userInfo.username;
@ -285,7 +285,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private onUserPermissionsEvent(event: UserPermissionsEvent): void private onUserPermissionsEvent(event: UserPermissionsEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
this._clubLevel = event.getParser().clubLevel; this._clubLevel = event.getParser().clubLevel;
this._securityLevel = event.getParser().securityLevel; this._securityLevel = event.getParser().securityLevel;
@ -294,11 +294,11 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private onAvailabilityStatusMessageEvent(event: AvailabilityStatusMessageEvent): void private onAvailabilityStatusMessageEvent(event: AvailabilityStatusMessageEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this._systemOpen = parser.isOpen; this._systemOpen = parser.isOpen;
this._systemShutdown = parser.onShutdown; this._systemShutdown = parser.onShutdown;
@ -307,13 +307,13 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private onChangeNameUpdateEvent(event: ChangeUserNameResultMessageEvent): void private onChangeNameUpdateEvent(event: ChangeUserNameResultMessageEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
if (parser.resultCode !== ChangeUserNameResultMessageEvent.NAME_OK) return; if(parser.resultCode !== ChangeUserNameResultMessageEvent.NAME_OK) return;
this._canChangeName = false; this._canChangeName = false;
@ -322,13 +322,13 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private onUserNameChangeMessageEvent(event: UserNameChangeMessageEvent): void private onUserNameChangeMessageEvent(event: UserNameChangeMessageEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
if (parser.webId !== this.userId) return; if(parser.webId !== this.userId) return;
this._name = parser.newName; this._name = parser.newName;
this._canChangeName = false; this._canChangeName = false;
@ -338,11 +338,11 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private onRoomModelNameEvent(event: RoomReadyMessageEvent): void private onRoomModelNameEvent(event: RoomReadyMessageEvent): void
{ {
if (!event) return; if(!event) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
HabboWebTools.roomVisited(parser.roomId); HabboWebTools.roomVisited(parser.roomId);
} }
@ -353,13 +353,13 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
this._furnitureReady = true; this._furnitureReady = true;
if (!this._furnitureListenersNotified) if(!this._furnitureListenersNotified)
{ {
this._furnitureListenersNotified = true; this._furnitureListenersNotified = true;
if (this._pendingFurnitureListeners && this._pendingFurnitureListeners.length) if(this._pendingFurnitureListeners && this._pendingFurnitureListeners.length)
{ {
for (const listener of this._pendingFurnitureListeners) listener && listener.loadFurnitureData(); for(const listener of this._pendingFurnitureListeners) listener && listener.loadFurnitureData();
} }
} }
@ -372,29 +372,29 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
this._productsReady = true; this._productsReady = true;
for (const listener of this._pendingProductListeners) listener && listener.loadProductData(); for(const listener of this._pendingProductListeners) listener && listener.loadProductData();
this._pendingProductListeners = []; this._pendingProductListeners = [];
} }
private onInClientLinkEvent(event: InClientLinkEvent): void private onInClientLinkEvent(event: InClientLinkEvent): void
{ {
if (!event) return; if(!event) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
Nitro.instance.createLinkEvent(parser.link); Nitro.instance.createLinkEvent(parser.link);
} }
private onMysteryBoxKeysEvent(event: MysteryBoxKeysEvent): void private onMysteryBoxKeysEvent(event: MysteryBoxKeysEvent): void
{ {
if (!event) return; if(!event) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this.events.dispatchEvent(new MysteryBoxKeysUpdateEvent(parser.boxColor, parser.keyColor)); this.events.dispatchEvent(new MysteryBoxKeysUpdateEvent(parser.boxColor, parser.keyColor));
} }
@ -403,7 +403,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
{ {
this._noobnessLevel = event.getParser().noobnessLevel; this._noobnessLevel = event.getParser().noobnessLevel;
if (this._noobnessLevel !== NoobnessLevelEnum.OLD_IDENTITY) if(this._noobnessLevel !== NoobnessLevelEnum.OLD_IDENTITY)
{ {
Nitro.instance.core.configuration.setValue<number>('new.identity', 1); Nitro.instance.core.configuration.setValue<number>('new.identity', 1);
} }
@ -419,7 +419,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private destroyFurnitureData(): void private destroyFurnitureData(): void
{ {
if (!this._furnitureData) return; if(!this._furnitureData) return;
this._furnitureData.dispose(); this._furnitureData.dispose();
@ -428,7 +428,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private destroyProductData(): void private destroyProductData(): void
{ {
if (!this._productData) return; if(!this._productData) return;
this._productData.dispose(); this._productData.dispose();
@ -439,18 +439,18 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
{ {
const existing = this._floorItems.get(id); const existing = this._floorItems.get(id);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public getFloorItemDataByName(name: string): IFurnitureData public getFloorItemDataByName(name: string): IFurnitureData
{ {
if (!name || !this._floorItems || !this._floorItems.size) return null; if(!name || !this._floorItems || !this._floorItems.size) return null;
for (const item of this._floorItems.values()) for(const item of this._floorItems.values())
{ {
if (!item || (item.className !== name)) continue; if(!item || (item.className !== name)) continue;
return item; return item;
} }
@ -460,18 +460,18 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
{ {
const existing = this._wallItems.get(id); const existing = this._wallItems.get(id);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public getWallItemDataByName(name: string): IFurnitureData public getWallItemDataByName(name: string): IFurnitureData
{ {
if (!name || !this._wallItems || !this._wallItems.size) return null; if(!name || !this._wallItems || !this._wallItems.size) return null;
for (const item of this._wallItems.values()) for(const item of this._wallItems.values())
{ {
if (!item || (item.className !== name)) continue; if(!item || (item.className !== name)) continue;
return item; return item;
} }
@ -479,7 +479,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
public getProductData(type: string): IProductData public getProductData(type: string): IProductData
{ {
if (!this._productsReady) this.loadProductData(); if(!this._productsReady) this.loadProductData();
return this._products.get(type); return this._products.get(type);
} }
@ -521,7 +521,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
public giveRespect(userId: number): void public giveRespect(userId: number): void
{ {
if ((userId < 0) || (this._respectsLeft <= 0)) return; if((userId < 0) || (this._respectsLeft <= 0)) return;
this.send(new UserRespectComposer(userId)); this.send(new UserRespectComposer(userId));
@ -530,7 +530,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
public givePetRespect(petId: number): void public givePetRespect(petId: number): void
{ {
if ((petId < 0) || (this._respectsPetLeft <= 0)) return; if((petId < 0) || (this._respectsPetLeft <= 0)) return;
this.send(new PetRespectComposer(petId)); this.send(new PetRespectComposer(petId));

View File

@ -4,6 +4,7 @@ import { IAssetManager } from '../../../core/asset/IAssetManager';
import { IMessageEvent } from '../../../core/communication/messages/IMessageEvent'; import { IMessageEvent } from '../../../core/communication/messages/IMessageEvent';
import { NitroSprite } from '../../../core/utils/proxy/NitroSprite'; import { NitroSprite } from '../../../core/utils/proxy/NitroSprite';
import { GroupBadgePartsEvent } from '../../communication/messages/incoming/group/GroupBadgePartsEvent'; import { GroupBadgePartsEvent } from '../../communication/messages/incoming/group/GroupBadgePartsEvent';
import { GroupBadgePartsComposer } from '../../communication/messages/outgoing/group/GroupBadgePartsComposer';
import { Nitro } from '../../Nitro'; import { Nitro } from '../../Nitro';
import { BadgeImageReadyEvent } from '../events/BadgeImageReadyEvent'; import { BadgeImageReadyEvent } from '../events/BadgeImageReadyEvent';
import { IDisposable } from './../../../core/common/disposable/IDisposable'; import { IDisposable } from './../../../core/common/disposable/IDisposable';
@ -56,7 +57,7 @@ export class BadgeImageManager implements IDisposable
for(const message of this._messages) this._sessionDataManager.communication.registerMessageEvent(message); for(const message of this._messages) this._sessionDataManager.communication.registerMessageEvent(message);
//this._sessionDataManager.send(new GroupBadgePartsComposer()); this._sessionDataManager.send(new GroupBadgePartsComposer());
} }
} }
@ -208,7 +209,7 @@ export class BadgeImageManager implements IDisposable
{ {
if(!partName || !partName.length) continue; if(!partName || !partName.length) continue;
const texture = this._assets.getTexture(`badgepart_${ partName }`); const texture = this._assets.getTexture(`badgepart_${partName}`);
if(!texture) continue; if(!texture) continue;
@ -243,9 +244,9 @@ export class BadgeImageManager implements IDisposable
if(!data) return; if(!data) return;
data.bases.forEach((names, id) => this._groupBases.set(id, names.map( val => val.replace('.png', '').replace('.gif', '')))); data.bases.forEach((names, id) => this._groupBases.set(id, names.map(val => val.replace('.png', '').replace('.gif', ''))));
data.symbols.forEach( (names, id) => this._groupSymbols.set(id, names.map( val => val.replace('.png', '').replace('.gif', '')))); data.symbols.forEach((names, id) => this._groupSymbols.set(id, names.map(val => val.replace('.png', '').replace('.gif', ''))));
this._groupPartColors = data.partColors; this._groupPartColors = data.partColors;
this._readyToGenerateGroupBadges = true; this._readyToGenerateGroupBadges = true;

View File

@ -51,21 +51,21 @@ export class RoomUsersHandler extends BaseHandler
private onRoomUnitEvent(event: RoomUnitEvent): void private onRoomUnitEvent(event: RoomUnitEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
const users = event.getParser().users; const users = event.getParser().users;
const usersToAdd: RoomUserData[] = []; const usersToAdd: RoomUserData[] = [];
if (users && users.length) if(users && users.length)
{ {
for (const user of users) for(const user of users)
{ {
if (!user) continue; if(!user) continue;
const userData = new RoomUserData(user.roomIndex); const userData = new RoomUserData(user.roomIndex);
@ -92,7 +92,7 @@ export class RoomUsersHandler extends BaseHandler
userData.botSkills = user.botSkills; userData.botSkills = user.botSkills;
userData.isModerator = user.isModerator; userData.isModerator = user.isModerator;
if (!session.userDataManager.getUserData(user.roomIndex)) usersToAdd.push(userData); if(!session.userDataManager.getUserData(user.roomIndex)) usersToAdd.push(userData);
session.userDataManager.updateUserData(userData); session.userDataManager.updateUserData(userData);
} }
@ -103,15 +103,15 @@ export class RoomUsersHandler extends BaseHandler
private onRoomUnitInfoEvent(event: RoomUnitInfoEvent): void private onRoomUnitInfoEvent(event: RoomUnitInfoEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
session.userDataManager.updateFigure(parser.unitId, parser.figure, parser.gender, false, false); session.userDataManager.updateFigure(parser.unitId, parser.figure, parser.gender, false, false);
session.userDataManager.updateMotto(parser.unitId, parser.motto); session.userDataManager.updateMotto(parser.unitId, parser.motto);
@ -123,41 +123,41 @@ export class RoomUsersHandler extends BaseHandler
private onRoomUnitRemoveEvent(event: RoomUnitRemoveEvent): void private onRoomUnitRemoveEvent(event: RoomUnitRemoveEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
session.userDataManager.removeUserData(event.getParser().unitId); session.userDataManager.removeUserData(event.getParser().unitId);
} }
private onRoomUnitDanceEvent(event: RoomUnitDanceEvent): void private onRoomUnitDanceEvent(event: RoomUnitDanceEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
this.listener.events.dispatchEvent(new RoomSessionDanceEvent(session, parser.unitId, parser.danceId)); this.listener.events.dispatchEvent(new RoomSessionDanceEvent(session, parser.unitId, parser.danceId));
} }
private onUserCurrentBadgesEvent(event: UserCurrentBadgesEvent): void private onUserCurrentBadgesEvent(event: UserCurrentBadgesEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
session.userDataManager.setUserBadges(parser.userId, parser.badges); session.userDataManager.setUserBadges(parser.userId, parser.badges);
@ -166,49 +166,49 @@ export class RoomUsersHandler extends BaseHandler
private onRoomDoorbellEvent(event: DoorbellMessageEvent): void private onRoomDoorbellEvent(event: DoorbellMessageEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const username = parser.userName; const username = parser.userName;
if (!username || !username.length) return; if(!username || !username.length) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
this.listener.events.dispatchEvent(new RoomSessionDoorbellEvent(RoomSessionDoorbellEvent.DOORBELL, session, username)); this.listener.events.dispatchEvent(new RoomSessionDoorbellEvent(RoomSessionDoorbellEvent.DOORBELL, session, username));
} }
private onUserNameChangeMessageEvent(event: UserNameChangeMessageEvent): void private onUserNameChangeMessageEvent(event: UserNameChangeMessageEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
session.userDataManager.updateName(parser.id, parser.newName); session.userDataManager.updateName(parser.id, parser.newName);
} }
private onNewFriendRequestEvent(event: NewFriendRequestEvent): void private onNewFriendRequestEvent(event: NewFriendRequestEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
const request = parser.request; const request = parser.request;
@ -217,15 +217,15 @@ export class RoomUsersHandler extends BaseHandler
private onPetInfoEvent(event: PetInfoEvent): void private onPetInfoEvent(event: PetInfoEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
const petData = new RoomPetData(); const petData = new RoomPetData();
@ -261,15 +261,15 @@ export class RoomUsersHandler extends BaseHandler
private onPetStatusUpdateEvent(event: PetStatusUpdateEvent): void private onPetStatusUpdateEvent(event: PetStatusUpdateEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
session.userDataManager.updatePetBreedingStatus(parser.roomIndex, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission); session.userDataManager.updatePetBreedingStatus(parser.roomIndex, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission);
@ -278,15 +278,15 @@ export class RoomUsersHandler extends BaseHandler
private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
const figure = parser.figureData.figuredata; const figure = parser.figureData.figuredata;
@ -297,21 +297,21 @@ export class RoomUsersHandler extends BaseHandler
private onPetPlacingError(event: PetPlacingErrorEvent): void private onPetPlacingError(event: PetPlacingErrorEvent): void
{ {
if (!event) return; if(!event) return;
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
let type: string = null; let type: string = null;
switch (parser.errorCode) switch(parser.errorCode)
{ {
case 0: case 0:
type = RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL; type = RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL;
@ -333,28 +333,28 @@ export class RoomUsersHandler extends BaseHandler
break; break;
} }
if (!type || type.length == 0) return; if(!type || type.length == 0) return;
this.listener.events.dispatchEvent(new RoomSessionErrorMessageEvent(type, session)); this.listener.events.dispatchEvent(new RoomSessionErrorMessageEvent(type, session));
} }
private onBotError(event: BotErrorEvent): void private onBotError(event: BotErrorEvent): void
{ {
if (!event) return; if(!event) return;
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
let type: string = null; let type: string = null;
switch (parser.errorCode) switch(parser.errorCode)
{ {
case 0: case 0:
type = RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL; type = RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL;
@ -373,23 +373,23 @@ export class RoomUsersHandler extends BaseHandler
break; break;
} }
if (!type || type.length == 0) return; if(!type || type.length == 0) return;
this.listener.events.dispatchEvent(new RoomSessionErrorMessageEvent(type, session)); this.listener.events.dispatchEvent(new RoomSessionErrorMessageEvent(type, session));
} }
private onFavoriteMembershipUpdateMessageEvent(event: FavoriteMembershipUpdateMessageEvent): void private onFavoriteMembershipUpdateMessageEvent(event: FavoriteMembershipUpdateMessageEvent): void
{ {
if (!this.listener) return; if(!this.listener) return;
const parser = event.getParser(); const parser = event.getParser();
const session = this.listener.getSession(this.roomId); const session = this.listener.getSession(this.roomId);
if (!session) return; if(!session) return;
const userData = session.userDataManager.getUserDataByIndex(parser.roomIndex); const userData = session.userDataManager.getUserDataByIndex(parser.roomIndex);
if (!userData) return; if(!userData) return;
userData.groupId = parser.groupId; userData.groupId = parser.groupId;
userData.groupName = parser.groupName; userData.groupName = parser.groupName;