Lint: convert-member-functions-to-static (20 hits)
Métodos privados que no consultan estado de la instancia pasan a 'static' en la declaración del header. Las definiciones en el .cpp pierden el 'const' trailing (incompatible con static). Cero callsites afectados: las llamadas via 'this->method()' o sin qualifier siguen siendo válidas para métodos estáticos. Aplicado en: - Shape: trim, startsWith, extractValue, parsePoints. - VectorText: getShapeFilename, get_text_width, get_text_height. - Pack: readFile, calculateChecksum, encryptData. - DebrisManager: computeExplosionDirection. - Enemy: attemptSafeSpawn. - LogoScene / TitleScene: checkSkipButtonPressed (consulta Input singleton). - SpawnController: get_enemics_vius. - StageManager: processPlaying. - ShipAnimator: updateEntering, updateFloating, updateExiting, configureShipP1, configureShipP2, computeOffscreenPosition. - Director: run (los miembros executable_path_ / system_folder_ se fijan en el ctor y no se vuelven a leer en el loop principal). Verificado previamente con grep que ningún '&Class::method' los usa como function pointer (cambiar a estático cambiaría su tipo). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -89,7 +89,7 @@ auto Shape::parseFile(const std::string& contingut) -> bool {
|
||||
}
|
||||
|
||||
// Helper: trim whitespace
|
||||
auto Shape::trim(const std::string& str) const -> std::string {
|
||||
auto Shape::trim(const std::string& str) -> std::string {
|
||||
const char* whitespace = " \t\n\r";
|
||||
size_t start = str.find_first_not_of(whitespace);
|
||||
if (start == std::string::npos) {
|
||||
@@ -102,7 +102,7 @@ auto Shape::trim(const std::string& str) const -> std::string {
|
||||
|
||||
// Helper: startsWith
|
||||
auto Shape::startsWith(const std::string& str,
|
||||
const std::string& prefix) const -> bool {
|
||||
const std::string& prefix) -> bool {
|
||||
if (str.length() < prefix.length()) {
|
||||
return false;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ auto Shape::startsWith(const std::string& str,
|
||||
}
|
||||
|
||||
// Helper: extract value after ':'
|
||||
auto Shape::extractValue(const std::string& line) const -> std::string {
|
||||
auto Shape::extractValue(const std::string& line) -> std::string {
|
||||
size_t colon = line.find(':');
|
||||
if (colon == std::string::npos) {
|
||||
return "";
|
||||
@@ -134,7 +134,7 @@ void Shape::parseCenter(const std::string& value) {
|
||||
}
|
||||
|
||||
// Helper: parse points "x1,y1 x2,y2 x3,y3"
|
||||
auto Shape::parsePoints(const std::string& str) const -> std::vector<Vec2> {
|
||||
auto Shape::parsePoints(const std::string& str) -> std::vector<Vec2> {
|
||||
std::vector<Vec2> points;
|
||||
std::istringstream iss(trim(str));
|
||||
std::string pair;
|
||||
|
||||
@@ -55,12 +55,13 @@ class Shape {
|
||||
// que el ctor por defecto no deje el campo indeterminado.
|
||||
std::string nom_; // Nom de la shape (per depuració)
|
||||
|
||||
// Helpers privats per parsejar
|
||||
[[nodiscard]] auto trim(const std::string& str) const -> std::string;
|
||||
[[nodiscard]] auto startsWith(const std::string& str, const std::string& prefix) const -> bool;
|
||||
[[nodiscard]] auto extractValue(const std::string& line) const -> std::string;
|
||||
// Helpers privats per parsejar. Son estáticos: no necesitan estado
|
||||
// de instancia, trabajan sobre el string pasado por parámetro.
|
||||
[[nodiscard]] static auto trim(const std::string& str) -> std::string;
|
||||
[[nodiscard]] static auto startsWith(const std::string& str, const std::string& prefix) -> bool;
|
||||
[[nodiscard]] static auto extractValue(const std::string& line) -> std::string;
|
||||
void parseCenter(const std::string& value);
|
||||
[[nodiscard]] auto parsePoints(const std::string& str) const -> std::vector<Vec2>;
|
||||
[[nodiscard]] static auto parsePoints(const std::string& str) -> std::vector<Vec2>;
|
||||
};
|
||||
|
||||
} // namespace Graphics
|
||||
|
||||
@@ -79,7 +79,7 @@ void VectorText::loadCharset() {
|
||||
<< '\n';
|
||||
}
|
||||
|
||||
auto VectorText::getShapeFilename(char c) const -> std::string {
|
||||
auto VectorText::getShapeFilename(char c) -> std::string {
|
||||
// Mapeo carácter → nombre de archivo (con prefix "font/").
|
||||
// Dígitos 0-9 y mayúsculas A-Z comparten el mismo path: la shape se llama
|
||||
// como el caracter mismo, así que se agrupan en un único case.
|
||||
@@ -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) const -> float {
|
||||
auto VectorText::get_text_width(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) const -> float {
|
||||
auto VectorText::get_text_height(float scale) -> float {
|
||||
return BASE_CHAR_HEIGHT * scale;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,13 @@ class VectorText {
|
||||
// - brightness: factor de brightness (0.0-1.0, default 1.0 = màxima brightness)
|
||||
void renderCentered(const std::string& text, const Vec2& centre_punt, float scale = 1.0F, float spacing = 2.0F, float brightness = 1.0F) const;
|
||||
|
||||
// Calcular ancho total de un string (útil para centrado)
|
||||
[[nodiscard]] auto get_text_width(const std::string& text, float scale = 1.0F, float spacing = 2.0F) const -> float;
|
||||
// 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;
|
||||
|
||||
// Calcular altura del texto (útil para centrado vertical)
|
||||
[[nodiscard]] auto get_text_height(float scale = 1.0F) const -> float;
|
||||
// Calcular altura del texto (útil para centrado vertical).
|
||||
[[nodiscard]] static auto get_text_height(float scale = 1.0F) -> float;
|
||||
|
||||
// Verificar si un carácter está soportado
|
||||
[[nodiscard]] auto is_supported(char c) const -> bool;
|
||||
@@ -51,7 +53,7 @@ class VectorText {
|
||||
std::unordered_map<char, std::shared_ptr<Shape>> chars_;
|
||||
|
||||
void loadCharset();
|
||||
[[nodiscard]] auto getShapeFilename(char c) const -> std::string;
|
||||
[[nodiscard]] static auto getShapeFilename(char c) -> std::string;
|
||||
};
|
||||
|
||||
} // namespace Graphics
|
||||
|
||||
Reference in New Issue
Block a user