clang-tidy modernize

This commit is contained in:
2025-07-20 12:51:24 +02:00
parent bfda842d3c
commit 1f0184fde2
74 changed files with 658 additions and 665 deletions

View File

@@ -1,9 +1,9 @@
#include "game.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget
#include <stdlib.h> // Para rand, size_t
#include <algorithm> // Para find_if, clamp, find, min
#include <cstdlib> // Para rand, size_t
#include <functional> // Para function
#include <iterator> // Para distance, size
@@ -399,7 +399,7 @@ void Game::destroyAllItems() {
}
// Comprueba la colisión entre el jugador y los globos activos
std::shared_ptr<Balloon> Game::checkPlayerBalloonCollision(std::shared_ptr<Player> &player) {
auto Game::checkPlayerBalloonCollision(std::shared_ptr<Player> &player) -> std::shared_ptr<Balloon> {
for (auto &balloon : balloon_manager_->getBalloons()) {
if (!balloon->isInvulnerable() && !balloon->isPowerBall()) {
if (checkCollision(player->getCollider(), balloon->getCollider())) {
@@ -594,7 +594,7 @@ void Game::renderItems() {
}
// Devuelve un item al azar y luego segun sus probabilidades
ItemType Game::dropItem() {
auto Game::dropItem() -> ItemType {
const auto LUCKY_NUMBER = rand() % 100;
const auto ITEM = rand() % 6;
@@ -960,8 +960,8 @@ void Game::initPaths() {
const int X1 = param.game.play_area.center_x - W / 2;
const int X2 = param.game.play_area.rect.w;
const int Y = param.game.play_area.center_y;
paths_.emplace_back(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 20));
paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0));
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 20);
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
}
// Recorrido para el texto de "Last Stage!" o de "X stages left" o "Game Over" (2,3)
@@ -972,8 +972,8 @@ void Game::initPaths() {
const int Y1 = param.game.play_area.center_y - H / 2;
const int Y2 = -H;
const int X = param.game.play_area.center_x;
paths_.emplace_back(Path(createPath(Y0, Y1, PathType::VERTICAL, X, 80, easeOutQuint), 20));
paths_.emplace_back(Path(createPath(Y1, Y2, PathType::VERTICAL, X, 80, easeInQuint), 0));
paths_.emplace_back(createPath(Y0, Y1, PathType::VERTICAL, X, 80, easeOutQuint), 20);
paths_.emplace_back(createPath(Y1, Y2, PathType::VERTICAL, X, 80, easeInQuint), 0);
}
// Recorrido para el texto de "Congratulations!!" (3,4)
@@ -985,8 +985,8 @@ void Game::initPaths() {
const int X1 = param.game.play_area.center_x - W / 2;
const int X2 = param.game.play_area.rect.w;
const int Y = param.game.play_area.center_y - H / 2 - 20;
paths_.emplace_back(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400));
paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0));
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400);
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
}
// Recorrido para el texto de "1.000.000 points!" (5,6)
@@ -998,8 +998,8 @@ void Game::initPaths() {
const int X1 = param.game.play_area.center_x - W / 2;
const int X2 = -W;
const int Y = param.game.play_area.center_y + H / 2 - 20;
paths_.emplace_back(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400));
paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0));
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400);
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
}
}
@@ -1021,7 +1021,7 @@ void Game::updateHelper() {
}
// Comprueba si todos los jugadores han terminado de jugar
bool Game::allPlayersAreWaitingOrGameOver() {
auto Game::allPlayersAreWaitingOrGameOver() -> bool {
auto success = true;
for (const auto &player : players_)
success &= player->isWaiting() || player->isGameOver();
@@ -1030,7 +1030,7 @@ bool Game::allPlayersAreWaitingOrGameOver() {
}
// Comprueba si todos los jugadores han terminado de jugar
bool Game::allPlayersAreGameOver() {
auto Game::allPlayersAreGameOver() -> bool {
auto success = true;
for (const auto &player : players_)
success &= player->isGameOver();
@@ -1039,7 +1039,7 @@ bool Game::allPlayersAreGameOver() {
}
// Comprueba si todos los jugadores han terminado de jugar
bool Game::allPlayersAreNotPlaying() {
auto Game::allPlayersAreNotPlaying() -> bool {
auto success = true;
for (const auto &player : players_)
success &= !player->isPlaying();
@@ -1131,7 +1131,7 @@ void Game::checkPlayersStatusPlaying() {
}
// Obtiene un jugador a partir de su "id"
std::shared_ptr<Player> Game::getPlayer(int id) {
auto Game::getPlayer(int id) -> std::shared_ptr<Player> {
auto it = std::find_if(players_.begin(), players_.end(), [id](const auto &player) { return player->getId() == id; });
if (it != players_.end()) {
@@ -1141,7 +1141,7 @@ std::shared_ptr<Player> Game::getPlayer(int id) {
}
// Obtiene un controlador a partir del "id" del jugador
int Game::getController(int player_id) {
auto Game::getController(int player_id) -> int {
auto it = std::find_if(Options::controllers.begin(), Options::controllers.end(), [player_id](const auto &controller) { return controller.player_id == player_id; });
if (it != Options::controllers.end()) {