From f7875baa2d01d4d32fa58a76924649325397c635 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 18 Apr 2026 14:03:51 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20fase=206=20=E2=80=94=20Rule=20of=20?= =?UTF-8?q?5=20a=20Mapa=20i=20ModuleGame=20(no-copiables,=20no-movibles)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Mapa té un JD8_Surface fondo propi que s'allibera al destructor: una còpia accidental provocaria double-free. Ara els 4 copy/move ops estan = delete. - ModuleGame ja era no-copiable implícitament per tindre unique_ptr members, però els = delete expliciten la intenció i protegeixen davant refactors futurs que afegeixquen tipus copiables. Fi de la modernització RAII per fases (1–6). Co-Authored-By: Claude Opus 4.7 (1M context) --- source/game/mapa.hpp | 5 +++++ source/game/modulegame.hpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/source/game/mapa.hpp b/source/game/mapa.hpp index d6e168b..d44dc6f 100644 --- a/source/game/mapa.hpp +++ b/source/game/mapa.hpp @@ -30,6 +30,11 @@ class Mapa { explicit Mapa(JD8_Surface gfx, Prota* sam); ~Mapa(void); + Mapa(const Mapa&) = delete; + Mapa& operator=(const Mapa&) = delete; + Mapa(Mapa&&) = delete; + Mapa& operator=(Mapa&&) = delete; + void draw(); void update(); bool novaMomia(); diff --git a/source/game/modulegame.hpp b/source/game/modulegame.hpp index 16dc6dd..52aba69 100644 --- a/source/game/modulegame.hpp +++ b/source/game/modulegame.hpp @@ -31,6 +31,11 @@ class ModuleGame : public scenes::Scene { ModuleGame(); ~ModuleGame() override; + ModuleGame(const ModuleGame&) = delete; + ModuleGame& operator=(const ModuleGame&) = delete; + ModuleGame(ModuleGame&&) = delete; + ModuleGame& operator=(ModuleGame&&) = delete; + void onEnter() override; void tick(int delta_ms) override; bool done() const override { return phase_ == Phase::Done; }