Force player save before kicking on player shutdown (#8157)
parent
23ea02c79c
commit
70672e1cb7
|
@ -257,6 +257,7 @@ Server::~Server()
|
||||||
if (kick_msg.empty()) {
|
if (kick_msg.empty()) {
|
||||||
kick_msg = g_settings->get("kick_msg_shutdown");
|
kick_msg = g_settings->get("kick_msg_shutdown");
|
||||||
}
|
}
|
||||||
|
m_env->saveLoadedPlayers(true);
|
||||||
m_env->kickAllPlayers(SERVER_ACCESSDENIED_SHUTDOWN,
|
m_env->kickAllPlayers(SERVER_ACCESSDENIED_SHUTDOWN,
|
||||||
kick_msg, reconnect);
|
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) {
|
for (RemotePlayer *player : m_players) {
|
||||||
if (player->checkModified() || (player->getPlayerSAO() &&
|
if (force || player->checkModified() || (player->getPlayerSAO() &&
|
||||||
player->getPlayerSAO()->getMeta().isModified())) {
|
player->getPlayerSAO()->getMeta().isModified())) {
|
||||||
try {
|
try {
|
||||||
m_player_database->savePlayer(player);
|
m_player_database->savePlayer(player);
|
||||||
|
|
|
@ -221,7 +221,7 @@ public:
|
||||||
void kickAllPlayers(AccessDeniedCode reason,
|
void kickAllPlayers(AccessDeniedCode reason,
|
||||||
const std::string &str_reason, bool reconnect);
|
const std::string &str_reason, bool reconnect);
|
||||||
// Save players
|
// Save players
|
||||||
void saveLoadedPlayers();
|
void saveLoadedPlayers(bool force = false);
|
||||||
void savePlayer(RemotePlayer *player);
|
void savePlayer(RemotePlayer *player);
|
||||||
PlayerSAO *loadPlayer(RemotePlayer *player, bool *new_player, session_t peer_id,
|
PlayerSAO *loadPlayer(RemotePlayer *player, bool *new_player, session_t peer_id,
|
||||||
bool is_singleplayer);
|
bool is_singleplayer);
|
||||||
|
|
Loading…
Reference in New Issue