From 70672e1cb7634afc8f884c3ff8a6dca1448abff7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lo=C3=AFc=20Blot?= Date: Sun, 3 Feb 2019 09:11:45 +0100 Subject: [PATCH] Force player save before kicking on player shutdown (#8157) --- src/server.cpp | 1 + src/serverenvironment.cpp | 4 ++-- src/serverenvironment.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/server.cpp b/src/server.cpp index 41ac87527..7db06acbf 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -257,6 +257,7 @@ Server::~Server() if (kick_msg.empty()) { kick_msg = g_settings->get("kick_msg_shutdown"); } + m_env->saveLoadedPlayers(true); m_env->kickAllPlayers(SERVER_ACCESSDENIED_SHUTDOWN, kick_msg, reconnect); } diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index 076a1e28f..0a83c4a38 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -568,10 +568,10 @@ void ServerEnvironment::kickAllPlayers(AccessDeniedCode reason, } } -void ServerEnvironment::saveLoadedPlayers() +void ServerEnvironment::saveLoadedPlayers(bool force) { for (RemotePlayer *player : m_players) { - if (player->checkModified() || (player->getPlayerSAO() && + if (force || player->checkModified() || (player->getPlayerSAO() && player->getPlayerSAO()->getMeta().isModified())) { try { m_player_database->savePlayer(player); diff --git a/src/serverenvironment.h b/src/serverenvironment.h index b883e0dc5..77adcf627 100644 --- a/src/serverenvironment.h +++ b/src/serverenvironment.h @@ -221,7 +221,7 @@ public: void kickAllPlayers(AccessDeniedCode reason, const std::string &str_reason, bool reconnect); // Save players - void saveLoadedPlayers(); + void saveLoadedPlayers(bool force = false); void savePlayer(RemotePlayer *player); PlayerSAO *loadPlayer(RemotePlayer *player, bool *new_player, session_t peer_id, bool is_singleplayer); -- 2.25.1