]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/network/clientpackethandler.cpp
Client handlers: Remove useless stringstream usage in two handlers (#5510)
[dragonfireclient.git] / src / network / clientpackethandler.cpp
index f1c44c7d81ee925ab92bd689568d5c1f24ac7d51..19f8bbf58a83f99bf35194c44f1c6dac5199fb37 100644 (file)
@@ -142,7 +142,7 @@ void Client::handleCommand_AcceptSudoMode(NetworkPacket* pkt)
 }
 void Client::handleCommand_DenySudoMode(NetworkPacket* pkt)
 {
-       m_chat_queue.push(L"Password change denied. Password NOT changed.");
+       pushToChatQueue(L"Password change denied. Password NOT changed.");
        // reset everything and be sad
        deleteAuthData();
 }
@@ -413,8 +413,8 @@ void Client::handleCommand_ChatMessage(NetworkPacket* pkt)
        }
 
        // If chat message not consummed by client lua API
-       if (!m_script->on_receiving_message(wide_to_utf8(message))) {
-               m_chat_queue.push(message);
+       if (!moddingEnabled() || !m_script->on_receiving_message(wide_to_utf8(message))) {
+               pushToChatQueue(message);
        }
 }
 
@@ -526,6 +526,10 @@ void Client::handleCommand_HP(NetworkPacket* pkt)
 
        player->hp = hp;
 
+       if (moddingEnabled()) {
+               m_script->on_hp_modification(hp);
+       }
+
        if (hp < oldhp) {
                // Add to ClientEvent queue
                ClientEvent event;
@@ -729,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);
 
@@ -756,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);
 
@@ -1136,7 +1136,7 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt)
        if (m_minimap_disabled_by_server && was_minimap_visible) {
                // defers a minimap update, therefore only call it if really
                // needed, by checking that minimap was visible before
-               m_mapper->setMinimapMode(MINIMAP_MODE_OFF);
+               m_minimap->setMinimapMode(MINIMAP_MODE_OFF);
        }
 }