1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:07:45 +00:00

Everywhere: Run clang-format

This commit is contained in:
Idan Horowitz 2022-04-01 20:58:27 +03:00 committed by Linus Groh
parent 0376c127f6
commit 086969277e
1665 changed files with 8479 additions and 8479 deletions

View file

@ -139,7 +139,7 @@ void Game::paint_event(GUI::PaintEvent& event)
painter.draw_text(lives_left_rect(), String::formatted("Lives: {}", m_lives), Gfx::TextAlignment::Center, Color::White);
if (m_paused) {
const char* msg = m_cheater ? "C H E A T E R" : "P A U S E D";
char const* msg = m_cheater ? "C H E A T E R" : "P A U S E D";
painter.draw_text(pause_rect(), msg, Gfx::TextAlignment::Center, Color::White);
}
}

View file

@ -86,7 +86,7 @@ private:
Gfx::IntRect pause_rect() const
{
const char* msg = m_cheater ? "C H E A T E R" : "P A U S E D";
char const* msg = m_cheater ? "C H E A T E R" : "P A U S E D";
int msg_width = font().width(msg);
int msg_height = font().glyph_height();
return { (game_width / 2) - (msg_width / 2), (game_height / 2) - (msg_height / 2), msg_width, msg_height };

View file

@ -24,9 +24,9 @@ ChessWidget::ChessWidget()
void ChessWidget::paint_event(GUI::PaintEvent& event)
{
const int min_size = min(width(), height());
const int widget_offset_x = (window()->width() - min_size) / 2;
const int widget_offset_y = (window()->height() - min_size) / 2;
int const min_size = min(width(), height());
int const widget_offset_x = (window()->width() - min_size) / 2;
int const widget_offset_y = (window()->height() - min_size) / 2;
GUI::Frame::paint_event(event);
@ -144,7 +144,7 @@ void ChessWidget::paint_event(GUI::PaintEvent& event)
Gfx::IntPoint move_point;
Gfx::IntPoint point_offset = { tile_width / 3, tile_height / 3 };
Gfx::IntSize rect_size = { tile_width / 3, tile_height / 3 };
for (const auto& square : m_available_moves) {
for (auto const& square : m_available_moves) {
if (side() == Chess::Color::White) {
move_point = { square.file * tile_width, (7 - square.rank) * tile_height };
} else {
@ -165,9 +165,9 @@ void ChessWidget::paint_event(GUI::PaintEvent& event)
void ChessWidget::mousedown_event(GUI::MouseEvent& event)
{
const int min_size = min(width(), height());
const int widget_offset_x = (window()->width() - min_size) / 2;
const int widget_offset_y = (window()->height() - min_size) / 2;
int const min_size = min(width(), height());
int const widget_offset_x = (window()->width() - min_size) / 2;
int const widget_offset_y = (window()->height() - min_size) / 2;
if (!frame_inner_rect().contains(event.position()))
return;
@ -306,9 +306,9 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event)
void ChessWidget::mousemove_event(GUI::MouseEvent& event)
{
const int min_size = min(width(), height());
const int widget_offset_x = (window()->width() - min_size) / 2;
const int widget_offset_y = (window()->height() - min_size) / 2;
int const min_size = min(width(), height());
int const widget_offset_x = (window()->width() - min_size) / 2;
int const widget_offset_y = (window()->height() - min_size) / 2;
if (!frame_inner_rect().contains(event.position()))
return;
@ -391,9 +391,9 @@ void ChessWidget::set_piece_set(StringView set)
Chess::Square ChessWidget::mouse_to_square(GUI::MouseEvent& event) const
{
const int min_size = min(width(), height());
const int widget_offset_x = (window()->width() - min_size) / 2;
const int widget_offset_y = (window()->height() - min_size) / 2;
int const min_size = min(width(), height());
int const widget_offset_x = (window()->width() - min_size) / 2;
int const widget_offset_y = (window()->height() - min_size) / 2;
int tile_width = min_size / 8;
int tile_height = min_size / 8;
@ -405,7 +405,7 @@ Chess::Square ChessWidget::mouse_to_square(GUI::MouseEvent& event) const
}
}
RefPtr<Gfx::Bitmap> ChessWidget::get_piece_graphic(const Chess::Piece& piece) const
RefPtr<Gfx::Bitmap> ChessWidget::get_piece_graphic(Chess::Piece const& piece) const
{
return m_pieces.get(piece).value();
}

View file

@ -27,22 +27,22 @@ public:
virtual void keydown_event(GUI::KeyEvent&) override;
Chess::Board& board() { return m_board; };
const Chess::Board& board() const { return m_board; };
Chess::Board const& board() const { return m_board; };
Chess::Board& board_playback() { return m_board_playback; };
const Chess::Board& board_playback() const { return m_board_playback; };
Chess::Board const& board_playback() const { return m_board_playback; };
Chess::Color side() const { return m_side; };
void set_side(Chess::Color side) { m_side = side; };
void set_piece_set(StringView set);
const String& piece_set() const { return m_piece_set; };
String const& piece_set() const { return m_piece_set; };
Chess::Square mouse_to_square(GUI::MouseEvent& event) const;
bool drag_enabled() const { return m_drag_enabled; }
void set_drag_enabled(bool e) { m_drag_enabled = e; }
RefPtr<Gfx::Bitmap> get_piece_graphic(const Chess::Piece& piece) const;
RefPtr<Gfx::Bitmap> get_piece_graphic(Chess::Piece const& piece) const;
bool show_available_moves() const { return m_show_available_moves; }
void set_show_available_moves(bool e) { m_show_available_moves = e; }
@ -61,8 +61,8 @@ public:
Color light_square_color;
};
const BoardTheme& board_theme() const { return m_board_theme; }
void set_board_theme(const BoardTheme& theme) { m_board_theme = theme; }
BoardTheme const& board_theme() const { return m_board_theme; }
void set_board_theme(BoardTheme const& theme) { m_board_theme = theme; }
void set_board_theme(StringView name);
enum class PlaybackDirection {
@ -101,7 +101,7 @@ public:
return Type::None;
}
bool operator==(const BoardMarking& other) const { return from == other.from && to == other.to; }
bool operator==(BoardMarking const& other) const { return from == other.from && to == other.to; }
};
private:

View file

@ -37,7 +37,7 @@ Engine::Engine(StringView command)
posix_spawn_file_actions_adddup2(&file_actions, rpipefds[1], STDOUT_FILENO);
String cstr(command);
const char* argv[] = { cstr.characters(), nullptr };
char const* argv[] = { cstr.characters(), nullptr };
if (posix_spawnp(&m_pid, cstr.characters(), &file_actions, nullptr, const_cast<char**>(argv), environ) < 0) {
perror("posix_spawnp");
VERIFY_NOT_REACHED();
@ -59,7 +59,7 @@ Engine::Engine(StringView command)
send_command(Chess::UCI::UCICommand());
}
void Engine::handle_bestmove(const Chess::UCI::BestMoveCommand& command)
void Engine::handle_bestmove(Chess::UCI::BestMoveCommand const& command)
{
if (m_bestmove_callback)
m_bestmove_callback(command.move());

View file

@ -17,13 +17,13 @@ public:
Engine(StringView command);
Engine(const Engine&) = delete;
Engine& operator=(const Engine&) = delete;
Engine(Engine const&) = delete;
Engine& operator=(Engine const&) = delete;
virtual void handle_bestmove(const Chess::UCI::BestMoveCommand&) override;
virtual void handle_bestmove(Chess::UCI::BestMoveCommand const&) override;
template<typename Callback>
void get_best_move(const Chess::Board& board, int time_limit, Callback&& callback)
void get_best_move(Chess::Board const& board, int time_limit, Callback&& callback)
{
send_command(Chess::UCI::PositionCommand({}, board.moves()));
Chess::UCI::GoCommand go_command;

View file

@ -41,9 +41,9 @@ private:
public:
struct Bug {
const float x { 50 };
const float radius { 16 };
const float starting_y { 200 };
float const x { 50 };
float const radius { 16 };
float const starting_y { 200 };
NonnullRefPtr<Gfx::Bitmap> falling_bitmap;
NonnullRefPtr<Gfx::Bitmap> flapping_bitmap;
float y {};
@ -81,13 +81,13 @@ public:
void flap()
{
const float flap_strength = 10.0f;
float const flap_strength = 10.0f;
velocity = -flap_strength;
}
void fall()
{
const float gravity = 1.0f;
float const gravity = 1.0f;
velocity += gravity;
}
@ -98,7 +98,7 @@ public:
};
struct Obstacle {
const float width { 20 };
float const width { 20 };
Color color { Color::DarkGray };
float x {};
float gap_top_y { 200 };

View file

@ -23,7 +23,7 @@ public:
void toggle_cell(size_t row, size_t column);
void set_cell(size_t row, size_t column, bool on);
bool cell(size_t row, size_t column) const;
const Vector<Vector<bool>>& cells() const { return m_cells; }
Vector<Vector<bool>> const& cells() const { return m_cells; }
void run_generation();
bool is_stalled() const { return m_stalled; }

View file

@ -45,7 +45,7 @@ public:
Optional<Board::RowAndColumn> get_row_and_column_for_point(int x, int y) const;
void resize_board(size_t rows, size_t columns);
const Board* board() const { return m_board.ptr(); }
Board const* board() const { return m_board.ptr(); }
bool is_running() const { return m_running; }
void set_running(bool r);

View file

@ -23,7 +23,7 @@
#include <LibGUI/Window.h>
#include <LibMain/Main.h>
const char* click_tip = "Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells";
char const* click_tip = "Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells";
ErrorOr<int> serenity_main(Main::Arguments arguments)
{

View file

@ -929,13 +929,13 @@ void Game::dump_state() const
auto& player = m_players[i];
dbgln("Player {}", player.name);
dbgln("Hand:");
for (const auto& card : player.hand)
for (auto const& card : player.hand)
if (card.is_null())
dbgln(" <empty>");
else
dbgln(" {}", *card);
dbgln("Taken:");
for (const auto& card : player.cards_taken)
for (auto const& card : player.cards_taken)
dbgln(" {}", card);
}
}

View file

@ -158,7 +158,7 @@ bool Player::has_card_of_suit(Card::Suit suit)
return matching_card.has_value();
}
void Player::remove_cards(const NonnullRefPtrVector<Card>& cards)
void Player::remove_cards(NonnullRefPtrVector<Card> const& cards)
{
for (auto& card : cards) {
hand.remove_first_matching([&card](auto& other_card) {

View file

@ -122,7 +122,7 @@ private:
void set_flag(Square&, bool);
Square& square(size_t row, size_t column) { return *m_squares[row * columns() + column]; }
const Square& square(size_t row, size_t column) const { return *m_squares[row * columns() + column]; }
Square const& square(size_t row, size_t column) const { return *m_squares[row * columns() + column]; }
void flood_fill(Square&);
void on_square_clicked_impl(Square&, bool);

View file

@ -41,7 +41,7 @@ void SnakeGame::reset()
update();
}
bool SnakeGame::is_available(const Coordinate& coord)
bool SnakeGame::is_available(Coordinate const& coord)
{
for (size_t i = 0; i < m_tail.size(); ++i) {
if (m_tail[i] == coord)
@ -171,7 +171,7 @@ void SnakeGame::keydown_event(GUI::KeyEvent& event)
}
}
Gfx::IntRect SnakeGame::cell_rect(const Coordinate& coord) const
Gfx::IntRect SnakeGame::cell_rect(Coordinate const& coord) const
{
auto game_rect = frame_inner_rect();
auto cell_size = Gfx::IntSize(game_rect.width() / m_columns, game_rect.height() / m_rows);
@ -224,7 +224,7 @@ void SnakeGame::queue_velocity(int v, int h)
m_velocity_queue.enqueue({ v, h });
}
const SnakeGame::Velocity& SnakeGame::last_velocity() const
SnakeGame::Velocity const& SnakeGame::last_velocity() const
{
if (!m_velocity_queue.is_empty())
return m_velocity_queue.last();

View file

@ -29,7 +29,7 @@ private:
int row { 0 };
int column { 0 };
bool operator==(const Coordinate& other) const
bool operator==(Coordinate const& other) const
{
return row == other.row && column == other.column;
}
@ -42,10 +42,10 @@ private:
void game_over();
void spawn_fruit();
bool is_available(const Coordinate&);
bool is_available(Coordinate const&);
void queue_velocity(int v, int h);
const Velocity& last_velocity() const;
Gfx::IntRect cell_rect(const Coordinate&) const;
Velocity const& last_velocity() const;
Gfx::IntRect cell_rect(Coordinate const&) const;
Gfx::IntRect score_rect() const;
Gfx::IntRect high_score_rect() const;

View file

@ -660,7 +660,7 @@ void Game::dump_layout() const
{
if constexpr (SOLITAIRE_DEBUG) {
dbgln("------------------------------");
for (const auto& stack : m_stacks)
for (auto const& stack : m_stacks)
dbgln("{}", stack);
}
}

View file

@ -143,7 +143,7 @@ private:
static constexpr Array piles = { Pile1, Pile2, Pile3, Pile4, Pile5, Pile6, Pile7 };
static constexpr Array foundations = { Foundation1, Foundation2, Foundation3, Foundation4 };
ALWAYS_INLINE const WasteRecycleRules& recycle_rules()
ALWAYS_INLINE WasteRecycleRules const& recycle_rules()
{
static constexpr Array<WasteRecycleRules, 2> rules { {
{ 0, -100 },