Typo in getOutgoingSequenceNumber => successfull to successful
[oweals/minetest.git] / src / network / serverpackethandler.cpp
index bb3a5346345265bb17d4f3b60a9af005b3fb0a9b..e01aeaa55e0d36b2058f884528a6be84fb533dae 100644 (file)
@@ -343,7 +343,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
                 * respond for some time, your server was overloaded or
                 * things like that.
                 */
-               infostream << "Server::ProcessData(): Cancelling: peer "
+               infostream << "Server::ProcessData(): Canceling: peer "
                                << pkt->getPeerId() << " not found" << std::endl;
                return;
        }
@@ -388,7 +388,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
                DenyAccess_Legacy(pkt->getPeerId(), std::wstring(
                                L"Your client's version is not supported.\n"
                                L"Server version is ")
-                               + narrow_to_wide(minetest_version_simple) + L"."
+                               + narrow_to_wide(g_version_string) + L"."
                );
                return;
        }
@@ -436,7 +436,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
                DenyAccess_Legacy(pkt->getPeerId(), std::wstring(
                                L"Your client's version is not supported.\n"
                                L"Server version is ")
-                               + narrow_to_wide(minetest_version_simple) + L",\n"
+                               + narrow_to_wide(g_version_string) + L",\n"
                                + L"server's PROTOCOL_VERSION is "
                                + narrow_to_wide(itos(SERVER_PROTOCOL_VERSION_MIN))
                                + L"..."
@@ -456,7 +456,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
                        DenyAccess_Legacy(pkt->getPeerId(), std::wstring(
                                        L"Your client's version is not supported.\n"
                                        L"Server version is ")
-                                       + narrow_to_wide(minetest_version_simple) + L",\n"
+                                       + narrow_to_wide(g_version_string) + L",\n"
                                        + L"server's PROTOCOL_VERSION (strict) is "
                                        + narrow_to_wide(itos(LATEST_PROTOCOL_VERSION))
                                        + L", client's PROTOCOL_VERSION is "
@@ -732,7 +732,7 @@ void Server::handleCommand_ClientReady(NetworkPacket* pkt)
        if (peer_proto_ver <= 22) {
                infostream << "Client sent message not expected by a "
                        << "client using protocol version <= 22,"
-                       << "disconnecing peer_id: " << peer_id << std::endl;
+                       << "disconnecting peer_id: " << peer_id << std::endl;
                m_con.DisconnectPeer(peer_id);
                return;
        }
@@ -756,12 +756,13 @@ void Server::handleCommand_ClientReady(NetworkPacket* pkt)
                return;
        }
 
-       u8 major_ver, minor_ver, patch_ver;
-       *pkt >> major_ver >> minor_ver >> patch_ver;
+       u8 major_ver, minor_ver, patch_ver, reserved;
+       std::string full_ver;
+       *pkt >> major_ver >> minor_ver >> patch_ver >> reserved >> full_ver;
 
        m_clients.setClientVersion(
                        peer_id, major_ver, minor_ver, patch_ver,
-                       std::string(pkt->getString(6),(u16) pkt->getU8(4)));
+                       full_ver);
 
        m_clients.event(peer_id, CSE_SetClientReady);
        m_script->on_joinplayer(playersao);
@@ -825,7 +826,7 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
 
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -841,7 +842,7 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
 
        PlayerSAO *playersao = player->getPlayerSAO();
        if (playersao == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player object for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -903,7 +904,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
 {
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -912,7 +913,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
 
        PlayerSAO *playersao = player->getPlayerSAO();
        if (playersao == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player object for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -951,8 +952,8 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
                ma->from_inv.applyCurrentPlayer(player->getName());
                ma->to_inv.applyCurrentPlayer(player->getName());
 
-               setInventoryModified(ma->from_inv);
-               setInventoryModified(ma->to_inv);
+               setInventoryModified(ma->from_inv, false);
+               setInventoryModified(ma->to_inv, false);
 
                bool from_inv_is_current_player =
                        (ma->from_inv.type == InventoryLocation::PLAYER) &&
@@ -1005,7 +1006,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
 
                da->from_inv.applyCurrentPlayer(player->getName());
 
-               setInventoryModified(da->from_inv);
+               setInventoryModified(da->from_inv, false);
 
                /*
                        Disable dropping items out of craftpreview
@@ -1032,7 +1033,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
 
                ca->craft_inv.applyCurrentPlayer(player->getName());
 
-               setInventoryModified(ca->craft_inv);
+               setInventoryModified(ca->craft_inv, false);
 
                //bool craft_inv_is_current_player =
                //      (ca->craft_inv.type == InventoryLocation::PLAYER) &&
@@ -1051,6 +1052,8 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
        a->apply(this, playersao, this);
        // Eat the action
        delete a;
+
+       SendInventory(playersao);
 }
 
 void Server::handleCommand_ChatMessage(NetworkPacket* pkt)
@@ -1073,7 +1076,7 @@ void Server::handleCommand_ChatMessage(NetworkPacket* pkt)
 
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1154,7 +1157,7 @@ void Server::handleCommand_Damage(NetworkPacket* pkt)
 
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1163,7 +1166,7 @@ void Server::handleCommand_Damage(NetworkPacket* pkt)
 
        PlayerSAO *playersao = player->getPlayerSAO();
        if (playersao == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player object for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1188,7 +1191,7 @@ void Server::handleCommand_Breath(NetworkPacket* pkt)
 
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1208,7 +1211,7 @@ void Server::handleCommand_Breath(NetworkPacket* pkt)
 
        PlayerSAO *playersao = player->getPlayerSAO();
        if (playersao == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player object for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1253,7 +1256,7 @@ void Server::handleCommand_Password(NetworkPacket* pkt)
 
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1290,7 +1293,7 @@ void Server::handleCommand_Password(NetworkPacket* pkt)
        } else {
                actionstream << player->getName() << " tries to change password but "
                                << "it fails" << std::endl;
-               SendChatMessage(pkt->getPeerId(), L"Password change failed or inavailable.");
+               SendChatMessage(pkt->getPeerId(), L"Password change failed or unavailable.");
        }
 }
 
@@ -1301,7 +1304,7 @@ void Server::handleCommand_PlayerItem(NetworkPacket* pkt)
 
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1310,7 +1313,7 @@ void Server::handleCommand_PlayerItem(NetworkPacket* pkt)
 
        PlayerSAO *playersao = player->getPlayerSAO();
        if (playersao == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player object for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1328,7 +1331,7 @@ void Server::handleCommand_Respawn(NetworkPacket* pkt)
 {
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1344,7 +1347,7 @@ void Server::handleCommand_Respawn(NetworkPacket* pkt)
                        << PP(player->getPosition()/BS) << std::endl;
 
        // ActiveObject is added to environment in AsyncRunStep after
-       // the previous addition has been succesfully removed
+       // the previous addition has been successfully removed
 }
 
 void Server::handleCommand_Interact(NetworkPacket* pkt)
@@ -1376,7 +1379,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
 
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1385,7 +1388,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
 
        PlayerSAO *playersao = player->getPlayerSAO();
        if (playersao == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player object for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1723,7 +1726,9 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
                if (m_script->item_OnUse(
                                item, playersao, pointed)) {
                        // Apply returned ItemStack
-                       playersao->setWieldedItem(item);
+                       if (playersao->setWieldedItem(item)) {
+                               SendInventory(playersao);
+                       }
                }
 
        } // action == 4
@@ -1777,7 +1782,7 @@ void Server::handleCommand_NodeMetaFields(NetworkPacket* pkt)
 
        Player *player = m_env->getPlayer(pkt->getPeerId());
        if (player == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!" << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());
@@ -1786,7 +1791,7 @@ void Server::handleCommand_NodeMetaFields(NetworkPacket* pkt)
 
        PlayerSAO *playersao = player->getPlayerSAO();
        if (playersao == NULL) {
-               errorstream << "Server::ProcessData(): Cancelling: "
+               errorstream << "Server::ProcessData(): Canceling: "
                                "No player object for peer_id=" << pkt->getPeerId()
                                << " disconnecting peer!"  << std::endl;
                m_con.DisconnectPeer(pkt->getPeerId());