style: aplicar readability-math-missing-parentheses

- Agregar paréntesis explícitos en operaciones matemáticas para claridad
- Ejemplos: '1.0F - a * b' → '1.0F - (a * b)'
- 291 correcciones aplicadas automáticamente con clang-tidy
- Check 2/N completado

🤖 Generated with Claude Code
This commit is contained in:
2025-12-18 13:09:35 +01:00
parent bc94eff176
commit 76786203a0
20 changed files with 123 additions and 121 deletions

View File

@@ -553,8 +553,8 @@ void EscenaJoc::dibuixar() {
// Calcular centre de l'àrea de joc usant constants
const SDL_FRect& play_area = Defaults::Zones::PLAYAREA;
float centre_x = play_area.x + play_area.w / 2.0F;
float centre_y = play_area.y + play_area.h / 2.0F;
float centre_x = play_area.x + (play_area.w / 2.0F);
float centre_y = play_area.y + (play_area.h / 2.0F);
text_.render_centered(game_over_text, {centre_x, centre_y}, escala, spacing);
@@ -761,7 +761,7 @@ void EscenaJoc::dibuixar_marcador() {
// Calcular centre de la zona del marcador
const SDL_FRect& scoreboard = Defaults::Zones::SCOREBOARD;
float centre_x = scoreboard.w / 2.0F;
float centre_y = scoreboard.y + scoreboard.h / 2.0F;
float centre_y = scoreboard.y + (scoreboard.h / 2.0F);
// Renderitzar centrat
text_.render_centered(text, {centre_x, centre_y}, escala, spacing);
@@ -792,11 +792,11 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const {
float phase1_progress = std::min(eased_progress / PHASE_1_END, 1.0F);
// Línia esquerra: creix des del centre cap a l'esquerra
int x1_phase1 = static_cast<int>(cx - (cx - x1) * phase1_progress);
int x1_phase1 = static_cast<int>(cx - ((cx - x1) * phase1_progress));
Rendering::linea(sdl_.obte_renderer(), cx, y1, x1_phase1, y1, true);
// Línia dreta: creix des del centre cap a la dreta
int x2_phase1 = static_cast<int>(cx + (x2 - cx) * phase1_progress);
int x2_phase1 = static_cast<int>(cx + ((x2 - cx) * phase1_progress));
Rendering::linea(sdl_.obte_renderer(), cx, y1, x2_phase1, y1, true);
}
@@ -805,7 +805,7 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const {
float phase2_progress = std::min((eased_progress - PHASE_1_END) / (PHASE_2_END - PHASE_1_END), 1.0F);
// Línia esquerra: creix des de dalt cap a baix
int y2_phase2 = static_cast<int>(y1 + (y2 - y1) * phase2_progress);
int y2_phase2 = static_cast<int>(y1 + ((y2 - y1) * phase2_progress));
Rendering::linea(sdl_.obte_renderer(), x1, y1, x1, y2_phase2, true);
// Línia dreta: creix des de dalt cap a baix
@@ -817,11 +817,11 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const {
float phase3_progress = (eased_progress - PHASE_2_END) / (1.0F - PHASE_2_END);
// Línia esquerra: creix des de l'esquerra cap al centre
int x_left_phase3 = static_cast<int>(x1 + (cx - x1) * phase3_progress);
int x_left_phase3 = static_cast<int>(x1 + ((cx - x1) * phase3_progress));
Rendering::linea(sdl_.obte_renderer(), x1, y2, x_left_phase3, y2, true);
// Línia dreta: creix des de la dreta cap al centre
int x_right_phase3 = static_cast<int>(x2 - (x2 - cx) * phase3_progress);
int x_right_phase3 = static_cast<int>(x2 - ((x2 - cx) * phase3_progress));
Rendering::linea(sdl_.obte_renderer(), x2, y2, x_right_phase3, y2, true);
}
}
@@ -842,13 +842,13 @@ void EscenaJoc::dibuixar_marcador_animat(float progress) {
// Calcular centre de la zona del marcador
const SDL_FRect& scoreboard = Defaults::Zones::SCOREBOARD;
float centre_x = scoreboard.w / 2.0F;
float centre_y_final = scoreboard.y + scoreboard.h / 2.0F;
float centre_y_final = scoreboard.y + (scoreboard.h / 2.0F);
// Posició Y inicial (offscreen, sota de la pantalla)
float centre_y_inicial = static_cast<float>(Defaults::Game::HEIGHT);
// Interpolació amb easing
float centre_y_animada = centre_y_inicial + (centre_y_final - centre_y_inicial) * eased_progress;
float centre_y_animada = centre_y_inicial + ((centre_y_final - centre_y_inicial) * eased_progress);
// Renderitzar centrat en posició animada
text_.render_centered(text, {centre_x, centre_y_animada}, escala, spacing);
@@ -873,7 +873,7 @@ Punt EscenaJoc::calcular_posicio_nau_init_hud(float progress, uint8_t player_id)
// X no canvia (destí segons player_id)
// Y interpola amb easing
float y_animada = y_inicial + (y_final - y_inicial) * eased_progress;
float y_animada = y_inicial + ((y_final - y_inicial) * eased_progress);
return {x_final, y_animada};
}
@@ -971,7 +971,7 @@ void EscenaJoc::detectar_col·lisions_bales_enemics() {
// Calcular distància quadrada (evita sqrt)
float dx = pos_bala.x - pos_enemic.x;
float dy = pos_bala.y - pos_enemic.y;
float distancia_quadrada = dx * dx + dy * dy;
float distancia_quadrada = (dx * dx) + (dy * dy);
// Comprovar col·lisió
if (distancia_quadrada <= SUMA_RADIS_QUADRAT) {
@@ -1058,7 +1058,7 @@ void EscenaJoc::detectar_col·lisio_naus_enemics() {
// Calculate squared distance (avoid sqrt)
float dx = static_cast<float>(pos_nau.x - pos_enemic.x);
float dy = static_cast<float>(pos_nau.y - pos_enemic.y);
float distancia_quadrada = dx * dx + dy * dy;
float distancia_quadrada = (dx * dx) + (dy * dy);
// Check collision
if (distancia_quadrada <= SUMA_RADIS_QUADRAT) {
@@ -1113,7 +1113,7 @@ void EscenaJoc::detectar_col·lisions_bales_jugadors() {
// Calculate squared distance (avoid sqrt)
float dx = pos_bala.x - pos_nau.x;
float dy = pos_bala.y - pos_nau.y;
float distancia_quadrada = dx * dx + dy * dy;
float distancia_quadrada = (dx * dx) + (dy * dy);
// Check collision
if (distancia_quadrada <= SUMA_RADIS_QUADRAT) {
@@ -1203,7 +1203,7 @@ void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) {
float text_height = text_.get_text_height(escala);
// Calculate position as if FULL text was there (for fixed position typewriter)
float x = play_area.x + (play_area.w - full_text_width) / 2.0F;
float x = play_area.x + ((play_area.w - full_text_width) / 2.0F);
float y = play_area.y + (play_area.h * Defaults::Game::STAGE_MESSAGE_Y_RATIO) - (text_height / 2.0F);
// Render only the partial message (typewriter effect)
@@ -1230,8 +1230,8 @@ Punt EscenaJoc::obtenir_punt_spawn(uint8_t player_id) const {
}
return {
zona.x + zona.w * x_ratio,
zona.y + zona.h * Defaults::Game::SPAWN_Y_RATIO};
zona.x + (zona.w * x_ratio),
zona.y + (zona.h * Defaults::Game::SPAWN_Y_RATIO)};
}
void EscenaJoc::disparar_bala(uint8_t player_id) {
@@ -1247,8 +1247,8 @@ void EscenaJoc::disparar_bala(uint8_t player_id) {
constexpr float LOCAL_TIP_Y = -12.0F;
float cos_a = std::cos(ship_angle);
float sin_a = std::sin(ship_angle);
float tip_x = LOCAL_TIP_X * cos_a - LOCAL_TIP_Y * sin_a + ship_centre.x;
float tip_y = LOCAL_TIP_X * sin_a + LOCAL_TIP_Y * cos_a + ship_centre.y;
float tip_x = (LOCAL_TIP_X * cos_a) - (LOCAL_TIP_Y * sin_a) + ship_centre.x;
float tip_y = (LOCAL_TIP_X * sin_a) + (LOCAL_TIP_Y * cos_a) + ship_centre.y;
Punt posicio_dispar = {tip_x, tip_y};
// Buscar primera bala inactiva en el pool del jugador
@@ -1380,8 +1380,8 @@ void EscenaJoc::dibuixar_continue() {
float escala_continue = Defaults::Game::ContinueScreen::CONTINUE_TEXT_SCALE;
float y_ratio_continue = Defaults::Game::ContinueScreen::CONTINUE_TEXT_Y_RATIO;
float centre_x = play_area.x + play_area.w / 2.0F;
float centre_y_continue = play_area.y + play_area.h * y_ratio_continue;
float centre_x = play_area.x + (play_area.w / 2.0F);
float centre_y_continue = play_area.y + (play_area.h * y_ratio_continue);
text_.render_centered(continue_text, {centre_x, centre_y_continue}, escala_continue, spacing);
@@ -1390,7 +1390,7 @@ void EscenaJoc::dibuixar_continue() {
float escala_counter = Defaults::Game::ContinueScreen::COUNTER_TEXT_SCALE;
float y_ratio_counter = Defaults::Game::ContinueScreen::COUNTER_TEXT_Y_RATIO;
float centre_y_counter = play_area.y + play_area.h * y_ratio_counter;
float centre_y_counter = play_area.y + (play_area.h * y_ratio_counter);
text_.render_centered(counter_str, {centre_x, centre_y_counter}, escala_counter, spacing);
@@ -1400,7 +1400,7 @@ void EscenaJoc::dibuixar_continue() {
float escala_info = Defaults::Game::ContinueScreen::INFO_TEXT_SCALE;
float y_ratio_info = Defaults::Game::ContinueScreen::INFO_TEXT_Y_RATIO;
float centre_y_info = play_area.y + play_area.h * y_ratio_info;
float centre_y_info = play_area.y + (play_area.h * y_ratio_info);
text_.render_centered(continues_text, {centre_x, centre_y_info}, escala_info, spacing);
}