Skip to content

Commit

Permalink
Fix according to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andriyndev committed Jan 7, 2025
1 parent 02317d3 commit c3d73e7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/serverenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
// A number that is much smaller than the timeout for particle spawners should/could ever be
#define PARTICLE_SPAWNER_NO_EXPIRY -1024.f

#define ACTIVE_OBJECT_RESAVE_DISTANCE_SQ 2 * 2

/*
ABMWithState
*/
Expand Down Expand Up @@ -2160,15 +2162,14 @@ void ServerEnvironment::deactivateFarObjects(const bool _force_delete)
// The block in which the object resides in
v3s16 blockpos_o = getNodeBlockPos(floatToInt(objectpos, BS));

// If object's static data is stored in a deactivated block and object
// is actually located in an active block, or if the object is actually located
// in an active block which is not neighboring to the block in which
// the object's static data is stored (there is at least one block between
// them), re-save to the block in which the object is actually located in.
// If object's static data is stored in a deactivated block or it has moved a bunch
// then re-save to the block in which the object is now located in.
// This only applies if the object is in a currently active block, since deactivating
// is handled by the code further below.
if (!force_delete && obj->isStaticAllowed() && obj->m_static_exists &&
m_active_blocks.contains(blockpos_o) &&
(!m_active_blocks.contains(obj->m_static_block) ||
blockpos_o.getDistanceFromSQ(obj->m_static_block) >= 2 * 2)) {
blockpos_o.getDistanceFromSQ(obj->m_static_block) >= ACTIVE_OBJECT_RESAVE_DISTANCE_SQ)) {

// Delete from block where object was located
deleteStaticFromBlock(obj, id, MOD_REASON_STATIC_DATA_REMOVED, false);
Expand Down

0 comments on commit c3d73e7

Please sign in to comment.