Fix OnPlayerJoining, use lastLocationDestination for travelingToLocation

This commit is contained in:
Natsumi
2022-07-29 20:51:31 +12:00
parent 2128a6adfa
commit 90fc91280d

View File

@@ -1084,10 +1084,6 @@ speechSynthesis.getVoices();
API.$on('USER:CURRENT', function (args) { API.$on('USER:CURRENT', function (args) {
var {json} = args; var {json} = args;
args.ref = this.applyCurrentUser(json); args.ref = this.applyCurrentUser(json);
var location = $app.lastLocation.location;
if ($app.gameLogDisabled) {
location = json.location;
}
this.applyUser({ this.applyUser({
id: json.id, id: json.id,
username: json.username, username: json.username,
@@ -1110,7 +1106,10 @@ speechSynthesis.getVoices();
fallbackAvatar: json.fallbackAvatar, fallbackAvatar: json.fallbackAvatar,
profilePicOverride: json.profilePicOverride, profilePicOverride: json.profilePicOverride,
isFriend: false, isFriend: false,
location location: json.location,
travelingToInstance: json.travelingToInstance,
travelingToLocation: json.travelingToLocation,
travelingToWorld: json.travelingToWorld
}); });
}); });
@@ -1341,6 +1340,9 @@ speechSynthesis.getVoices();
travelingToLocation: '', travelingToLocation: '',
travelingToWorld: '', travelingToWorld: '',
// VRCX // VRCX
$online_for: Date.now(),
$offline_for: Date.now(),
$travelingToTime: Date.now(),
$homeLocation: {}, $homeLocation: {},
$isVRCPlus: false, $isVRCPlus: false,
$isModerator: false, $isModerator: false,
@@ -1350,7 +1352,6 @@ speechSynthesis.getVoices();
$userColour: '', $userColour: '',
$trustSortNum: 1, $trustSortNum: 1,
$languages: [], $languages: [],
//
...json ...json
}; };
ref.$homeLocation = this.parseLocation(ref.homeLocation); ref.$homeLocation = this.parseLocation(ref.homeLocation);
@@ -1414,24 +1415,22 @@ speechSynthesis.getVoices();
} }
json.last_login = API.currentUser.last_login; json.last_login = API.currentUser.last_login;
json.last_activity = API.currentUser.last_activity; json.last_activity = API.currentUser.last_activity;
if ( if ($app.lastLocation.location === 'traveling') {
typeof json.location !== 'undefined' && json.location = 'traveling';
json.location === 'offline' json.travelingToLocation = $app.lastLocationDestination;
) { json.$travelingToTime = $app.lastLocationDestinationTime;
json.location = ''; } else if ($app.lastLocation.location) {
}
if (
typeof json.location === 'undefined' &&
typeof ref !== 'undefined'
) {
json.location = ref.location;
}
if ($app.lastLocation.location) {
json.location = $app.lastLocation.location; json.location = $app.lastLocation.location;
json.$location_at = $app.lastLocation.date; json.$location_at = $app.lastLocation.date;
} else if (ref) {
json.location = ref.location;
} else {
json.location = '';
}
if (json.location && json.location === 'offline') {
json.$online_for = API.currentUser.$online_for;
json.$offline_for = API.currentUser.$offline_for;
} }
json.$online_for = API.currentUser.$online_for;
json.$offline_for = API.currentUser.$offline_for;
} }
if (typeof json.statusDescription !== 'undefined') { if (typeof json.statusDescription !== 'undefined') {
json.statusDescription = $app.replaceBioSymbols( json.statusDescription = $app.replaceBioSymbols(
@@ -1510,6 +1509,7 @@ speechSynthesis.getVoices();
this.currentTravelers.set(ref.id, ref); this.currentTravelers.set(ref.id, ref);
$app.sharedFeed.pendingUpdate = true; $app.sharedFeed.pendingUpdate = true;
$app.updateSharedFeed(false); $app.updateSharedFeed(false);
$app.onPlayerTraveling(ref);
} }
} else { } else {
ref.$location = this.parseLocation(ref.location); ref.$location = this.parseLocation(ref.location);
@@ -1538,6 +1538,7 @@ speechSynthesis.getVoices();
this.currentTravelers.set(ref.id, ref); this.currentTravelers.set(ref.id, ref);
$app.sharedFeed.pendingUpdate = true; $app.sharedFeed.pendingUpdate = true;
$app.updateSharedFeed(false); $app.updateSharedFeed(false);
$app.onPlayerTraveling(ref);
} }
} else { } else {
ref.$location = this.parseLocation(ref.location); ref.$location = this.parseLocation(ref.location);
@@ -4390,9 +4391,10 @@ speechSynthesis.getVoices();
API.currentTravelers.forEach((ref) => { API.currentTravelers.forEach((ref) => {
var isFavorite = API.cachedFavoritesByObjectId.has(ref.id); var isFavorite = API.cachedFavoritesByObjectId.has(ref.id);
if ( if (
this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends' || (this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends' ||
(this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP' && (this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP' &&
isFavorite) isFavorite)) &&
!$app.lastLocation.playerList.has(ref.displayName)
) { ) {
if (ref.$location.tag === $app.lastLocation.location) { if (ref.$location.tag === $app.lastLocation.location) {
var feedEntry = { var feedEntry = {
@@ -7044,7 +7046,13 @@ speechSynthesis.getVoices();
// location at // location at
var compareByLocationAt = function (a, b) { var compareByLocationAt = function (a, b) {
if (a.location === 'traveling' && b.location === 'traveling') {
return 0;
}
if (a.location === 'traveling') { if (a.location === 'traveling') {
return 1;
}
if (b.location === 'traveling') {
return -1; return -1;
} }
if (a.$location_at < b.$location_at) { if (a.$location_at < b.$location_at) {
@@ -7499,7 +7507,7 @@ speechSynthesis.getVoices();
break; break;
} }
} }
this.updateCurrentInstanceWorld(this.lastLocation.location); this.updateCurrentInstanceWorld();
if (length > 0) { if (length > 0) {
for (var i = length + 1; i < data.length; i++) { for (var i = length + 1; i < data.length; i++) {
var ctx = data[i]; var ctx = data[i];
@@ -7584,7 +7592,7 @@ speechSynthesis.getVoices();
props.location[0] === 'traveling' && props.location[0] === 'traveling' &&
props.location[1] !== 'traveling' props.location[1] !== 'traveling'
) { ) {
$app.onPlayerTraveling(ref); // $app.onPlayerTraveling(ref);
// store previous location when user is traveling // store previous location when user is traveling
ref.$previousLocation = props.location[1]; ref.$previousLocation = props.location[1];
ref.$travelingToTime = Date.now(); ref.$travelingToTime = Date.now();
@@ -7803,7 +7811,6 @@ speechSynthesis.getVoices();
this.photonEventTablePrevious.data = this.photonEventTable.data; this.photonEventTablePrevious.data = this.photonEventTable.data;
this.photonEventTable.data = []; this.photonEventTable.data = [];
} }
this.updateCurrentInstanceWorld();
var playerList = Array.from(this.lastLocation.playerList.values()); var playerList = Array.from(this.lastLocation.playerList.values());
for (var ref of playerList) { for (var ref of playerList) {
var time = new Date().getTime() - ref.joinTime; var time = new Date().getTime() - ref.joinTime;
@@ -7833,6 +7840,7 @@ speechSynthesis.getVoices();
playerList: new Map(), playerList: new Map(),
friendList: new Map() friendList: new Map()
}; };
this.updateCurrentInstanceWorld();
this.updateVRLastLocation(); this.updateVRLastLocation();
this.getCurrentInstanceUserList(); this.getCurrentInstanceUserList();
this.lastVideoUrl = ''; this.lastVideoUrl = '';
@@ -8082,17 +8090,23 @@ speechSynthesis.getVoices();
} }
switch (gameLog.type) { switch (gameLog.type) {
case 'location-destination': case 'location-destination':
if (this.isGameRunning) { this.lastLocation.location = 'traveling';
this.clearNowPlaying();
this.updateCurrentInstanceWorld(gameLog.location);
}
this.lastLocationDestination = gameLog.location; this.lastLocationDestination = gameLog.location;
this.lastLocationDestinationTime = Date.parse(gameLog.dt); this.lastLocationDestinationTime = Date.parse(gameLog.dt);
API.currentUser.location = this.lastLocation.location;
API.currentUser.travelingToLocation =
this.lastLocationDestination;
API.currentUser.$travelingToTime =
this.lastLocationDestinationTime;
var entry = { var entry = {
created_at: gameLog.dt, created_at: gameLog.dt,
type: 'LocationDestination', type: 'LocationDestination',
location: gameLog.location location: gameLog.location
}; };
if (this.isGameRunning) {
this.clearNowPlaying();
this.updateCurrentInstanceWorld();
}
break; break;
case 'location': case 'location':
if (this.isGameRunning) { if (this.isGameRunning) {
@@ -8106,7 +8120,7 @@ speechSynthesis.getVoices();
friendList: new Map() friendList: new Map()
}; };
this.updateVRLastLocation(); this.updateVRLastLocation();
this.updateCurrentInstanceWorld(gameLog.location); this.updateCurrentInstanceWorld();
} }
var L = API.parseLocation(gameLog.location); var L = API.parseLocation(gameLog.location);
var entry = { var entry = {
@@ -9960,20 +9974,26 @@ speechSynthesis.getVoices();
}; };
$app.methods.updateDiscord = function () { $app.methods.updateDiscord = function () {
var currentLocation = this.lastLocation.location;
var timeStamp = this.lastLocation.date;
if (this.lastLocation.location === 'traveling') {
currentLocation = this.lastLocationDestination;
timeStamp = this.lastLocationDestinationTime;
}
if ( if (
!this.discordActive || !this.discordActive ||
!this.isGameRunning || !this.isGameRunning ||
(!this.lastLocation.location && !this.lastLocation$.tag) (!currentLocation && !this.lastLocation$.tag)
) { ) {
return; return;
} }
var L = this.lastLocation$; var L = this.lastLocation$;
if (this.lastLocation.location !== this.lastLocation$.tag) { if (currentLocation !== this.lastLocation$.tag) {
if (this.lastLocation.location) { if (currentLocation) {
Discord.SetActive(true); Discord.SetActive(true);
} }
Discord.SetTimestamps(this.lastLocation.date, 0); Discord.SetTimestamps(timeStamp, 0);
L = API.parseLocation(this.lastLocation.location); L = API.parseLocation(currentLocation);
L.worldName = ''; L.worldName = '';
L.thumbnailImageUrl = ''; L.thumbnailImageUrl = '';
L.worldCapacity = 0; L.worldCapacity = 0;
@@ -13229,10 +13249,11 @@ speechSynthesis.getVoices();
var users = []; var users = [];
var friendCount = 0; var friendCount = 0;
var playersInInstance = this.lastLocation.playerList; var playersInInstance = this.lastLocation.playerList;
if ( var currentLocation = this.lastLocation.location;
this.lastLocation.location === L.tag && if (this.lastLocation.location === 'traveling') {
playersInInstance.size > 0 currentLocation = this.lastLocationDestination;
) { }
if (currentLocation === L.tag && playersInInstance.size > 0) {
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;
@@ -13279,7 +13300,11 @@ speechSynthesis.getVoices();
} }
users.sort(compareByLocationAt); users.sort(compareByLocationAt);
D.users = users; D.users = users;
if (L.worldId && this.lastLocation.location === L.tag) { if (
L.worldId &&
currentLocation === L.tag &&
playersInInstance.size > 0
) {
D.instance = { D.instance = {
id: L.tag, id: L.tag,
occupants: this.lastLocation.playerList.size occupants: this.lastLocation.playerList.size
@@ -13466,7 +13491,11 @@ speechSynthesis.getVoices();
}; };
$app.data.currentInstanceLocation = {}; $app.data.currentInstanceLocation = {};
$app.methods.updateCurrentInstanceWorld = function (instanceId) { $app.methods.updateCurrentInstanceWorld = function () {
var instanceId = this.lastLocation.location;
if (this.lastLocation.location === 'traveling') {
instanceId = this.lastLocationDestination;
}
if (!instanceId) { if (!instanceId) {
this.currentInstanceWorld = { this.currentInstanceWorld = {
ref: {}, ref: {},
@@ -13478,10 +13507,7 @@ speechSynthesis.getVoices();
fileSize: '' fileSize: ''
}; };
this.currentInstanceLocation = {}; this.currentInstanceLocation = {};
} else if ( } else if (instanceId !== this.currentInstanceLocation.tag) {
instanceId !== this.currentInstanceLocation.tag &&
this.currentInstanceLocation.tag !== this.lastLocationDestination
) {
this.currentInstanceWorld = { this.currentInstanceWorld = {
ref: {}, ref: {},
isPC: false, isPC: false,
@@ -14240,9 +14266,13 @@ speechSynthesis.getVoices();
users: [] users: []
}; };
} }
var lastLocation$ = API.parseLocation(this.lastLocation.location); var currentLocation = this.lastLocation.location;
if (this.lastLocation.location === 'traveling') {
currentLocation = this.lastLocationDestination;
}
var lastLocation$ = API.parseLocation(currentLocation);
var playersInInstance = this.lastLocation.playerList; var playersInInstance = this.lastLocation.playerList;
if (lastLocation$.worldId === D.id) { if (lastLocation$.worldId === D.id && playersInInstance.size > 0) {
var friendsInInstance = this.lastLocation.friendList; var friendsInInstance = this.lastLocation.friendList;
var instance = { var instance = {
id: lastLocation$.instanceId, id: lastLocation$.instanceId,
@@ -14281,7 +14311,8 @@ speechSynthesis.getVoices();
typeof ref === 'undefined' || typeof ref === 'undefined' ||
typeof ref.$location === 'undefined' || typeof ref.$location === 'undefined' ||
ref.$location.worldId !== D.id || ref.$location.worldId !== D.id ||
ref.$location.instanceId === lastLocation$.instanceId (ref.$location.instanceId === lastLocation$.instanceId &&
playersInInstance.size > 0)
) { ) {
continue; continue;
} }
@@ -19573,7 +19604,8 @@ speechSynthesis.getVoices();
if ( if (
!this.isGameRunning || !this.isGameRunning ||
!this.lastLocation.location || !this.lastLocation.location ||
this.lastLocation.location !== ref.travelingToLocation this.lastLocation.location !== ref.travelingToLocation ||
this.lastLocation.playerList.has(ref.displayName)
) { ) {
return; return;
} }