Make lighting update occur immediately after ClientActiveObject addition to make...
authorPerttu Ahola <celeron55@gmail.com>
Sat, 26 Nov 2011 10:40:25 +0000 (12:40 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 17:13:53 +0000 (19:13 +0200)
src/environment.cpp

index a01bf1037908d6bc905cf040616e7dcc660960a0..c2bc2692e26092e664f54cac475667096b9eee80 100644 (file)
@@ -2289,8 +2289,18 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
        infostream<<"ClientEnvironment::addActiveObject(): "
                        <<"added (id="<<object->getId()<<")"<<std::endl;
        m_active_objects.insert(object->getId(), object);
-       // TODO: Make g_texturesource non-global
        object->addToScene(m_smgr, m_texturesource);
+       { // Update lighting immediately
+               u8 light = 0;
+               try{
+                       // Get node at head
+                       v3s16 p = object->getLightPosition();
+                       MapNode n = m_map->getNode(p);
+                       light = n.getLightBlend(getDayNightRatio(), m_gamedef->ndef());
+               }
+               catch(InvalidPositionException &e) {}
+               object->updateLight(light);
+       }
        return object->getId();
 }