- v3s16 p0;
- for(p0.X=0; p0.X<MAP_BLOCKSIZE; p0.X++)
- for(p0.Y=0; p0.Y<MAP_BLOCKSIZE; p0.Y++)
- for(p0.Z=0; p0.Z<MAP_BLOCKSIZE; p0.Z++)
- {
- v3s16 p = p0 + block->getPosRelative();
- MapNode n = block->getNodeNoEx(p0);
-
- /*
- Test something:
- Convert mud under proper lighting to grass
- */
- if(n.getContent() == CONTENT_MUD)
- {
- if(myrand()%20 == 0)
- {
- MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
- if(content_features(n_top).air_equivalent &&
- n_top.getLightBlend(getDayNightRatio()) >= 13)
- {
- n.setContent(CONTENT_GRASS);
- m_map->addNodeWithEvent(p, n);
- }
- }
- }
- /*
- Convert grass into mud if under something else than air
- */
- if(n.getContent() == CONTENT_GRASS)
- {
- //if(myrand()%20 == 0)
- {
- MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
- if(content_features(n_top).air_equivalent == false)
- {
- n.setContent(CONTENT_MUD);
- m_map->addNodeWithEvent(p, n);
- }
- }
- }
- /*
- Rats spawn around regular trees
- */
- if(n.getContent() == CONTENT_TREE ||
- n.getContent() == CONTENT_JUNGLETREE)
- {
- if(myrand()%200 == 0 && active_object_count_wider == 0)
- {
- v3s16 p1 = p + v3s16(myrand_range(-2, 2),
- 0, myrand_range(-2, 2));
- MapNode n1 = m_map->getNodeNoEx(p1);
- MapNode n1b = m_map->getNodeNoEx(p1+v3s16(0,-1,0));
- if(n1b.getContent() == CONTENT_GRASS &&
- n1.getContent() == CONTENT_AIR)
- {
- v3f pos = intToFloat(p1, BS);
- ServerActiveObject *obj = new RatSAO(this, 0, pos);
- addActiveObject(obj);
- }
- }
- }
- }
+ u32 time_ms = timer.stop(true);
+ u32 max_time_ms = 200;
+ if(time_ms > max_time_ms){
+ infostream<<"WARNING: active block modifiers took "
+ <<time_ms<<"ms (longer than "
+ <<max_time_ms<<"ms)"<<std::endl;
+ m_active_block_interval_overload_skip = (time_ms / max_time_ms) + 1;