Skip to content

Commit b0be7ab

Browse files
authored
ClientIface::sendToAll: honor packet configuration (#5590)
1 parent 98286a2 commit b0be7ab

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/clientiface.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3030
#include "emerge.h"
3131
#include "content_sao.h" // TODO this is used for cleanup of only
3232
#include "log.h"
33+
#include "network/serveropcodes.h"
3334
#include "util/srp.h"
3435

3536
const char *ClientInterface::statenames[] = {
@@ -678,16 +679,17 @@ void ClientInterface::send(u16 peer_id, u8 channelnum,
678679
m_con->Send(peer_id, channelnum, pkt, reliable);
679680
}
680681

681-
void ClientInterface::sendToAll(u16 channelnum,
682-
NetworkPacket* pkt, bool reliable)
682+
void ClientInterface::sendToAll(NetworkPacket *pkt)
683683
{
684684
MutexAutoLock clientslock(m_clients_mutex);
685-
for(UNORDERED_MAP<u16, RemoteClient*>::iterator i = m_clients.begin();
686-
i != m_clients.end(); ++i) {
685+
for (UNORDERED_MAP<u16, RemoteClient*>::iterator i = m_clients.begin();
686+
i != m_clients.end(); ++i) {
687687
RemoteClient *client = i->second;
688688

689689
if (client->net_proto_version != 0) {
690-
m_con->Send(client->peer_id, channelnum, pkt, reliable);
690+
m_con->Send(client->peer_id,
691+
clientCommandFactoryTable[pkt->getCommand()].channel, pkt,
692+
clientCommandFactoryTable[pkt->getCommand()].reliable);
691693
}
692694
}
693695
}

src/clientiface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ class ClientInterface {
458458
void send(u16 peer_id, u8 channelnum, NetworkPacket* pkt, bool reliable);
459459

460460
/* send to all clients */
461-
void sendToAll(u16 channelnum, NetworkPacket* pkt, bool reliable);
461+
void sendToAll(NetworkPacket *pkt);
462462

463463
/* delete a client */
464464
void DeleteClient(u16 peer_id);

src/server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ void Server::SendChatMessage(u16 peer_id, const std::wstring &message)
16421642
Send(&pkt);
16431643
}
16441644
else {
1645-
m_clients.sendToAll(0, &pkt, true);
1645+
m_clients.sendToAll(&pkt);
16461646
}
16471647
}
16481648

@@ -1761,7 +1761,7 @@ void Server::SendDeleteParticleSpawner(u16 peer_id, u32 id)
17611761
Send(&pkt);
17621762
}
17631763
else {
1764-
m_clients.sendToAll(0, &pkt, true);
1764+
m_clients.sendToAll(&pkt);
17651765
}
17661766

17671767
}
@@ -1866,7 +1866,7 @@ void Server::SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed)
18661866
pkt << time << time_speed;
18671867

18681868
if (peer_id == PEER_ID_INEXISTENT) {
1869-
m_clients.sendToAll(0, &pkt, true);
1869+
m_clients.sendToAll(&pkt);
18701870
}
18711871
else {
18721872
Send(&pkt);
@@ -2519,7 +2519,7 @@ void Server::sendDetachedInventory(const std::string &name, u16 peer_id)
25192519
const std::string &check = m_detached_inventories_player[name];
25202520
if (peer_id == PEER_ID_INEXISTENT) {
25212521
if (check == "")
2522-
return m_clients.sendToAll(0, &pkt, true);
2522+
return m_clients.sendToAll(&pkt);
25232523
RemotePlayer *p = m_env->getPlayer(check.c_str());
25242524
if (p)
25252525
m_clients.send(p->peer_id, 0, &pkt, true);

0 commit comments

Comments
 (0)