Fix for unloaded but active block problem
authorCiaran Gultnieks <ciaran@ciarang.com>
Thu, 20 Feb 2014 12:55:32 +0000 (12:55 +0000)
committersapier <Sapier at GMX dot net>
Sun, 2 Mar 2014 19:39:28 +0000 (20:39 +0100)
src/environment.cpp

index 08564046e9706b72d30461e47024f85317255f4d..0e7830a264dc78a409f98bb4e2d5b72b61562af5 100644 (file)
@@ -796,6 +796,14 @@ neighbor_found:
 
 void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
 {
+       // Reset usage timer immediately, otherwise a block that becomes active
+       // again at around the same time as it would normally be unloaded will
+       // get unloaded incorrectly. (I think this still leaves a small possibility
+       // of a race condition between this and server::AsyncRunStep, which only
+       // some kind of synchronisation will fix, but it at least reduces the window
+       // of opportunity for it to break from seconds to nanoseconds)
+       block->resetUsageTimer();
+
        // Get time difference
        u32 dtime_s = 0;
        u32 stamp = block->getTimestamp();