#include "mapblock_mesh.h"
#include "event.h"
#endif
+#include "server.h"
#include "daynightratio.h"
#include "map.h"
#include "emerge.h"
return true;
}
+void ServerEnvironment::kickAllPlayers(const std::string &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));
+ }
+}
+
void ServerEnvironment::saveLoadedPlayers()
{
std::string players_path = m_path_world + DIR_DELIM "players";
float getSendRecommendedInterval()
{ return m_recommended_send_interval; }
+ void kickAllPlayers(const std::string &reason);
// Save players
void saveLoadedPlayers();
void savePlayer(const std::string &playername);
// Execute script shutdown hooks
m_script->on_shutdown();
- infostream<<"Server: Saving players"<<std::endl;
+ infostream << "Server: Saving players" << std::endl;
m_env->saveLoadedPlayers();
- infostream<<"Server: Saving environment metadata"<<std::endl;
+ infostream << "Server: kick players" << std::endl;
+ m_env->kickAllPlayers("Server shutting down...");
+
+ infostream << "Server: Saving environment metadata" << std::endl;
m_env->saveMeta();
}
throw ServerError(async_err);
}
else {
+ m_env->kickAllPlayers("The server has crashed. Disconnecting all players. Please reconnect soon...");
errorstream << "UNRECOVERABLE error occurred. Stopping server. "
<< "Please fix the following error:" << std::endl
<< async_err << std::endl;