mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
[Patch 2/4] Network rework: packet writing, sending and cleanups
NetworkPacket.cpp: * Remove some deprecated functions, we must use streaming interface * m_data converted from u8* to std::vector<u8> * Add an exporter to forge packet to Connection object * implement operator << std::wstring. n * implement operator << std::string * dynamic resize when write packet content. * fix string writing and performances. * create ServerCommandFactory, used by client to get useful informations about packet processing (sending). * Reliability * Transmit channel * Implement putRawString for some ugly char (_INIT packet), and use it. * Many packet read and write migrated * Implement oldForgePacket to interface writing with current connection * fix U8/char/bool writing * fix string writing and performances. * add some missing functions * Use v3s16 read instead of reading x,y,z separately * Add irr::video::SColor support into packets * Add some missing handlers * Add a template function to increase offset * Throw a serialization error on packet reading (must be improved) PacketFactories: * Create ServerCommandFactory, used by client to get useful informations about packet processing (sending). * Create ClientCommandFactory, used by server to get useful informations about packet processing (sending). Client.cpp: * implement NetworkPacket ::Send interface. * Move packet handlers to a dedicated file * Remove Client::Send(SharedBuffer) Server.cpp: * implement NetworkPacket ::Send interface. * Rewrite all packets using NetworkPacket * Move packet handlers to a dedicated file * Remove Server::Send(SharedBuffer) ClientIface.cpp: * Remove sendToAll(SharedBuffer<u8>) Connection.hpp rework: * Remove duplicate include * Remove duplicate negation * Remove a useless variable * Improve code performance by using a m_peers_list instead of scanning m_peers map * Remove Connection::Send(SharedBuffer) * Fix useafterfree into NetworkPacket Sending * Remove unused Connection::sendToAll Test.cpp: * Remove dead code * Update tests to use NetworkPackets Misc: * add new wrappers to Send packets in client, using NetworkPacket * Add NetworkPacket methods for Connection * coding style fix * dead code since changes cleanup * Use v3s16 read instead of reading x,y,z separately in some packets * Use different files to handle packets received by client and server * Cleanup: Remove useless includes ok @Zeno- Tested by @Zeno- @VanessaE and @nerzhul on running servers
This commit is contained in:
parent
efa977518a
commit
ed04e8e9e4
22 changed files with 3921 additions and 4182 deletions
50
src/server.h
50
src/server.h
|
@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#ifndef SERVER_HEADER
|
||||
#define SERVER_HEADER
|
||||
|
||||
#include "connection.h"
|
||||
#include "network/connection.h"
|
||||
#include "irr_v3d.h"
|
||||
#include "map.h"
|
||||
#include "hud.h"
|
||||
|
@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "util/thread.h"
|
||||
#include "environment.h"
|
||||
#include "clientiface.h"
|
||||
#include "network/toserverpacket.h"
|
||||
#include "network/networkpacket.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
@ -193,32 +193,34 @@ public:
|
|||
* Command Handlers
|
||||
*/
|
||||
|
||||
void handleCommand(ToServerPacket* pkt);
|
||||
void handleCommand(NetworkPacket* pkt);
|
||||
|
||||
void handleCommand_Null(ToServerPacket* pkt) {};
|
||||
void handleCommand_Deprecated(ToServerPacket* pkt);
|
||||
void handleCommand_Init(ToServerPacket* pkt);
|
||||
void handleCommand_Init2(ToServerPacket* pkt);
|
||||
void handleCommand_RequestMedia(ToServerPacket* pkt);
|
||||
void handleCommand_ReceivedMedia(ToServerPacket* pkt);
|
||||
void handleCommand_ClientReady(ToServerPacket* pkt);
|
||||
void handleCommand_GotBlocks(ToServerPacket* pkt);
|
||||
void handleCommand_PlayerPos(ToServerPacket* pkt);
|
||||
void handleCommand_DeletedBlocks(ToServerPacket* pkt);
|
||||
void handleCommand_InventoryAction(ToServerPacket* pkt);
|
||||
void handleCommand_ChatMessage(ToServerPacket* pkt);
|
||||
void handleCommand_Damage(ToServerPacket* pkt);
|
||||
void handleCommand_Breath(ToServerPacket* pkt);
|
||||
void handleCommand_Password(ToServerPacket* pkt);
|
||||
void handleCommand_PlayerItem(ToServerPacket* pkt);
|
||||
void handleCommand_Respawn(ToServerPacket* pkt);
|
||||
void handleCommand_Interact(ToServerPacket* pkt);
|
||||
void handleCommand_RemovedSounds(ToServerPacket* pkt);
|
||||
void handleCommand_NodeMetaFields(ToServerPacket* pkt);
|
||||
void handleCommand_InventoryFields(ToServerPacket* pkt);
|
||||
void handleCommand_Null(NetworkPacket* pkt) {};
|
||||
void handleCommand_Deprecated(NetworkPacket* pkt);
|
||||
void handleCommand_Init(NetworkPacket* pkt);
|
||||
void handleCommand_Init2(NetworkPacket* pkt);
|
||||
void handleCommand_RequestMedia(NetworkPacket* pkt);
|
||||
void handleCommand_ReceivedMedia(NetworkPacket* pkt);
|
||||
void handleCommand_ClientReady(NetworkPacket* pkt);
|
||||
void handleCommand_GotBlocks(NetworkPacket* pkt);
|
||||
void handleCommand_PlayerPos(NetworkPacket* pkt);
|
||||
void handleCommand_DeletedBlocks(NetworkPacket* pkt);
|
||||
void handleCommand_InventoryAction(NetworkPacket* pkt);
|
||||
void handleCommand_ChatMessage(NetworkPacket* pkt);
|
||||
void handleCommand_Damage(NetworkPacket* pkt);
|
||||
void handleCommand_Breath(NetworkPacket* pkt);
|
||||
void handleCommand_Password(NetworkPacket* pkt);
|
||||
void handleCommand_PlayerItem(NetworkPacket* pkt);
|
||||
void handleCommand_Respawn(NetworkPacket* pkt);
|
||||
void handleCommand_Interact(NetworkPacket* pkt);
|
||||
void handleCommand_RemovedSounds(NetworkPacket* pkt);
|
||||
void handleCommand_NodeMetaFields(NetworkPacket* pkt);
|
||||
void handleCommand_InventoryFields(NetworkPacket* pkt);
|
||||
|
||||
void ProcessData(u8 *data, u32 datasize, u16 peer_id);
|
||||
|
||||
void Send(NetworkPacket* pkt);
|
||||
|
||||
// Environment must be locked when called
|
||||
void setTimeOfDay(u32 time);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue