Lint: rename públicos al inglés + refactor cognitive-complexity + unused-includes
Identifier-naming: rename de métodos públicos y cross-file al inglés
(camelBack), traducción de campos y locales en el proceso (TitleShip,
StageManager, SpawnController, ShipAnimator, helpers de PlayArea, etc.).
Refactor por cognitive-complexity (>25): GameScene::draw (59→3) con 9
helpers de estado, PhysicsWorld::resolveBodyCollisions (35→5) extrayendo
resolveBodyPair, Options::load{Window,Physics,Audio}ConfigFromYaml
(32/49/57→5/2/3) con templates readField, TitleScene::update (68→4) con
5 sub-pasos por estado + handleSkipInput/handleStartInput +
triggerExitForJoinedPlayers, DebrisManager::explode (39→3) con
extractSegments/spawnDebris/applyAngularVelocity/applyVisualRotation.
use-anyofallof: bucles → std::ranges::any_of/all_of en Input,
ShipAnimator y SpawnController.
readability-static-accessed-through-instance: Director::run y
VectorText::getTextWidth/Height invocados por clase.
readability-convert-member-functions-to-static: ResourcePack::decryptData.
unused-includes: eliminación de <utility>, <cstdint>, <vector>,
<iostream>, defaults.hpp y otros no usados directamente en headers y
unidades de traducción. Restablecido core/defaults.hpp en title_scene.cpp
(falsa "unused" del header).
Bug fix: eliminado isActive() duplicado en Bullet (redeclaración tras
rename de esta_activa→isActive que chocaba con el override de Entity).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -37,11 +37,11 @@ class Shape {
|
||||
auto parseFile(const std::string& contingut) -> bool;
|
||||
|
||||
// Getters
|
||||
[[nodiscard]] auto get_primitives() const -> const std::vector<ShapePrimitive>& {
|
||||
[[nodiscard]] auto getPrimitives() const -> const std::vector<ShapePrimitive>& {
|
||||
return primitives_;
|
||||
}
|
||||
[[nodiscard]] auto getCenter() const -> const Vec2& { return center_; }
|
||||
[[nodiscard]] auto get_escala_defecte() const -> float { return escala_defecte_; }
|
||||
[[nodiscard]] auto getDefaultScale() const -> float { return escala_defecte_; }
|
||||
[[nodiscard]] auto isValid() const -> bool { return !primitives_.empty(); }
|
||||
|
||||
// Info de depuració
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
namespace Graphics {
|
||||
|
||||
// Inicialización de variables estàtiques
|
||||
std::unordered_map<std::string, std::shared_ptr<Shape>> ShapeLoader::cache_;
|
||||
std::string ShapeLoader::base_path_ = "data/shapes/";
|
||||
std::unordered_map<std::string, std::shared_ptr<Shape>> ShapeLoader::cache;
|
||||
|
||||
auto ShapeLoader::load(const std::string& filename) -> std::shared_ptr<Shape> {
|
||||
// Check cache first
|
||||
auto it = cache_.find(filename);
|
||||
if (it != cache_.end()) {
|
||||
auto it = cache.find(filename);
|
||||
if (it != cache.end()) {
|
||||
std::cout << "[ShapeLoader] Cache hit: " << filename << '\n';
|
||||
return it->second; // Cache hit
|
||||
}
|
||||
@@ -56,17 +55,17 @@ auto ShapeLoader::load(const std::string& filename) -> std::shared_ptr<Shape> {
|
||||
std::cout << "[ShapeLoader] Carregat: " << normalized << " (" << shape->getName()
|
||||
<< ", " << shape->getNumPrimitives() << " primitives)" << '\n';
|
||||
|
||||
cache_[filename] = shape;
|
||||
cache[filename] = shape;
|
||||
return shape;
|
||||
}
|
||||
|
||||
void ShapeLoader::clear_cache() {
|
||||
std::cout << "[ShapeLoader] Netejant caché (" << cache_.size() << " formes)"
|
||||
void ShapeLoader::clearCache() {
|
||||
std::cout << "[ShapeLoader] Netejant caché (" << cache.size() << " formes)"
|
||||
<< '\n';
|
||||
cache_.clear();
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
auto ShapeLoader::get_cache_size() -> size_t { return cache_.size(); }
|
||||
auto ShapeLoader::getCacheSize() -> size_t { return cache.size(); }
|
||||
|
||||
auto ShapeLoader::resolvePath(const std::string& filename) -> std::string {
|
||||
// Si es un path absolut (comença con '/'), usar-lo directament
|
||||
@@ -75,12 +74,12 @@ auto ShapeLoader::resolvePath(const std::string& filename) -> std::string {
|
||||
}
|
||||
|
||||
// Si ya conté el prefix base_path, usar-lo directament
|
||||
if (filename.starts_with(base_path_)) {
|
||||
if (filename.starts_with(BASE_PATH)) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
// Altrament, añadir base_path (ara suporta subdirectoris)
|
||||
return base_path_ + filename;
|
||||
return std::string(BASE_PATH) + filename;
|
||||
}
|
||||
|
||||
} // namespace Graphics
|
||||
|
||||
@@ -23,14 +23,14 @@ class ShapeLoader {
|
||||
static auto load(const std::string& filename) -> std::shared_ptr<Shape>;
|
||||
|
||||
// Netejar caché (útil per debug/recàrrega)
|
||||
static void clear_cache();
|
||||
static void clearCache();
|
||||
|
||||
// Estadístiques (debug)
|
||||
static auto get_cache_size() -> size_t;
|
||||
static auto getCacheSize() -> size_t;
|
||||
|
||||
private:
|
||||
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache_;
|
||||
static std::string base_path_; // "data/shapes/"
|
||||
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache;
|
||||
static constexpr const char* BASE_PATH = "data/shapes/";
|
||||
|
||||
// Helpers privats
|
||||
static auto resolvePath(const std::string& filename) -> std::string;
|
||||
|
||||
@@ -137,7 +137,7 @@ void Starfield::update(float delta_time) {
|
||||
}
|
||||
|
||||
// Establir multiplicador de brightness
|
||||
void Starfield::set_brightness(float multiplier) {
|
||||
void Starfield::setBrightness(float multiplier) {
|
||||
multiplicador_brightness_ = std::max(0.0F, multiplier); // Evitar valors negatius
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ void Starfield::draw() {
|
||||
float brightness = computeBrightness(estrella);
|
||||
|
||||
// Renderizar estrella sin rotación
|
||||
Rendering::render_shape(
|
||||
Rendering::renderShape(
|
||||
renderer_,
|
||||
shape_estrella_,
|
||||
estrella.position,
|
||||
|
||||
@@ -43,8 +43,8 @@ class Starfield {
|
||||
void draw();
|
||||
|
||||
// Setters per ajustar parámetros en time real
|
||||
void set_punt_fuga(const Vec2& point) { punt_fuga_ = point; }
|
||||
void set_brightness(float multiplier);
|
||||
void setVanishingPoint(const Vec2& point) { punt_fuga_ = point; }
|
||||
void setBrightness(float multiplier);
|
||||
|
||||
private:
|
||||
// Estructura interna per cada estrella
|
||||
|
||||
@@ -175,7 +175,7 @@ auto VectorText::getShapeFilename(char c) -> std::string {
|
||||
}
|
||||
}
|
||||
|
||||
auto VectorText::is_supported(char c) const -> bool {
|
||||
auto VectorText::isSupported(char c) const -> bool {
|
||||
return chars_.contains(c);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ void VectorText::render(const std::string& text, const Vec2& position, float sca
|
||||
// Ajustar X e Y para que position represente esquina superior izquierda
|
||||
// (render_shape espera el centro, así que sumamos la mitad de ancho y altura)
|
||||
Vec2 char_pos = {.x = current_x + (CHAR_WIDTH_SCALED / 2.0F), .y = position.y + (CHAR_HEIGHT_SCALED / 2.0F)};
|
||||
Rendering::render_shape(renderer_, it->second, char_pos, 0.0F, scale, 1.0F, brightness);
|
||||
Rendering::renderShape(renderer_, it->second, char_pos, 0.0F, scale, 1.0F, brightness);
|
||||
|
||||
// Avanzar posición
|
||||
current_x += CHAR_WIDTH_SCALED + SPACING_SCALED;
|
||||
@@ -236,8 +236,8 @@ void VectorText::render(const std::string& text, const Vec2& position, float sca
|
||||
|
||||
void VectorText::renderCentered(const std::string& text, const Vec2& centre_punt, float scale, float spacing, float brightness) const {
|
||||
// Calcular dimensions del text
|
||||
float text_width = get_text_width(text, scale, spacing);
|
||||
float text_height = get_text_height(scale);
|
||||
float text_width = getTextWidth(text, scale, spacing);
|
||||
float text_height = getTextHeight(scale);
|
||||
|
||||
// Calcular posición de l'esquina superior izquierda
|
||||
// restant la meitat de las dimensions del point central
|
||||
@@ -249,7 +249,7 @@ void VectorText::renderCentered(const std::string& text, const Vec2& centre_punt
|
||||
render(text, posicio_esquerra, scale, spacing, brightness);
|
||||
}
|
||||
|
||||
auto VectorText::get_text_width(const std::string& text, float scale, float spacing) -> float {
|
||||
auto VectorText::getTextWidth(const std::string& text, float scale, float spacing) -> float {
|
||||
if (text.empty()) {
|
||||
return 0.0F;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ auto VectorText::get_text_width(const std::string& text, float scale, float spac
|
||||
return (visual_chars * CHAR_WIDTH_SCALED) + ((visual_chars - 1) * SPACING_SCALED);
|
||||
}
|
||||
|
||||
auto VectorText::get_text_height(float scale) -> float {
|
||||
auto VectorText::getTextHeight(float scale) -> float {
|
||||
return BASE_CHAR_HEIGHT * scale;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ class VectorText {
|
||||
// Calcular ancho total de un string (útil para centrado).
|
||||
// Es estático: no depende del estado del VectorText (el ancho viene de
|
||||
// las constantes BASE_CHAR_WIDTH/BASE_CHAR_HEIGHT del archivo .cpp).
|
||||
[[nodiscard]] static auto get_text_width(const std::string& text, float scale = 1.0F, float spacing = 2.0F) -> float;
|
||||
[[nodiscard]] static auto getTextWidth(const std::string& text, float scale = 1.0F, float spacing = 2.0F) -> float;
|
||||
|
||||
// Calcular altura del texto (útil para centrado vertical).
|
||||
[[nodiscard]] static auto get_text_height(float scale = 1.0F) -> float;
|
||||
[[nodiscard]] static auto getTextHeight(float scale = 1.0F) -> float;
|
||||
|
||||
// Verificar si un carácter está soportado
|
||||
[[nodiscard]] auto is_supported(char c) const -> bool;
|
||||
[[nodiscard]] auto isSupported(char c) const -> bool;
|
||||
|
||||
private:
|
||||
Rendering::Renderer* renderer_;
|
||||
|
||||
Reference in New Issue
Block a user