From 1a9227785fcceb708a7290d29151566122a7587b 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 f225745da02..20566e75f85 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -418,8 +418,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); } @@ -427,9 +425,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 000a978932d..6e663f5c0a4 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 6a9123a9bd9..e7ff52e803f 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 5daaa459952..f29c57397ff 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."); }