Fix hacked GTK3/GLFW crash by vendoring a patched sqweek/dialog

The built hacked binary segfaults on Linux the moment a native GTK3
dialog (file/folder browse) opens while a GLFW/OpenGL context is live:
sqweek/dialog's Linux backend never calls XInitThreads() before
gtk_init(), and GLFW's own X11 backend installs a process-wide Xlib
error handler that collides with GTK's.

Vendor a pinned copy of github.com/sqweek/dialog (New BSD) into
modding/sqweek-dialog/ so it can be patched like every other vendored
source here: sqweek-dialog-patches/01-xinitthreads.patch adds the
missing XInitThreads() call, and hacked-patches/01-use-patched-dialog.patch
adds a go.mod replace directive pointing hacked's own sqweek/dialog
dependency at that local copy. build-hacked.sh now stages both hacked/
and sqweek-dialog/ into a scratch modding/build/ directory and applies
their patch series before compiling, rather than building hacked/ in
place; .gitignore picks up that new scratch directory.

Also expand modding/README.md: number its existing sections and add a
worked "Example: Editing a message" walkthrough covering Static World
Data, the Messages window's clipboard-only text editing, saving the
Mod Location, and the absolute-path requirement for run.sh's mod-folder
argument.
This commit is contained in:
ml
2026-09-26 10:37:01 +02:00
parent c91080aba7
commit e410d82680
20 changed files with 994 additions and 5 deletions
+19 -1
View File
@@ -14,12 +14,30 @@
set -euo pipefail
MODDING_ROOT="$(pwd)"
HACKED_SRC="$MODDING_ROOT/hacked"
OUT_DIR="$MODDING_ROOT/dist"
SCRATCH_DIR="$MODDING_ROOT/build"
HACKED_SRC="$SCRATCH_DIR/hacked"
DIALOG_SRC="$SCRATCH_DIR/sqweek-dialog"
VERSION="hacked-$(date -u +%Y%m%d)"
echo "Version: $VERSION"
echo "== Preparing scratch, patched copies of hacked/ and sqweek-dialog/ =="
# hacked/ and sqweek-dialog/ are vendored unmodified (see README.md) - never
# built or patched in place. hacked-patches/'s go.mod edit points
# sqweek/dialog at ../sqweek-dialog (a sibling directory here), so both
# scratch copies must keep that same relative layout.
rm -rf "$SCRATCH_DIR"
mkdir -p "$SCRATCH_DIR"
cp -a "$MODDING_ROOT/hacked" "$HACKED_SRC"
cp -a "$MODDING_ROOT/sqweek-dialog" "$DIALOG_SRC"
for p in "$MODDING_ROOT"/hacked-patches/*.patch; do
patch -p1 -d "$HACKED_SRC" < "$p"
done
for p in "$MODDING_ROOT"/sqweek-dialog-patches/*.patch; do
patch -p1 -d "$DIALOG_SRC" < "$p"
done
rm -rf "$OUT_DIR"
mkdir -p "$OUT_DIR/linux/hacked" "$OUT_DIR/win/hacked"