Server kicks: make messages configurable, cache wstring
This commit is contained in:
parent
f9dbec6edf
commit
bf7174f3f9
|
@ -388,6 +388,12 @@
|
|||
# "log" = mimic and log backtrace of deprecated call (default for debug).
|
||||
# "error" = abort on usage of deprecated call (suggested for mod developers).
|
||||
#deprecated_lua_api_handling = legacy
|
||||
|
||||
#kick_msg_shutdown = Server shutting down.
|
||||
# A message to be displayed to all clients when the server shuts down
|
||||
#kick_msg_crash = This server has experienced an internal error. You will now be disconnected.
|
||||
# A message to be displayed to all clients when the server crashes
|
||||
|
||||
# Mod profiler
|
||||
#mod_profiling = false
|
||||
# Detailed mod profile data
|
||||
|
|
|
@ -252,6 +252,9 @@ void set_default_settings(Settings *settings)
|
|||
settings->setDefault("deprecated_lua_api_handling", "log");
|
||||
#endif
|
||||
|
||||
settings->setDefault("kick_msg_shutdown", "Server shutting down.");
|
||||
settings->setDefault("kick_msg_crash", "This server has experienced an internal error. You will now be disconnected.");
|
||||
|
||||
settings->setDefault("profiler_print_interval", "0");
|
||||
settings->setDefault("enable_mapgen_debug_info", "false");
|
||||
settings->setDefault("active_object_send_range_blocks", "3");
|
||||
|
|
|
@ -428,10 +428,11 @@ bool ServerEnvironment::line_of_sight(v3f pos1, v3f pos2, float stepsize, v3s16
|
|||
|
||||
void ServerEnvironment::kickAllPlayers(const std::string &reason)
|
||||
{
|
||||
std::wstring wreason = utf8_to_wide(reason);
|
||||
for (std::vector<Player*>::iterator it = m_players.begin();
|
||||
it != m_players.end();
|
||||
++it) {
|
||||
((Server*)m_gamedef)->DenyAccess_Legacy((*it)->peer_id, utf8_to_wide(reason));
|
||||
((Server*)m_gamedef)->DenyAccess_Legacy((*it)->peer_id, wreason);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -397,8 +397,8 @@ Server::~Server()
|
|||
infostream << "Server: Saving players" << std::endl;
|
||||
m_env->saveLoadedPlayers();
|
||||
|
||||
infostream << "Server: kick players" << std::endl;
|
||||
m_env->kickAllPlayers("Server shutting down...");
|
||||
infostream << "Server: Kicking players" << std::endl;
|
||||
m_env->kickAllPlayers(g_settings->get("kick_msg_shutdown"));
|
||||
|
||||
infostream << "Server: Saving environment metadata" << std::endl;
|
||||
m_env->saveMeta();
|
||||
|
@ -502,7 +502,7 @@ void Server::step(float dtime)
|
|||
throw ServerError(async_err);
|
||||
}
|
||||
else {
|
||||
m_env->kickAllPlayers("The server has crashed. Disconnecting all players. Please reconnect soon...");
|
||||
m_env->kickAllPlayers(g_settings->get("kick_msg_crash"));
|
||||
errorstream << "UNRECOVERABLE error occurred. Stopping server. "
|
||||
<< "Please fix the following error:" << std::endl
|
||||
<< async_err << std::endl;
|
||||
|
|
Loading…
Reference in New Issue