From: Ingo Ruhnke Date: Sun, 3 Aug 2014 17:05:09 +0000 (+0200) Subject: Replaced std::auto_ptr<> with std::unique_ptr<> X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=af57bbb32aa9c5fa815c122dca81b79a281b5651;p=supertux.git Replaced std::auto_ptr<> with std::unique_ptr<> --- diff --git a/src/addon/addon_manager.cpp b/src/addon/addon_manager.cpp index fe2de8397..e2c3c5538 100644 --- a/src/addon/addon_manager.cpp +++ b/src/addon/addon_manager.cpp @@ -143,7 +143,7 @@ AddonManager::check_online() log_warning << "Unknown token '" << token << "' in Add-on list" << std::endl; continue; } - std::auto_ptr addon(new Addon()); + std::unique_ptr addon(new Addon()); addon->parse(*(iter.lisp())); addon->installed = false; addon->loaded = false; diff --git a/src/audio/sound_manager.cpp b/src/audio/sound_manager.cpp index 89f86b21d..9f2b36f62 100644 --- a/src/audio/sound_manager.cpp +++ b/src/audio/sound_manager.cpp @@ -118,7 +118,7 @@ SoundManager::intern_create_sound_source(const std::string& filename) { assert(sound_enabled); - std::auto_ptr source (new OpenALSoundSource()); + std::unique_ptr 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 file (load_sound_file(filename)); + std::unique_ptr 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 file (load_sound_file(filename)); + std::unique_ptr 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 source + std::unique_ptr 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 newmusic (new StreamSoundSource()); + std::unique_ptr newmusic (new StreamSoundSource()); newmusic->set_sound_file(load_sound_file(filename)); newmusic->set_looping(true); newmusic->set_relative(true); diff --git a/src/badguy/bomb.hpp b/src/badguy/bomb.hpp index e2f4e7628..a45dd2298 100644 --- a/src/badguy/bomb.hpp +++ b/src/badguy/bomb.hpp @@ -45,7 +45,7 @@ private: bool grabbed; MovingObject* grabber; - std::auto_ptr ticking; + std::unique_ptr ticking; private: Bomb(const Bomb&); diff --git a/src/badguy/dart.hpp b/src/badguy/dart.hpp index a76c6675d..8ba5f2ac7 100644 --- a/src/badguy/dart.hpp +++ b/src/badguy/dart.hpp @@ -45,7 +45,7 @@ public: protected: const BadGuy* parent; /**< collisions with this BadGuy will be ignored */ - std::auto_ptr sound_source; /**< SoundSource for ambient sound */ + std::unique_ptr sound_source; /**< SoundSource for ambient sound */ private: Dart(const Dart&); diff --git a/src/badguy/flame.hpp b/src/badguy/flame.hpp index 651367489..c3e63e82c 100644 --- a/src/badguy/flame.hpp +++ b/src/badguy/flame.hpp @@ -44,7 +44,7 @@ private: Color light; SpritePtr lightsprite; - std::auto_ptr sound_source; + std::unique_ptr sound_source; }; #endif diff --git a/src/badguy/goldbomb.hpp b/src/badguy/goldbomb.hpp index d82d28e5a..7d4f7fab1 100644 --- a/src/badguy/goldbomb.hpp +++ b/src/badguy/goldbomb.hpp @@ -59,7 +59,7 @@ private: bool grabbed; MovingObject* grabber; - std::auto_ptr ticking; + std::unique_ptr ticking; }; #endif diff --git a/src/badguy/haywire.hpp b/src/badguy/haywire.hpp index 83d04012c..5e4817d15 100644 --- a/src/badguy/haywire.hpp +++ b/src/badguy/haywire.hpp @@ -44,8 +44,8 @@ private: bool is_stunned; float time_stunned; - std::auto_ptr ticking; - std::auto_ptr grunting; + std::unique_ptr ticking; + std::unique_ptr grunting; }; #endif /* HEADER_SUPERTUX_BADGUY_HAYWIRE_HPP */ diff --git a/src/badguy/treewillowisp.hpp b/src/badguy/treewillowisp.hpp index 05b287608..8b78856b8 100644 --- a/src/badguy/treewillowisp.hpp +++ b/src/badguy/treewillowisp.hpp @@ -66,7 +66,7 @@ private: float radius; float speed; - std::auto_ptr sound_source; + std::unique_ptr sound_source; GhostTree* tree; Vector suck_target; diff --git a/src/badguy/willowisp.hpp b/src/badguy/willowisp.hpp index 42ad8fc70..22e2c62d7 100644 --- a/src/badguy/willowisp.hpp +++ b/src/badguy/willowisp.hpp @@ -73,10 +73,10 @@ private: std::string target_spawnpoint; std::string hit_script; - std::auto_ptr sound_source; + std::unique_ptr sound_source; - std::auto_ptr path; - std::auto_ptr walker; + std::unique_ptr path; + std::unique_ptr walker; float flyspeed; float track_range; diff --git a/src/object/camera.hpp b/src/object/camera.hpp index 7158528af..3c53f8440 100644 --- a/src/object/camera.hpp +++ b/src/object/camera.hpp @@ -110,8 +110,8 @@ private: Vector cached_translation; // autoscroll mode - std::auto_ptr autoscroll_path; - std::auto_ptr autoscroll_walker; + std::unique_ptr autoscroll_path; + std::unique_ptr autoscroll_walker; // shaking Timer shaketimer; diff --git a/src/object/platform.hpp b/src/object/platform.hpp index 6c4d8277a..f9ba370b5 100644 --- a/src/object/platform.hpp +++ b/src/object/platform.hpp @@ -65,8 +65,8 @@ public: } private: - std::auto_ptr path; - std::auto_ptr walker; + std::unique_ptr path; + std::unique_ptr walker; Vector speed; diff --git a/src/object/player.hpp b/src/object/player.hpp index bcbbcbc79..e2a514b2e 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -262,7 +262,7 @@ private: bool deactivated; Controller* controller; - std::auto_ptr scripting_controller; /**< This controller is used when the Player is controlled via scripting */ + std::unique_ptr scripting_controller; /**< This controller is used when the Player is controlled via scripting */ PlayerStatus* player_status; bool duck; bool dead; diff --git a/src/physfs/physfs_file_system.cpp b/src/physfs/physfs_file_system.cpp index 1575da0d4..6f11497cf 100644 --- a/src/physfs/physfs_file_system.cpp +++ b/src/physfs/physfs_file_system.cpp @@ -37,10 +37,10 @@ PhysFSFileSystem::open_directory(const std::string& pathname) return files; } -std::auto_ptr +std::unique_ptr PhysFSFileSystem::open_file(const std::string& filename) { - return std::auto_ptr(new IFileStream(filename)); + return std::unique_ptr(new IFileStream(filename)); } /* EOF */ diff --git a/src/physfs/physfs_file_system.hpp b/src/physfs/physfs_file_system.hpp index dea9ad276..767718951 100644 --- a/src/physfs/physfs_file_system.hpp +++ b/src/physfs/physfs_file_system.hpp @@ -25,7 +25,7 @@ public: PhysFSFileSystem(); std::vector open_directory(const std::string& pathname); - std::auto_ptr open_file(const std::string& filename); + std::unique_ptr open_file(const std::string& filename); }; #endif diff --git a/src/sprite/sprite_manager.cpp b/src/sprite/sprite_manager.cpp index 72d282ce7..6c6628efb 100644 --- a/src/sprite/sprite_manager.cpp +++ b/src/sprite/sprite_manager.cpp @@ -90,7 +90,7 @@ SpriteManager::load(const std::string& filename) throw std::runtime_error(msg.str()); } - std::auto_ptr data ( + std::unique_ptr data ( new SpriteData(*sprite, FileSystem::dirname(filename)) ); sprites[filename] = data.release(); diff --git a/src/supertux/game_session.hpp b/src/supertux/game_session.hpp index 33cdd2d5e..cdad31935 100644 --- a/src/supertux/game_session.hpp +++ b/src/supertux/game_session.hpp @@ -106,7 +106,7 @@ private: void on_escape_press(); void process_menu(); - std::auto_ptr level; + std::unique_ptr level; SurfacePtr statistics_backdrop; // scripts @@ -141,7 +141,7 @@ private: std::istream* playback_demo_stream; CodeController* demo_controller; - std::auto_ptr game_menu; + std::unique_ptr game_menu; float play_time; /**< total time in seconds that this session ran interactively */ diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index 3cd091234..e39e24bc6 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -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(new PhysFSFileSystem)); + dictionary_manager->set_filesystem(std::unique_ptr(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(VideoSystem::new_renderer()); - std::auto_ptr lightmap(VideoSystem::new_lightmap()); + std::unique_ptr renderer(VideoSystem::new_renderer()); + std::unique_ptr 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 default_playerstatus(new PlayerStatus()); + const std::unique_ptr 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 session ( + std::unique_ptr 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); diff --git a/src/supertux/menu/contrib_menu.cpp b/src/supertux/menu/contrib_menu.cpp index 34895b73d..9219bfa34 100644 --- a/src/supertux/menu/contrib_menu.cpp +++ b/src/supertux/menu/contrib_menu.cpp @@ -46,7 +46,7 @@ ContribMenu::ContribMenu() : { try { - std::auto_ptr world (new World()); + std::unique_ptr world (new World()); world->load(*it + "/info"); if (!world->hide_from_contribs) { diff --git a/src/supertux/menu/contrib_menu.hpp b/src/supertux/menu/contrib_menu.hpp index 25e9fd308..649b7847a 100644 --- a/src/supertux/menu/contrib_menu.hpp +++ b/src/supertux/menu/contrib_menu.hpp @@ -25,7 +25,7 @@ class World; class ContribMenu : public Menu { private: - std::auto_ptr m_contrib_world_menu; + std::unique_ptr m_contrib_world_menu; std::vector m_contrib_worlds; public: diff --git a/src/supertux/menu/main_menu.hpp b/src/supertux/menu/main_menu.hpp index 0f900a4a5..734cb2de4 100644 --- a/src/supertux/menu/main_menu.hpp +++ b/src/supertux/menu/main_menu.hpp @@ -36,9 +36,9 @@ enum MainMenuIDs { class MainMenu : public Menu { private: - std::auto_ptr m_addon_menu; - std::auto_ptr m_contrib_menu; - std::auto_ptr m_main_world; + std::unique_ptr m_addon_menu; + std::unique_ptr m_contrib_menu; + std::unique_ptr m_main_world; public: MainMenu(); diff --git a/src/supertux/menu/options_menu.hpp b/src/supertux/menu/options_menu.hpp index 473f3dd6d..8ac34d309 100644 --- a/src/supertux/menu/options_menu.hpp +++ b/src/supertux/menu/options_menu.hpp @@ -33,7 +33,7 @@ public: void check_menu(); protected: - std::auto_ptr language_menu; + std::unique_ptr language_menu; }; #endif diff --git a/src/supertux/screen_manager.hpp b/src/supertux/screen_manager.hpp index d885443a6..4e0fb50ff 100644 --- a/src/supertux/screen_manager.hpp +++ b/src/supertux/screen_manager.hpp @@ -69,10 +69,10 @@ private: bool nextpush; /// measured fps float fps; - std::auto_ptr next_screen; - std::auto_ptr current_screen; - std::auto_ptr console; - std::auto_ptr screen_fade; + std::unique_ptr next_screen; + std::unique_ptr current_screen; + std::unique_ptr console; + std::unique_ptr screen_fade; std::vector screen_stack; bool screenshot_requested; /**< true if a screenshot should be taken after the next frame has been rendered */ }; diff --git a/src/supertux/tile_manager.cpp b/src/supertux/tile_manager.cpp index 49c2cd6c7..0b8ff046a 100644 --- a/src/supertux/tile_manager.cpp +++ b/src/supertux/tile_manager.cpp @@ -37,7 +37,7 @@ TileSet* TileManager::get_tileset(const std::string &filename) if(i != tilesets.end()) return i->second; - std::auto_ptr tileset (new TileSet(filename)); + std::unique_ptr 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 result(new TileSet()); + std::unique_ptr result(new TileSet()); lisp::ListIterator iter(&reader); while(iter.next()) { diff --git a/src/supertux/tile_set_parser.cpp b/src/supertux/tile_set_parser.cpp index f29c57397..ca118c9b3 100644 --- a/src/supertux/tile_set_parser.cpp +++ b/src/supertux/tile_set_parser.cpp @@ -137,7 +137,7 @@ TileSetParser::parse_tile(const Reader& reader) if(images) imagespecs = parse_tile_images(*images); - std::auto_ptr tile(new Tile(imagespecs, editor_imagespecs, attributes, data, fps)); + std::unique_ptr 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(new Tile(imagespecs, editor_imagespecs, + std::unique_ptr 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(); diff --git a/src/supertux/title_screen.hpp b/src/supertux/title_screen.hpp index 205ef1ccb..35a18c83f 100644 --- a/src/supertux/title_screen.hpp +++ b/src/supertux/title_screen.hpp @@ -56,10 +56,10 @@ private: void generate_main_menu(); private: - std::auto_ptr main_menu; + std::unique_ptr main_menu; SurfacePtr frame; - std::auto_ptr controller; - std::auto_ptr titlesession; + std::unique_ptr controller; + std::unique_ptr titlesession; std::string copyright_text; private: diff --git a/src/supertux/world.hpp b/src/supertux/world.hpp index 596ec2c70..d0dbc59e2 100644 --- a/src/supertux/world.hpp +++ b/src/supertux/world.hpp @@ -64,7 +64,7 @@ private: HSQOBJECT world_thread; std::string title; std::string description; - std::auto_ptr player_status; + std::unique_ptr player_status; public: bool hide_from_contribs; diff --git a/src/util/ref.hpp b/src/util/ref.hpp index f16786074..90c9e622b 100644 --- a/src/util/ref.hpp +++ b/src/util/ref.hpp @@ -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 class Ref diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index e65cad050..dc2203b06 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -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; } diff --git a/src/worldmap/worldmap.hpp b/src/worldmap/worldmap.hpp index af7c104a1..0925edc0f 100644 --- a/src/worldmap/worldmap.hpp +++ b/src/worldmap/worldmap.hpp @@ -85,7 +85,7 @@ private: static WorldMap* current_; - std::auto_ptr worldmap_menu; + std::unique_ptr worldmap_menu; Vector camera_offset;