Replaced std::auto_ptr<> with std::unique_ptr<>
authorIngo Ruhnke <grumbel@gmail.com>
Sun, 3 Aug 2014 17:05:09 +0000 (19:05 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Sun, 3 Aug 2014 18:57:20 +0000 (20:57 +0200)
29 files changed:
src/addon/addon_manager.cpp
src/audio/sound_manager.cpp
src/badguy/bomb.hpp
src/badguy/dart.hpp
src/badguy/flame.hpp
src/badguy/goldbomb.hpp
src/badguy/haywire.hpp
src/badguy/treewillowisp.hpp
src/badguy/willowisp.hpp
src/object/camera.hpp
src/object/platform.hpp
src/object/player.hpp
src/physfs/physfs_file_system.cpp
src/physfs/physfs_file_system.hpp
src/sprite/sprite_manager.cpp
src/supertux/game_session.hpp
src/supertux/main.cpp
src/supertux/menu/contrib_menu.cpp
src/supertux/menu/contrib_menu.hpp
src/supertux/menu/main_menu.hpp
src/supertux/menu/options_menu.hpp
src/supertux/screen_manager.hpp
src/supertux/tile_manager.cpp
src/supertux/tile_set_parser.cpp
src/supertux/title_screen.hpp
src/supertux/world.hpp
src/util/ref.hpp
src/worldmap/worldmap.cpp
src/worldmap/worldmap.hpp

index fe2de83..e2c3c55 100644 (file)
@@ -143,7 +143,7 @@ AddonManager::check_online()
         log_warning << "Unknown token '" << token << "' in Add-on list" << std::endl;
         continue;
       }
-      std::auto_ptr<Addon> addon(new Addon());
+      std::unique_ptr<Addon> addon(new Addon());
       addon->parse(*(iter.lisp()));
       addon->installed = false;
       addon->loaded = false;
index 89f86b2..9f2b36f 100644 (file)
@@ -118,7 +118,7 @@ SoundManager::intern_create_sound_source(const std::string& filename)
 {
   assert(sound_enabled);
 
-  std::auto_ptr<OpenALSoundSource> source (new OpenALSoundSource());
+  std::unique_ptr<OpenALSoundSource> source (new OpenALSoundSource());
 
   ALuint buffer;
 
@@ -128,7 +128,7 @@ SoundManager::intern_create_sound_source(const std::string& filename)
     buffer = i->second;
   } else {
     // Load sound file
-    std::auto_ptr<SoundFile> file (load_sound_file(filename));
+    std::unique_ptr<SoundFile> file (load_sound_file(filename));
 
     if(file->size < 100000) {
       buffer = load_file_into_buffer(file.get());
@@ -171,7 +171,7 @@ SoundManager::preload(const std::string& filename)
   if(i != buffers.end())
     return;
   try {
-    std::auto_ptr<SoundFile> file (load_sound_file(filename));
+    std::unique_ptr<SoundFile> file (load_sound_file(filename));
     // only keep small files
     if(file->size >= 100000)
       return;
@@ -190,7 +190,7 @@ SoundManager::play(const std::string& filename, const Vector& pos)
     return;
 
   try {
-    std::auto_ptr<OpenALSoundSource> source
+    std::unique_ptr<OpenALSoundSource> source
       (intern_create_sound_source(filename));
 
     if(pos.x < 0 || pos.y < 0) {
@@ -293,7 +293,7 @@ SoundManager::play_music(const std::string& filename, bool fade)
   }
 
   try {
-    std::auto_ptr<StreamSoundSource> newmusic (new StreamSoundSource());
+    std::unique_ptr<StreamSoundSource> newmusic (new StreamSoundSource());
     newmusic->set_sound_file(load_sound_file(filename));
     newmusic->set_looping(true);
     newmusic->set_relative(true);
index e2f4e76..a45dd22 100644 (file)
@@ -45,7 +45,7 @@ private:
   bool grabbed;
   MovingObject* grabber;
 
-  std::auto_ptr<SoundSource> ticking;
+  std::unique_ptr<SoundSource> ticking;
 
 private:
   Bomb(const Bomb&);
index a76c667..8ba5f2a 100644 (file)
@@ -45,7 +45,7 @@ public:
 
 protected:
   const BadGuy* parent; /**< collisions with this BadGuy will be ignored */
-  std::auto_ptr<SoundSource> sound_source; /**< SoundSource for ambient sound */
+  std::unique_ptr<SoundSource> sound_source; /**< SoundSource for ambient sound */
 
 private:
   Dart(const Dart&);
index 6513674..c3e63e8 100644 (file)
@@ -44,7 +44,7 @@ private:
   Color light;
   SpritePtr lightsprite;
 
-  std::auto_ptr<SoundSource> sound_source;
+  std::unique_ptr<SoundSource> sound_source;
 };
 
 #endif
index d82d28e..7d4f7fa 100644 (file)
@@ -59,7 +59,7 @@ private:
   bool grabbed;
   MovingObject* grabber;
 
-  std::auto_ptr<SoundSource> ticking;
+  std::unique_ptr<SoundSource> ticking;
 };
 
 #endif
index 83d0401..5e4817d 100644 (file)
@@ -44,8 +44,8 @@ private:
   bool is_stunned;
   float time_stunned;
   
-  std::auto_ptr<SoundSource> ticking;  
-  std::auto_ptr<SoundSource> grunting;
+  std::unique_ptr<SoundSource> ticking;  
+  std::unique_ptr<SoundSource> grunting;
 };
 
 #endif /* HEADER_SUPERTUX_BADGUY_HAYWIRE_HPP */
index 05b2876..8b78856 100644 (file)
@@ -66,7 +66,7 @@ private:
   float radius;
   float speed;
 
-  std::auto_ptr<SoundSource> sound_source;
+  std::unique_ptr<SoundSource> sound_source;
   GhostTree* tree;
 
   Vector suck_target;
index 42ad8fc..22e2c62 100644 (file)
@@ -73,10 +73,10 @@ private:
   std::string target_spawnpoint;
   std::string hit_script;
 
-  std::auto_ptr<SoundSource> sound_source;
+  std::unique_ptr<SoundSource> sound_source;
 
-  std::auto_ptr<Path>        path;
-  std::auto_ptr<PathWalker>  walker;
+  std::unique_ptr<Path>        path;
+  std::unique_ptr<PathWalker>  walker;
 
   float flyspeed;
   float track_range;
index 7158528..3c53f84 100644 (file)
@@ -110,8 +110,8 @@ private:
   Vector cached_translation;
 
   // autoscroll mode
-  std::auto_ptr<Path> autoscroll_path;
-  std::auto_ptr<PathWalker> autoscroll_walker;
+  std::unique_ptr<Path> autoscroll_path;
+  std::unique_ptr<PathWalker> autoscroll_walker;
 
   // shaking
   Timer shaketimer;
index 6c4d827..f9ba370 100644 (file)
@@ -65,8 +65,8 @@ public:
   }
 
 private:
-  std::auto_ptr<Path> path;
-  std::auto_ptr<PathWalker> walker;
+  std::unique_ptr<Path> path;
+  std::unique_ptr<PathWalker> walker;
 
   Vector speed;
 
index bcbbcbc..e2a514b 100644 (file)
@@ -262,7 +262,7 @@ private:
   bool deactivated;
 
   Controller* controller;
-  std::auto_ptr<CodeController> scripting_controller; /**< This controller is used when the Player is controlled via scripting */
+  std::unique_ptr<CodeController> scripting_controller; /**< This controller is used when the Player is controlled via scripting */
   PlayerStatus* player_status;
   bool duck;
   bool dead;
index 1575da0..6f11497 100644 (file)
@@ -37,10 +37,10 @@ PhysFSFileSystem::open_directory(const std::string& pathname)
   return files;
 }
 
-std::auto_ptr<std::istream>
+std::unique_ptr<std::istream>
 PhysFSFileSystem::open_file(const std::string& filename)
 {
-  return std::auto_ptr<std::istream>(new IFileStream(filename));
+  return std::unique_ptr<std::istream>(new IFileStream(filename));
 }
 
 /* EOF */
index dea9ad2..7677189 100644 (file)
@@ -25,7 +25,7 @@ public:
   PhysFSFileSystem();
 
   std::vector<std::string>    open_directory(const std::string& pathname);
-  std::auto_ptr<std::istream> open_file(const std::string& filename);
+  std::unique_ptr<std::istream> open_file(const std::string& filename);
 };
 
 #endif
index 72d282c..6c6628e 100644 (file)
@@ -90,7 +90,7 @@ SpriteManager::load(const std::string& filename)
     throw std::runtime_error(msg.str());
   }
 
-  std::auto_ptr<SpriteData> data (
+  std::unique_ptr<SpriteData> data (
     new SpriteData(*sprite, FileSystem::dirname(filename)) );
   sprites[filename] = data.release();
 
index 33cdd2d..cdad319 100644 (file)
@@ -106,7 +106,7 @@ private:
   void on_escape_press();
   void process_menu();
 
-  std::auto_ptr<Level> level;
+  std::unique_ptr<Level> level;
   SurfacePtr statistics_backdrop;
 
   // scripts
@@ -141,7 +141,7 @@ private:
   std::istream* playback_demo_stream;
   CodeController* demo_controller;
 
-  std::auto_ptr<Menu> game_menu;
+  std::unique_ptr<Menu> game_menu;
 
   float play_time; /**< total time in seconds that this session ran interactively */
 
index 3cd0912..e39e24b 100644 (file)
@@ -74,7 +74,7 @@ Main::init_tinygettext()
 {
   dictionary_manager = new tinygettext::DictionaryManager();
   tinygettext::Log::set_log_info_callback(0);
-  dictionary_manager->set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new PhysFSFileSystem));
+  dictionary_manager->set_filesystem(std::unique_ptr<tinygettext::FileSystem>(new PhysFSFileSystem));
 
   dictionary_manager->add_directory("locale");
   dictionary_manager->set_charset("UTF-8");
@@ -437,7 +437,7 @@ Main::init_video()
     SDL_SetWindowIcon(Renderer::instance()->get_window(), icon);
     SDL_FreeSurface(icon);
   }
-  SDL_ShowCursor(0);
+  //SDL_ShowCursor(0);
 
   log_info << (g_config->use_fullscreen?"fullscreen ":"window ")
            << " Window: "     << g_config->window_size
@@ -546,8 +546,8 @@ Main::run(int argc, char** argv)
       return 0;
 
     timelog("video");
-    std::auto_ptr<Renderer> renderer(VideoSystem::new_renderer());
-    std::auto_ptr<Lightmap> lightmap(VideoSystem::new_lightmap());
+    std::unique_ptr<Renderer> renderer(VideoSystem::new_renderer());
+    std::unique_ptr<Lightmap> lightmap(VideoSystem::new_lightmap());
     DrawingContext context(*renderer, *lightmap);
     context_pointer = &context;
     init_video();
@@ -571,7 +571,7 @@ Main::run(int argc, char** argv)
 
     timelog(0);
 
-    const std::auto_ptr<PlayerStatus> default_playerstatus(new PlayerStatus());
+    const std::unique_ptr<PlayerStatus> default_playerstatus(new PlayerStatus());
 
     g_screen_manager = new ScreenManager();
 
@@ -594,7 +594,7 @@ Main::run(int argc, char** argv)
         g_screen_manager->push_screen(new worldmap::WorldMap(
                                  FileSystem::basename(g_config->start_level), default_playerstatus.get()));
       } else {
-        std::auto_ptr<GameSession> session (
+        std::unique_ptr<GameSession> session (
           new GameSession(FileSystem::basename(g_config->start_level), default_playerstatus.get()));
 
         g_config->random_seed =session->get_demo_random_seed(g_config->start_demo);
index 34895b7..9219bfa 100644 (file)
@@ -46,7 +46,7 @@ ContribMenu::ContribMenu() :
   {
     try
     {
-      std::auto_ptr<World> world (new World());
+      std::unique_ptr<World> world (new World());
       world->load(*it + "/info");
       if (!world->hide_from_contribs) 
       {
index 25e9fd3..649b784 100644 (file)
@@ -25,7 +25,7 @@ class World;
 class ContribMenu : public Menu
 {
 private:
-  std::auto_ptr<ContribWorldMenu> m_contrib_world_menu;
+  std::unique_ptr<ContribWorldMenu> m_contrib_world_menu;
   std::vector<World*> m_contrib_worlds;
 
 public:
index 0f900a4..734cb2d 100644 (file)
@@ -36,9 +36,9 @@ enum MainMenuIDs {
 class MainMenu : public Menu
 {
 private:
-  std::auto_ptr<AddonMenu>   m_addon_menu;
-  std::auto_ptr<ContribMenu> m_contrib_menu;
-  std::auto_ptr<World>       m_main_world;
+  std::unique_ptr<AddonMenu>   m_addon_menu;
+  std::unique_ptr<ContribMenu> m_contrib_menu;
+  std::unique_ptr<World>       m_main_world;
 
 public:
   MainMenu();
index 473f3dd..8ac34d3 100644 (file)
@@ -33,7 +33,7 @@ public:
   void check_menu();
 
 protected:
-  std::auto_ptr<LanguageMenu> language_menu; 
+  std::unique_ptr<LanguageMenu> language_menu; 
 };
 
 #endif
index d885443..4e0fb50 100644 (file)
@@ -69,10 +69,10 @@ private:
   bool nextpush;
   /// measured fps
   float fps;
-  std::auto_ptr<Screen> next_screen;
-  std::auto_ptr<Screen> current_screen;
-  std::auto_ptr<Console> console;
-  std::auto_ptr<ScreenFade> screen_fade;
+  std::unique_ptr<Screen> next_screen;
+  std::unique_ptr<Screen> current_screen;
+  std::unique_ptr<Console> console;
+  std::unique_ptr<ScreenFade> screen_fade;
   std::vector<Screen*> screen_stack;
   bool screenshot_requested; /**< true if a screenshot should be taken after the next frame has been rendered */
 };
index 49c2cd6..0b8ff04 100644 (file)
@@ -37,7 +37,7 @@ TileSet* TileManager::get_tileset(const std::string &filename)
   if(i != tilesets.end())
     return i->second;
 
-  std::auto_ptr<TileSet> tileset (new TileSet(filename));
+  std::unique_ptr<TileSet> tileset (new TileSet(filename));
   tilesets.insert(std::make_pair(filename, tileset.get()));
 
   return tileset.release();
@@ -45,7 +45,7 @@ TileSet* TileManager::get_tileset(const std::string &filename)
 
 TileSet* TileManager::parse_tileset_definition(const Reader& reader)
 {
-  std::auto_ptr<TileSet> result(new TileSet());
+  std::unique_ptr<TileSet> result(new TileSet());
 
   lisp::ListIterator iter(&reader);
   while(iter.next()) {
index f29c573..ca118c9 100644 (file)
@@ -137,7 +137,7 @@ TileSetParser::parse_tile(const Reader& reader)
   if(images)
       imagespecs = parse_tile_images(*images);
 
-  std::auto_ptr<Tile> tile(new Tile(imagespecs, editor_imagespecs, attributes, data, fps));
+  std::unique_ptr<Tile> tile(new Tile(imagespecs, editor_imagespecs, attributes, data, fps));
 
   if (id >= m_tileset.tiles.size())
     m_tileset.tiles.resize(id+1, 0);
@@ -299,7 +299,7 @@ TileSetParser::parse_tiles(const Reader& reader)
           editor_imagespecs.push_back(Tile::ImageSpec(m_tiles_path + *j, Rectf(x, y, x + 32, y + 32)));
         }
 
-        std::auto_ptr<Tile> tile(new Tile(imagespecs, editor_imagespecs,
+        std::unique_ptr<Tile> tile(new Tile(imagespecs, editor_imagespecs,
                                           (has_attributes ? attributes[i] : 0), (has_datas ? datas[i] : 0), fps));
         if (m_tileset.tiles[ids[i]] == 0) {
           m_tileset.tiles[ids[i]] = tile.release();
index 205ef1c..35a18c8 100644 (file)
@@ -56,10 +56,10 @@ private:
   void generate_main_menu();
   
 private:
-  std::auto_ptr<MainMenu> main_menu;
+  std::unique_ptr<MainMenu> main_menu;
   SurfacePtr frame;
-  std::auto_ptr<CodeController> controller;
-  std::auto_ptr<GameSession> titlesession;
+  std::unique_ptr<CodeController> controller;
+  std::unique_ptr<GameSession> titlesession;
   std::string copyright_text;
 
 private:
index 596ec2c..d0dbc59 100644 (file)
@@ -64,7 +64,7 @@ private:
   HSQOBJECT world_thread;
   std::string title;
   std::string description;
-  std::auto_ptr<PlayerStatus> player_status;
+  std::unique_ptr<PlayerStatus> player_status;
 
 public:
   bool hide_from_contribs;
index f167860..90c9e62 100644 (file)
@@ -19,7 +19,7 @@
 
 /** This class behaves like a pointer to a refcounted object, but increments the
  * reference count when new objects are assigned and decrements the refcounter
- * when its lifetime has expired. (similar to std::auto_ptr)
+ * when its lifetime has expired. (similar to std::unique_ptr)
  */
 template<typename T>
 class Ref
index e65cad0..dc2203b 100644 (file)
@@ -870,7 +870,8 @@ WorldMap::draw_status(DrawingContext& context)
           }
         */
 
-        get_level_target_time(*level);
+        if (level->target_time == 0.0f)
+          get_level_target_time(*level);
         level->statistics.draw_worldmap_info(context, level->target_time);
         break;
       }
index af7c104..0925edc 100644 (file)
@@ -85,7 +85,7 @@ private:
 
   static WorldMap* current_;
 
-  std::auto_ptr<Menu> worldmap_menu;
+  std::unique_ptr<Menu> worldmap_menu;
 
   Vector camera_offset;