aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-09-26 11:57:51 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-09-26 11:57:51 +0300
commitb9e680d06cf56b7c8b41a6b5626a3b94304adf42 (patch)
tree36bcc857ef5e2d83fdc0c10cbc02ec81ffebbe78 /src
parent0ccc0ac927bdbfcc97c1b5c9d5dc64754946f817 (diff)
downloadminetest-b9e680d06cf56b7c8b41a6b5626a3b94304adf42.tar.gz
minetest-b9e680d06cf56b7c8b41a6b5626a3b94304adf42.tar.bz2
minetest-b9e680d06cf56b7c8b41a6b5626a3b94304adf42.zip
Server user limit configuration option
Diffstat (limited to 'src')
-rw-r--r--src/defaultsettings.cpp1
-rw-r--r--src/server.cpp28
2 files changed, 20 insertions, 9 deletions
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 1e17f2f3a..698389121 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -77,6 +77,7 @@ void set_default_settings()
// Server stuff
g_settings.setDefault("motd", "");
+ g_settings.setDefault("max_users", "20");
g_settings.setDefault("enable_experimental", "false");
g_settings.setDefault("creative_mode", "false");
g_settings.setDefault("enable_damage", "true");
diff --git a/src/server.cpp b/src/server.cpp
index 304eb8920..bf74737fc 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -2096,11 +2096,21 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
stringToPrivs(g_settings.get("default_privs")));
m_authmanager.save();
}
+
+ // Enforce user limit.
+ // Don't enforce for users that have some admin right
+ if(m_clients.size() >= g_settings.getU16("max_users") &&
+ (m_authmanager.getPrivs(playername)
+ & (PRIV_SERVER|PRIV_BAN|PRIV_PRIVS)) == 0 &&
+ playername != g_settings.get("name"))
+ {
+ SendAccessDenied(m_con, peer_id, L"Too many users.");
+ return;
+ }
// Get player
Player *player = emergePlayer(playername, password, peer_id);
-
/*{
// DEBUG: Test serialization
std::ostringstream test_os;
@@ -4426,16 +4436,16 @@ void Server::handlePeerChange(PeerChange &c)
// Collect information about leaving in chat
std::wstring message;
{
- std::wstring name = L"unknown";
Player *player = m_env.getPlayer(c.peer_id);
if(player != NULL)
- name = narrow_to_wide(player->getName());
-
- message += L"*** ";
- message += name;
- message += L" left game";
- if(c.timeout)
- message += L" (timed out)";
+ {
+ std::wstring name = narrow_to_wide(player->getName());
+ message += L"*** ";
+ message += name;
+ message += L" left game";
+ if(c.timeout)
+ message += L" (timed out)";
+ }
}
/*// Delete player