From: Perttu Ahola Date: Mon, 17 Oct 2011 08:52:38 +0000 (+0300) Subject: Workaround for blocks having a huge amount of active objects; add log messages relate... X-Git-Tag: 0.3.dev-20111021~30 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e9888c8e2525e9f3d476a96d42662f521f780c27;p=oweals%2Fminetest.git Workaround for blocks having a huge amount of active objects; add log messages related to active objects for investigation --- diff --git a/src/environment.cpp b/src/environment.cpp index 5c7b295ef..25e65d2be 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1345,8 +1345,6 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, assert(object); if(object->getId() == 0){ u16 new_id = getFreeServerActiveObjectId(m_active_objects); - verbosestream<<"ServerEnvironment::addActiveObjectRaw(): " - <<"created new id "<getBlockNoCreateNoEx(blockpos); if(block) { - verbosestream<<"ServerEnvironment::addActiveObjectRaw(): " - <<"found block for storing id="<getId() - <<" statically" - <<" (set_changed="<<(set_changed?"true":"false")<<")" - <m_static_objects.m_active.insert(object->getId(), s_obj); object->m_static_exists = true; object->m_static_block = blockpos; @@ -1400,8 +1392,9 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, block->setChangedFlag(); } else{ - errorstream<<"ServerEnv: Could not find a block for " - <<"storing newly added active object statically"<getId(); @@ -1466,6 +1459,40 @@ void ServerEnvironment::removeRemovedObjects() } } +static void print_hexdump(std::ostream &o, const std::string &data) +{ + const int linelength = 16; + for(int l=0; ; l++){ + int i0 = linelength * l; + bool at_end = false; + int thislinelength = linelength; + if(i0 + thislinelength > (int)data.size()){ + thislinelength = data.size() - i0; + at_end = true; + } + for(int di=0; di= 32) + o<getPos()) <<" ("<m_static_objects.m_stored.size() <<" objects)"<m_static_objects.m_stored.size() >= 50); + if(large_amount){ + errorstream<<"suspiciously large amount of objects detected: " + <m_static_objects.m_stored.size()<<" in " + <getPos()) + <<"; not activating."< new_stored; @@ -1497,9 +1532,18 @@ void ServerEnvironment::activateObjects(MapBlock *block) // If couldn't create object, store static data back. if(obj==NULL) { + errorstream<<"ServerEnvironment::activateObjects(): " + <<"failed to create active object from static object " + <<"in block "<m_static_objects.insert(0, s_obj); + block->setChangedFlag(); + obj->m_static_exists = true; + obj->m_static_block = block->getPos(); + } } else{ errorstream<<"ServerEnv: Could not find or generate " - <<"a block for storing static object"<m_static_exists = false; + <<"a block for storing id="<getId() + <<" statically"<