diff --git a/bin/maa-online-daily-run b/bin/maa-online-daily-run index 3492180..32ac6fd 100755 --- a/bin/maa-online-daily-run +++ b/bin/maa-online-daily-run @@ -35,6 +35,12 @@ ATTEMPT_MAX_SECONDS="${MAA_ONLINE_ATTEMPT_MAX_SECONDS:-3000}" # per-attempt cei # while the game does first-login resource processing; without this, MAA burns # the whole attempt (and its quota) failing recognition on every task. PREFLIGHT_MAX_SECONDS="${MAA_ONLINE_PREFLIGHT_MAX_SECONDS:-780}" +# Archive pre-flight screenshots (one every 30s) so a bad first boot can be +# diagnosed visually afterwards: the bad screen is static, so a handful of +# saved frames tell us exactly what the game was showing. +PREFLIGHT_SHOT_DIR="${MAA_ONLINE_PREFLIGHT_SHOT_DIR:-$LOG_DIR/preflight}" +rm -rf "$PREFLIGHT_SHOT_DIR" +mkdir -p "$PREFLIGHT_SHOT_DIR" mkdir -p "$LOG_DIR" @@ -107,13 +113,16 @@ fi # Screen classes by PNG size, calibrated on real captures (2026-09-23): # black/loading <20KB | login 200-350KB (开始唤醒) | title ~480KB | # announcement/menu >=650KB (hand off to MAA) -preflight() { # arg1: max seconds; returns 0 once the screen looks in-game - local max="$1" elapsed=0 last_action=-20 ready_hits=0 +preflight() { # arg1: max seconds, arg2: attempt no.; returns 0 once the screen looks in-game + local max="$1" attempt_no="${2:-x}" elapsed=0 last_action=-20 ready_hits=0 local png=/tmp/maa-preflight.png while [ "$elapsed" -lt "$max" ]; do if api GET /screencap > "$png" 2>/dev/null; then local size size=$(stat -c %s "$png" 2>/dev/null || echo 0) + if [ $((elapsed % 30)) -eq 0 ]; then + cp "$png" "$PREFLIGHT_SHOT_DIR/a${attempt_no}-t$(printf '%04d' "$elapsed").png" 2>/dev/null + fi if [ "$size" -ge 650000 ]; then # Require the in-game-class screen to be stable: a single large # frame can still be a loading/transition screen (2026-09-25 @@ -181,7 +190,7 @@ while [ "$attempt" -lt "$MAX_ATTEMPTS" ]; do continue fi echo "[daily-run] attempt $attempt: preflight: waiting for a recognizable game screen (max ${PREFLIGHT_MAX_SECONDS}s) ..." - if ! preflight "$PREFLIGHT_MAX_SECONDS"; then + if ! preflight "$PREFLIGHT_MAX_SECONDS" "$attempt"; then REASON="preflight timed out after ${PREFLIGHT_MAX_SECONDS}s; game screen never became ready" echo "[daily-run] attempt $attempt failed: $REASON; releasing cloud session" >&2 api POST /exit >/dev/null 2>&1 || true