From 8b3d4a31f6b2a1816683a45d3f20aaa106ae0aa2 Mon Sep 17 00:00:00 2001 From: Lock l00p Date: Sun, 8 Oct 2023 04:38:58 +0000 Subject: [PATCH] Added shutdown for WASM and attempted to set up saving for WASM. --- host.c | 9 ++++++++- quakedef.h | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/host.c b/host.c index 5a65ce2b..f12b8b8e 100644 --- a/host.c +++ b/host.c @@ -728,7 +728,9 @@ static inline double Host_UpdateTime (double newtime, double oldtime) return time; } - +#ifdef __EMSCRIPTEN__ +EM_JS(void,emshutdown,(),{FS.syncfs(); window.close();}); +#endif void Host_Loop(void){ // Something bad happened, or the server disconnected if (setjmp(host.abortframe)) @@ -745,6 +747,11 @@ void Host_Loop(void){ sleeptime -= Sys_DirtyTime() - host.dirtytime; // execution time host.sleeptime = Host_Sleep(sleeptime); + #ifdef __EMSCRIPTEN__ + if(host.state == host_shutdown){ + emshutdown(); + } + #endif } void Host_Main(void) diff --git a/quakedef.h b/quakedef.h index f423d598..88b48068 100644 --- a/quakedef.h +++ b/quakedef.h @@ -26,7 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define GAMENAME "id1" #define STARTCONFIGFILENAME "quake.rc" -#define CONFIGFILENAME "config.cfg" +#ifndef __EMSCRIPTEN__ + #define CONFIGFILENAME "config.cfg" +#else + #define CONFIGFILENAME "/data/config.cfg" +#endif // moveflags values #define MOVEFLAG_VALID 0x80000000 -- 2.39.2