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:
@@ -33,7 +33,7 @@ static Punt transform_point(const Punt& point, const Punt& shape_centre, const P
|
||||
float rotated_y = (scaled_x * sin_a) + (scaled_y * cos_a);
|
||||
|
||||
// 4. Aplicar trasllació a posició mundial
|
||||
return {rotated_x + posicio.x, rotated_y + posicio.y};
|
||||
return {.x = rotated_x + posicio.x, .y = rotated_y + posicio.y};
|
||||
}
|
||||
|
||||
DebrisManager::DebrisManager(SDL_Renderer* renderer)
|
||||
@@ -72,12 +72,12 @@ void DebrisManager::explotar(const std::shared_ptr<Graphics::Shape>& shape,
|
||||
if (primitive.type == Graphics::PrimitiveType::POLYLINE) {
|
||||
// Polyline: extreure segments consecutius
|
||||
for (size_t i = 0; i < primitive.points.size() - 1; i++) {
|
||||
segments.push_back({primitive.points[i], primitive.points[i + 1]});
|
||||
segments.emplace_back(primitive.points[i], primitive.points[i + 1]);
|
||||
}
|
||||
} else { // PrimitiveType::LINE
|
||||
// Line: un únic segment
|
||||
if (primitive.points.size() >= 2) {
|
||||
segments.push_back({primitive.points[0], primitive.points[1]});
|
||||
segments.emplace_back(primitive.points[0], primitive.points[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,8 +271,8 @@ void DebrisManager::actualitzar(float delta_time) {
|
||||
}
|
||||
|
||||
// 3. Calcular centre del segment
|
||||
Punt centre = {(debris.p1.x + debris.p2.x) / 2.0F,
|
||||
(debris.p1.y + debris.p2.y) / 2.0F};
|
||||
Punt centre = {.x = (debris.p1.x + debris.p2.x) / 2.0F,
|
||||
.y = (debris.p1.y + debris.p2.y) / 2.0F};
|
||||
|
||||
// 4. Actualitzar posició del centre
|
||||
centre.x += debris.velocitat.x * delta_time;
|
||||
@@ -346,7 +346,7 @@ Punt DebrisManager::calcular_direccio_explosio(const Punt& p1,
|
||||
// Segment al centre (cas extrem molt improbable), retornar direcció aleatòria
|
||||
float angle_rand =
|
||||
(std::rand() / static_cast<float>(RAND_MAX)) * 2.0F * Defaults::Math::PI;
|
||||
return {std::cos(angle_rand), std::sin(angle_rand)};
|
||||
return {.x = std::cos(angle_rand), .y = std::sin(angle_rand)};
|
||||
}
|
||||
|
||||
dx /= length;
|
||||
@@ -362,7 +362,7 @@ Punt DebrisManager::calcular_direccio_explosio(const Punt& p1,
|
||||
float final_x = (dx * cos_v) - (dy * sin_v);
|
||||
float final_y = (dx * sin_v) + (dy * cos_v);
|
||||
|
||||
return {final_x, final_y};
|
||||
return {.x = final_x, .y = final_y};
|
||||
}
|
||||
|
||||
void DebrisManager::reiniciar() {
|
||||
|
||||
Reference in New Issue
Block a user