Skip to content

Commit

Permalink
Fix #4759.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfence committed Jan 27, 2024
1 parent 4468813 commit cb689b5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/serverenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1900,19 +1900,14 @@ u16 ServerEnvironment::addActiveObjectRaw(std::unique_ptr<ServerActiveObject> ob
return 0;
}

// Register reference in scripting api (must be done before post-init)
m_script->addObjectReference(object);
// Post-initialize object
object->addedToEnvironment(dtime_s);

// Add static data to block
if (object->isStaticAllowed()) {
// Add static object to active static list of the block
v3f objectpos = object->getBasePosition();
StaticObject s_obj(object, objectpos);
// Add to the block where the object is located in
v3s16 blockpos = getNodeBlockPos(floatToInt(objectpos, BS));
MapBlock *block = m_map->emergeBlock(blockpos);
MapBlock *block = m_map->emergeBlock(blockpos, false);
if (block) {
block->m_static_objects.setActive(object->getId(), s_obj);
object->m_static_exists = true;
Expand All @@ -1926,9 +1921,16 @@ u16 ServerEnvironment::addActiveObjectRaw(std::unique_ptr<ServerActiveObject> ob
errorstream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"could not emerge block for storing id="<<object->getId()
<<" statically (pos="<<p<<")"<<std::endl;
m_ao_manager.removeObject(object->getId());
return 0;
}
}

// Register reference in scripting api (must be done before post-init)
m_script->addObjectReference(object);
// Post-initialize object
object->addedToEnvironment(dtime_s);

return object->getId();
}

Expand Down

0 comments on commit cb689b5

Please sign in to comment.