From: Tobias Markus Date: Sun, 1 Mar 2015 21:24:17 +0000 (+0100) Subject: Fixing a few cppcheck warnings X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=394aff4351bc13e8118482621926e95328fbea71;p=supertux.git Fixing a few cppcheck warnings --- diff --git a/src/addon/addon_manager.cpp b/src/addon/addon_manager.cpp index 60099bf4c..43e149012 100644 --- a/src/addon/addon_manager.cpp +++ b/src/addon/addon_manager.cpp @@ -48,7 +48,6 @@ MD5 md5_from_file(const std::string& filename) MD5 md5; - unsigned char buffer[1024]; PHYSFS_file* file = PHYSFS_openRead(filename.c_str()); if (!file) { @@ -60,6 +59,7 @@ MD5 md5_from_file(const std::string& filename) { while (true) { + unsigned char buffer[1024]; PHYSFS_sint64 len = PHYSFS_read(file, buffer, 1, sizeof(buffer)); if (len <= 0) break; md5.update(buffer, len); diff --git a/src/supertux/player_status.cpp b/src/supertux/player_status.cpp index 2ce2de74d..2c95b8f93 100644 --- a/src/supertux/player_status.cpp +++ b/src/supertux/player_status.cpp @@ -67,15 +67,17 @@ void PlayerStatus::reset() void PlayerStatus::add_coins(int count, bool play_sound) { - static float sound_played_time = 0; coins = std::min(coins + count, MAX_COINS); - if(play_sound) { - if(count >= 100) - SoundManager::current()->play("sounds/lifeup.wav"); - else if (real_time > sound_played_time + 0.010) { - SoundManager::current()->play("sounds/coin.wav"); - sound_played_time = real_time; - } + + if(!play_sound) + return; + + static float sound_played_time = 0; + if(count >= 100) + SoundManager::current()->play("sounds/lifeup.wav"); + else if (real_time > sound_played_time + 0.010) { + SoundManager::current()->play("sounds/coin.wav"); + sound_played_time = real_time; } }