Bulk add OnPlayerLeft to database when leaving instance

This commit is contained in:
Natsumi
2022-08-28 23:51:51 +12:00
parent a17f9c77c6
commit a7e14370d9
2 changed files with 46 additions and 9 deletions

View File

@@ -7808,7 +7808,12 @@ speechSynthesis.getVoices();
friendList: new Map()
};
$app.methods.lastLocationReset = function () {
$app.methods.lastLocationReset = function (gameLogDate) {
var dateTime = gameLogDate;
if (!gameLogDate) {
dateTime = new Date().toJSON();
}
var dateTimeStamp = Date.parse(dateTime);
this.photonLobby = new Map();
this.photonLobbyCurrent = new Map();
this.photonLobbyMaster = 0;
@@ -7827,23 +7832,23 @@ speechSynthesis.getVoices();
this.photonEventTable.data = [];
}
var playerList = Array.from(this.lastLocation.playerList.values());
var dataBaseEntries = [];
for (var ref of playerList) {
var time = new Date().getTime() - ref.joinTime;
var entry = {
created_at: new Date().toJSON(),
created_at: dateTime,
type: 'OnPlayerLeft',
displayName: ref.displayName,
location: this.lastLocation.location,
userId: ref.userId,
time
time: dateTimeStamp - ref.joinTime
};
database.addGamelogJoinLeaveToDatabase(entry);
dataBaseEntries.unshift(entry);
this.addGameLog(entry);
}
database.addGamelogJoinLeaveBulk(dataBaseEntries);
if (this.lastLocation.date !== 0) {
var timeLocation = new Date().getTime() - this.lastLocation.date;
var update = {
time: timeLocation,
time: dateTimeStamp - this.lastLocation.date,
created_at: new Date(this.lastLocation.date).toJSON()
};
database.updateGamelogLocationTimeToDatabase(update);
@@ -8114,7 +8119,7 @@ speechSynthesis.getVoices();
type: 'LocationDestination',
location: gameLog.location
});
this.lastLocationReset();
this.lastLocationReset(gameLog.dt);
this.lastLocation.location = 'traveling';
this.lastLocationDestination = gameLog.location;
this.lastLocationDestinationTime = Date.parse(gameLog.dt);
@@ -8127,7 +8132,7 @@ speechSynthesis.getVoices();
break;
case 'location':
if (this.isGameRunning) {
this.lastLocationReset();
this.lastLocationReset(gameLog.dt);
this.clearNowPlaying();
this.lastLocation = {
date: Date.parse(gameLog.dt),