refactor(core/rendering): esborrar codi mort a Sprite/Surface i inline Sprite::update (DEAD-04/-05/-07/-08/-10 + PATCH-04)

Eliminats mètodes sense callers:
- Sprite::getRect() (DEAD-04)
- Sprite::incX / incY (DEAD-05)
- AnimatedSprite::getCurrentAnimationSize() (DEAD-07)
- Surface::getSurfaceData() (DEAD-08)

Sprite::update passa a ser virtual amb cos buit inline al header, en
lloc de la definició a .cpp amb (void)delta_time; desapareix una línia
de "parxejament" sense alterar la polimorfia (Player::update, heretat
via AnimatedSprite/MovingSprite, continua fent override correctament).
Això tanca DEAD-10 i PATCH-04 alhora.

Els ctors per defecte Sprite()/MovingSprite() s'apunten com WONTFIX al
document: són necessaris per a la cadena de construcció base d'Animated
Sprite (que no delega explícitament al ctor parametritzat).

Build + smoke 5s xvfb OK (exit 124).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
JailDesignerandClaude Opus 4.7 committed 2026-04-20 09:43:39 +02:00
1 parent b51109e380
commit 597402aa1b
5 files changed
+13 -19

No files matched your search

@@ -27,7 +27,6 @@ class AnimatedSprite : public MovingSprite {
void update(float delta_time) override;
auto animationIsCompleted() -> bool;
auto getCurrentAnimationSize() -> int { return static_cast<int>(animations_[current_animation_].frames.size()); }
void setCurrentAnimation(const std::string& name = "default");
void setCurrentAnimation(int index = 0);
-4
View File
@@ -43,7 +43,3 @@ void Sprite::clear() {
pos_ = {.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F};
clip_ = {.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F};
}
void Sprite::update(float delta_time) {
(void)delta_time;
}
+3 -4
View File
@@ -16,7 +16,9 @@ class Sprite {
virtual ~Sprite() = default;
virtual void update(float delta_time);
// Hook d'actualització per frame. Base buida (no hi ha Sprite pur a
// actualitzar); les subclasses mòbils/animades fan override.
virtual void update(float /*delta_time*/) {}
virtual void render();
// Renderitza substituint l'índex source_color per target_color (ús típic:
// la classe Text, que recolora glifs monocroms per paràmetre).
@@ -30,7 +32,6 @@ class Sprite {
[[nodiscard]] auto getPosition() const -> SDL_FRect { return pos_; }
[[nodiscard]] auto getClip() const -> SDL_FRect { return clip_; }
[[nodiscard]] auto getSurface() const -> std::shared_ptr<Surface> { return surface_; }
auto getRect() -> SDL_FRect& { return pos_; }
void setX(float x) { pos_.x = x; }
void setY(float y) { pos_.y = y; }
@@ -39,8 +40,6 @@ class Sprite {
void setPosition(float x, float y);
void setPosition(SDL_FPoint p);
void setPosition(SDL_FRect r) { pos_ = r; }
void incX(float value) { pos_.x += value; }
void incY(float value) { pos_.y += value; }
void setClip(SDL_FRect rect) { clip_ = rect; }
void setClip(float x, float y, float w, float h) { clip_ = SDL_FRect{.x = x, .y = y, .w = w, .h = h}; }
-1
View File
@@ -58,7 +58,6 @@ class Surface {
void putPixel(int x, int y, Uint8 color);
[[nodiscard]] auto getPixel(int x, int y) const -> Uint8;
[[nodiscard]] auto getSurfaceData() const -> std::shared_ptr<SurfaceData> { return surface_data_; }
[[nodiscard]] auto getWidth() const -> int { return surface_data_->width; }
[[nodiscard]] auto getHeight() const -> int { return surface_data_->height; }