Skip to content

Commit

Permalink
Made code -Wshadow clean, missed a bunch of issues in the last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Grumbel committed Aug 17, 2014
1 parent 5a632cc commit 22a1e0b
Show file tree
Hide file tree
Showing 74 changed files with 451 additions and 447 deletions.
4 changes: 2 additions & 2 deletions src/addon/addon_manager.cpp
Expand Up @@ -379,10 +379,10 @@ AddonManager::load_addons()
// Search for infoFiles
std::string infoFileName = "";
char** rc2 = PHYSFS_enumerateFiles("/");
for(char** i = rc2; *i != 0; ++i) {
for(char** j = rc2; *j != 0; ++j) {

// get filename of potential infoFile
std::string potentialInfoFileName = *i;
std::string potentialInfoFileName = *j;

// make sure it looks like an infoFile
static const std::string infoExt = ".nfo";
Expand Down
16 changes: 8 additions & 8 deletions src/addon/md5.cpp
Expand Up @@ -89,33 +89,33 @@ void MD5::update (uint8_t* input, uint32_t input_length) {
}

void MD5::update(FILE *file) {
uint8_t buffer[1024];
uint8_t buffer_[1024];
int len;

while ((len=fread(buffer, 1, 1024, file))) update(buffer, len);
while ((len=fread(buffer_, 1, 1024, file))) update(buffer_, len);

fclose (file);
}

void MD5::update(std::istream& stream) {
uint8_t buffer[1024];
uint8_t buffer_[1024];
int len;

while (stream.good()) {
stream.read((char*)buffer, 1024); // note that return value of read is unusable.
stream.read((char*)buffer_, 1024); // note that return value of read is unusable.
len=stream.gcount();
update(buffer, len);
update(buffer_, len);
}
}

void MD5::update(std::ifstream& stream) {
uint8_t buffer[1024];
uint8_t buffer_[1024];
int len;

while (stream.good()) {
stream.read((char*)buffer, 1024); // note that return value of read is unusable.
stream.read((char*)buffer_, 1024); // note that return value of read is unusable.
len=stream.gcount();
update(buffer, len);
update(buffer_, len);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/audio/ogg_sound_file.cpp
Expand Up @@ -18,14 +18,14 @@

#include <assert.h>

OggSoundFile::OggSoundFile(PHYSFS_file* file, double loop_begin, double loop_at) :
OggSoundFile::OggSoundFile(PHYSFS_file* file_, double loop_begin_, double loop_at_) :
file(),
vorbis_file(),
loop_begin(),
loop_at(),
normal_buffer_loop()
{
this->file = file;
this->file = file_;

ov_callbacks callbacks = { cb_read, cb_seek, cb_close, cb_tell };
ov_open_callbacks(file, &vorbis_file, 0, 0, callbacks);
Expand All @@ -37,11 +37,11 @@ OggSoundFile::OggSoundFile(PHYSFS_file* file, double loop_begin, double loop_at)
bits_per_sample = 16;
size = static_cast<size_t> (ov_pcm_total(&vorbis_file, -1) * 2);

double samples_begin = loop_begin * rate;
double sample_loop = loop_at * rate;
double samples_begin = loop_begin_ * rate;
double sample_loop = loop_at_ * rate;

this->loop_begin = (ogg_int64_t) samples_begin;
if(loop_begin < 0) {
if(loop_begin_ < 0) {
this->loop_at = (ogg_int64_t) -1;
} else {
this->loop_at = (ogg_int64_t) sample_loop;
Expand Down
6 changes: 3 additions & 3 deletions src/audio/sound_manager.cpp
Expand Up @@ -125,9 +125,9 @@ SoundManager::intern_create_sound_source(const std::string& filename)
buffer = load_file_into_buffer(*file);
buffers.insert(std::make_pair(filename, buffer));
} else {
std::unique_ptr<StreamSoundSource> source(new StreamSoundSource);
source->set_sound_file(std::move(file));
return std::move(source);
std::unique_ptr<StreamSoundSource> source_(new StreamSoundSource);
source_->set_sound_file(std::move(file));
return std::move(source_);
}

log_debug << "Uncached sound \"" << filename << "\" requested to be played" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/audio/stream_sound_source.cpp
Expand Up @@ -99,10 +99,10 @@ StreamSoundSource::update()
}

void
StreamSoundSource::set_fading(FadeState state, float fade_time)
StreamSoundSource::set_fading(FadeState state, float fade_time_)
{
this->fade_state = state;
this->fade_time = fade_time;
this->fade_time = fade_time_;
this->fade_start_time = real_time;
}

Expand Down
4 changes: 2 additions & 2 deletions src/audio/stream_sound_source.hpp
Expand Up @@ -38,9 +38,9 @@ class StreamSoundSource : public OpenALSoundSource
}
void update();

void set_looping(bool looping)
void set_looping(bool looping_)
{
this->looping = looping;
this->looping = looping_;
}
bool get_looping() const
{
Expand Down
8 changes: 4 additions & 4 deletions src/badguy/badguy.cpp
Expand Up @@ -433,14 +433,14 @@ BadGuy::run_dead_script()
}

void
BadGuy::set_state(State state)
BadGuy::set_state(State state_)
{
if(this->state == state)
if(this->state == state_)
return;

State laststate = this->state;
this->state = state;
switch(state) {
this->state = state_;
switch(state_) {
case STATE_SQUISHED:
state_timer.start(SQUISH_TIME);
break;
Expand Down
16 changes: 8 additions & 8 deletions src/badguy/bomb.cpp
Expand Up @@ -21,15 +21,15 @@
#include "sprite/sprite.hpp"
#include "supertux/sector.hpp"

Bomb::Bomb(const Vector& pos, Direction dir, std::string custom_sprite /*= "images/creatures/mr_bomb/mr_bomb.sprite"*/ ) :
BadGuy( pos, dir, custom_sprite ),
Bomb::Bomb(const Vector& pos, Direction dir_, std::string custom_sprite /*= "images/creatures/mr_bomb/mr_bomb.sprite"*/ ) :
BadGuy( pos, dir_, custom_sprite ),
state(),
grabbed(false),
grabber(NULL),
ticking()
{
state = STATE_TICKING;
set_action(dir == LEFT ? "ticking-left" : "ticking-right", 1);
set_action(dir_ == LEFT ? "ticking-left" : "ticking-right", 1);
countMe = false;

ticking = sound_manager->create_sound_source("sounds/fizz.wav");
Expand Down Expand Up @@ -104,10 +104,10 @@ Bomb::kill_fall()
}

void
Bomb::grab(MovingObject& object, const Vector& pos, Direction dir)
Bomb::grab(MovingObject& object, const Vector& pos, Direction dir_)
{
movement = pos - get_pos();
this->dir = dir;
this->dir = dir_;

// We actually face the opposite direction of Tux here to make the fuse more
// visible instead of hiding it behind Tux
Expand All @@ -118,13 +118,13 @@ Bomb::grab(MovingObject& object, const Vector& pos, Direction dir)
}

void
Bomb::ungrab(MovingObject& object, Direction dir)
Bomb::ungrab(MovingObject& object, Direction dir_)
{
this->dir = dir;
this->dir = dir_;
// portable objects are usually pushed away from Tux when dropped, but we
// don't want that, so we set the position
//FIXME: why don't we want that? shouldn't behavior be consistent?
set_pos(object.get_pos() + Vector(dir == LEFT ? -16 : 16, get_bbox().get_height()*0.66666 - 32));
set_pos(object.get_pos() + Vector(dir_ == LEFT ? -16 : 16, get_bbox().get_height()*0.66666 - 32));
set_colgroup_active(COLGROUP_MOVING);
grabbed = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/badguy/fish.cpp
Expand Up @@ -67,9 +67,9 @@ Fish::draw(DrawingContext& context)
}

HitResponse
Fish::hit(const CollisionHit& hit)
Fish::hit(const CollisionHit& hit_)
{
if(hit.top) {
if(hit_.top) {
physic.set_velocity_y(0);
}

Expand Down
6 changes: 3 additions & 3 deletions src/badguy/ghosttree.cpp
Expand Up @@ -176,15 +176,15 @@ GhostTree::active_update(float elapsed_time)
assert (suck_lantern);
Vector pos = suck_lantern->get_pos();
Vector delta = get_bbox().get_middle() + SUCK_TARGET_OFFSET - pos;
Vector dir = delta.unit();
Vector dir_ = delta.unit();
if (delta.norm() < 1) {
dir = delta;
dir_ = delta;
suck_lantern->ungrab(*this, RIGHT);
suck_lantern->remove_me();
suck_lantern = 0;
sprite->set_action("swallow", 1);
} else {
pos += dir;
pos += dir_;
suck_lantern->grab(*this, pos, RIGHT);
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/badguy/goldbomb.cpp
Expand Up @@ -168,11 +168,11 @@ GoldBomb::kill_fall()
}

void
GoldBomb::grab(MovingObject& object, const Vector& pos, Direction dir)
GoldBomb::grab(MovingObject& object, const Vector& pos, Direction dir_)
{
if(tstate == STATE_TICKING){
movement = pos - get_pos();
this->dir = dir;
this->dir = dir_;

// We actually face the opposite direction of Tux here to make the fuse more
// visible instead of hiding it behind Tux
Expand All @@ -183,8 +183,8 @@ GoldBomb::grab(MovingObject& object, const Vector& pos, Direction dir)
}
else if(frozen){
movement = pos - get_pos();
this->dir = dir;
sprite->set_action(dir == LEFT ? "iced-left" : "iced-right");
this->dir = dir_;
sprite->set_action(dir_ == LEFT ? "iced-left" : "iced-right");
set_colgroup_active(COLGROUP_DISABLED);
grabbed = true;
}
Expand Down
16 changes: 8 additions & 8 deletions src/badguy/kugelblitz.cpp
Expand Up @@ -99,10 +99,10 @@ Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit)
}

HitResponse
Kugelblitz::hit(const CollisionHit& hit)
Kugelblitz::hit(const CollisionHit& hit_)
{
// hit floor?
if(hit.bottom) {
if(hit_.bottom) {
if (!groundhit_pos_set)
{
pos_groundhit = get_pos();
Expand All @@ -117,7 +117,7 @@ Kugelblitz::hit(const CollisionHit& hit)
movement_timer.start(MOVETIME);
lifetime.start(LIFETIME);

} else if(hit.top) { // bumped on roof
} else if(hit_.top) { // bumped on roof
physic.set_velocity_y(0);
}

Expand Down Expand Up @@ -194,17 +194,17 @@ Kugelblitz::try_activate()
float X_OFFSCREEN_DISTANCE = 400;
float Y_OFFSCREEN_DISTANCE = 600;

Player* player = get_nearest_player();
if (!player) return;
Vector dist = player->get_bbox().get_middle() - get_bbox().get_middle();
Player* player_ = get_nearest_player();
if (!player_) return;
Vector dist = player_->get_bbox().get_middle() - get_bbox().get_middle();
if ((fabsf(dist.x) <= X_OFFSCREEN_DISTANCE) && (fabsf(dist.y) <= Y_OFFSCREEN_DISTANCE)) {
set_state(STATE_ACTIVE);
if (!is_initialized) {

// 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;
Expand Down
4 changes: 2 additions & 2 deletions src/badguy/mole_rock.cpp
Expand Up @@ -31,9 +31,9 @@ MoleRock::MoleRock(const Reader& reader) :
sound_manager->preload("sounds/stomp.wav");
}

MoleRock::MoleRock(const Vector& pos, const Vector& velocity, const BadGuy* parent = 0) :
MoleRock::MoleRock(const Vector& pos, const Vector& velocity, const BadGuy* parent_ = 0) :
BadGuy(pos, LEFT, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2),
parent(parent),
parent(parent_),
initial_velocity(velocity)
{
physic.enable_gravity(true);
Expand Down
10 changes: 5 additions & 5 deletions src/badguy/mrbomb.cpp
Expand Up @@ -113,20 +113,20 @@ MrBomb::kill_fall()
}

void
MrBomb::grab(MovingObject&, const Vector& pos, Direction dir)
MrBomb::grab(MovingObject&, const Vector& pos, Direction dir_)
{
assert(frozen);
movement = pos - get_pos();
this->dir = dir;
sprite->set_action(dir == LEFT ? "iced-left" : "iced-right");
this->dir = dir_;
sprite->set_action(dir_ == LEFT ? "iced-left" : "iced-right");
set_colgroup_active(COLGROUP_DISABLED);
grabbed = true;
}

void
MrBomb::ungrab(MovingObject& , Direction dir)
MrBomb::ungrab(MovingObject& , Direction dir_)
{
this->dir = dir;
this->dir = dir_;
set_colgroup_active(COLGROUP_MOVING);
grabbed = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/badguy/skydive.cpp
Expand Up @@ -58,10 +58,10 @@ SkyDive::collision_badguy(BadGuy&, const CollisionHit& hit)
} /* HitResponse collision_badguy */

void
SkyDive::grab (MovingObject&, const Vector& pos, Direction dir)
SkyDive::grab (MovingObject&, const Vector& pos, Direction dir_)
{
movement = pos - get_pos();
this->dir = dir;
this->dir = dir_;

is_grabbed = true;

Expand Down

0 comments on commit 22a1e0b

Please sign in to comment.