mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02:00
Fix some memory leaks on packet sending.
This commit is contained in:
@@ -2079,24 +2079,19 @@ void Server::sendRemoveNode(v3s16 p, u16 ignore_id,
|
||||
float maxd = far_d_nodes*BS;
|
||||
v3f p_f = intToFloat(p, BS);
|
||||
|
||||
NetworkPacket* pkt = new NetworkPacket(TOCLIENT_REMOVENODE, 2 + 2 + 2);
|
||||
NetworkPacket* pkt = new NetworkPacket(TOCLIENT_REMOVENODE, 6);
|
||||
*pkt << p;
|
||||
|
||||
std::list<u16> clients = m_clients.getClientIDs();
|
||||
for(std::list<u16>::iterator
|
||||
i = clients.begin();
|
||||
i != clients.end(); ++i)
|
||||
{
|
||||
if(far_players)
|
||||
{
|
||||
i != clients.end(); ++i) {
|
||||
if(far_players) {
|
||||
// Get player
|
||||
Player *player = m_env->getPlayer(*i);
|
||||
if(player)
|
||||
{
|
||||
if(Player *player = m_env->getPlayer(*i)) {
|
||||
// If player is far away, only set modified blocks not sent
|
||||
v3f player_pos = player->getPosition();
|
||||
if(player_pos.getDistanceFrom(p_f) > maxd)
|
||||
{
|
||||
if(player_pos.getDistanceFrom(p_f) > maxd) {
|
||||
far_players->push_back(*i);
|
||||
continue;
|
||||
}
|
||||
@@ -2118,7 +2113,7 @@ void Server::sendAddNode(v3s16 p, MapNode n, u16 ignore_id,
|
||||
v3f p_f = intToFloat(p, BS);
|
||||
|
||||
std::list<u16> clients = m_clients.getClientIDs();
|
||||
for(std::list<u16>::iterator
|
||||
for(std::list<u16>::iterator
|
||||
i = clients.begin();
|
||||
i != clients.end(); ++i)
|
||||
{
|
||||
@@ -2139,7 +2134,7 @@ void Server::sendAddNode(v3s16 p, MapNode n, u16 ignore_id,
|
||||
}
|
||||
}
|
||||
|
||||
NetworkPacket* pkt = new NetworkPacket(TOCLIENT_ADDNODE, 0);
|
||||
NetworkPacket* pkt = new NetworkPacket(TOCLIENT_ADDNODE, 6 + 2 + 1 + 1 + 1);
|
||||
m_clients.Lock();
|
||||
RemoteClient* client = m_clients.lockedGetClientNoEx(*i);
|
||||
if (client != 0) {
|
||||
|
Reference in New Issue
Block a user