fix emscripten

This commit is contained in:
2026-04-15 23:52:52 +02:00
parent 0faa605ad9
commit 294e665b11
2 changed files with 12 additions and 4 deletions

View File

@@ -87,9 +87,13 @@ elseif(APPLE)
endif() endif()
elseif(EMSCRIPTEN) elseif(EMSCRIPTEN)
target_compile_definitions(${PROJECT_NAME} PRIVATE EMSCRIPTEN_BUILD) target_compile_definitions(${PROJECT_NAME} PRIVATE EMSCRIPTEN_BUILD)
# En wasm NO empaquetamos un resources.pack: el propio --preload-file de
# emscripten ya hace el mismo trabajo (bundle del directorio en un .data),
# así que metemos directamente 'data' y dejamos que el Resource lea por
# filesystem (MEMFS). Evita doble empaquetado y el uso de memoria extra.
target_link_options(${PROJECT_NAME} PRIVATE target_link_options(${PROJECT_NAME} PRIVATE
--preload-file ${CMAKE_SOURCE_DIR}/resources.pack@/resources.pack "SHELL:--preload-file ${CMAKE_SOURCE_DIR}/data@/data"
--preload-file ${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt@/gamecontrollerdb.txt "SHELL:--preload-file ${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt@/gamecontrollerdb.txt"
-sALLOW_MEMORY_GROWTH=1 -sALLOW_MEMORY_GROWTH=1
-sMAX_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
) )

View File

@@ -58,9 +58,13 @@ Director::Director(int argc, const char *argv[]) {
createSystemFolder("jailgames/coffee_crisis_debug"); createSystemFolder("jailgames/coffee_crisis_debug");
#endif #endif
// Inicializa el sistema de recursos (pack + fallback) // Inicializa el sistema de recursos (pack + fallback).
// En wasm siempre se usa filesystem (MEMFS) porque el propio --preload-file
// de emscripten ya empaqueta data/ — no hay resources.pack.
{ {
#ifdef RELEASE_BUILD #if defined(__EMSCRIPTEN__)
const bool enable_fallback = true;
#elif defined(RELEASE_BUILD)
const bool enable_fallback = false; const bool enable_fallback = false;
#else #else
const bool enable_fallback = true; const bool enable_fallback = true;