mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Network cleanup (#6302)
* Cleanup network headers * Move peerhandler to a specific header to reduce compilation times * Move socket.cpp/h to network folder * More work * Network code cleanups * Move socket.{cpp,h} to network folder * Move Address object to network/address.{cpp,h} * Move network exceptions to network/networkexceptions.h * Client: use unique_ptr for Connection * Server/ClientIface: use shared_ptr for Connection * Format fixes * Remove socket.cpp socket.h from clang-format whitelist * Also fix NetworkPacket code style & make it under clang-format
This commit is contained in:
parent
928609c8bd
commit
c7160cb629
27 changed files with 1059 additions and 924 deletions
|
@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "settings.h"
|
||||
#include "tool.h"
|
||||
#include "version.h"
|
||||
#include "network/connection.h"
|
||||
#include "network/networkprotocol.h"
|
||||
#include "network/serveropcodes.h"
|
||||
#include "util/auth.h"
|
||||
|
@ -686,7 +687,7 @@ void Server::handleCommand_ClientReady(NetworkPacket* pkt)
|
|||
actionstream
|
||||
<< "TOSERVER_CLIENT_READY stage 2 client init failed for peer_id: "
|
||||
<< peer_id << std::endl;
|
||||
m_con.DisconnectPeer(peer_id);
|
||||
m_con->DisconnectPeer(peer_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -695,7 +696,7 @@ void Server::handleCommand_ClientReady(NetworkPacket* pkt)
|
|||
errorstream
|
||||
<< "TOSERVER_CLIENT_READY client sent inconsistent data, disconnecting peer_id: "
|
||||
<< peer_id << std::endl;
|
||||
m_con.DisconnectPeer(peer_id);
|
||||
m_con->DisconnectPeer(peer_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -830,7 +831,7 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -839,7 +840,7 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player object for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -891,7 +892,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -900,7 +901,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player object for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1072,7 +1073,7 @@ void Server::handleCommand_ChatMessage(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1100,7 +1101,7 @@ void Server::handleCommand_Damage(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1109,7 +1110,7 @@ void Server::handleCommand_Damage(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player object for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1166,7 +1167,7 @@ void Server::handleCommand_Password(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1219,7 +1220,7 @@ void Server::handleCommand_PlayerItem(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1228,7 +1229,7 @@ void Server::handleCommand_PlayerItem(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player object for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1246,7 +1247,7 @@ void Server::handleCommand_Respawn(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1299,7 +1300,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1308,7 +1309,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player object for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1738,7 +1739,7 @@ void Server::handleCommand_NodeMetaFields(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1747,7 +1748,7 @@ void Server::handleCommand_NodeMetaFields(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player object for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1789,7 +1790,7 @@ void Server::handleCommand_InventoryFields(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1798,7 +1799,7 @@ void Server::handleCommand_InventoryFields(NetworkPacket* pkt)
|
|||
errorstream << "Server::ProcessData(): Canceling: "
|
||||
"No player object for peer_id=" << pkt->getPeerId()
|
||||
<< " disconnecting peer!" << std::endl;
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
m_con->DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue