Files
vibe3_physics/source/engine.cpp
Sergio Valor ebeec288ee Fix: Crash al acceder a themes[] con índices de temas dinámicos
PROBLEMA:
Crash (segfault) al activar temas dinámicos OCEAN WAVES (tecla 9) y
NEON PULSE (tecla 0). Funcionamiento correcto con SUNRISE (tecla 8).

CAUSA:
Múltiples lugares del código accedían a themes_[current_theme_] sin
verificar si current_theme_ era un tema dinámico (índices 7/8/9).

El array themes_[] solo tiene 7 elementos (índices 0-6):
- SUNSET, OCEAN, NEON, FOREST, RGB, MONOCHROME, LAVENDER

Los temas dinámicos están en dynamic_themes_[] (índices 0-2):
- DYNAMIC_1=7 (SUNRISE), DYNAMIC_2=8 (OCEAN WAVES), DYNAMIC_3=9 (NEON PULSE)

Acceder a themes_[7/8/9] causaba out-of-bounds → puntero inválido
→ crash en strlen(name_es).

PUNTOS DE FALLO IDENTIFICADOS:
1. render() línea ~738: Mostrar nombre del tema en pantalla
2. render() línea ~808: Debug display "THEME XXX"
3. initBalls() línea ~864: Seleccionar colores para pelotas nuevas

SOLUCIÓN:
 Añadir verificación dynamic_theme_active_ antes de acceder a arrays
 Si tema dinámico: usar dynamic_themes_[current_dynamic_theme_index_]
 Si tema estático: usar themes_[static_cast<int>(current_theme_)]

CORRECCIONES APLICADAS:
- render() (show_text_): Obtener color y nombre desde DynamicTheme
- render() (show_debug_): Obtener name_en desde DynamicTheme
- initBalls(): Seleccionar colores desde keyframe actual de DynamicTheme

RESULTADO:
-  SUNRISE (Numpad 8) funciona correctamente
-  OCEAN WAVES (Numpad 9) funciona correctamente (antes crasheaba)
-  NEON PULSE (Numpad 0) funciona correctamente (antes crasheaba)
-  Temas estáticos (1-7) siguen funcionando normalmente

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-05 20:31:31 +02:00

100 KiB