mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
CSM: Revert "[CSM] Add send_chat_message and run_server_chatcommand"
Original PR: #5747.
This reverts commit 39f4a2f607
.
This commit is contained in:
parent
a5c37717ff
commit
bdac12761c
9 changed files with 3 additions and 108 deletions
|
@ -83,7 +83,6 @@ Client::Client(
|
|||
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this),
|
||||
m_address_name(address_name),
|
||||
m_server_ser_ver(SER_FMT_VER_INVALID),
|
||||
m_last_chat_message_sent(time(NULL)),
|
||||
m_password(password),
|
||||
m_chosen_auth_mech(AUTH_MECHANISM_NONE),
|
||||
m_media_downloader(new ClientMediaDownloader()),
|
||||
|
@ -388,14 +387,6 @@ void Client::step(float dtime)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Send pending messages on out chat queue
|
||||
*/
|
||||
if (!m_out_chat_queue.empty() && canSendChatMessage()) {
|
||||
sendChatMessage(m_out_chat_queue.front());
|
||||
m_out_chat_queue.pop();
|
||||
}
|
||||
|
||||
/*
|
||||
Handle environment
|
||||
*/
|
||||
|
@ -1152,50 +1143,13 @@ void Client::sendInventoryAction(InventoryAction *a)
|
|||
Send(&pkt);
|
||||
}
|
||||
|
||||
bool Client::canSendChatMessage() const
|
||||
{
|
||||
u32 now = time(NULL);
|
||||
float time_passed = now - m_last_chat_message_sent;
|
||||
|
||||
float virt_chat_message_allowance = m_chat_message_allowance + time_passed *
|
||||
(CLIENT_CHAT_MESSAGE_LIMIT_PER_10S / 8.0f);
|
||||
|
||||
if (virt_chat_message_allowance < 1.0f)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Client::sendChatMessage(const std::wstring &message)
|
||||
{
|
||||
const s16 max_queue_size = g_settings->getS16("max_out_chat_queue_size");
|
||||
if (canSendChatMessage()) {
|
||||
u32 now = time(NULL);
|
||||
float time_passed = now - m_last_chat_message_sent;
|
||||
m_last_chat_message_sent = time(NULL);
|
||||
NetworkPacket pkt(TOSERVER_CHAT_MESSAGE, 2 + message.size() * sizeof(u16));
|
||||
|
||||
m_chat_message_allowance += time_passed * (CLIENT_CHAT_MESSAGE_LIMIT_PER_10S / 8.0f);
|
||||
if (m_chat_message_allowance > CLIENT_CHAT_MESSAGE_LIMIT_PER_10S)
|
||||
m_chat_message_allowance = CLIENT_CHAT_MESSAGE_LIMIT_PER_10S;
|
||||
pkt << message;
|
||||
|
||||
m_chat_message_allowance -= 1.0f;
|
||||
|
||||
NetworkPacket pkt(TOSERVER_CHAT_MESSAGE, 2 + message.size() * sizeof(u16));
|
||||
|
||||
pkt << message;
|
||||
|
||||
Send(&pkt);
|
||||
} else if (m_out_chat_queue.size() < (u16) max_queue_size || max_queue_size == -1) {
|
||||
m_out_chat_queue.push(message);
|
||||
} else {
|
||||
infostream << "Could not queue chat message because maximum out chat queue size ("
|
||||
<< max_queue_size << ") is reached." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Client::clearOutChatQueue()
|
||||
{
|
||||
m_out_chat_queue = std::queue<std::wstring>();
|
||||
Send(&pkt);
|
||||
}
|
||||
|
||||
void Client::sendChangePassword(const std::string &oldpassword,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue