#!/usr/bin/env bash # Take a ship capture INSIDE the mission's clean window. # # The 0x82307128 crash storms the tutorial 56-112s after it starts, but both # runs with a warm cache gave ~1 minute of clean, advancing mission first # (docs/re/title-crash-stl-tree.md). F10 has to be pressed in there, so this # polls for the flight screen and fires immediately rather than on a fixed sleep. # # ship_capture_window.sh [outdir] set -u export HOME=/sylph-home/re SDL_AUDIODRIVER=dummy DISPLAY=:98 SD="$(cd "$(dirname "$0")" && pwd)" OUT="${1:-/sylph-home/re/shipcap}" mkdir -p "$OUT" rm -f "$OUT"/xenia_ship_capture_*.log ( cd "$OUT" && ATTEMPTS=1 timeout 1500 "$SD/tutorial_launch.sh" "$OUT" > "$OUT/launch.log" 2>&1 ) & LAUNCH=$! win="" deadline=$(( SECONDS + 900 )) fired=0 while [ $SECONDS -lt $deadline ]; do sleep 4 screenshot /tmp/sc.png >/dev/null 2>&1 || continue s="$(python3 "$SD/screen_id.py" /tmp/sc.png 2>/dev/null | awk '{print $1}')" if [ "$s" = "flight" ] && [ "$fired" -eq 0 ]; then win="$(xdotool search --name 'Xenia-canary' 2>/dev/null | tail -1)" [ -n "$win" ] || { echo "no window"; break; } echo "FLIGHT at ${SECONDS}s -> F10" xdotool windowactivate --sync "$win" 2>/dev/null; sleep 0.5 xdotool key F10; sleep 4 # A second press: the capture takes one batch of draws, and the first frame # of a mission may not have the ships in it yet. xdotool key F10 fired=1 sleep 25 break fi done echo "--- captures written ---" ls -la "$OUT"/xenia_ship_capture_*.log 2>/dev/null || ls -la /sylph-home/re/xenia_ship_capture_*.log 2>/dev/null || echo "(none)" wait $LAUNCH 2>/dev/null echo "--- crash dumps: $(grep -ac 'CRASH DUMP' "$OUT/canary.stdout" 2>/dev/null) ---"