]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Immediately activate blocks when a player joins
authorsfan5 <sfan5@live.de>
Thu, 26 May 2022 20:14:22 +0000 (22:14 +0200)
committersfan5 <sfan5@live.de>
Sun, 29 May 2022 12:00:19 +0000 (14:00 +0200)
issue: #10884
This makes it possible for objects to immediately be activated,
but doesn't guarantee it since blocks may still need be emerged.

src/serverenvironment.cpp
src/serverenvironment.h

index 630c111c5a36c5252182db68b427645f82faf9a3..bff563a61eb531f115ae1651449d2be107b1f03c 100644 (file)
@@ -626,6 +626,9 @@ PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,
        /* Add object to environment */
        addActiveObject(playersao);
 
+       // Update active blocks asap so objects in those blocks appear on the client
+       m_force_update_active_blocks = true;
+
        return playersao;
 }
 
@@ -1332,8 +1335,10 @@ void ServerEnvironment::step(float dtime)
        /*
                Manage active block list
        */
-       if (m_active_blocks_management_interval.step(dtime, m_cache_active_block_mgmt_interval)) {
+       if (m_active_blocks_mgmt_interval.step(dtime, m_cache_active_block_mgmt_interval) ||
+               m_force_update_active_blocks) {
                ScopeProfiler sp(g_profiler, "ServerEnv: update active blocks", SPT_AVG);
+
                /*
                        Get player block positions
                */
@@ -1396,6 +1401,7 @@ void ServerEnvironment::step(float dtime)
                        activateBlock(block);
                }
        }
+       m_force_update_active_blocks = false;
 
        /*
                Mess around in active blocks
index 5dc329a60e8f531a686ac4020cea6607a0bc3f1a..223cd3420599b659b342a1054fa09eafca65f93a 100644 (file)
@@ -454,7 +454,8 @@ class ServerEnvironment : public Environment
        IntervalLimiter m_object_management_interval;
        // List of active blocks
        ActiveBlockList m_active_blocks;
-       IntervalLimiter m_active_blocks_management_interval;
+       bool m_force_update_active_blocks = false;
+       IntervalLimiter m_active_blocks_mgmt_interval;
        IntervalLimiter m_active_block_modifier_interval;
        IntervalLimiter m_active_blocks_nodemetadata_interval;
        // Whether the variables below have been read from file yet