style: aplicar todos los checks readability-* (225 fixes)
Cambios aplicados: - readability-braces-around-statements (añadir llaves en ifs/fors) - readability-implicit-bool-conversion (puntero → bool explícito) - readability-container-size-empty (.empty() en lugar de .size()==0) - readability-container-contains (.contains() C++20) - readability-make-member-function-const (métodos const) - readability-else-after-return (5 casos adicionales) - Añadido #include <cmath> en defaults.hpp Checks excluidos (justificados): - identifier-naming: Cascada de 300+ cambios - identifier-length: Nombres cortos son OK en este proyecto - magic-numbers: Demasiados falsos positivos - convert-member-functions-to-static: Rompe encapsulación - use-anyofallof: C++20 ranges no universal - function-cognitive-complexity: Complejidad aceptable - clang-analyzer-security.insecureAPI.rand: rand() suficiente para juegos
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "escena_joc.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
@@ -76,9 +77,7 @@ void EscenaJoc::executar() {
|
||||
last_time = current_time;
|
||||
|
||||
// Limitar delta_time per evitar grans salts
|
||||
if (delta_time > 0.05F) {
|
||||
delta_time = 0.05F;
|
||||
}
|
||||
delta_time = std::min(delta_time, 0.05F);
|
||||
|
||||
// Actualitzar comptador de FPS
|
||||
sdl_.updateFPS(delta_time);
|
||||
@@ -1036,9 +1035,15 @@ void EscenaJoc::detectar_col·lisio_naus_enemics() {
|
||||
// Check collision for BOTH players
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
// Skip collisions if player is dead or invulnerable
|
||||
if (itocado_per_jugador_[i] > 0.0F) continue;
|
||||
if (!naus_[i].esta_viva()) continue;
|
||||
if (naus_[i].es_invulnerable()) continue;
|
||||
if (itocado_per_jugador_[i] > 0.0F) {
|
||||
continue;
|
||||
}
|
||||
if (!naus_[i].esta_viva()) {
|
||||
continue;
|
||||
}
|
||||
if (naus_[i].es_invulnerable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Punt& pos_nau = naus_[i].get_centre();
|
||||
|
||||
@@ -1099,14 +1104,22 @@ void EscenaJoc::detectar_col·lisions_bales_jugadors() {
|
||||
// Check collision with BOTH players
|
||||
for (uint8_t player_id = 0; player_id < 2; player_id++) {
|
||||
// Skip if player is dead, invulnerable, or inactive
|
||||
if (itocado_per_jugador_[player_id] > 0.0F) continue;
|
||||
if (!naus_[player_id].esta_viva()) continue;
|
||||
if (naus_[player_id].es_invulnerable()) continue;
|
||||
if (itocado_per_jugador_[player_id] > 0.0F) {
|
||||
continue;
|
||||
}
|
||||
if (!naus_[player_id].esta_viva()) {
|
||||
continue;
|
||||
}
|
||||
if (naus_[player_id].es_invulnerable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip inactive players
|
||||
bool jugador_actiu = (player_id == 0) ? config_partida_.jugador1_actiu
|
||||
: config_partida_.jugador2_actiu;
|
||||
if (!jugador_actiu) continue;
|
||||
if (!jugador_actiu) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Punt& pos_nau = naus_[player_id].get_centre();
|
||||
|
||||
@@ -1236,8 +1249,12 @@ Punt EscenaJoc::obtenir_punt_spawn(uint8_t player_id) const {
|
||||
|
||||
void EscenaJoc::disparar_bala(uint8_t player_id) {
|
||||
// Verificar que el jugador está vivo
|
||||
if (itocado_per_jugador_[player_id] > 0.0F) return;
|
||||
if (!naus_[player_id].esta_viva()) return;
|
||||
if (itocado_per_jugador_[player_id] > 0.0F) {
|
||||
return;
|
||||
}
|
||||
if (!naus_[player_id].esta_viva()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calcular posición en la punta de la nave
|
||||
const Punt& ship_centre = naus_[player_id].get_centre();
|
||||
|
||||
Reference in New Issue
Block a user