refactor(core/rendering): deduplicar Text::write* i nomenar magic numbers (DUP-03 + HC-01)
Text tenia cinc mètodes (write, writeColored, writeMonoDigits, length, lengthMonoDigits) i dos getters (glyphWidth, getGlyphClip) que repetien el mateix patró de resolució de codepoint: find(cp), fallback a '?' si no hi és. Extret a un helper privat resolveGlyph(cp) que centralitza aquesta lògica; totes les funcions passen a usar-lo. write() ara delega directament a writeColored(...) passant el color per defecte, eliminant ~19 línies del bucle UTF-8 duplicades. Els literals 1 (índex de "tinta" al PNG) i 15 (color per defecte a la paleta) passen a ser Text::INK_COLOR_INDEX i Text::DEFAULT_TEXT_COLOR (HC-01). Build + smoke 5s xvfb OK (exit 124). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5f46fb22a4
commit
a63deac6a3
3 files changed
+47
-53
No files matched your search
@@ -21,7 +21,7 @@ Los IDs se mantienen estables una vez asignados. Cada entrada apunta al(los) fic
|
||||
| COUP-01 | Inversión de dependencia `core/rendering → game/*` | DONE |
|
||||
| DUP-02 | `Surface::render` / `renderWithColorReplace` duplicados | DONE |
|
||||
| CONV-03 | Shaders MSL como raw strings en `.cpp` + helpers duplicados | DONE |
|
||||
| DUP-03 | Familia `Text::write*` con bucle UTF-8 repetido 5 veces | PENDING |
|
||||
| DUP-03 | Familia `Text::write*` con bucle UTF-8 repetido 5 veces | DONE |
|
||||
| COUP-02 | `Screen` instancia `SDL3GPUShader` directamente + `Surface` → `Screen::get()` | PENDING |
|
||||
|
||||
---
|
||||
@@ -32,7 +32,7 @@ Los IDs se mantienen estables una vez asignados. Cada entrada apunta al(los) fic
|
||||
|----|---------------|----------|-----------|--------|-------|
|
||||
| DUP-01 | `gif.cpp:238-276` | 3 ramas del switch extension saltan bloque+subloops idénticos | Importante | PENDING | helper `skipExtensionBlocks` |
|
||||
| DUP-02 | `surface.cpp:80-137` | `render` vs `renderWithColorReplace` ~90% idénticos | Crítico | DONE | `render()` delega amb source==target==transparent |
|
||||
| DUP-03 | `text.cpp:145-289` | bucle UTF-8 repetido en write/writeColored/writeMonoDigits/length/lengthMonoDigits | Importante | PENDING | iterador de glifos |
|
||||
| DUP-03 | `text.cpp:145-289` | bucle UTF-8 repetido en write/writeColored/writeMonoDigits/length/lengthMonoDigits | Importante | DONE | `resolveGlyph` + `write` delega a `writeColored` |
|
||||
| DUP-04 | `sdl3gpu_shader.cpp:165-201` + `crtpi_pipeline.cpp:165-202` | `createShaderMSL/SPIRV` duplicados | Importante | DONE | `sdl3gpu/shader_factory.hpp` |
|
||||
| DUP-05 | `sdl3gpu_shader.cpp:18-35` + `crtpi_pipeline.cpp:17-34` | vertex shader MSL duplicado | Menor | DONE | `sdl3gpu/msl/postfx_vert.msl.h` compartit |
|
||||
| DUP-06 | `surface.cpp:14-43` | constructor Surface abre y parsea GIF 2 veces | Importante | PENDING | `loadGif` devuelve pixels+palette |
|
||||
@@ -42,7 +42,7 @@ Los IDs se mantienen estables una vez asignados. Cada entrada apunta al(los) fic
|
||||
|
||||
| ID | Fichero:línea | Hallazgo | Severidad | Estado | Notas |
|
||||
|----|---------------|----------|-----------|--------|-------|
|
||||
| HC-01 | `text.cpp:159` | `render(1, 15)` — `1` (tinta) y `15` (color por defecto) literales | Importante | PENDING | `INK_INDEX` / `DEFAULT_COLOR` |
|
||||
| HC-01 | `text.cpp:159` | `render(1, 15)` — `1` (tinta) y `15` (color por defecto) literales | Importante | DONE | `Text::INK_COLOR_INDEX` i `DEFAULT_TEXT_COLOR` |
|
||||
| HC-02 | `surface.cpp:29`, `screen.cpp:56,218,244` | `0xFF000000U`/`0xFF` alfa repetido | Menor | PENDING | `OPAQUE_ALPHA` |
|
||||
| HC-03 | `gif.cpp:71,95,…` | LZW `<11`/`<12`/`<2` y máscaras `0x80/0x70/0x07…` sin nombre | Menor | PENDING | constantes con nombre |
|
||||
| HC-04 | `notifier.hpp:41-46`, `render_info.hpp:38-40` | HUD constants hardcoded en clase, no en `defaults`/YAML | Importante | PENDING | `Defaults::Hud::…` o config.yaml |
|
||||
@@ -123,4 +123,5 @@ Los IDs se mantienen estables una vez asignados. Cada entrada apunta al(los) fic
|
||||
- `9434e4e` — COUP-01a: `Notifier` desacoblat de `game/ui/notification_presets`
|
||||
- `9395520` — COUP-01b: `RenderInfo` desacoblat de `game/options` + `game/ui/ui_palette`
|
||||
- `d479475` — DUP-02: `Surface::render` delega a `renderWithColorReplace`
|
||||
- `<pendent>` — CONV-03 + DUP-04 + DUP-05 + PATCH-07: shaders MSL i helpers extrets a `sdl3gpu/msl/` i `sdl3gpu/shader_factory.hpp`
|
||||
- `5f46fb2` — CONV-03 + DUP-04 + DUP-05 + PATCH-07: shaders MSL i helpers extrets a `sdl3gpu/msl/` i `sdl3gpu/shader_factory.hpp`
|
||||
- `<pendent>` — DUP-03 + HC-01: `Text` amb `resolveGlyph` i constants `INK_COLOR_INDEX` / `DEFAULT_TEXT_COLOR`
|
||||
Reference in new issue
Block a user