Skip to content
Permalink
Browse files

Force player save before kicking on player shutdown (#8157)

  • Loading branch information...
nerzhul committed Feb 3, 2019
1 parent 23ea02c commit 70672e1cb7634afc8f884c3ff8a6dca1448abff7
Showing with 4 additions and 3 deletions.
  1. +1 −0 src/server.cpp
  2. +2 −2 src/serverenvironment.cpp
  3. +1 −1 src/serverenvironment.h
@@ -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);
}
@@ -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);
@@ -221,7 +221,7 @@ class ServerEnvironment : public Environment
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);

0 comments on commit 70672e1

Please sign in to comment.
You can’t perform that action at this time.