Change music fade-in time
[supertux.git] / src / supertux / sector.cpp
index a2afe93..ba097a0 100644 (file)
@@ -115,8 +115,15 @@ Sector::Sector(Level* parent) :
 Sector::~Sector()
 {
   using namespace scripting;
+  try
+  {
+    deactivate();
+  }
+  catch(const std::exception& err)
+  {
+    log_warning << err.what() << std::endl;
+  }
 
-  deactivate();
 
   for(auto i = scripts.begin(); i != scripts.end(); ++i) {
     HSQOBJECT& object = *i;
@@ -587,7 +594,8 @@ Sector::activate(const Vector& player_pos)
 
     // spawning tux in the ground would kill him
     if(!is_free_of_tiles(p->get_bbox())) {
-      log_warning << "Tried spawning Tux in solid matter. Compensating." << std::endl;
+      std::string current_level = "[" + Sector::current()->get_level()->filename + "] ";
+      log_warning << current_level << "Tried spawning Tux in solid matter. Compensating." << std::endl;
       Vector npos = p->get_bbox().p1;
       npos.y-=32;
       p->move(npos);
@@ -1489,6 +1497,20 @@ Sector::play_music(MusicType type)
   }
 }
 
+void
+Sector::resume_music()
+{
+  if(SoundManager::current()->get_current_music() == music)
+  {
+    SoundManager::current()->resume_music(3.2f);
+  }
+  else
+  {
+    SoundManager::current()->stop_music();
+    SoundManager::current()->play_music(music, true);
+  }
+}
+
 MusicType
 Sector::get_music_type()
 {