Skip to content

Commit

Permalink
Fix a bug when entity's location might not be updated in case of serv…
Browse files Browse the repository at this point in the history
…er crash
  • Loading branch information
andriyndev authored Dec 30, 2024
1 parent f2b1cc3 commit 6aeb807
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/serverenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2161,11 +2161,13 @@ void ServerEnvironment::deactivateFarObjects(const bool _force_delete)
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, re-save to the block in
// which the object is actually located in.
// is actually located in an active block, or the distance between stored
// and actual location of the object, re-save to the block in which
// the object is actually located in.
if (!force_delete && obj->isStaticAllowed() && obj->m_static_exists &&
!m_active_blocks.contains(obj->m_static_block) &&
m_active_blocks.contains(blockpos_o)) {
m_active_blocks.contains(blockpos_o) &&
(!m_active_blocks.contains(obj->m_static_block) ||
blockpos_o.getDistanceFromSQ(obj->m_static_block) >= MAP_BLOCKSIZE * MAP_BLOCKSIZE)) {

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

0 comments on commit 6aeb807

Please sign in to comment.