summaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-11-09 06:04:24 +0100
committerest31 <MTest31@outlook.com>2015-11-09 06:04:24 +0100
commit63e7137e3bb3ef2531faac995e8817b2c3fedc8c (patch)
tree74ce090d61a52f008a51940e276cf7a24f516643 /src/server.cpp
parent889f893ff37021d97d1805c2e21128b5befa21f5 (diff)
downloadminetest-63e7137e3bb3ef2531faac995e8817b2c3fedc8c.tar.gz
minetest-63e7137e3bb3ef2531faac995e8817b2c3fedc8c.tar.bz2
minetest-63e7137e3bb3ef2531faac995e8817b2c3fedc8c.zip
Put ChatEvent handler into own function
Comply with line limit.
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 9315fcf80..c93abb10c 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -585,21 +585,7 @@ void Server::AsyncRunStep(bool initial_step)
MutexAutoLock lock(m_env_mutex);
while (!m_admin_chat->command_queue.empty()) {
ChatEvent *evt = m_admin_chat->command_queue.pop_frontNoEx();
- if (evt->type == CET_NICK_ADD) {
- // The terminal informed us of its nick choice
- m_admin_nick = ((ChatEventNick *)evt)->nick;
- if (!m_script->getAuth(m_admin_nick, NULL, NULL)) {
- errorstream << "You haven't set up an account." << std::endl
- << "Please log in using the client as '"
- << m_admin_nick << "' with a secure password." << std::endl
- << "Until then, you can't execute admin tasks via the console," << std::endl
- << "and everybody can claim the user account instead of you," << std::endl
- << "giving them full control over this server." << std::endl;
- }
- } else {
- assert(evt->type == CET_CHAT);
- handleAdminChat((ChatEventChat *)evt);
- }
+ handleChatInterfaceEvent(evt);
delete evt;
}
}
@@ -2749,6 +2735,25 @@ void Server::UpdateCrafting(Player* player)
plist->changeItem(0, preview);
}
+void Server::handleChatInterfaceEvent(ChatEvent *evt)
+{
+ if (evt->type == CET_NICK_ADD) {
+ // The terminal informed us of its nick choice
+ m_admin_nick = ((ChatEventNick *)evt)->nick;
+ if (!m_script->getAuth(m_admin_nick, NULL, NULL)) {
+ errorstream << "You haven't set up an account." << std::endl
+ << "Please log in using the client as '"
+ << m_admin_nick << "' with a secure password." << std::endl
+ << "Until then, you can't execute admin tasks via the console," << std::endl
+ << "and everybody can claim the user account instead of you," << std::endl
+ << "giving them full control over this server." << std::endl;
+ }
+ } else {
+ assert(evt->type == CET_CHAT);
+ handleAdminChat((ChatEventChat *)evt);
+ }
+}
+
std::wstring Server::handleChat(const std::string &name, const std::wstring &wname,
const std::wstring &wmessage, u16 peer_id_to_avoid_sending)
{