continued.
[oweals/minetest.git] / src / mapblock.cpp
index 186256589fded7eaac1514379d2701b151adf5b7..90ff05bd1468434066d23e51baa06dfe69b73ed6 100644 (file)
@@ -688,6 +688,7 @@ void MapBlock::updateMesh(u32 daynight_ratio)
                collector.fillMesh(mesh_new);
 
                // Use VBO for mesh (this just would set this for ever buffer)
+               // This will lead to infinite memory usage because or irrlicht.
                //mesh_new->setHardwareMappingHint(scene::EHM_STATIC);
                
                /*std::cout<<"MapBlock has "<<fastfaces_new->getSize()<<" faces "
@@ -756,17 +757,17 @@ void MapBlock::updateMesh(u32 daynight_ratio)
                                        = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
                        if(dir == v3s16(0,-1,0))
                                buf->getMaterial().setTexture(0,
-                                               g_irrlicht->getTexture("../data/torch_on_floor.png"));
+                                               g_irrlicht->getTexture(porting::getDataPath("torch_on_floor.png").c_str()));
                        else if(dir == v3s16(0,1,0))
                                buf->getMaterial().setTexture(0,
-                                               g_irrlicht->getTexture("../data/torch_on_ceiling.png"));
+                                               g_irrlicht->getTexture(porting::getDataPath("torch_on_ceiling.png").c_str()));
                        // For backwards compatibility
                        else if(dir == v3s16(0,0,0))
                                buf->getMaterial().setTexture(0,
-                                               g_irrlicht->getTexture("../data/torch_on_floor.png"));
+                                               g_irrlicht->getTexture(porting::getDataPath("torch_on_floor.png").c_str()));
                        else
                                buf->getMaterial().setTexture(0, 
-                                               g_irrlicht->getTexture("../data/torch.png"));
+                                               g_irrlicht->getTexture(porting::getDataPath("torch.png").c_str()));
 
                        // Add to mesh
                        mesh_new->addMeshBuffer(buf);
@@ -860,7 +861,9 @@ void MapBlock::updateMesh(u32 daynight_ratio)
        is_underground is set.
 
        At the moment, all sunlighted nodes are added to light_sources.
-       TODO: This could be optimized.
+       - SUGG: This could be optimized
+
+       Turns sunglighted mud into grass.
 */
 bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources)
 {
@@ -880,10 +883,6 @@ bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources)
                                MapNode n = getNodeParent(v3s16(x, MAP_BLOCKSIZE, z));
                                if(n.getLight(LIGHTBANK_DAY) != LIGHT_SUN)
                                {
-                                       /*if(is_underground)
-                                       {
-                                               no_sunlight = true;
-                                       }*/
                                        no_sunlight = true;
                                }
                        }
@@ -891,15 +890,14 @@ bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources)
                        {
                                no_top_block = true;
                                
-                               // TODO: This makes over-ground roofed places sunlighted
+                               // NOTE: This makes over-ground roofed places sunlighted
                                // Assume sunlight, unless is_underground==true
                                if(is_underground)
                                {
                                        no_sunlight = true;
                                }
                                
-                               // TODO: There has to be some way to allow this behaviour
-                               // As of now, it just makes everything dark.
+                               // NOTE: As of now, it just would make everything dark.
                                // No sunlight here
                                //no_sunlight = true;
                        }
@@ -928,7 +926,15 @@ bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources)
 
                                                light_sources.insert(pos_relative + pos, true);
                                        }
-                                       else{
+                                       else
+                                       {
+                                               // Turn mud into grass
+                                               if(n.d == CONTENT_MUD)
+                                               {
+                                                       n.d = CONTENT_GRASS;
+                                               }
+
+                                               // Sunlight goes no further
                                                break;
                                        }
                                }
@@ -1021,11 +1027,11 @@ void MapBlock::stepObjects(float dtime, bool server, u32 daynight_ratio)
                m_spawn_timer -= dtime;
                if(m_spawn_timer <= 0.0)
                {
-                       m_spawn_timer += rand() % 300;
+                       m_spawn_timer += myrand() % 300;
                        
                        v2s16 p2d(
-                               (rand()%(MAP_BLOCKSIZE-1))+0,
-                               (rand()%(MAP_BLOCKSIZE-1))+0
+                               (myrand()%(MAP_BLOCKSIZE-1))+0,
+                               (myrand()%(MAP_BLOCKSIZE-1))+0
                        );
 
                        s16 y = getGroundLevel(p2d);