style: aplicar checks modernize-* (215 fixes)
Cambios aplicados:
- [[nodiscard]] añadido a funciones que retornan valores
- .starts_with() en lugar de .find() == 0
- Inicializadores designados {.x=0, .y=0}
- auto en castings obvios
- = default para constructores triviales
- Funciones deleted movidas a public
- std::numbers::pi_v<float> (C++20)
Checks excluidos:
- use-trailing-return-type: Estilo controversial
- avoid-c-arrays: Arrays C aceptables en ciertos contextos
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
Bala::Bala(SDL_Renderer* renderer)
|
||||
: renderer_(renderer),
|
||||
centre_({0.0F, 0.0F}),
|
||||
centre_({.x = 0.0F, .y = 0.0F}),
|
||||
angle_(0.0F),
|
||||
velocitat_(0.0F),
|
||||
esta_(false),
|
||||
@@ -33,7 +33,7 @@ Bala::Bala(SDL_Renderer* renderer)
|
||||
void Bala::inicialitzar() {
|
||||
// Inicialment inactiva
|
||||
esta_ = false;
|
||||
centre_ = {0.0F, 0.0F};
|
||||
centre_ = {.x = 0.0F, .y = 0.0F};
|
||||
angle_ = 0.0F;
|
||||
velocitat_ = 0.0F;
|
||||
grace_timer_ = 0.0F;
|
||||
|
||||
@@ -22,10 +22,10 @@ class Bala {
|
||||
void dibuixar() const;
|
||||
|
||||
// Getters (API pública sense canvis)
|
||||
bool esta_activa() const { return esta_; }
|
||||
const Punt& get_centre() const { return centre_; }
|
||||
uint8_t get_owner_id() const { return owner_id_; }
|
||||
float get_grace_timer() const { return grace_timer_; }
|
||||
[[nodiscard]] bool esta_activa() const { return esta_; }
|
||||
[[nodiscard]] const Punt& get_centre() const { return centre_; }
|
||||
[[nodiscard]] uint8_t get_owner_id() const { return owner_id_; }
|
||||
[[nodiscard]] float get_grace_timer() const { return grace_timer_; }
|
||||
void desactivar() { esta_ = false; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
Enemic::Enemic(SDL_Renderer* renderer)
|
||||
: renderer_(renderer),
|
||||
centre_({0.0F, 0.0F}),
|
||||
centre_({.x = 0.0F, .y = 0.0F}),
|
||||
angle_(0.0F),
|
||||
velocitat_(0.0F),
|
||||
drotacio_(0.0F),
|
||||
|
||||
@@ -45,25 +45,25 @@ class Enemic {
|
||||
void dibuixar() const;
|
||||
|
||||
// Getters (API pública sense canvis)
|
||||
bool esta_actiu() const { return esta_; }
|
||||
const Punt& get_centre() const { return centre_; }
|
||||
const std::shared_ptr<Graphics::Shape>& get_forma() const { return forma_; }
|
||||
[[nodiscard]] bool esta_actiu() const { return esta_; }
|
||||
[[nodiscard]] const Punt& get_centre() const { return centre_; }
|
||||
[[nodiscard]] const std::shared_ptr<Graphics::Shape>& get_forma() const { return forma_; }
|
||||
void destruir() { esta_ = false; }
|
||||
float get_brightness() const { return brightness_; }
|
||||
float get_drotacio() const { return drotacio_; }
|
||||
Punt get_velocitat_vector() const {
|
||||
[[nodiscard]] float get_brightness() const { return brightness_; }
|
||||
[[nodiscard]] float get_drotacio() const { return drotacio_; }
|
||||
[[nodiscard]] Punt get_velocitat_vector() const {
|
||||
return {
|
||||
velocitat_ * std::cos(angle_ - (Constants::PI / 2.0F)),
|
||||
velocitat_ * std::sin(angle_ - (Constants::PI / 2.0F))};
|
||||
.x = velocitat_ * std::cos(angle_ - (Constants::PI / 2.0F)),
|
||||
.y = velocitat_ * std::sin(angle_ - (Constants::PI / 2.0F))};
|
||||
}
|
||||
|
||||
// Set ship position reference for tracking behavior
|
||||
void set_ship_position(const Punt* ship_pos) { ship_position_ = ship_pos; }
|
||||
|
||||
// [NEW] Getters for stage system (base stats)
|
||||
float get_base_velocity() const;
|
||||
float get_base_rotation() const;
|
||||
TipusEnemic get_tipus() const { return tipus_; }
|
||||
[[nodiscard]] float get_base_velocity() const;
|
||||
[[nodiscard]] float get_base_rotation() const;
|
||||
[[nodiscard]] TipusEnemic get_tipus() const { return tipus_; }
|
||||
|
||||
// [NEW] Setters for difficulty multipliers (stage system)
|
||||
void set_velocity(float vel) { velocitat_ = vel; }
|
||||
@@ -74,8 +74,8 @@ class Enemic {
|
||||
void set_tracking_strength(float strength);
|
||||
|
||||
// [NEW] Invulnerability queries
|
||||
bool es_invulnerable() const { return timer_invulnerabilitat_ > 0.0F; }
|
||||
float get_temps_invulnerabilitat() const { return timer_invulnerabilitat_; }
|
||||
[[nodiscard]] bool es_invulnerable() const { return timer_invulnerabilitat_ > 0.0F; }
|
||||
[[nodiscard]] float get_temps_invulnerabilitat() const { return timer_invulnerabilitat_; }
|
||||
|
||||
private:
|
||||
SDL_Renderer* renderer_;
|
||||
@@ -116,6 +116,6 @@ class Enemic {
|
||||
void comportament_pentagon(float delta_time);
|
||||
void comportament_quadrat(float delta_time);
|
||||
void comportament_molinillo(float delta_time);
|
||||
float calcular_escala_actual() const; // Returns scale with palpitation applied
|
||||
[[nodiscard]] float calcular_escala_actual() const; // Returns scale with palpitation applied
|
||||
bool intent_spawn_safe(const Punt& ship_pos, float& out_x, float& out_y);
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
Nau::Nau(SDL_Renderer* renderer, const char* shape_file)
|
||||
: renderer_(renderer),
|
||||
centre_({0.0F, 0.0F}),
|
||||
centre_({.x = 0.0F, .y = 0.0F}),
|
||||
angle_(0.0F),
|
||||
velocitat_(0.0F),
|
||||
esta_tocada_(false),
|
||||
|
||||
@@ -23,17 +23,17 @@ class Nau {
|
||||
void dibuixar() const;
|
||||
|
||||
// Getters (API pública sense canvis)
|
||||
const Punt& get_centre() const { return centre_; }
|
||||
float get_angle() const { return angle_; }
|
||||
bool esta_viva() const { return !esta_tocada_; }
|
||||
bool esta_tocada() const { return esta_tocada_; }
|
||||
bool es_invulnerable() const { return invulnerable_timer_ > 0.0F; }
|
||||
const std::shared_ptr<Graphics::Shape>& get_forma() const { return forma_; }
|
||||
float get_brightness() const { return brightness_; }
|
||||
Punt get_velocitat_vector() const {
|
||||
[[nodiscard]] const Punt& get_centre() const { return centre_; }
|
||||
[[nodiscard]] float get_angle() const { return angle_; }
|
||||
[[nodiscard]] bool esta_viva() const { return !esta_tocada_; }
|
||||
[[nodiscard]] bool esta_tocada() const { return esta_tocada_; }
|
||||
[[nodiscard]] bool es_invulnerable() const { return invulnerable_timer_ > 0.0F; }
|
||||
[[nodiscard]] const std::shared_ptr<Graphics::Shape>& get_forma() const { return forma_; }
|
||||
[[nodiscard]] float get_brightness() const { return brightness_; }
|
||||
[[nodiscard]] Punt get_velocitat_vector() const {
|
||||
return {
|
||||
velocitat_ * std::cos(angle_ - (Constants::PI / 2.0F)),
|
||||
velocitat_ * std::sin(angle_ - (Constants::PI / 2.0F))};
|
||||
.x = velocitat_ * std::cos(angle_ - (Constants::PI / 2.0F)),
|
||||
.y = velocitat_ * std::sin(angle_ - (Constants::PI / 2.0F))};
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
||||
Reference in New Issue
Block a user