mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Fix active object adding to not generated block (#14311)
This commit is contained in:
parent
c9e10e1dd9
commit
83f779c52d
2 changed files with 16 additions and 9 deletions
|
@ -1044,7 +1044,8 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
|
|||
<<stamp<<", game time: "<<m_game_time<<std::endl;*/
|
||||
|
||||
// Remove stored static objects if clearObjects was called since block's timestamp
|
||||
if (stamp == BLOCK_TIMESTAMP_UNDEFINED || stamp < m_last_clear_objects_time) {
|
||||
// Note that non-generated blocks may still have stored static objects
|
||||
if (stamp != BLOCK_TIMESTAMP_UNDEFINED && stamp < m_last_clear_objects_time) {
|
||||
block->m_static_objects.clearStored();
|
||||
// do not set changed flag to avoid unnecessary mapblock writes
|
||||
}
|
||||
|
@ -1892,11 +1893,6 @@ 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
|
||||
|
@ -1915,12 +1911,20 @@ u16 ServerEnvironment::addActiveObjectRaw(std::unique_ptr<ServerActiveObject> ob
|
|||
MOD_REASON_ADD_ACTIVE_OBJECT_RAW);
|
||||
} else {
|
||||
v3s16 p = floatToInt(objectpos, BS);
|
||||
errorstream<<"ServerEnvironment::addActiveObjectRaw(): "
|
||||
<<"could not emerge block for storing id="<<object->getId()
|
||||
<<" statically (pos="<<p<<")"<<std::endl;
|
||||
errorstream << "ServerEnvironment::addActiveObjectRaw(): "
|
||||
<< "could not emerge block " << p << " for storing id="
|
||||
<< object->getId() << " statically" << std::endl;
|
||||
// clean in case of error
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue