From: Christoph Sommer Date: Tue, 25 Jul 2006 19:48:09 +0000 (+0000) Subject: Committed some code beautification patches by Tron X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d6e2020d36ff5b61efee046f31c829eaac06b8cd;p=supertux.git Committed some code beautification patches by Tron SVN-Revision: 4091 --- diff --git a/src/audio/sound_manager.hpp b/src/audio/sound_manager.hpp index 657ca06a3..edf929011 100644 --- a/src/audio/sound_manager.hpp +++ b/src/audio/sound_manager.hpp @@ -70,7 +70,7 @@ public: bool is_sound_enabled() { return sound_enabled; } bool is_audio_enabled() { - return (device == 0 || context == 0 ? false : true); + return device != 0 && context != 0; } void update(); diff --git a/src/control/controller.cpp b/src/control/controller.cpp index 05a33aaaa..ee7a3e2f0 100644 --- a/src/control/controller.cpp +++ b/src/control/controller.cpp @@ -62,13 +62,13 @@ Controller::hold(Control control) bool Controller::pressed(Control control) { - return oldControls[control] == false && controls[control] == true; + return !oldControls[control] && controls[control]; } bool Controller::released(Control control) { - return oldControls[control] == true && controls[control] == false; + return oldControls[control] && !controls[control]; } void diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index 7bd5961d9..6f8222ae8 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -342,8 +342,7 @@ JoystickKeyboardController::process_event(const SDL_Event& event) return; } - controls[i->second] = - event.type == SDL_JOYBUTTONDOWN ? true : false; + controls[i->second] = (event.type == SDL_JOYBUTTONDOWN); break; } @@ -382,7 +381,7 @@ JoystickKeyboardController::process_key_event(const SDL_Event& event) return; } Control control = key_mapping->second; - controls[control] = event.type == SDL_KEYDOWN ? true : false; + controls[control] = (event.type == SDL_KEYDOWN); } void @@ -481,7 +480,7 @@ JoystickKeyboardController::process_menu_key_event(const SDL_Event& event) break; } - controls[control] = event.type == SDL_KEYDOWN ? true : false; + controls[control] = (event.type == SDL_KEYDOWN); } void diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 05ef76c51..4ddaa1492 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -162,7 +162,7 @@ for(Buttons::iterator i = buttons.begin(); i != buttons.end(); ++i) i->pos.y + i->size.y > (row + buttons_box.y) * buttons_size.y) continue; - i->draw(context, i->id == button_selected ? true : false); + i->draw(context, i->id == button_selected); } context.pop_transform(); } diff --git a/src/main.cpp b/src/main.cpp index fabccddff..8f1f50dd6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -503,7 +503,6 @@ int main(int argc, char** argv) //init_rand(); PAK: this call might subsume the above 3, but I'm chicken! main_loop->run(); - } catch(std::exception& e) { log_fatal << "Unexpected exception: " << e.what() << std::endl; result = 1; diff --git a/src/moving_object.hpp b/src/moving_object.hpp index ae0e1d753..b23302ad4 100644 --- a/src/moving_object.hpp +++ b/src/moving_object.hpp @@ -229,7 +229,7 @@ private: * during collision detection */ Rect dest; - + bool solid; /**< true if this object should be considered when doing collision detection */ }; diff --git a/src/object/level_time.cpp b/src/object/level_time.cpp index 591176344..233e40020 100644 --- a/src/object/level_time.cpp +++ b/src/object/level_time.cpp @@ -71,7 +71,7 @@ LevelTime::draw(DrawingContext& context) Surface* time_surf = time_surface.get(); if (time_surf) { float all_width = time_surf->get_width() + white_text->get_text_width(time_text); - context.draw_surface(time_surf, Vector((SCREEN_WIDTH - all_width)/2, BORDER_Y + 1), LAYER_FOREGROUND1); + context.draw_surface(time_surf, Vector((SCREEN_WIDTH - all_width)/2, BORDER_Y + 1), LAYER_FOREGROUND1); context.draw_text(gold_text, time_text, Vector((SCREEN_WIDTH - all_width)/2 + time_surf->get_width(), BORDER_Y), LEFT_ALLIGN, LAYER_FOREGROUND1); } } diff --git a/src/object/player.cpp b/src/object/player.cpp index 2d7e88c8c..a80ea94ff 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -543,8 +543,8 @@ Player::handle_vertical_input() /* When Down is not held anymore, disable butt jump */ if(butt_jump && !controller->hold(Controller::DOWN)) butt_jump = false; - - // swimming + + // swimming physic.set_acceleration_y(0); if (swimming) { if (controller->hold(Controller::UP) || controller->hold(Controller::JUMP)) physic.set_acceleration_y(-2000); diff --git a/src/object/rock.cpp b/src/object/rock.cpp index aa883a1ae..6c45b0b9c 100644 --- a/src/object/rock.cpp +++ b/src/object/rock.cpp @@ -107,7 +107,6 @@ Rock::grab(MovingObject& , const Vector& pos, Direction) set_group( COLGROUP_DISABLED ); on_ground = true; grabbed = true; - } void diff --git a/src/physic.hpp b/src/physic.hpp index e05b65f3b..abfdba530 100644 --- a/src/physic.hpp +++ b/src/physic.hpp @@ -67,10 +67,10 @@ public: /// Enables or disables handling of gravity. void enable_gravity(bool gravity_enabled); bool gravity_enabled() const; - + /// Set gravity to apply to object when enabled void set_gravity(float gravity); - + /// Get gravity to apply to object when enabled float get_gravity() const; diff --git a/src/player_status.cpp b/src/player_status.cpp index f638bca92..95f994e71 100644 --- a/src/player_status.cpp +++ b/src/player_status.cpp @@ -152,7 +152,7 @@ PlayerStatus::draw(DrawingContext& context) Surface* coin_surf = coin_surface.get(); if (coin_surf) { - context.draw_surface(coin_surf, Vector(SCREEN_WIDTH - BORDER_X - coin_surf->get_width() - gold_text->get_text_width(coins_text), BORDER_Y + 1), LAYER_FOREGROUND1); + context.draw_surface(coin_surf, Vector(SCREEN_WIDTH - BORDER_X - coin_surf->get_width() - gold_text->get_text_width(coins_text), BORDER_Y + 1), LAYER_FOREGROUND1); } context.draw_text(gold_text, coins_text, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y), RIGHT_ALLIGN, LAYER_FOREGROUND1); diff --git a/src/trigger/scripttrigger.cpp b/src/trigger/scripttrigger.cpp index afac8aeb9..6af9b8c05 100644 --- a/src/trigger/scripttrigger.cpp +++ b/src/trigger/scripttrigger.cpp @@ -74,7 +74,7 @@ ScriptTrigger::write(lisp::Writer& writer) writer.write_float("width", bbox.get_width()); writer.write_float("height", bbox.get_height()); writer.write_string("script", script); - writer.write_bool("button", (triggerevent == EVENT_ACTIVATE) ? true : false); + writer.write_bool("button", triggerevent == EVENT_ACTIVATE); writer.end_list("scripttrigger"); }