continued.
[oweals/minetest.git] / src / environment.cpp
index bb2d168edd425f60afab9f1de1f70705ea2477df..7c236c3556a54324eca746e5980a43c8078df006 100644 (file)
@@ -103,6 +103,8 @@ void Environment::step(float dtime)
                                i != m_players.end(); i++)
                {
                        Player *player = *i;
+
+                       v3f playerpos = player->getPosition();
                        
                        // Apply physics to local player
                        if(player->isLocal())
@@ -135,12 +137,22 @@ void Environment::step(float dtime)
                        */
                        player->move(dtime_part, *m_map);
                        
+                       /*
+                               Update lighting on remote players on client
+                       */
+                       u8 light = LIGHT_MAX;
+                       try{
+                               // Get node at feet
+                               v3s16 p = floatToInt(playerpos + v3f(0,BS/4,0));
+                               MapNode n = m_map->getNode(p);
+                               light = n.getLightBlend(m_daynight_ratio);
+                       }
+                       catch(InvalidPositionException &e) {}
+                       player->updateLight(light);
+
                        /*
                                Add footsteps to grass
                        */
-                       //TimeTaker footsteptimer("footstep", g_device);
-                       // 0ms
-                       v3f playerpos = player->getPosition();
                        // Get node that is at BS/4 under player
                        v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0));
                        try{
@@ -149,7 +161,7 @@ void Environment::step(float dtime)
                                {
                                        n.d = CONTENT_GRASS_FOOTSTEPS;
                                        m_map->setNode(bottompos, n);
-
+#ifndef SERVER
                                        // Update mesh on client
                                        if(m_map->mapType() == MAPTYPE_CLIENT)
                                        {
@@ -157,12 +169,12 @@ void Environment::step(float dtime)
                                                MapBlock *b = m_map->getBlockNoCreate(p_blocks);
                                                b->updateMesh(m_daynight_ratio);
                                        }
+#endif
                                }
                        }
                        catch(InvalidPositionException &e)
                        {
                        }
-                       //footsteptimer.stop();
                }
        }
        while(dtime > 0.001);
@@ -179,7 +191,9 @@ void Environment::addPlayer(Player *player)
 {
        DSTACK(__FUNCTION_NAME);
        //Check that only one local player exists and peer_ids are unique
+#ifndef SERVER
        assert(player->isLocal() == false || getLocalPlayer() == NULL);
+#endif
        assert(getPlayer(player->peer_id) == NULL);
        m_players.push_back(player);
 }
@@ -203,6 +217,7 @@ re_search:
        }
 }
 
+#ifndef SERVER
 LocalPlayer * Environment::getLocalPlayer()
 {
        for(core::list<Player*>::Iterator i = m_players.begin();
@@ -214,6 +229,7 @@ LocalPlayer * Environment::getLocalPlayer()
        }
        return NULL;
 }
+#endif
 
 Player * Environment::getPlayer(u16 peer_id)
 {
@@ -243,6 +259,7 @@ void Environment::printPlayers(std::ostream &o)
        }
 }
 
+#ifndef SERVER
 void Environment::updateMeshes(v3s16 blockpos)
 {
        m_map->updateMeshes(blockpos, m_daynight_ratio);
@@ -252,6 +269,7 @@ void Environment::expireMeshes(bool only_daynight_diffed)
 {
        m_map->expireMeshes(only_daynight_diffed);
 }
+#endif
 
 void Environment::setDayNightRatio(u32 r)
 {