Skip to content

Commit

Permalink
Fix current user instance timer when game is running elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Sep 7, 2023
1 parent c6ccb14 commit 5330b30
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
35 changes: 22 additions & 13 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4836,8 +4836,7 @@ speechSynthesis.getVoices();

this.currentUser.presence.instance = content.instance;
this.currentUser.presence.world = content.worldId;
this.currentUser.$locationTag = content.location;
$app.updateCurrentUserLocation();
$app.setCurrentUserLocation(content.location);
break;

case 'group-joined':
Expand Down Expand Up @@ -5106,7 +5105,8 @@ speechSynthesis.getVoices();
methods: {
update() {
if (!this.epoch) {
this.text = '';
this.text = '-';
return;
}
this.text = timeToText(Date.now() - this.epoch);
}
Expand Down Expand Up @@ -5165,7 +5165,7 @@ speechSynthesis.getVoices();
if (epoch >= 0) {
this.text = timeToText(epoch);
} else {
this.text = '';
this.text = '-';
}
}
},
Expand Down Expand Up @@ -23092,14 +23092,15 @@ speechSynthesis.getVoices();
if (result || !this.isRealInstance(location)) {
return;
}
// wait a bit for SteamVR to potentially close before deciding to relaunch
var restartDelay = 4000;
if (this.isGameNoVR) {
this.restartCrashedGame(location);
return;
// wait for game to close before relaunching
restartDelay = 2000;
}
// wait a bit for SteamVR to potentially close before deciding to relaunch
workerTimers.setTimeout(
() => this.restartCrashedGame(location),
3000
restartDelay
);
});
};
Expand Down Expand Up @@ -25047,17 +25048,25 @@ speechSynthesis.getVoices();
ref.$online_for = API.currentUser.$online_for;
ref.$offline_for = API.currentUser.$offline_for;
ref.$location = API.parseLocation(currentLocation);
ref.$location_at = this.lastLocation.date;
ref.$travelingToTime = this.lastLocationDestinationTime;
if (!this.isGameRunning) {
ref.$location_at = Date.now();
ref.$travelingToTime = Date.now();
if (!this.isGameRunning || this.gameLogDisabled) {
ref.$location_at = API.currentUser.$location_at;
ref.$travelingToTime = API.currentUser.$travelingToTime;
this.applyUserDialogLocation();
this.applyWorldDialogInstances();
this.applyGroupDialogInstances();
} else {
ref.$location_at = this.lastLocation.date;
ref.$travelingToTime = this.lastLocationDestinationTime;
}
};

$app.methods.setCurrentUserLocation = function (location) {
API.currentUser.$location_at = Date.now();
API.currentUser.$travelingToTime = Date.now();
API.currentUser.$locationTag = location;
this.updateCurrentUserLocation();
};

$app.data.avatarHistory = new Set();
$app.data.avatarHistoryArray = [];

Expand Down
2 changes: 1 addition & 1 deletion html/src/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ html
img(v-lazy="userImage(API.currentUser)")
.detail
span.name(v-text="API.currentUser.displayName" :style="{'color':API.currentUser.$userColour}")
location.extra(v-if="isGameRunning" :location="lastLocation.location" :traveling="lastLocationDestination" :link="false")
location.extra(v-if="isGameRunning && !gameLogDisabled" :location="lastLocation.location" :traveling="lastLocationDestination" :link="false")
location.extra(v-else-if="isRealInstance(API.currentUser.$locationTag) || isRealInstance(API.currentUser.$travelingToLocation)" :location="API.currentUser.$locationTag" :traveling="API.currentUser.$travelingToLocation" :link="false")
span.extra(v-else v-text="API.currentUser.statusDescription")
.x-friend-group.x-link(@click="isFriendsGroup0 = !isFriendsGroup0" v-show="friendsGroup0.length")
Expand Down

0 comments on commit 5330b30

Please sign in to comment.