Skip to content

Commit

Permalink
Some minor code cleanup resulting from a user running code through cp…
Browse files Browse the repository at this point in the history
…pcheck, mostly removal of redundant code

More info on fan forum: http://forum.freegamedev.net/viewtopic.php?f=68&t=5048
  • Loading branch information
LMH0013 authored and Tobias Markus committed Jan 24, 2014
1 parent 2433c27 commit 1a92277
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
6 changes: 1 addition & 5 deletions src/control/joystickkeyboardcontroller.cpp
Expand Up @@ -418,18 +418,14 @@ 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);
}

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);
Expand Down
2 changes: 1 addition & 1 deletion src/supertux/console.cpp
Expand Up @@ -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();
Expand Down
22 changes: 4 additions & 18 deletions src/supertux/info_box_line.cpp
Expand Up @@ -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;
}
}

Expand All @@ -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;
}
}

Expand All @@ -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;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/supertux/tile_set_parser.cpp
Expand Up @@ -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.");
}
Expand Down

0 comments on commit 1a92277

Please sign in to comment.