[cppcheck] Part 3: More perf fixes that were missed during non-verbose run for whatev...
[supertux.git] / src / scripting / floating_image.cpp
index 270814d..77fe80b 100644 (file)
 #include "supertux/sector.hpp"
 #include "worldmap/worldmap.hpp"
 
-namespace Scripting {
+namespace scripting {
 
-FloatingImage::FloatingImage(const std::string& spritefile)
+FloatingImage::FloatingImage(const std::string& spritefile) :
+  floating_image(std::make_shared<_FloatingImage>(spritefile))
 {
-  using namespace WorldMapNS;
+  using namespace worldmap;
 
-  floating_image = new _FloatingImage(spritefile);
   if(Sector::current() != NULL) {
-    Sector::current()->add_object(floating_image.get());
+    Sector::current()->add_object(floating_image);
   } else if(WorldMap::current() != NULL) {
-    WorldMap::current()->add_object(floating_image.get());
+    WorldMap::current()->add_object(floating_image);
   } else {
     throw new std::runtime_error("Neither sector nor worldmap active");
   }