mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix connected_players on_shutdown (#14739)
This commit is contained in:
parent
bc23a610d3
commit
7a64527db5
4 changed files with 46 additions and 25 deletions
|
@ -329,27 +329,6 @@ Server::~Server()
|
|||
SendChatMessage(PEER_ID_INEXISTENT, ChatMessage(CHATMESSAGE_TYPE_ANNOUNCE,
|
||||
L"*** Server shutting down"));
|
||||
|
||||
if (m_env) {
|
||||
MutexAutoLock envlock(m_env_mutex);
|
||||
|
||||
infostream << "Server: Saving players" << std::endl;
|
||||
m_env->saveLoadedPlayers();
|
||||
|
||||
infostream << "Server: Kicking players" << std::endl;
|
||||
std::string kick_msg;
|
||||
bool reconnect = false;
|
||||
if (isShutdownRequested()) {
|
||||
reconnect = m_shutdown_state.should_reconnect;
|
||||
kick_msg = m_shutdown_state.message;
|
||||
}
|
||||
if (kick_msg.empty()) {
|
||||
kick_msg = g_settings->get("kick_msg_shutdown");
|
||||
}
|
||||
m_env->saveLoadedPlayers(true);
|
||||
kickAllPlayers(SERVER_ACCESSDENIED_SHUTDOWN,
|
||||
kick_msg, reconnect);
|
||||
}
|
||||
|
||||
actionstream << "Server: Shutting down" << std::endl;
|
||||
|
||||
// Stop server step from happening
|
||||
|
@ -369,16 +348,33 @@ Server::~Server()
|
|||
if (m_env) {
|
||||
MutexAutoLock envlock(m_env_mutex);
|
||||
|
||||
infostream << "Server: Executing shutdown hooks" << std::endl;
|
||||
try {
|
||||
// Empty out the environment, this can also invoke callbacks.
|
||||
m_env->deactivateBlocksAndObjects();
|
||||
m_script->on_shutdown();
|
||||
} catch (ModError &e) {
|
||||
addShutdownError(e);
|
||||
}
|
||||
|
||||
infostream << "Server: Executing shutdown hooks" << std::endl;
|
||||
infostream << "Server: Saving players" << std::endl;
|
||||
m_env->saveLoadedPlayers();
|
||||
|
||||
infostream << "Server: Kicking players" << std::endl;
|
||||
std::string kick_msg;
|
||||
bool reconnect = false;
|
||||
if (isShutdownRequested()) {
|
||||
reconnect = m_shutdown_state.should_reconnect;
|
||||
kick_msg = m_shutdown_state.message;
|
||||
}
|
||||
if (kick_msg.empty()) {
|
||||
kick_msg = g_settings->get("kick_msg_shutdown");
|
||||
}
|
||||
m_env->saveLoadedPlayers(true);
|
||||
kickAllPlayers(SERVER_ACCESSDENIED_SHUTDOWN,
|
||||
kick_msg, reconnect);
|
||||
|
||||
try {
|
||||
m_script->on_shutdown();
|
||||
// Empty out the environment, this can also invoke callbacks.
|
||||
m_env->deactivateBlocksAndObjects();
|
||||
} catch (ModError &e) {
|
||||
addShutdownError(e);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue