From e27484a0398ef33020accc52c5a53c2fc8761345 Mon Sep 17 00:00:00 2001 From: Charsy89 Date: Wed, 20 Nov 2019 16:11:11 -0700 Subject: [PATCH] Fix verifySet, give msg syntax --- src/Room.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Room.js b/src/Room.js index a3019f1..e3322d5 100644 --- a/src/Room.js +++ b/src/Room.js @@ -11,7 +11,7 @@ class Room extends EventEmitter { this.server = server; this.crown = null; this.crowndropped = false; - this.settings = this.verifySet(this._id,settings); + this.settings = this.verifySet(this._id,{set:settings}); this.chatmsgs = []; this.ppl = new Map(); this.connections = []; @@ -102,7 +102,6 @@ class Room extends EventEmitter { options.name ? this.ppl.get(pid).user.name = options.name : {}; options._id ? this.ppl.get(pid).user._id = options._id : {}; options.color ? this.ppl.get(pid).user.color = options.color : {}; - options.name ? this.ppl.get(pid).user.name = options.name : {}; this.connections.filter((ofo) => ofo.participantId == p.participantId).forEach((usr) => { options.name ? usr.user.name = options.name : {}; options._id ? usr.user._id = options._id : {}; @@ -394,21 +393,21 @@ class Room extends EventEmitter { if(this.isLobby(_id)) msg.set = {visible:true,color:this.server.defaultLobbyColor,color2:this.server.defaultLobbyColor2,chat:true,crownsolo:false,lobby:true}; } if(!isBool(msg.set.visible)){ - if(msg.set.visible == undefined) msg.set.visible = (room.settings.visible || true); + if(msg.set.visible == undefined) msg.set.visible = (!isObj(this.settings) ? true : this.settings.visible); else msg.set.visible = true; }; if(!isBool(msg.set.chat)){ - if(msg.set.chat == undefined) msg.set.chat = (room.settings.chat || true); + if(msg.set.chat == undefined) msg.set.chat = (!isObj(this.settings) ? true : this.settings.chat); else msg.set.chat = true; }; if(!isBool(msg.set.crownsolo)){ - if(msg.set.crownsolo == undefined) msg.set.crownsolo = (room.settings.crownsolo || false); + if(msg.set.crownsolo == undefined) msg.set.crownsolo = (!isObj(this.settings) ? false : this.settings.crownsolo); else msg.set.crownsolo = false; }; - if(!isString(msg.set.color) || !/^#[0-9a-f]{6}$/i.test(msg.set.color)) msg.set.color = (room.settings.color || this.server.defaultRoomColor); + if(!isString(msg.set.color) || !/^#[0-9a-f]{6}$/i.test(msg.set.color)) msg.set.color = (!isObj(this.settings) ? this.server.defaultRoomColor : this.settings.color); if(isString(msg.set.color2)){ if(!/^#[0-9a-f]{6}$/i.test(msg.set.color2)){ - if(room.settings.color2) msg.set.color2 = room.settings.color2; + if(this.settings.color2) msg.set.color2 = this.settings.color2; else delete msg.set.color2; // keep it nice and clean } };