diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 17:09:29 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 19:13:58 +0200 |
commit | 1c19f959db117d48538b93b5494d87d97515fdfb (patch) | |
tree | c7dd6a9e3f51247f2586cdee8f224d713e6abf99 | |
parent | dde22d26a84dfd1820f1eb55b2016e8fc0475f5b (diff) | |
download | minetest-1c19f959db117d48538b93b5494d87d97515fdfb.tar.gz minetest-1c19f959db117d48538b93b5494d87d97515fdfb.tar.bz2 minetest-1c19f959db117d48538b93b5494d87d97515fdfb.zip |
Fix active_object_count and active_object_count_wider not getting updated between ABM calls causing huge amounts of DMs and rats and stuff
-rw-r--r-- | src/environment.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index 1951996a2..41ba52a6f 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -618,22 +618,6 @@ public: return; ServerMap *map = &m_env->getServerMap(); - // Find out how many objects the block contains - 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; - 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) - continue; - active_object_count_wider += - block2->m_static_objects.m_active.size() - + block2->m_static_objects.m_stored.size(); - } v3s16 p0; for(p0.X=0; p0.X<MAP_BLOCKSIZE; p0.X++) @@ -650,9 +634,28 @@ public: continue; for(std::list<ActiveABM>::iterator - i = j->second.begin(); i != j->second.end(); i++){ + i = j->second.begin(); i != j->second.end(); i++) + { if(myrand() % i->chance != 0) continue; + + // Find out how many objects the block contains + 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; + 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) + continue; + active_object_count_wider += + block2->m_static_objects.m_active.size() + + block2->m_static_objects.m_stored.size(); + } + // Call all the trigger variations i->abm->trigger(m_env, p, n); i->abm->trigger(m_env, p, n, |