]> git.lizzy.rs Git - minetest.git/blobdiff - src/clientiface.cpp
Fix for #13255: Check if client has a block even if the server has unloaded it. ...
[minetest.git] / src / clientiface.cpp
index a1c3e1187384349de0717b8bef79b2459423c792..9d1a6cd0383f56d80b89bc06bf74679f57bd82b8 100644 (file)
@@ -295,23 +295,24 @@ void RemoteClient::GetNextBlocks (
                        }
 
                        /*
-                               Don't send already sent blocks
+                               Check if map has this block
                        */
-                       if (m_blocks_sent.find(p) != m_blocks_sent.end())
-                               continue;
+                       MapBlock *block = env->getMap().getBlockNoCreateNoEx(p);
+                       if (block) {
+                               // First: Reset usage timer, this block will be of use in the future.
+                               block->resetUsageTimer();
+                       }
 
                        /*
-                               Check if map has this block
+                               Don't send already sent blocks
                        */
-                       MapBlock *block = env->getMap().getBlockNoCreateNoEx(p);
+                       if (m_blocks_sent.find(p) != m_blocks_sent.end())
+                               continue;
 
                        bool block_not_found = false;
                        if (block) {
-                               // Reset usage timer, this block will be of use in the future.
-                               block->resetUsageTimer();
-
                                // Check whether the block exists (with data)
-                               if (block->isDummy() || !block->isGenerated())
+                               if (!block->isGenerated())
                                        block_not_found = true;
 
                                /*
@@ -472,20 +473,14 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
                {
                case CSE_AuthAccept:
                        m_state = CS_AwaitingInit2;
-                       if (chosen_mech == AUTH_MECHANISM_SRP ||
-                                       chosen_mech == AUTH_MECHANISM_LEGACY_PASSWORD)
-                               srp_verifier_delete((SRPVerifier *) auth_data);
-                       chosen_mech = AUTH_MECHANISM_NONE;
+                       resetChosenMech();
                        break;
                case CSE_Disconnect:
                        m_state = CS_Disconnecting;
                        break;
                case CSE_SetDenied:
                        m_state = CS_Denied;
-                       if (chosen_mech == AUTH_MECHANISM_SRP ||
-                                       chosen_mech == AUTH_MECHANISM_LEGACY_PASSWORD)
-                               srp_verifier_delete((SRPVerifier *) auth_data);
-                       chosen_mech = AUTH_MECHANISM_NONE;
+                       resetChosenMech();
                        break;
                default:
                        myerror << "HelloSent: Invalid client state transition! " << event;
@@ -561,9 +556,7 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
                        break;
                case CSE_SudoSuccess:
                        m_state = CS_SudoMode;
-                       if (chosen_mech == AUTH_MECHANISM_SRP)
-                               srp_verifier_delete((SRPVerifier *) auth_data);
-                       chosen_mech = AUTH_MECHANISM_NONE;
+                       resetChosenMech();
                        break;
                /* Init GotInit2 SetDefinitionsSent SetMediaSent SetDenied */
                default:
@@ -596,6 +589,15 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
        }
 }
 
+void RemoteClient::resetChosenMech()
+{
+       if (auth_data) {
+               srp_verifier_delete((SRPVerifier *) auth_data);
+               auth_data = nullptr;
+       }
+       chosen_mech = AUTH_MECHANISM_NONE;
+}
+
 u64 RemoteClient::uptime() const
 {
        return porting::getTimeS() - m_connection_time;