diff -ruN a/src/config.cpp b/src/config.cpp --- a/src/config.cpp +++ b/src/config.cpp @@ -20,8 +20,14 @@ const std::string help_roguelike_wizard = "data/rl_help_wizard.txt"; const std::string death_tomb = "data/death_tomb.txt"; const std::string death_royal = "data/death_royal.txt"; + #ifdef __EMSCRIPTEN__ + // The page keeps /saves in the browser (IndexedDB). + const std::string scores = "/saves/scores.dat"; + std::string save_game = "/saves/game.sav"; +#else const std::string scores = "scores.dat"; std::string save_game = "game.sav"; +#endif } // namespace files // Game options as set on startup and with `=` set options command -CJS- diff -ruN a/src/headers.h b/src/headers.h --- a/src/headers.h +++ b/src/headers.h @@ -18,7 +18,7 @@ #include #include -#elif __APPLE__ || __linux__ || __NetBSD__ || __MORPHOS__ +#elif __APPLE__ || __linux__ || __NetBSD__ || __MORPHOS__ || __EMSCRIPTEN__ #include #include diff -ruN a/src/ui_io.cpp b/src/ui_io.cpp --- a/src/ui_io.cpp +++ b/src/ui_io.cpp @@ -521,7 +521,16 @@ // a certain point, sleep for a second. There would need to be a way of resetting // the count, with a call made for commands like run or rest. bool checkForNonBlockingKeyPress(int microseconds) { -#ifdef _WIN32 +#ifdef __EMSCRIPTEN__ + // There is no stdin to select() on in the browser: look at the keys the page has queued. + (void) microseconds; + + timeout(0); + int result = getch(); + timeout(-1); + + return result > 0; +#elif defined(_WIN32) (void) microseconds; // Ugly non-blocking read...Ugh! -MRC- @@ -656,7 +665,7 @@ // Check user permissions on Unix based systems, // or if on Windows just return. -MRC- bool checkFilePermissions() { -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) if (0 != setuid(getuid())) { perror("Can't set permissions correctly! Setuid call failed.\n"); return false;