Client handlers: Remove useless stringstream usage in two handlers (#5510)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Tue, 4 Apr 2017 05:47:04 +0000 (07:47 +0200)
committerGitHub <noreply@github.com>
Tue, 4 Apr 2017 05:47:04 +0000 (07:47 +0200)
src/network/clientpackethandler.cpp

index dfaebbe533e12226ebd94f3f9c43eb916f4b5e01..19f8bbf58a83f99bf35194c44f1c6dac5199fb37 100644 (file)
@@ -733,9 +733,7 @@ void Client::handleCommand_NodeDef(NetworkPacket* pkt)
        sanity_check(!m_mesh_update_thread.isRunning());
 
        // Decompress node definitions
-       std::string datastring(pkt->getString(0), pkt->getSize());
-       std::istringstream is(datastring, std::ios_base::binary);
-       std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
+       std::istringstream tmp_is(pkt->readLongString(), std::ios::binary);
        std::ostringstream tmp_os;
        decompressZlib(tmp_is, tmp_os);
 
@@ -760,9 +758,7 @@ void Client::handleCommand_ItemDef(NetworkPacket* pkt)
        sanity_check(!m_mesh_update_thread.isRunning());
 
        // Decompress item definitions
-       std::string datastring(pkt->getString(0), pkt->getSize());
-       std::istringstream is(datastring, std::ios_base::binary);
-       std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
+       std::istringstream tmp_is(pkt->readLongString(), std::ios::binary);
        std::ostringstream tmp_os;
        decompressZlib(tmp_is, tmp_os);