Delete player statistics when deleting instances

Clear the statistics stored per user for the instance when an instance
is deleted.
This commit is contained in:
Hornwitser committed 2024-02-08 19:06:21 +01:00
1 parent 1021e29c98
commit 8865509011
4 files changed
+35

No files matched your search

+1
View File
@@ -964,6 +964,7 @@ export default class Controller {
this.instancesDirty = true;
this.clearSavesOfInstance(instanceId);
this.userManager.clearStatsOfInstance(instanceId);
let prev = instance.status;
instance.status = "deleted";
+9
View File
@@ -113,4 +113,13 @@ export default class UserManager {
this.onlineUsers.delete(user);
}
}
clearStatsOfInstance(instanceId: number) {
for (const user of this.users.values()) {
this.notifyLeave(user, instanceId);
user.instanceStats.delete(instanceId);
user.recalculatePlayerStats();
}
this.dirty = true;
}
}