Skip to content

Commit

Permalink
Pull in merge of minetest & irrlicht upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
paradust7 committed Jan 3, 2024
1 parent 801f59d commit 228211a
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 25 deletions.
2 changes: 1 addition & 1 deletion apply_patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi
EMSDK_ROOT="$1"
cd "$EMSDK_ROOT"

patch -p1 < "$BASE_DIR/emsdk_emcc.patch"
patch -p1 < "$BASE_DIR/emsdk_safeheap.patch"
patch -p1 < "$BASE_DIR/emsdk_file_packager.patch"
patch -p1 < "$BASE_DIR/emsdk_dirperms.patch"
patch -p1 < "$BASE_DIR/emsdk_setlk.patch"
2 changes: 1 addition & 1 deletion common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export MAKEFLAGS="-j$(nproc)"

export CFLAGS="$COMMON_CFLAGS -pthread -sUSE_PTHREADS=1 -fexceptions"
export CXXFLAGS="$COMMON_CFLAGS -pthread -sUSE_PTHREADS=1 -fexceptions"
export LDFLAGS="$COMMON_LDFLAGS -pthread -sUSE_PTHREADS=1 -fexceptions -sEXIT_RUNTIME"
export LDFLAGS="$COMMON_LDFLAGS -pthread -sUSE_PTHREADS=1 -fexceptions"

export EMSDK_ROOT="$EMSDK"
export EMSDK_SYSLIB="${EMSDK_ROOT}/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten"
Expand Down
12 changes: 0 additions & 12 deletions emsdk_emcc.patch

This file was deleted.

45 changes: 45 additions & 0 deletions emsdk_safeheap.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--- emsdk/upstream/emscripten/src/library_html5.js 2023-12-13 13:05:05.000000000 +0000
+++ emsdk-fixed/upstream/emscripten/src/library_html5.js 2024-01-03 07:06:34.904379178 +0000
@@ -476,16 +476,16 @@
#if !DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR
if (Module['canvas']) {
var rect = getBoundingClientRect(Module['canvas']);
- HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.canvasX / 4 }}}] = e.clientX - rect.left;
- HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.canvasY / 4 }}}] = e.clientY - rect.top;
+ HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.canvasX / 4 }}}] = Math.round(e.clientX - rect.left);
+ HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.canvasY / 4 }}}] = Math.round(e.clientY - rect.top);
} else { // Canvas is not initialized, return 0.
HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.canvasX / 4 }}}] = 0;
HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.canvasY / 4 }}}] = 0;
}
#endif
var rect = getBoundingClientRect(target);
- HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.targetX / 4 }}}] = e.clientX - rect.left;
- HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.targetY / 4 }}}] = e.clientY - rect.top;
+ HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.targetX / 4 }}}] = Math.round(e.clientX - rect.left);
+ HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.targetY / 4 }}}] = Math.round(e.clientY - rect.top);

#if MIN_SAFARI_VERSION <= 80000 || MIN_CHROME_VERSION <= 21 // https://caniuse.com/#search=movementX
#if MIN_CHROME_VERSION <= 76
@@ -705,7 +705,9 @@
#else
var uiEvent = JSEvents.uiEvent;
#endif
- {{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.detail, 'e.detail', 'i32') }}};
+ let edetail = Math.round(e.detail);
+ if (Number.isNaN(edetail)) edetail = 0;
+ {{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.detail, 'edetail', 'i32') }}};
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.documentBodyClientWidth, 'b.clientWidth', 'i32') }}};
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.documentBodyClientHeight, 'b.clientHeight', 'i32') }}};
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.windowInnerWidth, 'innerWidth', 'i32') }}};
@@ -1944,8 +1946,8 @@
HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.pageY / 4}}}] = t.pageY;
HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.isChanged / 4}}}] = t.isChanged;
HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.onTarget / 4}}}] = t.onTarget;
- HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.targetX / 4}}}] = t.clientX - targetRect.left;
- HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.targetY / 4}}}] = t.clientY - targetRect.top;
+ HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.targetX / 4}}}] = Math.round(t.clientX - targetRect.left);
+ HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.targetY / 4}}}] = Math.round(t.clientY - targetRect.top);
#if !DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR
HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.canvasX / 4}}}] = canvasRect ? t.clientX - canvasRect.left : 0;
HEAP32[idx + {{{ C_STRUCTS.EmscriptenTouchPoint.canvasY / 4}}}] = canvasRect ? t.clientY - canvasRect.top : 0;
4 changes: 2 additions & 2 deletions fetch_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ getrepo minetest_game "https://github.com/minetest/minetest_game.git" 99a7193095

# These repos are part of the fork
getrepo webshims "https://github.com/paradust7/webshims.git" 91c3fe85d2cb7f85cc8e19d3f53dc8f252a69ff7
getrepo minetest "https://github.com/paradust7/minetest.git" 20368d3a8d797f06c1a33aeb660f9ca4f5798595
getrepo irrlichtmt "https://github.com/paradust7/irrlicht.git" 5a79e1ae2bb0346e261152a21261af0531c2e4bf
getrepo minetest "https://github.com/paradust7/minetest.git" 126082a0a225836b2e584c8c5a8a43ea808d30a7
getrepo irrlichtmt "https://github.com/paradust7/irrlicht.git" 883bbad7b70825258aec2a6e22860bd57596f7f8

# Make irrlichtmt symlink
pushd "$SOURCES_DIR"/minetest/lib
Expand Down
1 change: 1 addition & 0 deletions incremental.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

export INCREMENTAL=true
./build_minetest.sh
./build_fsroot.sh
./build_www.sh
4 changes: 2 additions & 2 deletions install_emsdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ rm -rf emsdk
git clone https://github.com/emscripten-core/emsdk.git

pushd emsdk
./emsdk install 3.1.25
./emsdk activate 3.1.25
./emsdk install 3.1.51
./emsdk activate 3.1.51
popd

./apply_patches.sh emsdk
Expand Down
14 changes: 7 additions & 7 deletions static/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function makeArgv(args) {
const argv = _malloc((args.length + 1) * 4);
let i;
for (i = 0; i < args.length; i++) {
HEAPU32[(argv >>> 2) + i] = allocateUTF8(args[i]);
HEAPU32[(argv >>> 2) + i] = stringToNewUTF8(args[i]);
}
HEAPU32[(argv >>> 2) + i] = 0; // argv[argc] == NULL
return [i, argv];
Expand Down Expand Up @@ -345,10 +345,10 @@ Module['printErr'] = Module['print'];
// This probably should be the default behavior, but doesn't seem to be for WasmFS.
const workerInject = `
Module['print'] = (text) => {
postMessage({cmd: 'print', text: text, threadId: Module['_pthread_self']()});
postMessage({cmd: 'callHandler', handler: 'print', args: [text], threadId: Module['_pthread_self']()});
};
Module['printErr'] = (text) => {
postMessage({cmd: 'printErr', text: text, threadId: Module['_pthread_self']()});
postMessage({cmd: 'callHandler', handler: 'printErr', args: [text], threadId: Module['_pthread_self']()});
};
importScripts('minetest.js');
`;
Expand Down Expand Up @@ -662,7 +662,7 @@ class MinetestLauncher {
HEAPU8.set(arr, data + offset);
offset += arr.byteLength;
}
emloop_install_pack(allocateUTF8(name), data, received);
emloop_install_pack(stringToNewUTF8(name), data, received);
_free(data);
mtScheduler.setCondition(installedCond);
if (this.onprogress) {
Expand Down Expand Up @@ -733,19 +733,19 @@ class MinetestLauncher {
activateBody();
fixGeometry();
if (this.minetestConf) {
const confBuf = allocateUTF8(this.minetestConf)
const confBuf = stringToNewUTF8(this.minetestConf)
emloop_set_minetest_conf(confBuf);
_free(confBuf);
}
emloop_init_sound();
// Setup emsocket
// TODO: emsocket should export the helpers for this
emsocket_init();
const proxyBuf = allocateUTF8(this.proxyUrl);
const proxyBuf = stringToNewUTF8(this.proxyUrl);
emsocket_set_proxy(proxyBuf);
_free(proxyBuf);
if (this.vpn) {
const vpnBuf = allocateUTF8(this.vpn);
const vpnBuf = stringToNewUTF8(this.vpn);
emsocket_set_vpn(vpnBuf);
_free(vpnBuf);
}
Expand Down

0 comments on commit 228211a

Please sign in to comment.