Worldmaps reset ambient light.
authorWolfgang Becker <uafr@gmx.de>
Sat, 16 Dec 2006 20:35:59 +0000 (20:35 +0000)
committerWolfgang Becker <uafr@gmx.de>
Sat, 16 Dec 2006 20:35:59 +0000 (20:35 +0000)
SVN-Revision: 4472

src/worldmap/worldmap.cpp
src/worldmap/worldmap.hpp

index a47c628..404f14c 100644 (file)
@@ -133,7 +133,7 @@ string_to_direction(const std::string& directory)
 //---------------------------------------------------------------------------
 
 WorldMap::WorldMap(const std::string& filename, const std::string& force_spawnpoint)
-  : tux(0), solids(0), force_spawnpoint(force_spawnpoint)
+  : tux(0), solids(0), ambient_light( 1.0f, 1.0f, 1.0f, 1.0f ), force_spawnpoint(force_spawnpoint)
 {
   tile_manager.reset(new TileManager("images/worldmap.strf"));
 
@@ -286,6 +286,14 @@ WorldMap::load(const std::string& filename)
         Teleporter* teleporter = new Teleporter(iter.lisp());
         teleporters.push_back(teleporter);
         add_object(teleporter);
+      } else if(iter.item() == "ambient-light") {
+        std::vector<float> vColor;
+        sector->get_vector( "ambient-light", vColor );
+        if(vColor.size() < 3) {
+          log_warning << "(ambient-light) requires a color as argument" << std::endl;
+        } else {
+          ambient_light = Color( vColor );
+        }
       } else if(iter.item() == "name") {
         // skip
       } else {
@@ -643,6 +651,7 @@ WorldMap::at_teleporter(const Vector& pos)
 void
 WorldMap::draw(DrawingContext& context)
 {
+  context.set_ambient_color( ambient_light );
   context.push_transform();
   context.set_translation(camera_offset);
 
index acbbedb..b650690 100644 (file)
@@ -113,6 +113,7 @@ private:
   typedef std::vector<HSQOBJECT> ScriptList;
   ScriptList scripts;
 
+  Color ambient_light;
   std::string force_spawnpoint; /**< if set, spawnpoint will be forced to this value */
 
 public:
@@ -190,7 +191,6 @@ private:
 
   void load(const std::string& filename);
   void on_escape_press();
-
 };
 
 } // namespace WorldMapNS