From d226bb24308a6490de7e35dc8cf7239b5d4ecbf9 Mon Sep 17 00:00:00 2001 From: LMH Date: Wed, 6 Nov 2013 14:12:19 -1000 Subject: [PATCH] Some minor code cleanup resulting from a user running code through cppcheck, mostly removal of redundant code More info on fan forum: http://forum.freegamedev.net/viewtopic.php?f=68&t=5048 --- src/control/joystickkeyboardcontroller.cpp | 6 +----- src/supertux/console.cpp | 2 +- src/supertux/info_box_line.cpp | 22 ++++------------------ src/supertux/tile_set_parser.cpp | 4 ++-- 4 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index 6c9e9c06d..aa051522a 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -417,8 +417,6 @@ JoystickKeyboardController::process_axis_event(const SDL_JoyAxisEvent& jaxis) } else { if (jaxis.value < -dead_zone) set_joy_controls(left->second, true); - else if (jaxis.value > dead_zone) - set_joy_controls(left->second, false); else set_joy_controls(left->second, false); } @@ -426,9 +424,7 @@ JoystickKeyboardController::process_axis_event(const SDL_JoyAxisEvent& jaxis) if(right == joy_axis_map.end()) { // std::cout << "Unmapped joyaxis " << (int)jaxis.axis << " moved" << std::endl; } else { - if (jaxis.value < -dead_zone) - set_joy_controls(right->second, false); - else if (jaxis.value > dead_zone) + if (jaxis.value > dead_zone) set_joy_controls(right->second, true); else set_joy_controls(right->second, false); diff --git a/src/supertux/console.cpp b/src/supertux/console.cpp index 883ec09d6..efc5ccdb6 100644 --- a/src/supertux/console.cpp +++ b/src/supertux/console.cpp @@ -311,7 +311,7 @@ Console::autocomplete() sq_pop(vm, 1); // remove table // depending on number of hits, show matches or autocomplete - if (cmds.size() == 0) addLines("No known command starts with \""+prefix+"\""); + if (cmds.empty()) addLines("No known command starts with \""+prefix+"\""); if (cmds.size() == 1) { // one match: just replace input buffer with full command std::string replaceWith = cmds.front(); diff --git a/src/supertux/info_box_line.cpp b/src/supertux/info_box_line.cpp index 6a9123a9b..e7ff52e80 100644 --- a/src/supertux/info_box_line.cpp +++ b/src/supertux/info_box_line.cpp @@ -31,20 +31,16 @@ FontPtr get_font_by_format_char(char format_char) { { case ' ': return Resources::small_font; - break; case '-': return Resources::big_font; - break; case '\t': case '*': case '#': case '!': return Resources::normal_font; - break; default: return Resources::normal_font; - log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; - break; + //log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; } } @@ -53,21 +49,17 @@ Color get_color_by_format_char(char format_char) { { case ' ': return TextScroller::small_color; - break; case '-': return TextScroller::heading_color; - break; case '*': return TextScroller::reference_color; case '\t': case '#': case '!': return TextScroller::normal_color; - break; default: return Color(0,0,0); - log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; - break; + //log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; } } @@ -76,26 +68,20 @@ InfoBoxLine::LineType get_linetype_by_format_char(char format_char) { { case ' ': return InfoBoxLine::SMALL; - break; + case '\t': return InfoBoxLine::NORMAL; - break; case '-': return InfoBoxLine::HEADING; - break; case '*': return InfoBoxLine::REFERENCE; - break; case '#': return InfoBoxLine::NORMAL_LEFT; - break; case '!': return InfoBoxLine::IMAGE; - break; default: return InfoBoxLine::SMALL; - log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; - break; + //log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; } } diff --git a/src/supertux/tile_set_parser.cpp b/src/supertux/tile_set_parser.cpp index 5daaa4599..f29c57397 100644 --- a/src/supertux/tile_set_parser.cpp +++ b/src/supertux/tile_set_parser.cpp @@ -241,11 +241,11 @@ TileSetParser::parse_tiles(const Reader& reader) float fps = 10; reader.get("fps", fps); - if (width <= 0) + if (width == 0) { throw std::runtime_error("Width is zero."); } - else if (height <= 0) + else if (height == 0) { throw std::runtime_error("Height is zero."); } -- 2.11.0