Added default and cancel button to the Dialog
[supertux.git] / src / object / ambient_sound.cpp
index 05748fa..14539e6 100644 (file)
 #include "supertux/sector.hpp"
 #include "util/reader.hpp"
 
-AmbientSound::AmbientSound(const Reader& lisp)
+AmbientSound::AmbientSound(const Reader& lisp) :
+  name(),
+  position(),
+  dimension(),
+  sample(),
+  sound_source(),
+  latency(),
+  distance_factor(),
+  distance_bias(),
+  silence_distance(),
+  maximumvolume(),
+  targetvolume(),
+  currentvolume(),
+  volume_ptr()
 {
   name="";
   position.x = 0;
@@ -75,12 +88,25 @@ AmbientSound::AmbientSound(const Reader& lisp)
 
   lisp.get("silence_distance",silence_distance);
 
-  sound_source = 0; // not playing at the beginning
-  sound_manager->preload(sample);
+  sound_source.reset(); // not playing at the beginning
+  SoundManager::current()->preload(sample);
   latency=0;
 }
 
-AmbientSound::AmbientSound(Vector pos, float factor, float bias, float vol, std::string file)
+AmbientSound::AmbientSound(Vector pos, float factor, float bias, float vol, std::string file) :
+  name(),
+  position(),
+  dimension(),
+  sample(),
+  sound_source(),
+  latency(),
+  distance_factor(),
+  distance_bias(),
+  silence_distance(),
+  maximumvolume(),
+  targetvolume(),
+  currentvolume(),
+  volume_ptr()
 {
   position.x=pos.x;
   position.y=pos.y;
@@ -101,11 +127,12 @@ AmbientSound::AmbientSound(Vector pos, float factor, float bias, float vol, std:
     silence_distance = 1/distance_factor;
 
   sound_source = 0; // not playing at the beginning
-  sound_manager->preload(sample);
+  SoundManager::current()->preload(sample);
   latency=0;
 }
 
-AmbientSound::~AmbientSound() {
+AmbientSound::~AmbientSound()
+{
   stop_playing();
 }
 
@@ -115,16 +142,16 @@ AmbientSound::hit(Player& )
 }
 
 void
-AmbientSound::stop_playing() {
-  delete sound_source;
-  sound_source = 0;
+AmbientSound::stop_playing()
+{
+  sound_source.reset();
 }
 
 void
 AmbientSound::start_playing()
 {
   try {
-    sound_source = sound_manager->create_sound_source(sample);
+    sound_source = SoundManager::current()->create_sound_source(sample);
     if(!sound_source)
       throw std::runtime_error("file not found");
 
@@ -134,8 +161,7 @@ AmbientSound::start_playing()
     sound_source->play();
   } catch(std::exception& e) {
     log_warning << "Couldn't play '" << sample << "': " << e.what() << "" << std::endl;
-    delete sound_source;
-    sound_source = 0;
+    sound_source.reset();
     remove_me();
   }
 }
@@ -207,14 +233,14 @@ AmbientSound::draw(DrawingContext &)
 void
 AmbientSound::expose(HSQUIRRELVM vm, SQInteger table_idx)
 {
-  Scripting::AmbientSound* interface = static_cast<Scripting::AmbientSound*> (this);
-  expose_object(vm, table_idx, interface, name, false);
+  scripting::AmbientSound* _this = static_cast<scripting::AmbientSound*> (this);
+  expose_object(vm, table_idx, _this, name, false);
 }
 
 void
 AmbientSound::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
 {
-  Scripting::unexpose_object(vm, table_idx, name);
+  scripting::unexpose_object(vm, table_idx, name);
 }
 
 void
@@ -236,6 +262,4 @@ AmbientSound::get_pos_y() const
   return position.y;
 }
 
-IMPLEMENT_FACTORY(AmbientSound, "ambient_sound");
-
 /* EOF */