mirror of
https://github.com/Xevion/Pac-Man.git
synced 2026-01-31 02:25:04 -06:00
fix(emscripten): avoid Module.arguments access with ASSERTIONS enabled
Skip env::args() on Emscripten builds to prevent accessing Module.arguments after runtime initialization, which causes abort with ASSERTIONS=1.
This commit is contained in:
+8
-3
@@ -104,9 +104,14 @@ unsafe extern "C" fn main_loop_callback(_arg: *mut std::ffi::c_void) {
|
|||||||
/// This function initializes SDL, the window, the game state, and then enters
|
/// This function initializes SDL, the window, the game state, and then enters
|
||||||
/// the main game loop.
|
/// the main game loop.
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
// Parse command line arguments
|
// Parse command line arguments (only on desktop - Emscripten ignores force_console)
|
||||||
let args: Vec<String> = env::args().collect();
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
let force_console = args.iter().any(|arg| arg == "--console" || arg == "-c");
|
let force_console = {
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
args.iter().any(|arg| arg == "--console" || arg == "-c")
|
||||||
|
};
|
||||||
|
#[cfg(target_os = "emscripten")]
|
||||||
|
let force_console = false;
|
||||||
|
|
||||||
// On Emscripten, this connects the subscriber to the browser console
|
// On Emscripten, this connects the subscriber to the browser console
|
||||||
platform::init_console(force_console).expect("Could not initialize console");
|
platform::init_console(force_console).expect("Could not initialize console");
|
||||||
|
|||||||
Reference in New Issue
Block a user