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/network/serveropcodes.cpp | |
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/network/serveropcodes.cpp')
-rw-r--r-- | src/network/serveropcodes.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/network/serveropcodes.cpp b/src/network/serveropcodes.cpp index 11d2c65ea..bd36b427f 100644 --- a/src/network/serveropcodes.cpp +++ b/src/network/serveropcodes.cpp @@ -93,3 +93,92 @@ const ToServerCommandHandler toServerCommandTable[TOSERVER_NUM_MSG_TYPES] = { "TOSERVER_BREATH", TOSERVER_STATE_INGAME, &Server::handleCommand_Breath }, // 0x42 { "TOSERVER_CLIENT_READY", TOSERVER_STATE_STARTUP, &Server::handleCommand_ClientReady }, // 0x43 }; + +const static ClientCommandFactory null_command_factory = { "TOCLIENT_NULL", 0, false }; + +const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] = +{ + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + { "TOCLIENT_INIT", 0, true }, // 0x10 + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + { "TOCLIENT_BLOCKDATA", 2, true }, // 0x20 + { "TOCLIENT_ADDNODE", 0, true }, // 0x21 + { "TOCLIENT_REMOVENODE", 0, true }, // 0x22 + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + { "TOCLIENT_INVENTORY", 0, true }, // 0x27 + null_command_factory, + { "TOCLIENT_TIME_OF_DAY", 0, true }, // 0x29 + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + null_command_factory, + { "TOCLIENT_CHAT_MESSAGE", 0, true }, // 0x30 + { "TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD", 0, true }, // 0x31 + { "TOCLIENT_ACTIVE_OBJECT_MESSAGES", 0, true }, // 0x32 Special packet, sent by 0 (rel) and 1 (unrel) channel + { "TOCLIENT_HP", 0, true }, // 0x33 + { "TOCLIENT_MOVE_PLAYER", 0, true }, // 0x34 + { "TOCLIENT_ACCESS_DENIED", 0, true }, // 0x35 + { "TOCLIENT_PLAYERITEM", 0, false }, // 0x36 obsolete + { "TOCLIENT_DEATHSCREEN", 0, true }, // 0x37 + { "TOCLIENT_MEDIA", 2, true }, // 0x38 + { "TOCLIENT_TOOLDEF", 0, false }, // 0x39 obsolete + { "TOCLIENT_NODEDEF", 0, true }, // 0x3a + { "TOCLIENT_CRAFTITEMDEF", 0, false }, // 0x3b obsolete + { "TOCLIENT_ANNOUNCE_MEDIA", 0, true }, // 0x3c + { "TOCLIENT_ITEMDEF", 0, true }, // 0x3d + null_command_factory, + { "TOCLIENT_PLAY_SOUND", 0, true }, // 0x3f + { "TOCLIENT_STOP_SOUND", 0, true }, // 0x40 + { "TOCLIENT_PRIVILEGES", 0, true }, // 0x41 + { "TOCLIENT_INVENTORY_FORMSPEC", 0, true }, // 0x42 + { "TOCLIENT_DETACHED_INVENTORY", 0, true }, // 0x43 + { "TOCLIENT_SHOW_FORMSPEC", 0, true }, // 0x44 + { "TOCLIENT_MOVEMENT", 0, true }, // 0x45 + { "TOCLIENT_SPAWN_PARTICLE", 0, true }, // 0x46 + { "TOCLIENT_ADD_PARTICLESPAWNER", 0, true }, // 0x47 + { "TOCLIENT_DELETE_PARTICLESPAWNER", 0, true }, // 0x48 + { "TOCLIENT_HUDADD", 1, true }, // 0x49 + { "TOCLIENT_HUDRM", 1, true }, // 0x4a + { "TOCLIENT_HUDCHANGE", 0, true }, // 0x4b + { "TOCLIENT_HUD_SET_FLAGS", 0, true }, // 0x4c + { "TOCLIENT_HUD_SET_PARAM", 0, true }, // 0x4d + { "TOCLIENT_BREATH", 0, true }, // 0x4e + { "TOCLIENT_SET_SKY", 0, true }, // 0x4f + { "TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO", 0, true }, // 0x50 + { "TOCLIENT_LOCAL_PLAYER_ANIMATIONS", 0, true }, // 0x51 + { "TOCLIENT_EYE_OFFSET", 0, true }, // 0x52 +}; |