]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Added shutdown for WASM and attempted to set up saving for WASM.
authorLock l00p <hakzstudios@gmail.com>
Sun, 8 Oct 2023 04:38:58 +0000 (04:38 +0000)
committerLock l00p <hakzstudios@gmail.com>
Sun, 8 Oct 2023 04:38:58 +0000 (04:38 +0000)
host.c
quakedef.h

diff --git a/host.c b/host.c
index 5a65ce2b03e7a71ffbfa2e27dd4e7721ddb65b67..f12b8b8e38df8cc3310f054555b29aaed3a96dd0 100644 (file)
--- 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)
index f423d5985aab35137cab98ed205e47f8c9f43a13..88b480688bd572ce837c3ae48bff3165acbdfa67 100644 (file)
@@ -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