Only use playersInInstance for current instance user list

This commit is contained in:
Natsumi
2021-04-04 06:32:00 +13:00
parent 43dd0f2c4d
commit 47d3d3885b

View File

@@ -7539,21 +7539,12 @@ speechSynthesis.getVoices();
} }
} }
var users = []; var users = [];
if (L.isOffline === false) { var playersInInstance = this.lastLocation.playerList;
for (var { ref } of this.friends.values()) { if ((this.lastLocation.location === L.tag) && (playersInInstance.length > 0)) {
if (typeof ref !== 'undefined' &&
ref.location === L.tag) {
users.push(ref);
}
}
}
if (this.isGameRunning &&
this.lastLocation.location === L.tag) {
var ref = API.cachedUsers.get(API.currentUser.id); var ref = API.cachedUsers.get(API.currentUser.id);
if (typeof ref === 'undefined') { if (typeof ref === 'undefined') {
ref = API.currentUser; ref = API.currentUser;
} }
var playersInInstance = this.lastLocation.playerList;
if (playersInInstance.includes(ref.displayName)) { if (playersInInstance.includes(ref.displayName)) {
users.push(ref); 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); users.sort(compareByDisplayName);
D.users = users; D.users = users;
@@ -8085,27 +8085,9 @@ speechSynthesis.getVoices();
users: [] 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];
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); var lastLocation$ = API.parseLocation(this.lastLocation.location);
if (lastLocation$.worldId === D.id) { var playersInInstance = this.lastLocation.playerList;
if ((lastLocation$.worldId === D.id) && (playersInInstance.length > 0)) {
var instance = instances[lastLocation$.instanceId]; var instance = instances[lastLocation$.instanceId];
if (typeof instance === 'undefined') { if (typeof instance === 'undefined') {
instance = { instance = {
@@ -8115,12 +8097,11 @@ speechSynthesis.getVoices();
}; };
instances[instance.id] = instance; instances[instance.id] = instance;
} }
instances[instance.id].occupants = this.lastLocation.playerList.length; instances[instance.id].occupants = playersInInstance.length;
var ref = API.cachedUsers.get(API.currentUser.id); var ref = API.cachedUsers.get(API.currentUser.id);
if (typeof ref === 'undefined') { if (typeof ref === 'undefined') {
ref = API.currentUser; ref = API.currentUser;
} }
var playersInInstance = this.lastLocation.playerList;
if (playersInInstance.includes(ref.displayName)) { if (playersInInstance.includes(ref.displayName)) {
instance.users.push(ref); instance.users.push(ref);
} }
@@ -8144,6 +8125,24 @@ speechSynthesis.getVoices();
} }
} }
} }
} 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 = []; var rooms = [];