diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-07-16 10:47:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-16 10:47:31 +0200 |
commit | 7ddf67aa1478813e12a5fcdfb4986b9e5adfe62f (patch) | |
tree | 0bbbee7ed9470e0de149ec9bdaf6a51693ec0e22 /src/clientiface.cpp | |
parent | ecbc972ea6a2371d64b1d9c9576d31be36b8ae6a (diff) | |
download | hax-minetest-server-7ddf67aa1478813e12a5fcdfb4986b9e5adfe62f.tar.gz hax-minetest-server-7ddf67aa1478813e12a5fcdfb4986b9e5adfe62f.zip |
Chat protocol rewrite (#5117)
* New TOCLIENT_CHAT_MESSAGE packet
* Rename old packet to TOCLIENT_CHAT_MESSAGE_OLD for compat
* Handle TOCLIENT_CHAT_MESSAGE new structure client side
* Client chat queue should use a specific object
* SendChatMessage: use the right packet depending on protocol version (not complete yet)
* Add chatmessage(type) objects and handle them client side (partially)
* Use ChatMessage instead of std::wstring server side
* Update with timestamp support
Diffstat (limited to 'src/clientiface.cpp')
-rw-r--r-- | src/clientiface.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/clientiface.cpp b/src/clientiface.cpp index a629ccee7..361315c3b 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -693,6 +693,32 @@ void ClientInterface::sendToAll(NetworkPacket *pkt) } } +void ClientInterface::sendToAllCompat(NetworkPacket *pkt, NetworkPacket *legacypkt, + u16 min_proto_ver) +{ + MutexAutoLock clientslock(m_clients_mutex); + for (std::unordered_map<u16, RemoteClient*>::iterator i = m_clients.begin(); + i != m_clients.end(); ++i) { + RemoteClient *client = i->second; + NetworkPacket *pkt_to_send = nullptr; + + if (client->net_proto_version >= min_proto_ver) { + pkt_to_send = pkt; + } else if (client->net_proto_version != 0) { + pkt_to_send = legacypkt; + } else { + warningstream << "Client with unhandled version to handle: '" + << client->net_proto_version << "'"; + continue; + } + + m_con->Send(client->peer_id, + clientCommandFactoryTable[pkt_to_send->getCommand()].channel, + pkt_to_send, + clientCommandFactoryTable[pkt_to_send->getCommand()].reliable); + } +} + RemoteClient* ClientInterface::getClientNoEx(u16 peer_id, ClientState state_min) { MutexAutoLock clientslock(m_clients_mutex); |