Some minor code cleanup resulting from a user running code through cppcheck, mostly...
authorLMH <lmh.0013@gmail.com>
Thu, 7 Nov 2013 00:12:19 +0000 (14:12 -1000)
committerLMH <lmh.0013@gmail.com>
Thu, 7 Nov 2013 00:12:19 +0000 (14:12 -1000)
More info on fan forum: http://forum.freegamedev.net/viewtopic.php?f=68&t=5048

src/control/joystickkeyboardcontroller.cpp
src/supertux/console.cpp
src/supertux/info_box_line.cpp
src/supertux/tile_set_parser.cpp

index 6c9e9c0..aa05152 100644 (file)
@@ -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);
index 883ec09..efc5ccd 100644 (file)
@@ -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();
index 6a9123a..e7ff52e 100644 (file)
@@ -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;
   }
 }
 
index 5daaa45..f29c573 100644 (file)
@@ -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.");
   }