mirror of
https://github.com/minetest/minetest.git
synced 2024-11-09 01:03:46 +01:00
Put ChatEvent handler into own function
Comply with line limit.
This commit is contained in:
parent
889f893ff3
commit
63e7137e3b
@ -585,21 +585,7 @@ void Server::AsyncRunStep(bool initial_step)
|
|||||||
MutexAutoLock lock(m_env_mutex);
|
MutexAutoLock lock(m_env_mutex);
|
||||||
while (!m_admin_chat->command_queue.empty()) {
|
while (!m_admin_chat->command_queue.empty()) {
|
||||||
ChatEvent *evt = m_admin_chat->command_queue.pop_frontNoEx();
|
ChatEvent *evt = m_admin_chat->command_queue.pop_frontNoEx();
|
||||||
if (evt->type == CET_NICK_ADD) {
|
handleChatInterfaceEvent(evt);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
delete evt;
|
delete evt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2749,6 +2735,25 @@ void Server::UpdateCrafting(Player* player)
|
|||||||
plist->changeItem(0, preview);
|
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,
|
std::wstring Server::handleChat(const std::string &name, const std::wstring &wname,
|
||||||
const std::wstring &wmessage, u16 peer_id_to_avoid_sending)
|
const std::wstring &wmessage, u16 peer_id_to_avoid_sending)
|
||||||
{
|
{
|
||||||
|
@ -476,6 +476,8 @@ private:
|
|||||||
void DeleteClient(u16 peer_id, ClientDeletionReason reason);
|
void DeleteClient(u16 peer_id, ClientDeletionReason reason);
|
||||||
void UpdateCrafting(Player *player);
|
void UpdateCrafting(Player *player);
|
||||||
|
|
||||||
|
void handleChatInterfaceEvent(ChatEvent *evt);
|
||||||
|
|
||||||
// This returns the answer to the sender of wmessage, or "" if there is none
|
// This returns the answer to the sender of wmessage, or "" if there is none
|
||||||
std::wstring handleChat(const std::string &name, const std::wstring &wname,
|
std::wstring handleChat(const std::string &name, const std::wstring &wname,
|
||||||
const std::wstring &wmessage,
|
const std::wstring &wmessage,
|
||||||
|
Loading…
Reference in New Issue
Block a user