diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2015-01-16 11:37:49 +0100 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2015-02-16 11:00:55 +0100 |
commit | ed04e8e9e407f0dd57fa83a9732b3a3968cb80e0 (patch) | |
tree | 488c3b155e78072c0f65a26b8e34b530d059f56c /src/client.h | |
parent | efa977518a60c47f3c409449be202298900372e8 (diff) | |
download | minetest-ed04e8e9e407f0dd57fa83a9732b3a3968cb80e0.tar.gz minetest-ed04e8e9e407f0dd57fa83a9732b3a3968cb80e0.tar.bz2 minetest-ed04e8e9e407f0dd57fa83a9732b3a3968cb80e0.zip |
[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
Diffstat (limited to 'src/client.h')
-rw-r--r-- | src/client.h | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/client.h b/src/client.h index 93143009e..1c29aac1e 100644 --- a/src/client.h +++ b/src/client.h @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef CLIENT_HEADER #define CLIENT_HEADER -#include "connection.h" +#include "network/connection.h" #include "environment.h" #include "irrlichttypes_extrabloated.h" #include "jthread/jmutex.h" @@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "localplayer.h" #include "hud.h" #include "particles.h" -#include "network/toclientpacket.h" +#include "network/networkpacket.h" struct MeshMakeData; class MapBlockMesh; @@ -346,57 +346,57 @@ public: * Command Handlers */ - void handleCommand(ToClientPacket* pkt); - - void handleCommand_Null(ToClientPacket* pkt) {}; - void handleCommand_Deprecated(ToClientPacket* pkt); - void handleCommand_Init(ToClientPacket* pkt); - void handleCommand_AccessDenied(ToClientPacket* pkt); - void handleCommand_RemoveNode(ToClientPacket* pkt); - void handleCommand_AddNode(ToClientPacket* pkt); - void handleCommand_BlockData(ToClientPacket* pkt); - void handleCommand_Inventory(ToClientPacket* pkt); - void handleCommand_TimeOfDay(ToClientPacket* pkt); - void handleCommand_ChatMessage(ToClientPacket* pkt); - void handleCommand_ActiveObjectRemoveAdd(ToClientPacket* pkt); - void handleCommand_ActiveObjectMessages(ToClientPacket* pkt); - void handleCommand_Movement(ToClientPacket* pkt); - void handleCommand_HP(ToClientPacket* pkt); - void handleCommand_Breath(ToClientPacket* pkt); - void handleCommand_MovePlayer(ToClientPacket* pkt); - void handleCommand_PlayerItem(ToClientPacket* pkt); - void handleCommand_DeathScreen(ToClientPacket* pkt); - void handleCommand_AnnounceMedia(ToClientPacket* pkt); - void handleCommand_Media(ToClientPacket* pkt); - void handleCommand_ToolDef(ToClientPacket* pkt); - void handleCommand_NodeDef(ToClientPacket* pkt); - void handleCommand_CraftItemDef(ToClientPacket* pkt); - void handleCommand_ItemDef(ToClientPacket* pkt); - void handleCommand_PlaySound(ToClientPacket* pkt); - void handleCommand_StopSound(ToClientPacket* pkt); - void handleCommand_Privileges(ToClientPacket* pkt); - void handleCommand_InventoryFormSpec(ToClientPacket* pkt); - void handleCommand_DetachedInventory(ToClientPacket* pkt); - void handleCommand_ShowFormSpec(ToClientPacket* pkt); - void handleCommand_SpawnParticle(ToClientPacket* pkt); - void handleCommand_AddParticleSpawner(ToClientPacket* pkt); - void handleCommand_DeleteParticleSpawner(ToClientPacket* pkt); - void handleCommand_HudAdd(ToClientPacket* pkt); - void handleCommand_HudRemove(ToClientPacket* pkt); - void handleCommand_HudChange(ToClientPacket* pkt); - void handleCommand_HudSetFlags(ToClientPacket* pkt); - void handleCommand_HudSetParam(ToClientPacket* pkt); - void handleCommand_HudSetSky(ToClientPacket* pkt); - void handleCommand_OverrideDayNightRatio(ToClientPacket* pkt); - void handleCommand_LocalPlayerAnimations(ToClientPacket* pkt); - void handleCommand_EyeOffset(ToClientPacket* pkt); + void handleCommand(NetworkPacket* pkt); + + void handleCommand_Null(NetworkPacket* pkt) {}; + void handleCommand_Deprecated(NetworkPacket* pkt); + void handleCommand_Init(NetworkPacket* pkt); + void handleCommand_AccessDenied(NetworkPacket* pkt); + void handleCommand_RemoveNode(NetworkPacket* pkt); + void handleCommand_AddNode(NetworkPacket* pkt); + void handleCommand_BlockData(NetworkPacket* pkt); + void handleCommand_Inventory(NetworkPacket* pkt); + void handleCommand_TimeOfDay(NetworkPacket* pkt); + void handleCommand_ChatMessage(NetworkPacket* pkt); + void handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt); + void handleCommand_ActiveObjectMessages(NetworkPacket* pkt); + void handleCommand_Movement(NetworkPacket* pkt); + void handleCommand_HP(NetworkPacket* pkt); + void handleCommand_Breath(NetworkPacket* pkt); + void handleCommand_MovePlayer(NetworkPacket* pkt); + void handleCommand_PlayerItem(NetworkPacket* pkt); + void handleCommand_DeathScreen(NetworkPacket* pkt); + void handleCommand_AnnounceMedia(NetworkPacket* pkt); + void handleCommand_Media(NetworkPacket* pkt); + void handleCommand_ToolDef(NetworkPacket* pkt); + void handleCommand_NodeDef(NetworkPacket* pkt); + void handleCommand_CraftItemDef(NetworkPacket* pkt); + void handleCommand_ItemDef(NetworkPacket* pkt); + void handleCommand_PlaySound(NetworkPacket* pkt); + void handleCommand_StopSound(NetworkPacket* pkt); + void handleCommand_Privileges(NetworkPacket* pkt); + void handleCommand_InventoryFormSpec(NetworkPacket* pkt); + void handleCommand_DetachedInventory(NetworkPacket* pkt); + void handleCommand_ShowFormSpec(NetworkPacket* pkt); + void handleCommand_SpawnParticle(NetworkPacket* pkt); + void handleCommand_AddParticleSpawner(NetworkPacket* pkt); + void handleCommand_DeleteParticleSpawner(NetworkPacket* pkt); + void handleCommand_HudAdd(NetworkPacket* pkt); + void handleCommand_HudRemove(NetworkPacket* pkt); + void handleCommand_HudChange(NetworkPacket* pkt); + void handleCommand_HudSetFlags(NetworkPacket* pkt); + void handleCommand_HudSetParam(NetworkPacket* pkt); + void handleCommand_HudSetSky(NetworkPacket* pkt); + void handleCommand_OverrideDayNightRatio(NetworkPacket* pkt); + void handleCommand_LocalPlayerAnimations(NetworkPacket* pkt); + void handleCommand_EyeOffset(NetworkPacket* pkt); void ProcessData(u8 *data, u32 datasize, u16 sender_peer_id); // Returns true if something was received bool AsyncProcessPacket(); bool AsyncProcessData(); - void Send(u16 channelnum, SharedBuffer<u8> data, bool reliable); + void Send(NetworkPacket* pkt); void interact(u8 action, const PointedThing& pointed); |