From: Perttu Ahola Date: Sun, 9 Sep 2012 11:18:14 +0000 (+0300) Subject: Fix ServerActiveObject stuff X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=1cc1b93e65d6d88e20786383cb09caf22a8c6494;p=zefram%2Fminetest%2Fminetest_engine.git Fix ServerActiveObject stuff --- diff --git a/src/environment.cpp b/src/environment.cpp index 05629b09..10ebd412 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -743,19 +743,25 @@ neighbor_found: u32 active_object_count = block->m_static_objects.m_active.size(); // Find out how many objects this and all the neighbors contain u32 active_object_count_wider = 0; + u32 wider_unknown_count = 0; for(s16 x=-1; x<=1; x++) for(s16 y=-1; y<=1; y++) for(s16 z=-1; z<=1; z++) { MapBlock *block2 = map->getBlockNoCreateNoEx( block->getPos() + v3s16(x,y,z)); - if(block2==NULL) + if(block2==NULL){ + wider_unknown_count = 0; continue; + } active_object_count_wider += block2->m_static_objects.m_active.size() + block2->m_static_objects.m_stored.size(); } - + // Extrapolate + u32 wider_known_count = 3*3*3 - wider_unknown_count; + active_object_count_wider += wider_unknown_count * active_object_count_wider / wider_known_count; + // Call all the trigger variations i->abm->trigger(m_env, p, n); i->abm->trigger(m_env, p, n, @@ -1465,9 +1471,10 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, "addActiveObjectRaw"); } else{ + v3s16 p = floatToInt(objectpos, BS); errorstream<<"ServerEnvironment::addActiveObjectRaw(): " <<"could not find block for storing id="<getId() - <<" statically"<emergeBlock(blockpos); + MapBlock *block = NULL; + try{ + block = m_map->emergeBlock(blockpos); + } catch(InvalidPositionException &e){ + // Handled via NULL pointer + } if(block) { @@ -1793,9 +1805,10 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete) } else{ if(!force_delete){ + v3s16 p = floatToInt(objectpos, BS); errorstream<<"ServerEnv: Could not find or generate " <<"a block for storing id="<getId() - <<" statically"<