From: Ingo Ruhnke Date: Sun, 17 Aug 2014 03:06:11 +0000 (+0200) Subject: Made code -Wshadow clean X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5a632cca810d50b4620fba49f57fc5236cec21af;p=supertux.git Made code -Wshadow clean --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 15694b755..8e8046e53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,12 +256,12 @@ IF(CMAKE_COMPILER_IS_GNUCC) ENDIF(WERROR) IF(WARNINGS) # temporarily disabled: - # -Wsign-conversion -Wfloat-equal -Wconversion -Wundef -Wshadow -Wswitch-default + # -Wsign-conversion -Wfloat-equal -Wconversion -Wundef -Wswitch-default # -Wswitch-enum -Wsign-promo -Wcast-qual -Woverloaded-virtual -Wmissing-format-attribute # -Wold-style-cast -Wpadded -Wabi -Winline -Wunsafe-loop-optimizations -Wstrict-overflow=5 # fails on MinGW: # -ansi - SET(SUPERTUX2_EXTRA_WARNING_FLAGS "-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Wformat=2 -Weffc++ -Wctor-dtor-privacy -Wstrict-null-sentinel -Wno-unused-parameter") + SET(SUPERTUX2_EXTRA_WARNING_FLAGS "-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Wformat=2 -Weffc++ -Wctor-dtor-privacy -Wstrict-null-sentinel -Wno-unused-parameter -Wshadow") ENDIF(WARNINGS) ENDIF(CMAKE_COMPILER_IS_GNUCC) diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 1901ccf31..5aefab491 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -33,8 +33,8 @@ static const float X_OFFSCREEN_DISTANCE = 1280; static const float Y_OFFSCREEN_DISTANCE = 800; static const int LAYER_FALLING = 500; -BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name, int layer) : - MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), +BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name_, int layer_) : + MovingSprite(pos, sprite_name_, layer_, COLGROUP_DISABLED), physic(), countMe(true), is_initialized(false), @@ -59,8 +59,8 @@ BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name, int layer) : dir = (start_dir == AUTO) ? LEFT : start_dir; } -BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite_name, int layer) : - MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), +BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite_name_, int layer_) : + MovingSprite(pos, sprite_name_, layer_, COLGROUP_DISABLED), physic(), countMe(true), is_initialized(false), @@ -85,8 +85,8 @@ BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite dir = (start_dir == AUTO) ? LEFT : start_dir; } -BadGuy::BadGuy(const Reader& reader, const std::string& sprite_name, int layer) : - MovingSprite(reader, sprite_name, layer, COLGROUP_DISABLED), +BadGuy::BadGuy(const Reader& reader, const std::string& sprite_name_, int layer_) : + MovingSprite(reader, sprite_name_, layer_, COLGROUP_DISABLED), physic(), countMe(true), is_initialized(false), @@ -490,8 +490,8 @@ BadGuy::try_activate() // if starting direction was set to AUTO, this is our chance to re-orient the badguy if (start_dir == AUTO) { - Player* player = get_nearest_player(); - if (player && (player->get_bbox().p1.x > get_bbox().p2.x)) { + Player* player_ = get_nearest_player(); + if (player_ && (player_->get_bbox().p1.x > get_bbox().p2.x)) { dir = RIGHT; } else { dir = LEFT; @@ -624,10 +624,10 @@ BadGuy::is_ignited() const } void -BadGuy::set_colgroup_active(CollisionGroup group) +BadGuy::set_colgroup_active(CollisionGroup group_) { - this->colgroup_active = group; - if (state == STATE_ACTIVE) set_group(group); + this->colgroup_active = group_; + if (state == STATE_ACTIVE) set_group(group_); } /* EOF */ diff --git a/src/badguy/dart.cpp b/src/badguy/dart.cpp index 47889d9d2..c75bea182 100644 --- a/src/badguy/dart.cpp +++ b/src/badguy/dart.cpp @@ -39,9 +39,9 @@ Dart::Dart(const Reader& reader) : sound_manager->preload("sounds/stomp.wav"); } -Dart::Dart(const Vector& pos, Direction d, const BadGuy* parent = 0) : +Dart::Dart(const Vector& pos, Direction d, const BadGuy* parent_ = 0) : BadGuy(pos, d, "images/creatures/dart/dart.sprite"), - parent(parent), + parent(parent_), sound_source() { physic.enable_gravity(false); diff --git a/src/badguy/goldbomb.cpp b/src/badguy/goldbomb.cpp index 1fbe184f6..fa180ead4 100644 --- a/src/badguy/goldbomb.cpp +++ b/src/badguy/goldbomb.cpp @@ -191,27 +191,27 @@ GoldBomb::grab(MovingObject& object, const Vector& pos, Direction dir) } void -GoldBomb::ungrab(MovingObject& object, Direction dir) +GoldBomb::ungrab(MovingObject& object, Direction dir_) { int toss_velocity_x = 0; int toss_velocity_y = 0; Player* player = dynamic_cast (&object); // toss upwards - if(dir == UP) + if(dir_ == UP) toss_velocity_y += -500; // toss to the side when moving sideways - if(player && player->physic.get_velocity_x()*(dir == LEFT ? -1 : 1) > 1) { - toss_velocity_x += (dir == LEFT) ? -200 : 200; + if(player && player->physic.get_velocity_x()*(dir_ == LEFT ? -1 : 1) > 1) { + toss_velocity_x += (dir_ == LEFT) ? -200 : 200; toss_velocity_y = (toss_velocity_y < -200) ? toss_velocity_y : -200; // toss farther when running - if(player && player->physic.get_velocity_x()*(dir == LEFT ? -1 : 1) > 200) - toss_velocity_x += player->physic.get_velocity_x()-(190*(dir == LEFT ? -1 : 1)); + if(player && player->physic.get_velocity_x()*(dir_ == LEFT ? -1 : 1) > 200) + toss_velocity_x += player->physic.get_velocity_x()-(190*(dir_ == LEFT ? -1 : 1)); } log_warning << toss_velocity_x << toss_velocity_y << std::endl;//// - //set_pos(object.get_pos() + Vector((dir == LEFT ? -33 : 33), get_bbox().get_height()*0.66666 - 32)); + //set_pos(object.get_pos() + Vector((dir_ == LEFT ? -33 : 33), get_bbox().get_height()*0.66666 - 32)); physic.set_velocity(toss_velocity_x, toss_velocity_y); set_colgroup_active(COLGROUP_MOVING); grabbed = false; diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index 8cf3bdbf2..c46e925b3 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -224,12 +224,12 @@ MrIceBlock::collision_squished(GameObject& object) } void -MrIceBlock::set_state(IceState state, bool up) +MrIceBlock::set_state(IceState state_, bool up) { - if(ice_state == state) + if(ice_state == state_) return; - switch(state) { + switch(state_) { case ICESTATE_NORMAL: this->set_action(dir == LEFT ? "left" : "right", /* loops = */ -1); WalkingBadguy::initialize(); @@ -259,26 +259,26 @@ MrIceBlock::set_state(IceState state, bool up) default: assert(false); } - ice_state = state; + ice_state = state_; } void -MrIceBlock::grab(MovingObject&, const Vector& pos, Direction dir) +MrIceBlock::grab(MovingObject&, const Vector& pos, Direction dir_) { movement = pos - get_pos(); - this->dir = dir; - this->set_action(dir == LEFT ? "flat-left" : "flat-right", /* loops = */ -1); + this->dir = dir_; + this->set_action(dir_ == LEFT ? "flat-left" : "flat-right", /* loops = */ -1); set_state(ICESTATE_GRABBED); set_colgroup_active(COLGROUP_DISABLED); } void -MrIceBlock::ungrab(MovingObject& , Direction dir) +MrIceBlock::ungrab(MovingObject& , Direction dir_) { - if(dir == UP) { + if(dir_ == UP) { set_state(ICESTATE_FLAT, true); } else { - this->dir = dir; + this->dir = dir_; set_state(ICESTATE_KICKED); } set_colgroup_active(COLGROUP_MOVING); diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index ec3c9dbbb..f2347cb3f 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -657,13 +657,13 @@ Menu::set_toggled(int id, bool toggled) } void -Menu::event(const SDL_Event& event) +Menu::event(const SDL_Event& ev) { - switch(event.type) { + switch(ev.type) { case SDL_MOUSEBUTTONDOWN: - if(event.button.button == SDL_BUTTON_LEFT) + if(ev.button.button == SDL_BUTTON_LEFT) { - Vector mouse_pos = Renderer::instance()->to_logical(event.motion.x, event.motion.y); + Vector mouse_pos = Renderer::instance()->to_logical(ev.motion.x, ev.motion.y); int x = int(mouse_pos.x); int y = int(mouse_pos.y); @@ -679,7 +679,7 @@ Menu::event(const SDL_Event& event) case SDL_MOUSEMOTION: { - Vector mouse_pos = Renderer::instance()->to_logical(event.motion.x, event.motion.y); + Vector mouse_pos = Renderer::instance()->to_logical(ev.motion.x, ev.motion.y); float x = mouse_pos.x; float y = mouse_pos.y; diff --git a/src/gui/menu_manager.cpp b/src/gui/menu_manager.cpp index aae71e927..89087b1b5 100644 --- a/src/gui/menu_manager.cpp +++ b/src/gui/menu_manager.cpp @@ -164,13 +164,13 @@ MenuManager::process_input() } void -MenuManager::event(const SDL_Event& event) +MenuManager::event(const SDL_Event& event_) { if (current() && !m_transition->is_active()) { // only pass events when the menu is fully visible and not in a // transition animation - current()->event(event); + current()->event(event_); } } diff --git a/src/lisp/parser.cpp b/src/lisp/parser.cpp index 53f646960..6eb17da80 100644 --- a/src/lisp/parser.cpp +++ b/src/lisp/parser.cpp @@ -68,19 +68,19 @@ static std::string dirname(const std::string& filename) } const Lisp* -Parser::parse(const std::string& filename) +Parser::parse(const std::string& filename_) { - IFileStreambuf ins(filename); + IFileStreambuf ins(filename_); std::istream in(&ins); if(!in.good()) { std::stringstream msg; - msg << "Parser problem: Couldn't open file '" << filename << "'."; + msg << "Parser problem: Couldn't open file '" << filename_ << "'."; throw std::runtime_error(msg.str()); } if(dictionary_manager) { - std::string rel_dir = dirname (filename); + std::string rel_dir = dirname (filename_); for(char** i = searchpath; *i != NULL; i++) { std::string abs_dir = std::string (*i) + PHYSFS_getDirSeparator () + rel_dir; @@ -89,7 +89,7 @@ Parser::parse(const std::string& filename) dictionary = & (dictionary_manager->get_dictionary()); } - return parse(in, filename); + return parse(in, filename_); } const Lisp* diff --git a/src/object/brick.cpp b/src/object/brick.cpp index 0dd7bdf68..8e85da787 100644 --- a/src/object/brick.cpp +++ b/src/object/brick.cpp @@ -48,7 +48,7 @@ Brick::hit(Player& player) } HitResponse -Brick::collision(GameObject& other, const CollisionHit& hit){ +Brick::collision(GameObject& other, const CollisionHit& hit_){ Player* player = dynamic_cast (&other); if (player) { @@ -75,7 +75,7 @@ Brick::collision(GameObject& other, const CollisionHit& hit){ if(explosion && explosion->hurts()) { try_break(player); } - return Block::collision(other, hit); + return Block::collision(other, hit_); } void diff --git a/src/object/invisible_block.cpp b/src/object/invisible_block.cpp index 07884819a..6fc64ea91 100644 --- a/src/object/invisible_block.cpp +++ b/src/object/invisible_block.cpp @@ -54,9 +54,9 @@ InvisibleBlock::collides(GameObject& other, const CollisionHit& ) } HitResponse -InvisibleBlock::collision(GameObject& other, const CollisionHit& hit) +InvisibleBlock::collision(GameObject& other, const CollisionHit& hit_) { - return Block::collision(other, hit); + return Block::collision(other, hit_); } void diff --git a/src/object/light.cpp b/src/object/light.cpp index ca707ace2..92a193482 100644 --- a/src/object/light.cpp +++ b/src/object/light.cpp @@ -18,9 +18,9 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" -Light::Light(const Vector& center, const Color& color) : +Light::Light(const Vector& center, const Color& color_) : position(center), - color(color), + color(color_), sprite() { sprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite"); diff --git a/src/object/particlesystem.cpp b/src/object/particlesystem.cpp index ae15ba07d..8df810869 100644 --- a/src/object/particlesystem.cpp +++ b/src/object/particlesystem.cpp @@ -22,8 +22,8 @@ #include "supertux/globals.hpp" #include "video/drawing_context.hpp" -ParticleSystem::ParticleSystem(float max_particle_size) : - max_particle_size(max_particle_size), +ParticleSystem::ParticleSystem(float max_particle_size_) : + max_particle_size(max_particle_size_), z_pos(), particles(), virtual_width(), diff --git a/src/object/path_walker.cpp b/src/object/path_walker.cpp index 3df9ed03a..47d18a4ea 100644 --- a/src/object/path_walker.cpp +++ b/src/object/path_walker.cpp @@ -19,9 +19,9 @@ #include #include -PathWalker::PathWalker(const Path* path, bool running) : +PathWalker::PathWalker(const Path* path, bool running_) : path(path), - running(running), + running(running_), current_node_nr(0), next_node_nr(0), stop_at_node_nr(running?-1:0), diff --git a/src/object/pulsing_light.cpp b/src/object/pulsing_light.cpp index 0133a5ce1..a37a7c015 100644 --- a/src/object/pulsing_light.cpp +++ b/src/object/pulsing_light.cpp @@ -19,11 +19,11 @@ #include "math/random_generator.hpp" -PulsingLight::PulsingLight(const Vector& center, float cycle_len, float min_alpha, float max_alpha, const Color& color) : - Light(center, color), - min_alpha(min_alpha), - max_alpha(max_alpha), - cycle_len(cycle_len), +PulsingLight::PulsingLight(const Vector& center, float cycle_len_, float min_alpha_, float max_alpha_, const Color& color_) : + Light(center, color_), + min_alpha(min_alpha_), + max_alpha(max_alpha_), + cycle_len(cycle_len_), t(0) { assert(cycle_len > 0); diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index b76d150da..b5ae6ed89 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -115,9 +115,9 @@ ScriptedObject::get_velocity_y() } void -ScriptedObject::set_visible(bool visible) +ScriptedObject::set_visible(bool visible_) { - this->visible = visible; + this->visible = visible_; } bool @@ -127,9 +127,9 @@ ScriptedObject::is_visible() } void -ScriptedObject::set_solid(bool solid) +ScriptedObject::set_solid(bool solid_) { - this->solid = solid; + this->solid = solid_; if( solid ){ set_group( COLGROUP_MOVING_STATIC ); } else { diff --git a/src/object/sprite_particle.cpp b/src/object/sprite_particle.cpp index 0f72a6b57..122404934 100644 --- a/src/object/sprite_particle.cpp +++ b/src/object/sprite_particle.cpp @@ -26,12 +26,12 @@ SpriteParticle::SpriteParticle(std::string sprite_name, std::string action, Vector position, AnchorPoint anchor, Vector velocity, Vector acceleration, - int drawing_layer) : + int drawing_layer_) : sprite(), position(position), velocity(velocity), acceleration(acceleration), - drawing_layer(drawing_layer), + drawing_layer(drawing_layer_), light(0.0f,0.0f,0.0f), lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-tiny.sprite")), glow(false) diff --git a/src/object/tilemap.hpp b/src/object/tilemap.hpp index 5732920e4..da17b5de1 100644 --- a/src/object/tilemap.hpp +++ b/src/object/tilemap.hpp @@ -96,8 +96,8 @@ public: boost::shared_ptr get_walker() { return walker; } - void set_offset(const Vector &offset) - { this->offset = offset; } + void set_offset(const Vector &offset_) + { this->offset = offset_; } /* Returns the position of the upper-left corner of * tile (x, y) in the sector. */ diff --git a/src/supertux/level.cpp b/src/supertux/level.cpp index 83e838be1..73f3a6ff1 100644 --- a/src/supertux/level.cpp +++ b/src/supertux/level.cpp @@ -162,11 +162,11 @@ Level::add_sector(Sector* sector) } Sector* -Level::get_sector(const std::string& name) +Level::get_sector(const std::string& name_) { for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) { Sector* sector = *i; - if(sector->get_name() == name) + if(sector->get_name() == name_) return sector; } diff --git a/src/supertux/moving_object.hpp b/src/supertux/moving_object.hpp index c1158526c..07984eb58 100644 --- a/src/supertux/moving_object.hpp +++ b/src/supertux/moving_object.hpp @@ -157,9 +157,9 @@ protected: friend class CollisionGrid; friend class Platform; - void set_group(CollisionGroup group) + void set_group(CollisionGroup group_) { - this->group = group; + this->group = group_; } /** The bounding box of the object (as used for collision detection, diff --git a/src/supertux/sector.hpp b/src/supertux/sector.hpp index e5da1d722..71232d7d8 100644 --- a/src/supertux/sector.hpp +++ b/src/supertux/sector.hpp @@ -95,8 +95,8 @@ public: /// adds a gameobject void add_object(GameObject* object); - void set_name(const std::string& name) - { this->name = name; } + void set_name(const std::string& name_) + { this->name = name_; } const std::string& get_name() const { return name; } diff --git a/src/video/drawing_context.cpp b/src/video/drawing_context.cpp index d31211368..3eacf3fe5 100644 --- a/src/video/drawing_context.cpp +++ b/src/video/drawing_context.cpp @@ -31,9 +31,9 @@ #include "video/texture_manager.hpp" #include "video/video_systems.hpp" -DrawingContext::DrawingContext(Renderer& renderer, Lightmap& lightmap) : - renderer(renderer), - lightmap(lightmap), +DrawingContext::DrawingContext(Renderer& renderer_, Lightmap& lightmap_) : + renderer(renderer_), + lightmap(lightmap_), transformstack(), transform(), blend_stack(), diff --git a/src/video/gl/gl_surface_data.hpp b/src/video/gl/gl_surface_data.hpp index ca906f710..460ad7e19 100644 --- a/src/video/gl/gl_surface_data.hpp +++ b/src/video/gl/gl_surface_data.hpp @@ -30,8 +30,8 @@ private: float uv_bottom; public: - GLSurfaceData(const Surface &surface) : - surface(surface), + GLSurfaceData(const Surface& surface_) : + surface(surface_), uv_left((float) surface.get_x() / surface.get_texture()->get_texture_width()), uv_top((float) surface.get_y() / surface.get_texture()->get_texture_height()), uv_right((float) (surface.get_x() + surface.get_width()) / surface.get_texture()->get_texture_width()),