From 06d20970bd5005edca5c6eb056080937f2e215df Mon Sep 17 00:00:00 2001 From: grumbel Date: Tue, 17 Nov 2009 21:32:46 +0000 Subject: [PATCH] More -Weffc++ cleanup, almost done git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6014 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/math/aatriangle.hpp | 2 +- src/object/particlesystem.cpp | 9 +++- src/object/particlesystem.hpp | 19 +++++-- src/object/particlesystem_interactive.cpp | 6 ++- src/object/particlesystem_interactive.hpp | 17 ++++-- src/object/player.cpp | 39 ++++++++++++++ src/object/player.hpp | 86 ++++++++++++++++--------------- src/object/pneumatic_platform.cpp | 6 ++- src/object/tilemap.cpp | 12 ++++- src/supertux/console.cpp | 7 +++ src/supertux/game_object.cpp | 6 ++- src/supertux/game_session.cpp | 12 +++++ src/supertux/levelintro.cpp | 4 +- src/supertux/mainloop.cpp | 7 +++ src/supertux/mainloop.hpp | 1 + src/supertux/moving_object.cpp | 7 ++- src/supertux/options_menu.cpp | 3 +- src/supertux/player_status.cpp | 18 +++---- src/supertux/player_status.hpp | 10 ++-- src/supertux/sector.cpp | 12 +++++ src/supertux/sector.hpp | 4 +- src/supertux/textscroller.cpp | 9 +++- src/supertux/tile_set.cpp | 8 +-- 23 files changed, 218 insertions(+), 86 deletions(-) diff --git a/src/math/aatriangle.hpp b/src/math/aatriangle.hpp index fa989a54c..c9defc8db 100644 --- a/src/math/aatriangle.hpp +++ b/src/math/aatriangle.hpp @@ -23,7 +23,7 @@ * An axis-aligned triangle (ie. a triangle where 2 sides are parallel to the x- * and y-axis. */ -class AATriangle : public Rect +class AATriangle : public Rect // FIXME: yuck { public: /** Directions: diff --git a/src/object/particlesystem.cpp b/src/object/particlesystem.cpp index bb79f54de..c6ad03cb7 100644 --- a/src/object/particlesystem.cpp +++ b/src/object/particlesystem.cpp @@ -23,7 +23,11 @@ #include "video/drawing_context.hpp" ParticleSystem::ParticleSystem(float max_particle_size) : - max_particle_size(max_particle_size) + max_particle_size(max_particle_size), + z_pos(), + particles(), + virtual_width(), + virtual_height() { virtual_width = SCREEN_WIDTH + max_particle_size * 2; virtual_height = SCREEN_HEIGHT + max_particle_size *2; @@ -176,7 +180,8 @@ void GhostParticleSystem::update(float elapsed_time) } CloudParticleSystem::CloudParticleSystem() : - ParticleSystem(128) + ParticleSystem(128), + cloudimage() { cloudimage = new Surface("images/objects/particles/cloud.png"); diff --git a/src/object/particlesystem.hpp b/src/object/particlesystem.hpp index 59c92b230..735552c21 100644 --- a/src/object/particlesystem.hpp +++ b/src/object/particlesystem.hpp @@ -51,9 +51,6 @@ public: virtual void draw(DrawingContext& context); protected: - float max_particle_size; - int z_pos; - class Particle { public: @@ -69,8 +66,11 @@ protected: Surface* texture; }; + float max_particle_size; + int z_pos; std::vector particles; - float virtual_width, virtual_height; + float virtual_width; + float virtual_height; }; class SnowParticleSystem : public ParticleSystem @@ -94,6 +94,13 @@ private: float wobble; float anchorx; float drift_speed; + + SnowParticle() : + speed(), + wobble(), + anchorx(), + drift_speed() + {} }; Surface* snowimages[3]; @@ -152,6 +159,10 @@ private: { public: float speed; + + CloudParticle() : + speed() + {} }; Surface* cloudimage; diff --git a/src/object/particlesystem_interactive.cpp b/src/object/particlesystem_interactive.cpp index 40a714782..5347f1355 100644 --- a/src/object/particlesystem_interactive.cpp +++ b/src/object/particlesystem_interactive.cpp @@ -28,7 +28,11 @@ //TODO: Find a way to make rain collide with objects like bonus blocks // Add an option to set rain strength // Fix rain being "respawned" over solid tiles -ParticleSystem_Interactive::ParticleSystem_Interactive() +ParticleSystem_Interactive::ParticleSystem_Interactive() : + z_pos(), + particles(), + virtual_width(), + virtual_height() { virtual_width = SCREEN_WIDTH; virtual_height = SCREEN_HEIGHT; diff --git a/src/object/particlesystem_interactive.hpp b/src/object/particlesystem_interactive.hpp index 0b5ade0cd..991fff74d 100644 --- a/src/object/particlesystem_interactive.hpp +++ b/src/object/particlesystem_interactive.hpp @@ -44,8 +44,6 @@ public: virtual void draw(DrawingContext& context); protected: - int z_pos; - class Particle { public: @@ -61,9 +59,12 @@ protected: Surface* texture; }; - std::vector particles; - float virtual_width, virtual_height; int collision(Particle* particle, Vector movement); + + int z_pos; + std::vector particles; + float virtual_width; + float virtual_height; }; class RainParticleSystem : public ParticleSystem_Interactive @@ -84,6 +85,10 @@ private: { public: float speed; + + RainParticle() : + speed() + {} }; Surface* rainimages[2]; @@ -112,6 +117,10 @@ private: { public: float speed; + + CometParticle() : + speed() + {} }; Surface* cometimages[2]; diff --git a/src/object/player.cpp b/src/object/player.cpp index 4db9d11a6..b056ecf32 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -103,12 +103,51 @@ bool no_water = true; } Player::Player(PlayerStatus* _player_status, const std::string& name) : + deactivated(), + controller(), scripting_controller(0), player_status(_player_status), + duck(), + dead(), + dying(), + backflipping(), + backflip_direction(), + peekingX(), + peekingY(), + swimming(), + speedlimit(), scripting_controller_old(0), + jump_early_apex(), + on_ice(), + ice_this_frame(), + dir(), + old_dir(), + last_ground_y(), + fall_mode(), + on_ground_flag(), + jumping(), + can_jump(), + jump_button_timer(), + wants_buttjump(), + does_buttjump(), + invincible_timer(), + skidding_timer(), + safe_timer(), + kick_timer(), + shooting_timer(), + dying_timer(), + growing(), + backflip_timer(), + physic(), + visible(), grabbed_object(NULL), + sprite(), + airarrow(), + floor_normal(), ghost_mode(false), edit_mode(false), + unduck_hurt_timer(), + idle_timer(), idle_stage(0), climbing(0) { diff --git a/src/object/player.hpp b/src/object/player.hpp index 7430fc9da..85771058f 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -50,51 +50,10 @@ class Player : public MovingObject, { public: enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING }; - - Controller* controller; - std::auto_ptr scripting_controller; /**< This controller is used when the Player is controlled via scripting */ - PlayerStatus* player_status; - bool duck; - bool dead; //Tux can only go this fast. If set to 0 no special limit is used, only the default limits. void set_speedlimit(float newlimit); float get_speedlimit(); -private: - bool dying; - bool backflipping; - int backflip_direction; - Direction peekingX, peekingY; - bool swimming; - float speedlimit; - Controller* scripting_controller_old; /**< Saves the old controller while the scripting_controller is used */ - bool jump_early_apex; - bool on_ice; - bool ice_this_frame; - -public: - Direction dir; - Direction old_dir; - - float last_ground_y; - FallMode fall_mode; - - bool on_ground_flag; - bool jumping; - bool can_jump; - Timer jump_button_timer; /**< started when player presses the jump button; runs until Tux jumps or JUMP_GRACE_TIME runs out */ - bool wants_buttjump; - bool does_buttjump; - - Timer invincible_timer; - Timer skidding_timer; - Timer safe_timer; - Timer kick_timer; - Timer shooting_timer; // used to show the arm when Tux is shooting - Timer dying_timer; - bool growing; - Timer backflip_timer; - public: Player(PlayerStatus* player_status, const std::string& name); virtual ~Player(); @@ -270,7 +229,6 @@ private: void handle_input(); void handle_input_ghost(); /**< input handling while in ghost mode */ void handle_input_climbing(); /**< input handling while climbing */ - bool deactivated; void init(); @@ -290,6 +248,50 @@ private: void apply_friction(); private: + bool deactivated; + + Controller* controller; + std::auto_ptr scripting_controller; /**< This controller is used when the Player is controlled via scripting */ + PlayerStatus* player_status; + bool duck; + bool dead; + +private: + bool dying; + bool backflipping; + int backflip_direction; + Direction peekingX; + Direction peekingY; + bool swimming; + float speedlimit; + Controller* scripting_controller_old; /**< Saves the old controller while the scripting_controller is used */ + bool jump_early_apex; + bool on_ice; + bool ice_this_frame; + +public: + Direction dir; + Direction old_dir; + + float last_ground_y; + FallMode fall_mode; + + bool on_ground_flag; + bool jumping; + bool can_jump; + Timer jump_button_timer; /**< started when player presses the jump button; runs until Tux jumps or JUMP_GRACE_TIME runs out */ + bool wants_buttjump; + bool does_buttjump; + + Timer invincible_timer; + Timer skidding_timer; + Timer safe_timer; + Timer kick_timer; + Timer shooting_timer; // used to show the arm when Tux is shooting + Timer dying_timer; + bool growing; + Timer backflip_timer; + Physic physic; bool visible; diff --git a/src/object/pneumatic_platform.cpp b/src/object/pneumatic_platform.cpp index c0700c941..839ddda7d 100644 --- a/src/object/pneumatic_platform.cpp +++ b/src/object/pneumatic_platform.cpp @@ -27,7 +27,8 @@ PneumaticPlatform::PneumaticPlatform(const Reader& reader) : slave(0), start_y(0), offset_y(0), - speed_y(0) + speed_y(0), + contacts() { start_y = get_pos().y; } @@ -38,7 +39,8 @@ PneumaticPlatform::PneumaticPlatform(PneumaticPlatform* master) : slave(this), start_y(master->start_y), offset_y(-master->offset_y), - speed_y(0) + speed_y(0), + contacts() { set_pos(get_pos() + Vector(master->get_bbox().get_width(), 0)); master->master = master; diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index 4581b4a24..535a807ba 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -27,6 +27,7 @@ TileMap::TileMap(const TileSet *new_tileset) : tileset(new_tileset), + tiles(), solid(false), speed_x(1), speed_y(1), @@ -35,16 +36,20 @@ TileMap::TileMap(const TileSet *new_tileset) : z_pos(0), x_offset(0), y_offset(0), - movement(Vector(0,0)), + movement(0,0), drawing_effect(NO_EFFECT), alpha(1.0), current_alpha(1.0), remaining_fade_time(0), + path(), + walker(), draw_target(DrawingContext::NORMAL) { } TileMap::TileMap(const Reader& reader) : + tileset(), + tiles(), solid(false), speed_x(1), speed_y(1), @@ -58,6 +63,8 @@ TileMap::TileMap(const Reader& reader) : alpha(1.0), current_alpha(1.0), remaining_fade_time(0), + path(), + walker(), draw_target(DrawingContext::NORMAL) { tileset = current_tileset; @@ -124,6 +131,7 @@ TileMap::TileMap(const Reader& reader) : TileMap::TileMap(const TileSet *new_tileset, std::string name, int z_pos, bool solid, size_t width, size_t height) : tileset(new_tileset), + tiles(), solid(solid), speed_x(1), speed_y(1), @@ -137,6 +145,8 @@ TileMap::TileMap(const TileSet *new_tileset, std::string name, int z_pos, alpha(1.0), current_alpha(1.0), remaining_fade_time(0), + path(), + walker(), draw_target(DrawingContext::NORMAL) { this->name = name; diff --git a/src/supertux/console.cpp b/src/supertux/console.cpp index 8d1e293a8..83a78e64c 100644 --- a/src/supertux/console.cpp +++ b/src/supertux/console.cpp @@ -28,13 +28,20 @@ static const float FADE_SPEED = 1; Console::Console() : + history(), history_position(history.end()), + lines(), + background(), + background2(), vm(NULL), + vm_object(), backgroundOffset(0), height(0), alpha(1.0), offset(0), focused(false), + font(), + fontheight(), stayOpen(0) { fontheight = 8; diff --git a/src/supertux/game_object.cpp b/src/supertux/game_object.cpp index bc203e528..bb76c99c5 100644 --- a/src/supertux/game_object.cpp +++ b/src/supertux/game_object.cpp @@ -19,13 +19,15 @@ GameObject::GameObject() : wants_to_die(false), - remove_listeners(NULL) + remove_listeners(NULL), + name() { } GameObject::GameObject(const GameObject& rhs) : wants_to_die(rhs.wants_to_die), - remove_listeners(NULL) + remove_listeners(NULL), + name(rhs.name) { } diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index a14c900de..40242e1ea 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -47,13 +47,25 @@ enum GameMenuIDs { GameSession::GameSession(const std::string& levelfile_, Statistics* statistics) : level(0), + statistics_backdrop(), + scripts(), currentsector(0), + levelnb(), + pause_menu_frame(), end_sequence(0), + game_pause(), + speed_before_pause(), levelfile(levelfile_), + reset_sector(), + reset_pos(), + newsector(), + newspawnpoint(), best_level_statistics(statistics), capture_demo_stream(0), + capture_file(), playback_demo_stream(0), demo_controller(0), + game_menu(), play_time(0), edit_mode(false), levelintro_shown(false) diff --git a/src/supertux/levelintro.cpp b/src/supertux/levelintro.cpp index f9a678e53..cc5dec4aa 100644 --- a/src/supertux/levelintro.cpp +++ b/src/supertux/levelintro.cpp @@ -28,8 +28,10 @@ LevelIntro::LevelIntro(const Level* level, const Statistics* best_level_statistics) : level(level), best_level_statistics(best_level_statistics), + player_sprite(), player_sprite_py(0), - player_sprite_vy(0) + player_sprite_vy(0), + player_sprite_jump_timer() { player_sprite = sprite_manager->create("images/creatures/tux/tux.sprite"); player_sprite->set_action("small-walk-right"); diff --git a/src/supertux/mainloop.cpp b/src/supertux/mainloop.cpp index 75b5a6033..d6dd0a306 100644 --- a/src/supertux/mainloop.cpp +++ b/src/supertux/mainloop.cpp @@ -43,10 +43,17 @@ float g_game_speed = 1.0f; MainLoop* g_main_loop = NULL; MainLoop::MainLoop() : + waiting_threads(), + running(), speed(1.0), nextpop(false), nextpush(false), fps(0), + next_screen(), + current_screen(), + console(), + screen_fade(), + screen_stack(), screenshot_requested(false) { using namespace Scripting; diff --git a/src/supertux/mainloop.hpp b/src/supertux/mainloop.hpp index cc0abf362..7f7b78fe4 100644 --- a/src/supertux/mainloop.hpp +++ b/src/supertux/mainloop.hpp @@ -61,6 +61,7 @@ private: void process_events(); void handle_screen_switch(); +private: bool running; float speed; bool nextpop; diff --git a/src/supertux/moving_object.cpp b/src/supertux/moving_object.cpp index 37ddbfe32..3ab6a775d 100644 --- a/src/supertux/moving_object.cpp +++ b/src/supertux/moving_object.cpp @@ -16,9 +16,12 @@ #include "supertux/moving_object.hpp" -MovingObject::MovingObject() +MovingObject::MovingObject() : + bbox(), + movement(), + group(COLGROUP_MOVING), + dest() { - group = COLGROUP_MOVING; } MovingObject::~MovingObject() diff --git a/src/supertux/options_menu.cpp b/src/supertux/options_menu.cpp index 5acb25c09..355102baa 100644 --- a/src/supertux/options_menu.cpp +++ b/src/supertux/options_menu.cpp @@ -101,7 +101,8 @@ protected: }; -OptionsMenu::OptionsMenu() +OptionsMenu::OptionsMenu() : + language_menu() { language_menu.reset(new LanguageMenu()); diff --git a/src/supertux/player_status.cpp b/src/supertux/player_status.cpp index 28a68729b..c19467993 100644 --- a/src/supertux/player_status.cpp +++ b/src/supertux/player_status.cpp @@ -31,11 +31,12 @@ static const int MAX_COINS = 9999; PlayerStatus* player_status = 0; -PlayerStatus::PlayerStatus() - : coins(START_COINS), - bonus(NO_BONUS), - max_fire_bullets(0), - max_ice_bullets(0) +PlayerStatus::PlayerStatus() : + coins(START_COINS), + bonus(NO_BONUS), + max_fire_bullets(0), + max_ice_bullets(0), + coin_surface() { reset(); @@ -153,11 +154,4 @@ PlayerStatus::draw(DrawingContext& context) context.pop_transform(); } -void -PlayerStatus::operator= (const PlayerStatus& other) -{ - coins = other.coins; - bonus = other.bonus; -} - /* EOF */ diff --git a/src/supertux/player_status.hpp b/src/supertux/player_status.hpp index f8ba72397..631534c41 100644 --- a/src/supertux/player_status.hpp +++ b/src/supertux/player_status.hpp @@ -52,18 +52,18 @@ public: void draw(DrawingContext& context); +public: int coins; BonusType bonus; int max_fire_bullets; /**< maximum number of fire bullets in play */ int max_ice_bullets; /**< maximum number of ice bullets in play */ - void operator= (const PlayerStatus& other); - private: - // don't use this - PlayerStatus(const PlayerStatus& other); - std::auto_ptr coin_surface; + +private: + PlayerStatus(const PlayerStatus&); + PlayerStatus& operator=(const PlayerStatus&); }; // global player state diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index 52d345fd2..0c9a2ae6e 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -57,10 +57,22 @@ bool Sector::draw_solids_only = false; Sector::Sector(Level* parent) : level(parent), + name(), + bullets(), + init_script(), + gameobjects_new(), currentmusic(LEVEL_MUSIC), + sector_table(), + scripts(), ambient_light( 1.0f, 1.0f, 1.0f, 1.0f ), + gameobjects(), + moving_objects(), + spawnpoints(), + portables(), + music(), gravity(10.0), player(0), + solid_tilemaps(), camera(0), effect(0) { diff --git a/src/supertux/sector.hpp b/src/supertux/sector.hpp index ae598d408..0b19f0e70 100644 --- a/src/supertux/sector.hpp +++ b/src/supertux/sector.hpp @@ -195,7 +195,6 @@ public: float get_gravity() const; private: - Level* level; /**< Parent level containing this sector */ uint32_t collision_tile_attributes(const Rect& dest) const; void before_object_remove(GameObject* object); @@ -235,8 +234,11 @@ private: void fix_old_tiles(); +private: static Sector* _current; + Level* level; /**< Parent level containing this sector */ + std::string name; std::vector bullets; diff --git a/src/supertux/textscroller.cpp b/src/supertux/textscroller.cpp index b9a62914d..db7dd4e19 100644 --- a/src/supertux/textscroller.cpp +++ b/src/supertux/textscroller.cpp @@ -133,8 +133,12 @@ TextScroller::draw(DrawingContext& context) } } -InfoBox::InfoBox(const std::string& text) - : firstline(0) +InfoBox::InfoBox(const std::string& text) : + firstline(0), + lines(), + images(), + arrow_scrollup(), + arrow_scrolldown() { // Split text string lines into a vector lines = InfoBoxLine::split(text, 400); @@ -302,6 +306,7 @@ InfoBoxLine::LineType get_linetype_by_format_char(char format_char) { InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) : lineType(NORMAL), font(normal_font), + color(), text(text), image(0) { diff --git a/src/supertux/tile_set.cpp b/src/supertux/tile_set.cpp index a96436dca..74a8fd67e 100644 --- a/src/supertux/tile_set.cpp +++ b/src/supertux/tile_set.cpp @@ -25,15 +25,17 @@ TileSet::TileSet() : tiles(), - tiles_path(""), + tiles_path(), tiles_loaded(false) { tiles.resize(1, 0); tiles[0] = new Tile(this); } -TileSet::TileSet(const std::string& filename) - : tiles_path(""), tiles_loaded(true) +TileSet::TileSet(const std::string& filename) : + tiles(), + tiles_path(), + tiles_loaded(true) { tiles_path = FileSystem::dirname(filename); -- 2.11.0