decompile the full iggy ui script corpus
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,6 +25,7 @@ ffdec.zip
|
||||
ffdec/
|
||||
tools/*.class
|
||||
as3/
|
||||
*.ffdec.log
|
||||
iggy-shim/build/
|
||||
iggy-shim/third_party/RmlUi/build-w64/
|
||||
iggy-shim/third_party/freetype/build-w64/
|
||||
|
||||
@@ -187,9 +187,10 @@ brief below:
|
||||
name png|- frames tx ty sx sy; V name up down left right. png dir w/o .png
|
||||
suffix = sprite dir, frame files <n>.png (may skip numbers).
|
||||
- Class-linked art: doc-class `public var Name:Class` (regex from as3) →
|
||||
skin export (ui-layout/skin*.json exports) → skin png. Only 14/105 720-scenes
|
||||
decompiled to as3/ so far — rerun the xargs ffdec batch for full coverage
|
||||
(some fail silently; check).
|
||||
skin export (ui-layout/skin*.json exports) → skin png. `extract-ui-as3.sh`
|
||||
decompiles 9,446 files from 370 canonical SWFs plus 3 distinct same-name
|
||||
variants under `as3/_variants/`; 18 SWFs are timeline/art-only and contain
|
||||
no ActionScript.
|
||||
- Upstream quirks: skinHD.swf + platformskinHD.swf in Windows64Media/Media are
|
||||
PE EXEs not SWFs (docs/UPSTREAM-ISSUES.md); 3 files have committed git
|
||||
conflict markers.
|
||||
|
||||
@@ -61,6 +61,9 @@ pushes state in every frame via `IggyPlayerCallMethodRS` (`SetHealth`, `Init`,
|
||||
concrete PNG (following `ImportAssets2` links into the skin SWFs, and AS3
|
||||
instance-var classes like `Button:FJ_MenuButton_Normal` into skin symbols).
|
||||
Nav links (`m_objNav*`) are extracted from the AS3 too.
|
||||
- **Editable ActionScript** (`as3/<name>/scripts`): decompiled by
|
||||
`extract-ui-as3.sh`. Same-named SWFs with different contents are preserved
|
||||
under `as3/_variants/`; identical duplicates are deduplicated.
|
||||
- **Interactivity** (`scene_registry.cpp`): generic semantics for
|
||||
`Init`/`SetLabel`/`SetFocus`/`SetSafeZone`/`Show*`/`Hide*`/checkbox; focus
|
||||
enumeration by id; keyboard nav (authored links + geometric fallback);
|
||||
@@ -73,6 +76,8 @@ cd iggy-shim
|
||||
./fetch-deps.sh # cross-compiles RmlUi + FreeType for windows-clang-cl
|
||||
cmake -B build -G Ninja # (see build-macos.sh for the full toolchain flags)
|
||||
cmake --build build # -> iggy_shim_w64.dll + .lib
|
||||
../extract-ui-pngs.sh # editable bitmap/shape/sprite art
|
||||
../extract-ui-as3.sh # editable ActionScript sources
|
||||
python3 ../gen-scenes-tsv.py # scene fingerprints
|
||||
python3 ../gen-scene-bundles.py # scene bundles
|
||||
```
|
||||
|
||||
293
extract-ui-as3.sh
Executable file
293
extract-ui-as3.sh
Executable file
@@ -0,0 +1,293 @@
|
||||
#!/usr/bin/env bash
|
||||
# Decompile ActionScript from every distinct Windows64 UI SWF.
|
||||
# Output: as3/<swf-name>/scripts/**/*.as plus differing basename variants.
|
||||
set -euo pipefail
|
||||
|
||||
GAME_DIR="${GAME_DIR:-$HOME/neoLegacy}"
|
||||
OUT_DIR="${OUT_DIR:-$HOME/neoLegacy-mac/as3}"
|
||||
FFDEC_JAR="${FFDEC_JAR:-$HOME/neoLegacy-mac/ffdec/ffdec.jar}"
|
||||
JOBS="${JOBS:-8}"
|
||||
LOG_FILE="${LOG_FILE:-${OUT_DIR}.ffdec.log}"
|
||||
ALLOW_SHRINK="${ALLOW_SHRINK:-0}"
|
||||
COMMON_MEDIA="$GAME_DIR/Minecraft.Client/Common/Media"
|
||||
WINDOWS_MEDIA="$GAME_DIR/Minecraft.Client/Windows64Media/Media"
|
||||
|
||||
if ! command -v java >/dev/null 2>&1; then
|
||||
echo "java is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v python3 >/dev/null 2>&1; then
|
||||
echo "python3 is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -r "$FFDEC_JAR" ]]; then
|
||||
echo "FFDec jar is not readable: $FFDEC_JAR" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -d "$COMMON_MEDIA" || ! -d "$WINDOWS_MEDIA" ]]; then
|
||||
echo "neoLegacy media roots were not found under: $GAME_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! "$JOBS" =~ ^[1-9][0-9]*$ ]]; then
|
||||
echo "JOBS must be a positive integer: $JOBS" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$ALLOW_SHRINK" != 0 && "$ALLOW_SHRINK" != 1 ]]; then
|
||||
echo "ALLOW_SHRINK must be 0 or 1: $ALLOW_SHRINK" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "$OUT_DIR")" "$(dirname "$LOG_FILE")"
|
||||
|
||||
lock_dir="${OUT_DIR}.lock"
|
||||
lock_acquired=0
|
||||
candidates=""
|
||||
ordered=""
|
||||
selected=""
|
||||
jobs_file=""
|
||||
stage_dir=""
|
||||
backup_dir="${OUT_DIR}.old.$$"
|
||||
worker_pid=""
|
||||
|
||||
terminate_workers() {
|
||||
local attempt
|
||||
if [[ -z "$worker_pid" ]] || ! kill -0 "$worker_pid" 2>/dev/null; then
|
||||
worker_pid=""
|
||||
return
|
||||
fi
|
||||
kill -TERM -- "-$worker_pid" 2>/dev/null || true
|
||||
wait "$worker_pid" 2>/dev/null || true
|
||||
for attempt in {1..20}; do
|
||||
kill -0 -- "-$worker_pid" 2>/dev/null || break
|
||||
sleep 0.05
|
||||
done
|
||||
kill -KILL -- "-$worker_pid" 2>/dev/null || true
|
||||
worker_pid=""
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
terminate_workers
|
||||
if [[ -e "$backup_dir" ]]; then
|
||||
rm -rf "$OUT_DIR"
|
||||
mv "$backup_dir" "$OUT_DIR" || true
|
||||
fi
|
||||
[[ -z "$candidates" ]] || rm -f "$candidates"
|
||||
[[ -z "$ordered" ]] || rm -f "$ordered"
|
||||
[[ -z "$selected" ]] || rm -f "$selected"
|
||||
[[ -z "$jobs_file" ]] || rm -f "$jobs_file"
|
||||
if [[ -n "$stage_dir" && -d "$stage_dir" ]]; then
|
||||
rm -rf "$stage_dir"
|
||||
fi
|
||||
if [[ "$lock_acquired" -eq 1 ]]; then
|
||||
rm -rf "$lock_dir"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
trap 'terminate_workers; exit 130' HUP INT TERM
|
||||
|
||||
if ! mkdir "$lock_dir" 2>/dev/null; then
|
||||
owner="$(cat "$lock_dir/pid" 2>/dev/null || true)"
|
||||
if [[ "$owner" =~ ^[0-9]+$ ]] && kill -0 "$owner" 2>/dev/null; then
|
||||
echo "another extraction is already running (pid $owner)" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$lock_dir"
|
||||
if ! mkdir "$lock_dir" 2>/dev/null; then
|
||||
echo "could not acquire extraction lock: $lock_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
printf '%s\n' "$$" >"$lock_dir/pid"
|
||||
lock_acquired=1
|
||||
|
||||
: >"$LOG_FILE"
|
||||
candidates="$(mktemp)"
|
||||
ordered="$(mktemp)"
|
||||
selected="$(mktemp)"
|
||||
jobs_file="$(mktemp)"
|
||||
stage_dir="$(mktemp -d "${OUT_DIR}.tmp.XXXXXX")"
|
||||
|
||||
scan_root() {
|
||||
local root="$1"
|
||||
local priority="$2"
|
||||
local swf
|
||||
local signature
|
||||
local valid
|
||||
local hash
|
||||
|
||||
while IFS= read -r -d '' swf; do
|
||||
signature="$(dd if="$swf" bs=3 count=1 2>/dev/null || true)"
|
||||
valid=1
|
||||
case "$signature" in
|
||||
FWS|CWS|ZWS) valid=0 ;;
|
||||
esac
|
||||
hash="$(shasum -a 256 "$swf" | awk '{print $1}')"
|
||||
printf '%s\t%s\t%s\t%s\t%s\n' \
|
||||
"$(basename "$swf")" "$valid" "$priority" "$hash" "$swf" >>"$candidates"
|
||||
done < <(find "$root" -type f -name '*.swf' -print0)
|
||||
}
|
||||
|
||||
scan_root "$COMMON_MEDIA" 0
|
||||
scan_root "$WINDOWS_MEDIA" 1
|
||||
|
||||
input_count="$(wc -l <"$candidates" | tr -d ' ')"
|
||||
if [[ "$input_count" -eq 0 ]]; then
|
||||
echo "no SWFs found under: $GAME_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LC_ALL=C sort -t $'\t' -k1,1 -k2,2n -k3,3n -k5,5 "$candidates" >"$ordered"
|
||||
awk -F '\t' '!seen[$1]++' "$ordered" >"$selected"
|
||||
|
||||
while IFS=$'\t' read -r name valid priority hash swf; do
|
||||
if [[ "$valid" -ne 0 ]]; then
|
||||
printf 'FAILED: %s (no valid SWF exists for this basename)\n' "$swf" >>"$LOG_FILE"
|
||||
fi
|
||||
done <"$selected"
|
||||
|
||||
failures="$(grep -c '^FAILED:' "$LOG_FILE" || true)"
|
||||
if [[ "$failures" -ne 0 ]]; then
|
||||
printf '%s distinct inputs are not valid SWFs; see %s\n' "$failures" "$LOG_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
variants=0
|
||||
duplicates=0
|
||||
jobs=0
|
||||
while IFS=$'\t' read -r name valid priority hash swf; do
|
||||
canonical="$(awk -F '\t' -v name="$name" '$1 == name {print; exit}' "$selected")"
|
||||
IFS=$'\t' read -r canonical_name canonical_valid canonical_priority canonical_hash canonical_swf <<<"$canonical"
|
||||
|
||||
if [[ "$valid" -ne 0 ]]; then
|
||||
duplicates="$((duplicates + 1))"
|
||||
printf 'IGNORED_INVALID: %s\n' "$swf" >>"$LOG_FILE"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$swf" == "$canonical_swf" ]]; then
|
||||
dest_rel="${name%.swf}"
|
||||
elif [[ "$hash" == "$canonical_hash" ]]; then
|
||||
duplicates="$((duplicates + 1))"
|
||||
printf 'IGNORED_IDENTICAL: %s\n' "$swf" >>"$LOG_FILE"
|
||||
continue
|
||||
elif [[ "$swf" == "$COMMON_MEDIA/"* ]]; then
|
||||
rel="${swf#"$COMMON_MEDIA"/}"
|
||||
dest_rel="_variants/common/${rel%.swf}"
|
||||
variants="$((variants + 1))"
|
||||
else
|
||||
rel="${swf#"$WINDOWS_MEDIA"/}"
|
||||
dest_rel="_variants/windows/${rel%.swf}"
|
||||
variants="$((variants + 1))"
|
||||
fi
|
||||
|
||||
printf '%s\0%s\0' "$swf" "$dest_rel" >>"$jobs_file"
|
||||
printf '%s\t%s\t%s\n' "$dest_rel" "$hash" "$swf" >>"$stage_dir/.sources.tsv"
|
||||
jobs="$((jobs + 1))"
|
||||
done <"$ordered"
|
||||
|
||||
export ALLOW_SHRINK FFDEC_JAR LOG_FILE OUT_DIR stage_dir
|
||||
extract_one() {
|
||||
local swf="$1"
|
||||
local dest_rel="$2"
|
||||
local dest="$stage_dir/$dest_rel"
|
||||
local previous="$OUT_DIR/$dest_rel"
|
||||
local diagnostics
|
||||
local old_count
|
||||
local new_count
|
||||
|
||||
diagnostics="$(mktemp)"
|
||||
mkdir -p "$dest"
|
||||
if ! java -jar "$FFDEC_JAR" -export script "$dest" "$swf" >"$diagnostics" 2>&1; then
|
||||
printf 'FAILED: %s\n' "$swf" >>"$LOG_FILE"
|
||||
sed 's/^/ /' "$diagnostics" >>"$LOG_FILE"
|
||||
rm -f "$diagnostics"
|
||||
return 1
|
||||
fi
|
||||
|
||||
old_count=0
|
||||
if [[ -d "$previous" ]]; then
|
||||
old_count="$(find "$previous" -name '*.as' | wc -l | tr -d ' ')"
|
||||
fi
|
||||
new_count="$(find "$dest" -name '*.as' | wc -l | tr -d ' ')"
|
||||
if [[ "$ALLOW_SHRINK" -eq 0 && "$new_count" -lt "$old_count" ]]; then
|
||||
printf 'FAILED: %s produced %s scripts; previous output had %s\n' \
|
||||
"$swf" "$new_count" "$old_count" >>"$LOG_FILE"
|
||||
sed 's/^/ /' "$diagnostics" >>"$LOG_FILE"
|
||||
rm -f "$diagnostics"
|
||||
return 1
|
||||
fi
|
||||
if [[ "$new_count" -eq 0 ]]; then
|
||||
printf 'EMPTY: %s\n' "$swf" >>"$LOG_FILE"
|
||||
fi
|
||||
rm -f "$diagnostics"
|
||||
}
|
||||
export -f extract_one
|
||||
|
||||
python3 -c 'import os, sys; os.setsid(); os.execvp("xargs", ("xargs", "-0", "-n2", "-P", sys.argv[1], "bash", "-c", "extract_one \"$0\" \"$1\""))' \
|
||||
"$JOBS" <"$jobs_file" &
|
||||
worker_pid="$!"
|
||||
worker_status=0
|
||||
wait "$worker_pid" || worker_status="$?"
|
||||
worker_pid=""
|
||||
if [[ "$worker_status" -ne 0 ]]; then
|
||||
failures="$(grep -c '^FAILED:' "$LOG_FILE" || true)"
|
||||
printf '%s SWFs failed to decompile; see %s\n' "$failures" "$LOG_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
scripts="$(find "$stage_dir" -name '*.as' | wc -l | tr -d ' ')"
|
||||
empty="$(grep -c '^EMPTY:' "$LOG_FILE" || true)"
|
||||
canonical_count="$(wc -l <"$selected" | tr -d ' ')"
|
||||
if [[ "$canonical_count" -eq 0 || "$scripts" -eq 0 ]]; then
|
||||
echo "FFDec produced no ActionScript output" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$ALLOW_SHRINK" -eq 0 && -d "$OUT_DIR" ]]; then
|
||||
old_files="$stage_dir/.old-files"
|
||||
new_files="$stage_dir/.new-files"
|
||||
missing_files="$stage_dir/.missing-files"
|
||||
(cd "$OUT_DIR" && find . -name '*.as' -print | LC_ALL=C sort) >"$old_files"
|
||||
(cd "$stage_dir" && find . -name '*.as' -print | LC_ALL=C sort) >"$new_files"
|
||||
comm -23 "$old_files" "$new_files" >"$missing_files"
|
||||
if [[ -s "$missing_files" ]]; then
|
||||
printf 'FAILED: new output is missing files from the previous extraction\n' >>"$LOG_FILE"
|
||||
awk 'NR <= 20 { print " " $0 }' "$missing_files" >>"$LOG_FILE"
|
||||
rm -f "$old_files" "$new_files" "$missing_files"
|
||||
printf 'new output shrank; see %s (set ALLOW_SHRINK=1 to accept)\n' "$LOG_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$old_files" "$new_files" "$missing_files"
|
||||
|
||||
if [[ -f "$OUT_DIR/.sources.tsv" ]]; then
|
||||
old_destinations="$stage_dir/.old-destinations"
|
||||
new_destinations="$stage_dir/.new-destinations"
|
||||
missing_destinations="$stage_dir/.missing-destinations"
|
||||
cut -f1 "$OUT_DIR/.sources.tsv" | LC_ALL=C sort >"$old_destinations"
|
||||
cut -f1 "$stage_dir/.sources.tsv" | LC_ALL=C sort >"$new_destinations"
|
||||
comm -23 "$old_destinations" "$new_destinations" >"$missing_destinations"
|
||||
if [[ -s "$missing_destinations" ]]; then
|
||||
printf 'FAILED: new output omits prior SWF destinations\n' >>"$LOG_FILE"
|
||||
awk 'NR <= 20 { print " " $0 }' "$missing_destinations" >>"$LOG_FILE"
|
||||
rm -f "$old_destinations" "$new_destinations" "$missing_destinations"
|
||||
printf 'SWF destination set shrank; see %s (set ALLOW_SHRINK=1 to accept)\n' "$LOG_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$old_destinations" "$new_destinations" "$missing_destinations"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -e "$OUT_DIR" ]]; then
|
||||
mv "$OUT_DIR" "$backup_dir"
|
||||
fi
|
||||
if ! mv "$stage_dir" "$OUT_DIR"; then
|
||||
exit 1
|
||||
fi
|
||||
stage_dir=""
|
||||
old_backup="$backup_dir"
|
||||
backup_dir=""
|
||||
rm -rf "$old_backup"
|
||||
|
||||
printf 'done: %s ActionScript files from %s canonical SWFs + %s distinct variants; ' \
|
||||
"$scripts" "$canonical_count" "$variants"
|
||||
printf '%s duplicate/invalid inputs ignored, %s scriptless SWFs\n' "$duplicates" "$empty"
|
||||
148
tests/test-extract-ui-as3.sh
Executable file
148
tests/test-extract-ui-as3.sh
Executable file
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
TEST_ROOT="$(mktemp -d)"
|
||||
trap 'rm -rf "$TEST_ROOT"' EXIT
|
||||
|
||||
GAME_DIR="$TEST_ROOT/neoLegacy"
|
||||
OUT_DIR="$TEST_ROOT/output as3"
|
||||
BIN_DIR="$TEST_ROOT/bin"
|
||||
FFDEC_JAR="$TEST_ROOT/ffdec.jar"
|
||||
COMMON_MEDIA="$GAME_DIR/Minecraft.Client/Common/Media"
|
||||
WINDOWS_MEDIA="$GAME_DIR/Minecraft.Client/Windows64Media/Media"
|
||||
|
||||
mkdir -p "$BIN_DIR" "$COMMON_MEDIA/with spaces" "$WINDOWS_MEDIA/duplicate" "$OUT_DIR"
|
||||
touch "$FFDEC_JAR"
|
||||
printf 'stale\n' >"$OUT_DIR/stale.as"
|
||||
printf 'FWS-one\n' >"$COMMON_MEDIA/with spaces/One Scene.swf"
|
||||
printf 'FWS-two\n' >"$COMMON_MEDIA/Two.swf"
|
||||
printf 'FWS-three\n' >"$COMMON_MEDIA/Three.swf"
|
||||
printf 'FWS-one-variant\n' >"$WINDOWS_MEDIA/duplicate/One Scene.swf"
|
||||
printf 'MZ-bad duplicate\n' >"$WINDOWS_MEDIA/duplicate/Two.swf"
|
||||
|
||||
cat >"$BIN_DIR/java" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
dest="$5"
|
||||
swf="$6"
|
||||
if [[ "${FAKE_FAIL:-}" == "$(basename "$swf")" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${FAKE_SLEEP:-0}" == 1 ]]; then
|
||||
printf '%s\n' "$$" >>"$FAKE_PID_FILE"
|
||||
trap 'exit 143' TERM
|
||||
sleep 30
|
||||
fi
|
||||
mkdir -p "$dest/scripts"
|
||||
if [[ "${FAKE_EMPTY:-}" == "$(basename "$swf")" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
printf 'source=%s\n' "$swf" >"$dest/scripts/source.as"
|
||||
EOF
|
||||
chmod +x "$BIN_DIR/java"
|
||||
|
||||
run_extract() {
|
||||
PATH="$BIN_DIR:$PATH" \
|
||||
GAME_DIR="$GAME_DIR" \
|
||||
OUT_DIR="$OUT_DIR" \
|
||||
FFDEC_JAR="$FFDEC_JAR" \
|
||||
LOG_FILE="$TEST_ROOT/ffdec.log" \
|
||||
ALLOW_SHRINK="${ALLOW_SHRINK:-0}" \
|
||||
JOBS=2 \
|
||||
"$REPO_DIR/extract-ui-as3.sh"
|
||||
}
|
||||
|
||||
ALLOW_SHRINK=1 run_extract >/dev/null
|
||||
[[ ! -e "$OUT_DIR/stale.as" ]]
|
||||
[[ -f "$OUT_DIR/One Scene/scripts/source.as" ]]
|
||||
[[ -f "$OUT_DIR/Two/scripts/source.as" ]]
|
||||
[[ -f "$OUT_DIR/Three/scripts/source.as" ]]
|
||||
[[ -f "$OUT_DIR/_variants/windows/duplicate/One Scene/scripts/source.as" ]]
|
||||
[[ "$(find "$OUT_DIR" -name '*.as' | wc -l | tr -d ' ')" -eq 4 ]]
|
||||
|
||||
before="$(find "$OUT_DIR" -type f -exec shasum -a 256 {} + | LC_ALL=C sort)"
|
||||
run_extract >/dev/null
|
||||
after="$(find "$OUT_DIR" -type f -exec shasum -a 256 {} + | LC_ALL=C sort)"
|
||||
[[ "$before" == "$after" ]]
|
||||
|
||||
mv "$COMMON_MEDIA/Three.swf" "$TEST_ROOT/Three.swf"
|
||||
if run_extract >/dev/null 2>&1; then
|
||||
echo "whole-output shrink unexpectedly succeeded" >&2
|
||||
exit 1
|
||||
fi
|
||||
mv "$TEST_ROOT/Three.swf" "$COMMON_MEDIA/Three.swf"
|
||||
[[ -f "$OUT_DIR/Three/scripts/source.as" ]]
|
||||
|
||||
printf 'MZ-invalid\n' >"$COMMON_MEDIA/Broken.swf"
|
||||
if run_extract >/dev/null 2>&1; then
|
||||
echo "malformed SWF unexpectedly succeeded" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm "$COMMON_MEDIA/Broken.swf"
|
||||
[[ -f "$OUT_DIR/Two/scripts/source.as" ]]
|
||||
|
||||
if FAKE_FAIL=Two.swf run_extract >/dev/null 2>&1; then
|
||||
echo "FFDec failure unexpectedly succeeded" >&2
|
||||
exit 1
|
||||
fi
|
||||
[[ -f "$OUT_DIR/Two/scripts/source.as" ]]
|
||||
|
||||
if FAKE_EMPTY=Two.swf run_extract >/dev/null 2>&1; then
|
||||
echo "shrinking output unexpectedly succeeded" >&2
|
||||
exit 1
|
||||
fi
|
||||
[[ -f "$OUT_DIR/Two/scripts/source.as" ]]
|
||||
|
||||
mkdir "$OUT_DIR.lock"
|
||||
printf '%s\n' "$$" >"$OUT_DIR.lock/pid"
|
||||
if run_extract >/dev/null 2>&1; then
|
||||
echo "concurrent extraction unexpectedly succeeded" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$OUT_DIR.lock"
|
||||
|
||||
export FAKE_SLEEP=1
|
||||
export FAKE_PID_FILE="$TEST_ROOT/java-pids"
|
||||
PATH="$BIN_DIR:$PATH" \
|
||||
GAME_DIR="$GAME_DIR" \
|
||||
OUT_DIR="$OUT_DIR" \
|
||||
FFDEC_JAR="$FFDEC_JAR" \
|
||||
LOG_FILE="$TEST_ROOT/ffdec.log" \
|
||||
JOBS=2 \
|
||||
"$REPO_DIR/extract-ui-as3.sh" >/dev/null 2>&1 &
|
||||
extract_pid="$!"
|
||||
for _ in {1..50}; do
|
||||
[[ -s "$FAKE_PID_FILE" ]] && break
|
||||
sleep 0.1
|
||||
done
|
||||
[[ -s "$FAKE_PID_FILE" ]]
|
||||
kill -TERM "$extract_pid"
|
||||
wait "$extract_pid" 2>/dev/null || true
|
||||
unset FAKE_SLEEP FAKE_PID_FILE
|
||||
while IFS= read -r java_pid; do
|
||||
for _ in {1..100}; do
|
||||
kill -0 "$java_pid" 2>/dev/null || break
|
||||
sleep 0.05
|
||||
done
|
||||
state="$(ps -p "$java_pid" -o stat= 2>/dev/null || true)"
|
||||
if [[ -n "$state" && "$state" != Z* ]]; then
|
||||
echo "FFDec worker survived extraction termination: $java_pid ($state)" >&2
|
||||
exit 1
|
||||
fi
|
||||
done <"$TEST_ROOT/java-pids"
|
||||
[[ ! -e "$OUT_DIR.lock" ]]
|
||||
[[ -f "$OUT_DIR/Three/scripts/source.as" ]]
|
||||
|
||||
if PATH="$BIN_DIR:$PATH" GAME_DIR="$GAME_DIR" OUT_DIR="$OUT_DIR" \
|
||||
FFDEC_JAR="$FFDEC_JAR" JOBS=0 "$REPO_DIR/extract-ui-as3.sh" >/dev/null 2>&1; then
|
||||
echo "invalid JOBS unexpectedly succeeded" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm "$COMMON_MEDIA/with spaces/One Scene.swf" "$COMMON_MEDIA/Two.swf" "$COMMON_MEDIA/Three.swf" \
|
||||
"$WINDOWS_MEDIA/duplicate/One Scene.swf" "$WINDOWS_MEDIA/duplicate/Two.swf"
|
||||
if run_extract >/dev/null 2>&1; then
|
||||
echo "empty media roots unexpectedly succeeded" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user