diff --git a/engine/Makefile b/engine/Makefile index ab4281d..1d96bc5 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -1895,6 +1895,7 @@ ifeq ($(FTE_TARGET),web) EMCC_LDFLAGS+= -s ALLOW_MEMORY_GROWTH=1 #reduce crashes... EMCC_LDFLAGS+= -s MAX_WEBGL_VERSION=2 #make use of what we can. EMCC_LDFLAGS+= -s TOTAL_STACK=5MB #big! + EMCC_LDFLAGS+=-s EXPORTED_FUNCTIONS=_main,_malloc,_free #openoses: the page calls FTEC.cbufadd, which needs malloc/free EMCC_LDFLAGS+=-s ERROR_ON_UNDEFINED_SYMBOLS=1 #fairly obvious. no runtime errors please. RELEASE_CFLAGS=-DOMIT_QCC -DGL_STATIC $(EMCC_CFLAGS) DEBUG_CFLAGS=-gsource-map -DOMIT_QCC -DGL_STATIC $(EMCC_CFLAGS) diff --git a/engine/server/savegame.c b/engine/server/savegame.c index 5286566..94f6454 100644 --- a/engine/server/savegame.c +++ b/engine/server/savegame.c @@ -11,6 +11,7 @@ extern cvar_t teamplay; extern cvar_t pr_enable_profiling; cvar_t sv_savefmt = CVARFD("sv_savefmt", "", CVAR_SAVE, "Specifies the format used for the saved game.\n0=legacy.\n1=fte\n2=binary"); +static qboolean sv_quietsave; //openoses: autosaves do not print "Saving game to..." cvar_t sv_autosave = CVARFD("sv_autosave", "5", CVAR_SAVE, "Interval for autosaves, in minutes. Set to 0 to disable autosave."); extern cvar_t pr_ssqc_memsize; @@ -246,7 +247,8 @@ static qboolean SV_LegacySavegame (const char *savename, qboolean verbose) COM_RequireExtension (name, ".sav", sizeof(name)); //do NOT allow .pak etc if (!FS_DisplayPath(name, FS_GAMEONLY, native, sizeof(native))) return false; - Con_TPrintf (U8("Saving game to %s...\n"), native); + if (!sv_quietsave) + Con_TPrintf (U8("Saving game to %s...\n"), native); f = FS_OpenVFS(name, "wbp", FS_GAMEONLY); if (!f) { @@ -1564,7 +1566,15 @@ void SV_AutoSave(void) autosavename = M_ChooseAutoSave(); Con_DPrintf("Autosaving to %s\n", autosavename); + sv_quietsave = true; SV_Savegame(autosavename, false); + sv_quietsave = false; +#ifdef FTE_TARGET_WEB + { //openoses: tell the web page which save is the newest checkpoint + extern void emscriptenfte_autosaved(const char *name); + emscriptenfte_autosaved(autosavename); + } +#endif sv.autosave_time = sv.time + sv_autosave.value * 60; #endif diff --git a/engine/web/ftejslib.js b/engine/web/ftejslib.js index bc04299..dc7e117 100644 --- a/engine/web/ftejslib.js +++ b/engine/web/ftejslib.js @@ -10,6 +10,11 @@ mergeInto(LibraryManager.library, // }, //FIXME: split+merge by \n + emscriptenfte_autosaved : function(name) + { //openoses: the engine made an autosave (checkpoint) + if (Module['onAutosave']) + Module['onAutosave'](UTF8ToString(name)); + }, emscriptenfte_print : function(msg) { FTEC.linebuffer += UTF8ToString(msg); @@ -18,7 +23,7 @@ mergeInto(LibraryManager.library, nl = FTEC.linebuffer.indexOf("\n"); if (nl == -1) break; - console.log(FTEC.linebuffer.substring(0, nl)); + (Module['onConsoleLine'] || console.log)(FTEC.linebuffer.substring(0, nl)); //openoses: let the page watch the console FTEC.linebuffer = FTEC.linebuffer.substring(nl+1); } }, @@ -114,6 +119,11 @@ mergeInto(LibraryManager.library, window.focus(); } }, + look : function(dx, dy) + { //openoses touch controls: relative view movement without pointer lock. + if (FTEC.evcb.mouse != 0) + {{{makeDynCall('viiffff','FTEC.evcb.mouse')}}}(0, false, dx, dy, 0, 0); + }, cbufadd : function(command) { if (FTEC.evcb.cbufaddtext != 0) @@ -634,7 +644,7 @@ mergeInto(LibraryManager.library, window.onresize = function() { - let scale = window.devicePixelRatio; //urgh. haxx. + let scale = Module['pixelScale'] || window.devicePixelRatio; //openoses: the page can cap the render scale (phones). if (scale <= 0) scale = 1; //emscripten's browser library will revert sizes wrongly or something when we're fullscreen, so make sure that doesn't happen. diff --git a/engine/web/sys_web.c b/engine/web/sys_web.c index 14aff73..e69d1e1 100644 --- a/engine/web/sys_web.c +++ b/engine/web/sys_web.c @@ -439,7 +439,7 @@ int Sys_MainLoop(double newtime) return vid_vsync.ival; } -int QDECL main(int argc, char **argv) +__attribute__((used, visibility("default"))) int QDECL main(int argc, char **argv) { memset(&parms, 0, sizeof(parms));