Fix: Buscar resources.pack relativo al ejecutable, no al working directory
- Movido getExecutableDirectory() a defines.h como función inline - Actualizado main.cpp para construir path absoluto a resources.pack - Eliminadas definiciones duplicadas en engine.cpp y main.cpp - Ahora funciona correctamente ejecutando desde cualquier carpeta (ej. build/) TEST confirmado: - Ejecutar desde raíz: ✅ Carga resources.pack - Ejecutar desde build/: ✅ Carga resources.pack 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -225,4 +225,31 @@ constexpr float LOGO_CONVERGENCE_DISTANCE = 20.0f; // Distancia (px) para con
|
||||
constexpr int LOGO_JUMP_PROBABILITY_FROM_DEMO = 5; // 5% probabilidad en DEMO normal (más raro)
|
||||
constexpr int LOGO_JUMP_PROBABILITY_FROM_DEMO_LITE = 3; // 3% probabilidad en DEMO LITE (aún más raro)
|
||||
|
||||
constexpr float PI = 3.14159265358979323846f; // Constante PI
|
||||
constexpr float PI = 3.14159265358979323846f; // Constante PI
|
||||
|
||||
// Función auxiliar para obtener la ruta del directorio del ejecutable
|
||||
#include <filesystem>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
inline std::string getExecutableDirectory() {
|
||||
#ifdef _WIN32
|
||||
char buffer[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, buffer, MAX_PATH);
|
||||
std::filesystem::path exe_path(buffer);
|
||||
return exe_path.parent_path().string();
|
||||
#else
|
||||
char buffer[PATH_MAX];
|
||||
ssize_t len = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
|
||||
if (len != -1) {
|
||||
buffer[len] = '\0';
|
||||
std::filesystem::path exe_path(buffer);
|
||||
return exe_path.parent_path().string();
|
||||
}
|
||||
return ".";
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user