Record all players as leaving on server exit

In the case of shutdown the Factorio server will not notify the
currently online players as leaving the game.  Notify the master server
that all remaining online players quit the game in this case.
This commit is contained in:
Hornwitser committed 2022-07-12 23:03:50 +02:00
1 parent ac62f66aa1
commit deb6842a4d
2 files changed
+7 -2

No files matched your search

+4 -2
View File
@@ -210,7 +210,8 @@ class BaseInstancePlugin {
* @param {string} event.name - Name of the player that joined/left.
* @param {string=} event.reason -
* Only present for type "leave". Reason for player leaving the
* game, one of the possible reasons in defines.disconnect_reason.
* game, one of the possible reasons in defines.disconnect_reason
* or "server_quit" if the server exits while the player is online.
*/
async onPlayerEvent(event) { }
@@ -505,7 +506,8 @@ class BaseMasterPlugin {
* @param {string} event.name - Name of the player that joined/left.
* @param {string=} event.reason -
* Only present for type "leave". Reason for player leaving the
* game, one of the possible reasons in defines.disconnect_reason.
* game, one of the possible reasons in defines.disconnect_reason
* or "server_quit" if the server exits while the player is online.
*/
async onPlayerEvent(instance, event) { }
+3
View File
@@ -483,6 +483,9 @@ class Instance extends libLink.Link {
pluginInstance.onExit();
}
for (let player of left) {
this._recordPlayerLeave(player, "server_quit");
}
this._saveStats().catch(err => this.logger.error(`Error saving stats:\n${err.stack}`));
}