From 47d3d3885bcc5867d4cdc0ffc17c9f18d2da8af9 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Sun, 4 Apr 2021 06:32:00 +1300 Subject: [PATCH] Only use playersInInstance for current instance user list --- html/src/app.js | 91 ++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 44c3f5dc..892cd5f2 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -7539,21 +7539,12 @@ speechSynthesis.getVoices(); } } var users = []; - if (L.isOffline === false) { - for (var { ref } of this.friends.values()) { - if (typeof ref !== 'undefined' && - ref.location === L.tag) { - users.push(ref); - } - } - } - if (this.isGameRunning && - this.lastLocation.location === L.tag) { + var playersInInstance = this.lastLocation.playerList; + if ((this.lastLocation.location === L.tag) && (playersInInstance.length > 0)) { var ref = API.cachedUsers.get(API.currentUser.id); if (typeof ref === 'undefined') { ref = API.currentUser; } - var playersInInstance = this.lastLocation.playerList; if (playersInInstance.includes(ref.displayName)) { users.push(ref); } @@ -7577,6 +7568,15 @@ speechSynthesis.getVoices(); } } } + } else { + if (L.isOffline === false) { + for (var { ref } of this.friends.values()) { + if (typeof ref !== 'undefined' && + ref.location === L.tag) { + users.push(ref); + } + } + } } users.sort(compareByDisplayName); D.users = users; @@ -8085,45 +8085,26 @@ speechSynthesis.getVoices(); users: [] }; } - for (var { ref } of this.friends.values()) { - if (typeof ref === 'undefined' || - typeof ref.$location === 'undefined' || - ref.$location.worldId !== D.id) { - continue; - } - var { instanceId } = ref.$location; - var instance = instances[instanceId]; + var lastLocation$ = API.parseLocation(this.lastLocation.location); + var playersInInstance = this.lastLocation.playerList; + if ((lastLocation$.worldId === D.id) && (playersInInstance.length > 0)) { + var instance = instances[lastLocation$.instanceId]; if (typeof instance === 'undefined') { instance = { - id: instanceId, - occupants: 0, - users: [] - }; - instances[instanceId] = instance; - } - instance.users.push(ref); - } - if (this.isGameRunning) { - var lastLocation$ = API.parseLocation(this.lastLocation.location); - if (lastLocation$.worldId === D.id) { - var instance = instances[lastLocation$.instanceId]; - if (typeof instance === 'undefined') { - instance = { id: lastLocation$.instanceId, occupants: 1, users: [] - }; - instances[instance.id] = instance; - } - instances[instance.id].occupants = this.lastLocation.playerList.length; - var ref = API.cachedUsers.get(API.currentUser.id); - if (typeof ref === 'undefined') { - ref = API.currentUser; - } - var playersInInstance = this.lastLocation.playerList; - if (playersInInstance.includes(ref.displayName)) { - instance.users.push(ref); - } + }; + instances[instance.id] = instance; + } + instances[instance.id].occupants = playersInInstance.length; + var ref = API.cachedUsers.get(API.currentUser.id); + if (typeof ref === 'undefined') { + ref = API.currentUser; + } + if (playersInInstance.includes(ref.displayName)) { + instance.users.push(ref); + } var friendsInInstance = this.lastLocation.friendList; for (var i = 0; i < friendsInInstance.length; i++) { var addUser = true; @@ -8142,9 +8123,27 @@ speechSynthesis.getVoices(); break; } } - } } } + } else { + for (var { ref } of this.friends.values()) { + if (typeof ref === 'undefined' || + typeof ref.$location === 'undefined' || + ref.$location.worldId !== D.id) { + continue; + } + var { instanceId } = ref.$location; + var instance = instances[instanceId]; + if (typeof instance === 'undefined') { + instance = { + id: instanceId, + occupants: 0, + users: [] + }; + instances[instanceId] = instance; + } + instance.users.push(ref); + } } var rooms = []; for (var instance of Object.values(instances)) {