From: Ingo Ruhnke Date: Sun, 13 Dec 2009 22:11:09 +0000 (+0000) Subject: Use boost::shared_ptr instead of std::auto_ptr X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e70165f7a2caf2f7234c3635b8e7d2c452c3c787;p=supertux.git Use boost::shared_ptr instead of std::auto_ptr SVN-Revision: 6206 --- diff --git a/src/badguy/yeti.hpp b/src/badguy/yeti.hpp index ac2603b53..326b263f6 100644 --- a/src/badguy/yeti.hpp +++ b/src/badguy/yeti.hpp @@ -63,7 +63,7 @@ private: Timer safe_timer; int stomp_count; int hit_points; - std::auto_ptr hud_head; + SurfacePtr hud_head; }; #endif diff --git a/src/gui/menu.hpp b/src/gui/menu.hpp index 13f7e2206..5c97fa1fb 100644 --- a/src/gui/menu.hpp +++ b/src/gui/menu.hpp @@ -22,10 +22,10 @@ #include #include "video/color.hpp" +#include "video/surface_ptr.hpp" class DrawingContext; class MenuItem; -class Surface; bool confirm_dialog(Surface* background, std::string text); @@ -138,11 +138,11 @@ private: int arrange_left; int active_item; - std::auto_ptr checkbox; - std::auto_ptr checkbox_checked; - std::auto_ptr back; - std::auto_ptr arrow_left; - std::auto_ptr arrow_right; + SurfacePtr checkbox; + SurfacePtr checkbox_checked; + SurfacePtr back; + SurfacePtr arrow_left; + SurfacePtr arrow_right; }; #endif diff --git a/src/object/background.hpp b/src/object/background.hpp index 75a1c9306..4c55d7c0b 100644 --- a/src/object/background.hpp +++ b/src/object/background.hpp @@ -65,9 +65,9 @@ private: float speed_y; /**< scroll-speed in vertical direction */ Vector scroll_speed; Vector scroll_offset; - std::auto_ptr image_top; /**< image to draw above pos */ - std::auto_ptr image; /**< image to draw, anchored at pos */ - std::auto_ptr image_bottom; /**< image to draw below pos+screenheight */ + SurfacePtr image_top; /**< image to draw above pos */ + SurfacePtr image; /**< image to draw, anchored at pos */ + SurfacePtr image_bottom; /**< image to draw below pos+screenheight */ }; #endif /*SUPERTUX_BACKGROUND_H*/ diff --git a/src/object/cloud_particle_system.hpp b/src/object/cloud_particle_system.hpp index db7b3d349..225d24636 100644 --- a/src/object/cloud_particle_system.hpp +++ b/src/object/cloud_particle_system.hpp @@ -20,6 +20,7 @@ #include #include "object/particlesystem.hpp" +#include "video/surface_ptr.hpp" class CloudParticleSystem : public ParticleSystem { @@ -45,7 +46,7 @@ private: {} }; - std::auto_ptr cloudimage; + SurfacePtr cloudimage; private: CloudParticleSystem(const CloudParticleSystem&); diff --git a/src/object/comet_particle_system.hpp b/src/object/comet_particle_system.hpp index f627a0533..c38e0b5ed 100644 --- a/src/object/comet_particle_system.hpp +++ b/src/object/comet_particle_system.hpp @@ -20,6 +20,7 @@ #include #include "object/particlesystem_interactive.hpp" +#include "video/surface_ptr.hpp" class CometParticleSystem : public ParticleSystem_Interactive { @@ -46,7 +47,7 @@ private: {} }; - std::auto_ptr cometimages[2]; + SurfacePtr cometimages[2]; private: CometParticleSystem(const CometParticleSystem&); diff --git a/src/object/ghost_particle_system.hpp b/src/object/ghost_particle_system.hpp index f8cf89bd6..b8eebb39a 100644 --- a/src/object/ghost_particle_system.hpp +++ b/src/object/ghost_particle_system.hpp @@ -20,6 +20,7 @@ #include #include "object/particlesystem.hpp" +#include "video/surface_ptr.hpp" class GhostParticleSystem : public ParticleSystem { @@ -45,7 +46,7 @@ private: {} }; - std::auto_ptr ghosts[2]; + SurfacePtr ghosts[2]; private: GhostParticleSystem(const GhostParticleSystem&); diff --git a/src/object/level_time.hpp b/src/object/level_time.hpp index 36b9870ba..3650c9c75 100644 --- a/src/object/level_time.hpp +++ b/src/object/level_time.hpp @@ -23,8 +23,7 @@ #include "supertux/script_interface.hpp" #include "util/reader_fwd.hpp" #include "video/color.hpp" - -class Surface; +#include "video/surface_ptr.hpp" class LevelTime : public GameObject, public ScriptInterface @@ -69,7 +68,7 @@ public: */ private: - std::auto_ptr time_surface; + SurfacePtr time_surface; bool running; float time_left; }; diff --git a/src/object/player.hpp b/src/object/player.hpp index 0db526c48..ebcf86368 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -300,7 +300,7 @@ public: std::auto_ptr sprite; /**< The main sprite representing Tux */ - std::auto_ptr airarrow; /**< arrow indicating Tux' position when he's above the camera */ + SurfacePtr airarrow; /**< arrow indicating Tux' position when he's above the camera */ Vector floor_normal; void try_grab(); diff --git a/src/object/rain_particle_system.hpp b/src/object/rain_particle_system.hpp index e3c257fe3..296740e34 100644 --- a/src/object/rain_particle_system.hpp +++ b/src/object/rain_particle_system.hpp @@ -20,6 +20,7 @@ #include #include "object/particlesystem_interactive.hpp" +#include "video/surface_ptr.hpp" class RainParticleSystem : public ParticleSystem_Interactive { @@ -45,7 +46,7 @@ private: {} }; - std::auto_ptr rainimages[2]; + SurfacePtr rainimages[2]; private: RainParticleSystem(const RainParticleSystem&); diff --git a/src/supertux/console.hpp b/src/supertux/console.hpp index 61c0d9beb..b463b51a1 100644 --- a/src/supertux/console.hpp +++ b/src/supertux/console.hpp @@ -23,11 +23,12 @@ #include #include +#include "video/surface_ptr.hpp" + class Console; class ConsoleStreamBuffer; class ConsoleCommandReceiver; class DrawingContext; -class Surface; class Font; class Console @@ -85,8 +86,8 @@ private: std::list::iterator history_position; /**< item of command history that is currently displayed */ std::list lines; /**< backbuffer of lines sent to the console. New lines get added to front. */ - std::auto_ptr background; /**< console background image */ - std::auto_ptr background2; /**< second, moving console background image */ + SurfacePtr background; /**< console background image */ + SurfacePtr background2; /**< second, moving console background image */ HSQUIRRELVM vm; /**< squirrel thread for the console (with custom roottable) */ HSQOBJECT vm_object; diff --git a/src/supertux/game_session.hpp b/src/supertux/game_session.hpp index 11d3a2e6c..57d613f2c 100644 --- a/src/supertux/game_session.hpp +++ b/src/supertux/game_session.hpp @@ -102,7 +102,7 @@ private: void process_menu(); std::auto_ptr level; - std::auto_ptr statistics_backdrop; + SurfacePtr statistics_backdrop; // scripts typedef std::vector ScriptList; diff --git a/src/supertux/info_box.hpp b/src/supertux/info_box.hpp index 6286a646e..ddc923035 100644 --- a/src/supertux/info_box.hpp +++ b/src/supertux/info_box.hpp @@ -22,9 +22,10 @@ #include #include +#include "video/surface_ptr.hpp" + class DrawingContext; class InfoBoxLine; -class Surface; /** This class is displaying a box with information text inside the game */ class InfoBox @@ -43,8 +44,8 @@ private: size_t firstline; std::vector lines; std::map images; - std::auto_ptr arrow_scrollup; - std::auto_ptr arrow_scrolldown; + SurfacePtr arrow_scrollup; + SurfacePtr arrow_scrolldown; private: InfoBox(const InfoBox&); diff --git a/src/supertux/info_box_line.cpp b/src/supertux/info_box_line.cpp index 16a69d6f7..119733f0a 100644 --- a/src/supertux/info_box_line.cpp +++ b/src/supertux/info_box_line.cpp @@ -106,7 +106,7 @@ InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) : font(Resources::normal_font), color(), text(text), - image(0) + image() { font = get_font_by_format_char(format_char); lineType = get_linetype_by_format_char(format_char); diff --git a/src/supertux/info_box_line.hpp b/src/supertux/info_box_line.hpp index d2b382173..7d5e9fe01 100644 --- a/src/supertux/info_box_line.hpp +++ b/src/supertux/info_box_line.hpp @@ -22,11 +22,11 @@ #include #include "video/color.hpp" +#include "video/surface_ptr.hpp" class DrawingContext; class Font; class Rectf; -class Surface; /** * Helper class for InfoBox: Represents a line of text @@ -49,7 +49,7 @@ private: Font* font; Color color; std::string text; - std::auto_ptr image; + SurfacePtr image; private: InfoBoxLine(const InfoBoxLine&); diff --git a/src/supertux/player_status.hpp b/src/supertux/player_status.hpp index 3f46b5381..aebee1792 100644 --- a/src/supertux/player_status.hpp +++ b/src/supertux/player_status.hpp @@ -23,8 +23,7 @@ #include "util/reader_fwd.hpp" #include "util/writer_fwd.hpp" #include "video/color.hpp" - -class Surface; +#include "video/surface_ptr.hpp" static const float BORDER_X = 10; static const float BORDER_Y = 10; @@ -59,7 +58,7 @@ public: int max_ice_bullets; /**< maximum number of ice bullets in play */ private: - std::auto_ptr coin_surface; + SurfacePtr coin_surface; private: PlayerStatus(const PlayerStatus&); diff --git a/src/supertux/textscroller.hpp b/src/supertux/textscroller.hpp index da4bc6530..e77f68803 100644 --- a/src/supertux/textscroller.hpp +++ b/src/supertux/textscroller.hpp @@ -22,9 +22,9 @@ #include "supertux/screen.hpp" #include "video/color.hpp" +#include "video/surface_ptr.hpp" class DrawingContext; -class Surface; class Font; class InfoBoxLine; @@ -50,7 +50,7 @@ private: float defaultspeed; float speed; std::string music; - std::auto_ptr background; + SurfacePtr background; std::vector lines; float scroll; bool fading; diff --git a/src/supertux/title_screen.hpp b/src/supertux/title_screen.hpp index 33964fa14..19c66adec 100644 --- a/src/supertux/title_screen.hpp +++ b/src/supertux/title_screen.hpp @@ -56,7 +56,7 @@ private: private: std::auto_ptr main_menu; - std::auto_ptr frame; + SurfacePtr frame; std::auto_ptr controller; std::auto_ptr titlesession; diff --git a/src/video/surface.cpp b/src/video/surface.cpp index 4d8582baf..6df0cf1c3 100644 --- a/src/video/surface.cpp +++ b/src/video/surface.cpp @@ -23,16 +23,16 @@ #include "video/texture.hpp" #include "video/video_systems.hpp" -std::auto_ptr +SurfacePtr Surface::create(const std::string& file) { - return std::auto_ptr(new Surface(file)); + return SurfacePtr(new Surface(file)); } -std::auto_ptr +SurfacePtr Surface::create(const std::string& file, const Rect& rect) { - return std::auto_ptr(new Surface(file, rect)); + return SurfacePtr(new Surface(file, rect)); } Surface::Surface(const std::string& file) : diff --git a/src/video/surface.hpp b/src/video/surface.hpp index e5d5c9725..ad1d9fef6 100644 --- a/src/video/surface.hpp +++ b/src/video/surface.hpp @@ -22,20 +22,19 @@ #include "math/vector.hpp" #include "math/rect.hpp" +#include "video/surface_ptr.hpp" class Texture; class SurfaceData; -/** - * A rectangular image. - * The class basically holds a reference to a texture with additional UV - * coordinates that specify a rectangular area on this texture - */ +/** A rectangular image. The class basically holds a reference to a + texture with additional UV coordinates that specify a rectangular + area on this texture */ class Surface { public: - static std::auto_ptr create(const std::string& file); - static std::auto_ptr create(const std::string& file, const Rect& rect); + static SurfacePtr create(const std::string& file); + static SurfacePtr create(const std::string& file, const Rect& rect); private: Texture* texture; @@ -62,9 +61,8 @@ public: int get_width() const; int get_height() const; Vector get_position() const; - /** - * returns a vector containing width and height - */ + + /** returns a vector containing width and height */ Vector get_size() const; };